Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions
CodecExactReadTest.cpp File Reference
#include "include/codec/SkCodec.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkStream.h"
#include "include/private/base/SkTemplates.h"
#include "tests/Test.h"
#include "tools/Resources.h"
#include <cstring>
#include <initializer_list>
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

 DEF_TEST (Codec_end, r)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( Codec_end  ,
 
)

Definition at line 53 of file CodecExactReadTest.cpp.

53 {
54 for (const char* path : { "images/plane.png",
55 "images/yellow_rose.png",
56 "images/plane_interlaced.png",
57 "images/mandrill.wbmp",
58 "images/randPixels.bmp",
59 }) {
61 if (!data) {
62 continue;
63 }
64
65 const int kNumImages = 2;
66 const size_t size = data->size();
67 sk_sp<SkData> multiData = SkData::MakeUninitialized(size * kNumImages);
68 void* dst = multiData->writable_data();
69 for (int i = 0; i < kNumImages; i++) {
70 memcpy(SkTAddOffset<void>(dst, size * i), data->data(), size);
71 }
72 data.reset();
73
74 SkMemoryStream stream(std::move(multiData));
75 for (int i = 0; i < kNumImages; ++i) {
76 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromStream(
77 std::make_unique<UnowningStream>(&stream)));
78 if (!codec) {
79 ERRORF(r, "Failed to create a codec from %s, iteration %i", path, i);
80 continue;
81 }
82
83 auto info = codec->getInfo().makeColorType(kN32_SkColorType);
84 SkBitmap bm;
85 bm.allocPixels(info);
86
87 auto result = codec->getPixels(bm.info(), bm.getPixels(), bm.rowBytes());
89 ERRORF(r, "Failed to getPixels from %s, iteration %i error %i", path, i, result);
90 continue;
91 }
92 }
93 }
94}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
sk_sp< SkData > GetResourceAsData(const char *resource)
Definition: Resources.cpp:42
#define ERRORF(r,...)
Definition: Test.h:293
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
size_t rowBytes() const
Definition: SkBitmap.h:238
void * getPixels() const
Definition: SkBitmap.h:283
const SkImageInfo & info() const
Definition: SkBitmap.h:139
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkSpan< const SkCodecs::Decoder > decoders, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
Definition: SkCodec.cpp:163
@ kSuccess
Definition: SkCodec.h:80
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition: SkData.cpp:116
void * writable_data()
Definition: SkData.h:52
GAsyncResult * result
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
Definition: switches.h:57
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
dst
Definition: cp.py:12
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63