Flutter Engine
The Flutter Engine
Functions
SkImageGeneratorNDK.cpp File Reference
#include "include/core/SkImageGenerator.h"
#include "include/core/SkImageInfo.h"
#include "include/ports/SkImageGeneratorNDK.h"
#include "src/ports/SkNDKConversions.h"
#include <android/bitmap.h>
#include <android/data_space.h>
#include <android/imagedecoder.h>

Go to the source code of this file.

Functions

static bool ok (int result)
 
static bool set_android_bitmap_format (AImageDecoder *decoder, SkColorType colorType)
 
static SkColorType colorType (AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
 
static sk_sp< SkColorSpaceget_default_colorSpace (const AImageDecoderHeaderInfo *headerInfo)
 
static bool set_target_size (AImageDecoder *decoder, const SkISize &size, const SkISize targetSize)
 

Function Documentation

◆ colorType()

static SkColorType colorType ( AImageDecoder *  decoder,
const AImageDecoderHeaderInfo *  headerInfo 
)
static

Definition at line 53 of file SkImageGeneratorNDK.cpp.

53 {
54 // AImageDecoder never defaults to gray, but allows setting it if the image is 8 bit gray.
57 }
58
59 auto format = static_cast<AndroidBitmapFormat>(
60 AImageDecoderHeaderInfo_getAndroidBitmapFormat(headerInfo));
62}
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
static bool set_android_bitmap_format(AImageDecoder *decoder, SkColorType colorType)
uint32_t uint32_t * format
SkColorType toColorType(AndroidBitmapFormat format)

◆ get_default_colorSpace()

static sk_sp< SkColorSpace > get_default_colorSpace ( const AImageDecoderHeaderInfo *  headerInfo)
static

Definition at line 64 of file SkImageGeneratorNDK.cpp.

64 {
65 auto dataSpace = static_cast<ADataSpace>(AImageDecoderHeaderInfo_getDataSpace(headerInfo));
66 if (auto cs = SkNDKConversions::toColorSpace(dataSpace)) {
67 return cs;
68 }
69
71}
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkColorSpace > toColorSpace(ADataSpace dataSpace)

◆ ok()

static bool ok ( int  result)
static

Definition at line 44 of file SkImageGeneratorNDK.cpp.

44 {
45 return result == ANDROID_IMAGE_DECODER_SUCCESS;
46}
GAsyncResult * result

◆ set_android_bitmap_format()

static bool set_android_bitmap_format ( AImageDecoder *  decoder,
SkColorType  colorType 
)
static

Definition at line 48 of file SkImageGeneratorNDK.cpp.

48 {
50 return ok(AImageDecoder_setAndroidBitmapFormat(decoder, format));
51}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool ok(int result)
AndroidBitmapFormat toAndroidBitmapFormat(SkColorType colorType)

◆ set_target_size()

static bool set_target_size ( AImageDecoder *  decoder,
const SkISize size,
const SkISize  targetSize 
)
static

Definition at line 109 of file SkImageGeneratorNDK.cpp.

109 {
110 if (size != targetSize) {
111 // AImageDecoder will scale to arbitrary sizes. Only support a size if it's supported by the
112 // underlying library.
113 const AImageDecoderHeaderInfo* headerInfo = AImageDecoder_getHeaderInfo(decoder);
114 const char* mimeType = AImageDecoderHeaderInfo_getMimeType(headerInfo);
115 if (0 == strcmp(mimeType, "image/jpeg")) {
116 bool supported = false;
117 for (int sampleSize : { 2, 4, 8 }) {
118 int32_t width;
119 int32_t height;
120 if (ok(AImageDecoder_computeSampledSize(decoder, sampleSize, &width, &height))
121 && targetSize == SkISize::Make(width, height)) {
122 supported = true;
123 break;
124 }
125 }
126 if (!supported) return false;
127 } else if (0 == strcmp(mimeType, "image/webp")) {
128 // libwebp supports arbitrary downscaling.
129 if (targetSize.width() > size.width() || targetSize.height() > size.height()) {
130 return false;
131 }
132 } else {
133 return false;
134 }
135 }
136 return ok(AImageDecoder_setTargetSize(decoder, targetSize.width(), targetSize.height()));
137}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37