Flutter Engine
The Flutter Engine
android_image_generator.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_SHELL_PLATFORM_ANDROID_ANDROID_IMAGE_GENERATOR_H_
6#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_IMAGE_GENERATOR_H_
7
8#include <jni.h>
9
10#include "flutter/fml/memory/ref_ptr.h"
11#include "flutter/fml/synchronization/waitable_event.h"
12#include "flutter/fml/task_runner.h"
13#include "flutter/lib/ui/painting/image_generator.h"
14
15namespace flutter {
16
18 private:
20
21 public:
23
24 // |ImageGenerator|
25 const SkImageInfo& GetInfo() override;
26
27 // |ImageGenerator|
28 unsigned int GetFrameCount() const override;
29
30 // |ImageGenerator|
31 unsigned int GetPlayCount() const override;
32
33 // |ImageGenerator|
35 unsigned int frame_index) override;
36
37 // |ImageGenerator|
38 SkISize GetScaledDimensions(float desired_scale) override;
39
40 // |ImageGenerator|
41 bool GetPixels(const SkImageInfo& info,
42 void* pixels,
43 size_t row_bytes,
44 unsigned int frame_index,
45 std::optional<unsigned int> prior_frame) override;
46
47 void DecodeImage();
48
49 static bool Register(JNIEnv* env);
50
51 static std::shared_ptr<ImageGenerator> MakeFromData(
53 const fml::RefPtr<fml::TaskRunner>& task_runner);
54
55 static void NativeImageHeaderCallback(JNIEnv* env,
56 jclass jcaller,
57 jlong generator_pointer,
58 int width,
59 int height);
60
61 private:
62 sk_sp<SkData> data_;
63 sk_sp<SkData> software_decoded_data_;
64
65 SkImageInfo image_info_;
66
67 /// Blocks until the header of the image has been decoded and the image
68 /// dimensions have been determined.
69 fml::ManualResetWaitableEvent header_decoded_latch_;
70
71 /// Blocks until the image has been fully decoded.
72 fml::ManualResetWaitableEvent fully_decoded_latch_;
73
74 void DoDecodeImage();
75
76 bool IsValidImageData();
77
78 FML_DISALLOW_COPY_ASSIGN_AND_MOVE(AndroidImageGenerator);
79};
80
81} // namespace flutter
82
83#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_IMAGE_GENERATOR_H_
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
unsigned int GetPlayCount() const override
The number of times an animated image should play through before playback stops.
static std::shared_ptr< ImageGenerator > MakeFromData(sk_sp< SkData > data, const fml::RefPtr< fml::TaskRunner > &task_runner)
unsigned int GetFrameCount() const override
Get the number of frames that the encoded image stores. This method is always expected to be called b...
const SkImageInfo & GetInfo() override
Returns basic information about the contents of the encoded image. This information can almost always...
static void NativeImageHeaderCallback(JNIEnv *env, jclass jcaller, jlong generator_pointer, int width, int height)
bool GetPixels(const SkImageInfo &info, void *pixels, size_t row_bytes, unsigned int frame_index, std::optional< unsigned int > prior_frame) override
Decode the image into a given buffer. This method is currently always used for sub-pixel image decodi...
SkISize GetScaledDimensions(float desired_scale) override
Given a scale value, find the closest image size that can be used for efficiently decoding the image....
const ImageGenerator::FrameInfo GetFrameInfo(unsigned int frame_index) override
Get information about a single frame in the context of a multi-frame image, useful for animation and ...
The minimal interface necessary for defining a decoder that can be used for both single and multi-fra...
Definition: __init__.py:1
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
int32_t height
int32_t width
Definition: SkSize.h:16
Info about a single frame in the context of a multi-frame image, useful for animation and blending.