Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
image_decoder.h
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#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_H_
6#define FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_H_
7
8#include <memory>
9
16
17namespace flutter {
18
19// An object that coordinates image decompression and texture upload across
20// multiple threads/components in the shell. This object must be created,
21// accessed and collected on the UI thread (typically the engine or its runtime
22// controller). None of the expensive operations performed by this component
23// occur in a frame pipeline.
25 public:
26 static std::unique_ptr<ImageDecoder> Make(
27 const Settings& settings,
28 const TaskRunners& runners,
29 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
30 const fml::WeakPtr<IOManager>& io_manager,
31 const std::shared_ptr<fml::SyncSwitch>& gpu_disabled_switch);
32
33 virtual ~ImageDecoder();
34
35 using ImageResult = std::function<void(sk_sp<DlImage>, std::string)>;
36
38 /// An unknown pixel format, reserved for error cases.
40 /// Explicitly declare the target pixel is left for the engine to decide.
44 };
45
51
52 // Takes an image descriptor and returns a handle to a texture resident on the
53 // GPU. All image decompression and resizes are done on a worker thread
54 // concurrently. Texture upload is done on the IO thread and the result
55 // returned back on the UI thread. On error, the texture is null but the
56 // callback is guaranteed to return on the UI thread.
57 virtual void Decode(fml::RefPtr<ImageDescriptor> descriptor,
58 const Options& options,
59 const ImageResult& result) = 0;
60
62
63 protected:
65 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner_;
67
69 const TaskRunners& runners,
70 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
71 fml::WeakPtr<IOManager> io_manager);
72
73 private:
75
77};
78
79} // namespace flutter
80
81#endif // FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_H_
std::function< void(sk_sp< DlImage >, std::string)> ImageResult
@ kDontCare
Explicitly declare the target pixel is left for the engine to decide.
@ kUnknown
An unknown pixel format, reserved for error cases.
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)
std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner_
virtual void Decode(fml::RefPtr< ImageDescriptor > descriptor, const Options &options, const ImageResult &result)=0
fml::TaskRunnerAffineWeakPtr< ImageDecoder > GetWeakPtr() const
fml::WeakPtr< IOManager > io_manager_
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
TargetPixelFormat target_format