Flutter Engine
The Flutter Engine
CodecPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef CodecPriv_DEFINED
8#define CodecPriv_DEFINED
9
12#include "include/core/SkData.h"
15#include "src/utils/SkOSPath.h"
17
18static DEFINE_string(codecWritePath, "",
19 "Dump image decodes from codec unit tests here.");
20
21inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
22 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(SkData::MakeWithoutCopy(mem, size)));
23 if (!codec) {
24 return false;
25 }
26
27 bm->allocPixels(codec->getInfo());
28 const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPixels(),
29 bm->rowBytes());
31}
32
33inline void write_bm(const char* name, const SkBitmap& bm) {
34 if (FLAGS_codecWritePath.isEmpty()) {
35 return;
36 }
37
38 SkString filename = SkOSPath::Join(FLAGS_codecWritePath[0], name);
39 filename.appendf(".png");
40 SkFILEWStream file(filename.c_str());
41 if (!SkPngEncoder::Encode(&file, bm.pixmap(), {})) {
42 SkDebugf("failed to write '%s'\n", filename.c_str());
43 }
44}
45
46#endif // CodecPriv_DEFINED
void write_bm(const char *name, const SkBitmap &bm)
Definition: CodecPriv.h:33
static DEFINE_string(codecWritePath, "", "Dump image decodes from codec unit tests here.")
bool decode_memory(const void *mem, size_t size, SkBitmap *bm)
Definition: CodecPriv.h:21
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
size_t rowBytes() const
Definition: SkBitmap.h:238
void * getPixels() const
Definition: SkBitmap.h:283
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
Definition: SkCodec.cpp:241
Result
Definition: SkCodec.h:76
@ kIncompleteInput
Definition: SkCodec.h:84
@ kSuccess
Definition: SkCodec.h:80
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Definition: SkData.h:116
static SkString Join(const char *rootPath, const char *relativePath)
Definition: SkOSPath.cpp:14
const char * c_str() const
Definition: SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550
GAsyncResult * result
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
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