Flutter Engine
The Flutter Engine
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
5#include "flutter/lib/ui/painting/image_decoder.h"
6
7#include "flutter/lib/ui/painting/image_decoder_skia.h"
8
9#if IMPELLER_SUPPORTS_RENDERING
10#include "flutter/lib/ui/painting/image_decoder_impeller.h"
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 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 std::move(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 std::move(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
ImageDecoder(const TaskRunners &runners, std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner, fml::WeakPtr< IOManager > io_manager)
fml::WeakPtr< ImageDecoder > GetWeakPtr() const
static std::unique_ptr< ImageDecoder > Make(const Settings &settings, const TaskRunners &runners, std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner, fml::WeakPtr< IOManager > io_manager, const std::shared_ptr< fml::SyncSwitch > &gpu_disabled_switch)
bool IsValid() const
Definition: task_runners.cc:46
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
virtual bool RunsTasksOnCurrentThread()
Definition: task_runner.cc:43
fml::WeakPtr< IOManager > io_manager_
#define FATAL(error)
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_DCHECK(condition)
Definition: logging.h:103
Definition: ref_ptr.h:256