Flutter Engine
 
Loading...
Searching...
No Matches
image_decoder.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9#if IMPELLER_SUPPORTS_RENDERING
11#endif // IMPELLER_SUPPORTS_RENDERING
12
13namespace flutter {
14
15std::unique_ptr<ImageDecoder> ImageDecoder::Make(
16 const Settings& settings,
17 const TaskRunners& runners,
18 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
19 const fml::WeakPtr<IOManager>& io_manager,
20 const std::shared_ptr<fml::SyncSwitch>& gpu_disabled_switch) {
21#if IMPELLER_SUPPORTS_RENDERING
22 if (settings.enable_impeller) {
23 return std::make_unique<ImageDecoderImpeller>(
24 runners, //
25 std::move(concurrent_task_runner), //
26 io_manager, //
27 settings.enable_wide_gamut, //
28 gpu_disabled_switch);
29 }
30#endif // IMPELLER_SUPPORTS_RENDERING
31#if !SLIMPELLER
32 return std::make_unique<ImageDecoderSkia>(
33 runners, //
34 std::move(concurrent_task_runner), //
35 io_manager //
36 );
37#else // !SLIMPELLER
38 FML_LOG(FATAL) << "Could not setup an image decoder.";
39 return nullptr;
40#endif // !SLIMPELLER
41}
42
44 const TaskRunners& runners,
45 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
46 fml::WeakPtr<IOManager> io_manager)
47 : runners_(runners),
48 concurrent_task_runner_(std::move(concurrent_task_runner)),
49 io_manager_(std::move(io_manager)),
50 weak_factory_(this) {
53 << "The image decoder must be created & collected on the UI thread.";
54}
55
57
59 return weak_factory_.GetWeakPtr();
60}
61
62} // namespace flutter
static std::unique_ptr< ImageDecoder > Make(const Settings &settings, const TaskRunners &runners, std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner, const fml::WeakPtr< IOManager > &io_manager, const std::shared_ptr< fml::SyncSwitch > &gpu_disabled_switch)
ImageDecoder(const TaskRunners &runners, std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner, fml::WeakPtr< IOManager > io_manager)
fml::TaskRunnerAffineWeakPtr< ImageDecoder > GetWeakPtr() const
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
virtual bool RunsTasksOnCurrentThread()
fml::WeakPtr< IOManager > io_manager_
#define FML_LOG(severity)
Definition logging.h:101
#define FML_DCHECK(condition)
Definition logging.h:122
Definition ref_ptr.h:261