Flutter Engine
The 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
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 return std::make_unique<ImageDecoderSkia>(
32 runners, //
33 std::move(concurrent_task_runner), //
34 std::move(io_manager) //
35 );
36}
37
39 const TaskRunners& runners,
40 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
41 fml::WeakPtr<IOManager> io_manager)
42 : runners_(runners),
43 concurrent_task_runner_(std::move(concurrent_task_runner)),
44 io_manager_(std::move(io_manager)),
45 weak_factory_(this) {
48 << "The image decoder must be created & collected on the UI thread.";
49}
50
52
54 return weak_factory_.GetWeakPtr();
55}
56
57} // 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)
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
virtual bool RunsTasksOnCurrentThread()
fml::WeakPtr< IOManager > io_manager_
#define FML_DCHECK(condition)
Definition logging.h:103
Definition ref_ptr.h:256