24#include <initializer_list>
50 ERRORF(r,
"Bitmaps have different image infos!");
53 const size_t rowBytes =
info.minRowBytes();
54 for (
int i = 0;
i <
info.height();
i++) {
56 ERRORF(r,
"Bitmaps have different pixels, starting on line %i!",
i);
65 size_t minBytes,
size_t increment) {
79 ERRORF(r,
"Failed to create codec for %s with %zu bytes",
name, minBytes);
95 if (
stream->isAllDataReceived()) {
96 ERRORF(r,
"Failed to start incremental decode\n");
100 stream->addNewData(increment);
105 partialCodec->getFrameCount();
115 if (
stream->isAllDataReceived()) {
116 ERRORF(r,
"Failed to completely decode %s",
name);
120 stream->addNewData(increment);
135 constexpr size_t kIncrement = 1000;
160 const char*
path =
"images/alphabetAnim.gif";
177 auto path =
"images/colorTables.gif";
185 ERRORF(r,
"Failed to create codec from %s",
path);
189 auto frameInfo = codec->getFrameInfo();
190 if (frameInfo.size() <= 1) {
191 ERRORF(r,
"Test is uninteresting with 0 or 1 frames");
196 std::unique_ptr<SkCodec> partialCodec(
nullptr);
197 for (
size_t i = 0; !partialCodec;
i++) {
198 if (
file->size() ==
i) {
199 ERRORF(r,
"Should have created a partial codec for %s",
path);
206 std::vector<SkCodec::FrameInfo> partialInfo;
207 size_t frameToCompare = 0;
209 partialInfo = partialCodec->getFrameInfo();
210 for (; frameToCompare < partialInfo.size(); frameToCompare++) {
212 == frameInfo[frameToCompare].fRequiredFrame);
215 if (frameToCompare == frameInfo.size()) {
220 ERRORF(r,
"Should have found all frames for %s",
path);
228 auto path =
"images/test640x479.gif";
242 const std::vector<size_t> frameByteCounts = { 455, 69350, 1344, 1346, 1327 };
243 std::vector<SkBitmap> frames;
244 for (
size_t i = 0;
true;
i++) {
251 frame.rowBytes(), &opts);
258 if (fullCodec->getFrameInfo().size() >
i) {
260 frames.push_back(
frame);
266 ERRORF(r,
"Failed to decode frame %zu from %s",
i,
path);
270 frames.push_back(
frame);
276 std::unique_ptr<SkStream>(haltingStream)));
278 ERRORF(r,
"Failed to create a partial codec from %s with %zu bytes out of %zu",
279 path, frameByteCounts[0],
file->size());
283 SkASSERT(frameByteCounts.size() > frames.size());
284 for (
size_t i = 0;
i < frames.size();
i++) {
285 const size_t fullFrameBytes = frameByteCounts[
i + 1];
286 const size_t firstHalf = fullFrameBytes / 2;
287 const size_t secondHalf = fullFrameBytes - firstHalf;
290 auto frameInfo = partialCodec->getFrameInfo();
302 ERRORF(r,
"Failed to start incremental decode for %s on frame %zu",
307 result = partialCodec->incrementalDecode();
311 result = partialCodec->incrementalDecode();
314 frameInfo = partialCodec->getFrameInfo();
318 ERRORF(r,
"\tfailure was on frame %zu",
i);
336 const size_t halfSize =
file->size() / 2;
338 std::make_unique<HaltingStream>(std::move(
file), halfSize)));
340 ERRORF(r,
"Failed to create codec for %s",
name);
351 ERRORF(r,
"Failed to start incremental decode\n");
364 result = partialCodec->incrementalDecode();
379 0x47, 0x49, 0x46, 0x38, 0x39, 0x61,
382 0x0A, 0x00, 0x0A, 0x00, 0x11, 0x00, 0x00,
385 0x2C, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x0A, 0x00, 0x81,
388 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
391 0x02, 0x16, 0x8C, 0x2D, 0x99, 0x87, 0x2A, 0x1C, 0xDC, 0x33, 0xA0, 0x02, 0x75,
392 0xEC, 0x95, 0xFA, 0xA8, 0xDE, 0x60, 0x8C, 0x04, 0x91, 0x4C, 0x01, 0x00,
403 ERRORF(r,
"failed to create codec");
441 result = codec->incrementalDecode();
446 result = codec->incrementalDecode();
453 const char*
name =
"images/baby_tux.png";
464 ERRORF(r,
"Failed to create a codec for %s",
name);
477 for (
const char*
name : {
"images/baby_tux.png",
478 "images/baby_tux.webp",
480 "images/color_wheel.gif",
481 "images/google_chrome.ico",
483 "images/mandrill.wbmp",
493 std::make_unique<SkMemoryStream>(
file->data(),
len), &
result));
496 ERRORF(r,
"Created an SkCodec for %s with %zu bytes, but "
503 ERRORF(r,
"Reported error %i for %s with %zu bytes",
static bool compare_bitmaps(skiatest::Reporter *r, const SkBitmap &bm1, const SkBitmap &bm2)
static unsigned char gNoGlobalColorMap[]
static SkImageInfo standardize_info(SkCodec *codec)
static bool create_truth(sk_sp< SkData > data, SkBitmap *dst)
static void test_partial(skiatest::Reporter *r, const char *name, const sk_sp< SkData > &file, size_t minBytes, size_t increment)
DEF_TEST(Codec_partial, r)
static void test_interleaved(skiatest::Reporter *r, const char *name)
void write_bm(const char *name, const SkBitmap &bm)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_sp< SkData > GetResourceAsData(const char *resource)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
#define REPORTER_ASSERT(r, cond,...)
void addNewData(size_t extra)
void allocPixels(const SkImageInfo &info, size_t rowBytes)
void * getAddr(int x, int y) const
const SkImageInfo & info() const
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkSpan< const SkCodecs::Decoder > decoders, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
SkImageInfo getInfo() const
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
static sk_sp< SkData > MakeSubset(const SkData *src, size_t offset, size_t length)
static float max(float r, float g, float b)
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
DEF_SWITCHES_START aot vmservice shared library name
static SkImageInfo MakeN32Premul(int width, int height)
std::shared_ptr< const fml::Mapping > data