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

Side by Side Diff: tests/KtxTest.cpp

Issue 1018953003: Add SkEncodedFormat, used by SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use a common enum for SkImageEncoder and SkImageDecoder and SkCodec Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 uint8_t g = rand.nextRangeU(0, 255); 45 uint8_t g = rand.nextRangeU(0, 255);
46 uint8_t b = rand.nextRangeU(0, 255); 46 uint8_t b = rand.nextRangeU(0, 255);
47 47
48 SkPMColor &pixel = *(reinterpret_cast<SkPMColor*>(row + x*sizeof(SkP MColor))); 48 SkPMColor &pixel = *(reinterpret_cast<SkPMColor*>(row + x*sizeof(SkP MColor)));
49 pixel = SkPreMultiplyARGB(a, r, g, b); 49 pixel = SkPreMultiplyARGB(a, r, g, b);
50 } 50 }
51 row += bm8888.rowBytes(); 51 row += bm8888.rowBytes();
52 } 52 }
53 REPORTER_ASSERT(reporter, !(bm8888.empty())); 53 REPORTER_ASSERT(reporter, !(bm8888.empty()));
54 54
55 SkAutoDataUnref encodedData(SkImageEncoder::EncodeData(bm8888, SkImageEncode r::kKTX_Type, 0)); 55 SkAutoDataUnref encodedData(SkImageEncoder::EncodeData(bm8888, kKTX_SkEncode dFormat, 0));
56 REPORTER_ASSERT(reporter, encodedData); 56 REPORTER_ASSERT(reporter, encodedData);
57 57
58 SkAutoTDelete<SkMemoryStream> stream(SkNEW_ARGS(SkMemoryStream, (encodedData ))); 58 SkAutoTDelete<SkMemoryStream> stream(SkNEW_ARGS(SkMemoryStream, (encodedData )));
59 REPORTER_ASSERT(reporter, stream); 59 REPORTER_ASSERT(reporter, stream);
60 60
61 SkBitmap decodedBitmap; 61 SkBitmap decodedBitmap;
62 bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitma p); 62 bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitma p);
63 REPORTER_ASSERT(reporter, imageDecodeSuccess); 63 REPORTER_ASSERT(reporter, imageDecodeSuccess);
64 64
65 REPORTER_ASSERT(reporter, decodedBitmap.colorType() == bm8888.colorType()); 65 REPORTER_ASSERT(reporter, decodedBitmap.colorType() == bm8888.colorType());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (NULL == fileData) { 148 if (NULL == fileData) {
149 SkDebugf("KtxReexportPKM: can't load test file %s\n", pkmFilename.c_str( )); 149 SkDebugf("KtxReexportPKM: can't load test file %s\n", pkmFilename.c_str( ));
150 return; 150 return;
151 } 151 }
152 152
153 bool installDiscardablePixelRefSuccess = 153 bool installDiscardablePixelRefSuccess =
154 SkInstallDiscardablePixelRef(fileData, &etcBitmap); 154 SkInstallDiscardablePixelRef(fileData, &etcBitmap);
155 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); 155 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess);
156 156
157 // Write the bitmap out to a KTX file. 157 // Write the bitmap out to a KTX file.
158 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0); 158 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, kKTX_SkEncodedFor mat, 0);
159 SkAutoDataUnref newKtxData(ktxDataPtr); 159 SkAutoDataUnref newKtxData(ktxDataPtr);
160 REPORTER_ASSERT(reporter, ktxDataPtr); 160 REPORTER_ASSERT(reporter, ktxDataPtr);
161 161
162 // See is this data is identical to data in existing ktx file. 162 // See is this data is identical to data in existing ktx file.
163 SkString ktxFilename = GetResourcePath("mandrill_128.ktx"); 163 SkString ktxFilename = GetResourcePath("mandrill_128.ktx");
164 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); 164 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str()));
165 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); 165 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData));
166 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698