Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: tests/CodecPriv.h

Issue 1757333002: Fix bug in SkGifCodec / Switch SkImageDec tests to use Codec (Closed) Base URL: https://skia.googlesource.com/skia.git@m50
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
8 #include "SkBitmap.h"
9 #include "SkCodec.h"
10 #include "SkData.h"
11
12 inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
13 SkAutoTUnref<SkData> data(SkData::NewWithoutCopy(mem, size));
14
15 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data.get()));
16 if (!codec) {
17 return false;
18 }
19
20 // Construct a color table for the decode if necessary
21 SkAutoTUnref<SkColorTable> colorTable(nullptr);
22 SkPMColor* colorPtr = nullptr;
23 int* colorCountPtr = nullptr;
24 int maxColors = 256;
25 if (kIndex_8_SkColorType == codec->getInfo().colorType()) {
26 SkPMColor colors[256];
27 colorTable.reset(new SkColorTable(colors, maxColors));
28 colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
29 colorCountPtr = &maxColors;
30 }
31
32 bm->allocPixels(codec->getInfo(), nullptr, colorTable.get());
33 const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPix els(),
34 bm->rowBytes(), nullptr, colorPtr, colorCountPtr);
35 return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput;
36 }
OLDNEW
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698