Flutter Engine
The Flutter Engine
Namespaces | Functions
SkImageEncoder_NDK.cpp File Reference
#include "include/core/SkBitmap.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkStream.h"
#include "include/encode/SkJpegEncoder.h"
#include "include/encode/SkPngEncoder.h"
#include "include/encode/SkWebpEncoder.h"
#include "include/private/base/SkTFitsIn.h"
#include "include/private/base/SkTo.h"
#include "src/encode/SkImageEncoderPriv.h"
#include "src/image/SkImage_Base.h"
#include "src/ports/SkNDKConversions.h"

Go to the source code of this file.

Namespaces

namespace  SkPngEncoder
 
namespace  SkJpegEncoder
 
namespace  SkWebpEncoder
 

Functions

static AndroidBitmapInfo info_for_pixmap (const SkPixmap &pmap)
 
static bool write_image_to_stream (SkWStream *stream, const SkPixmap &pmap, AndroidBitmapCompressFormat androidFormat, int quality)
 
SK_API std::unique_ptr< SkEncoderSkPngEncoder::Make (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API bool SkPngEncoder::Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API sk_sp< SkDataSkPngEncoder::Encode (GrDirectContext *ctx, const SkImage *img, const Options &options)
 
SK_API bool SkJpegEncoder::Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API bool SkJpegEncoder::Encode (SkWStream *dst, const SkYUVAPixmaps &src, const SkColorSpace *srcColorSpace, const Options &options)
 
SK_API sk_sp< SkDataSkJpegEncoder::Encode (GrDirectContext *ctx, const SkImage *img, const Options &options)
 
SK_API std::unique_ptr< SkEncoderSkJpegEncoder::Make (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API std::unique_ptr< SkEncoderSkJpegEncoder::Make (SkWStream *dst, const SkYUVAPixmaps &src, const SkColorSpace *srcColorSpace, const Options &options)
 
SK_API bool SkWebpEncoder::Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API sk_sp< SkDataSkWebpEncoder::Encode (GrDirectContext *ctx, const SkImage *img, const Options &options)
 
SK_API bool SkWebpEncoder::EncodeAnimated (SkWStream *dst, SkSpan< const SkEncoder::Frame > src, const Options &options)
 

Function Documentation

◆ info_for_pixmap()

static AndroidBitmapInfo info_for_pixmap ( const SkPixmap pmap)
static

Definition at line 20 of file SkImageEncoder_NDK.cpp.

20 {
21 // If any of these values is invalid (e.g. set to zero), the info will be rejected by
22 // AndroidBitmap_compress.
23 AndroidBitmapInfo info {
24 .width = SkTFitsIn<uint32_t>(pmap.width()) ? SkToU32(pmap.width()) : 0,
25 .height = SkTFitsIn<uint32_t>(pmap.height()) ? SkToU32(pmap.height()) : 0,
26 .stride = SkTFitsIn<uint32_t>(pmap.rowBytes()) ? SkToU32(pmap.rowBytes()) : 0,
28 };
29
30 switch (pmap.alphaType()) {
32 info.flags = ANDROID_BITMAP_FLAGS_ALPHA_PREMUL;
33 break;
35 info.flags = ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE;
36 break;
38 info.flags = ANDROID_BITMAP_FLAGS_ALPHA_UNPREMUL;
39 break;
40 default:
41 SkDEBUGFAIL("unspecified alphaType");
42 info.flags = ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE;
43 break;
44 }
45 return info;
46}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
kUnpremul_SkAlphaType
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static constexpr std::enable_if<(std::is_integral< S >::value||std::is_enum< S >::value)&&(std::is_integral< D >::value||std::is_enum< D >::value), bool >::type SkTFitsIn(S src)
Definition: SkTFitsIn.h:75
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
int width() const
Definition: SkPixmap.h:160
SkAlphaType alphaType() const
Definition: SkPixmap.h:175
uint32_t uint32_t * format
AndroidBitmapFormat toAndroidBitmapFormat(SkColorType colorType)
int32_t height

◆ write_image_to_stream()

static bool write_image_to_stream ( SkWStream stream,
const SkPixmap pmap,
AndroidBitmapCompressFormat  androidFormat,
int  quality 
)
static

Definition at line 48 of file SkImageEncoder_NDK.cpp.

51 {
52 AndroidBitmapInfo info = info_for_pixmap(pmap);
53
54 auto write_to_stream = [](void* userContext, const void* data, size_t size) {
55 return reinterpret_cast<SkWStream*>(userContext)->write(data, size);
56 };
57
58 return ANDROID_BITMAP_RESULT_SUCCESS == AndroidBitmap_compress(&info,
59 SkNDKConversions::toDataSpace(pmap.colorSpace()), pmap.addr(), androidFormat, quality,
60 reinterpret_cast<void*>(stream), write_to_stream);
61}
static AndroidBitmapInfo info_for_pixmap(const SkPixmap &pmap)
SkColorSpace * colorSpace() const
Definition: SkPixmap.cpp:61
const void * addr() const
Definition: SkPixmap.h:153
ADataSpace toDataSpace(SkColorSpace *cs)
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
void write(SkWStream *wStream, const T &text)
Definition: skqp.cpp:188
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63