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

Side by Side Diff: tests/KtxTest.cpp

Issue 1671193002: Make SkPicture/SkImageGenerator default to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move ImageGenerator impl into ktx code to share with nanobench Created 4 years, 10 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 | « src/ports/SkImageGenerator_skia.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 uint8_t *row = decodedPixels; 136 uint8_t *row = decodedPixels;
137 for (int j = 0; j < decodedBitmap.height(); ++j) { 137 for (int j = 0; j < decodedBitmap.height(); ++j) {
138 for (int i = 0; i < decodedBitmap.width(); ++i) { 138 for (int i = 0; i < decodedBitmap.width(); ++i) {
139 SkPMColor pixel = *(reinterpret_cast<SkPMColor*>(row + i*sizeof(SkPM Color))); 139 SkPMColor pixel = *(reinterpret_cast<SkPMColor*>(row + i*sizeof(SkPM Color)));
140 REPORTER_ASSERT(reporter, SkPreMultiplyARGB(0x80, 0xFF, 0xFF, 0xFF) == pixel); 140 REPORTER_ASSERT(reporter, SkPreMultiplyARGB(0x80, 0xFF, 0xFF, 0xFF) == pixel);
141 } 141 }
142 row += decodedBitmap.rowBytes(); 142 row += decodedBitmap.rowBytes();
143 } 143 }
144 } 144 }
145 145
146 // For KtxReexportPKM, below. Defined in SkImageDecoder_ktx.cpp
147 extern SkImageGenerator* decoder_image_generator(SkData*);
148
146 /** 149 /**
147 * Finally, make sure that if we get ETC1 data from a PKM file that we can then 150 * Finally, make sure that if we get ETC1 data from a PKM file that we can then
148 * accurately write it out into a KTX file (i.e. transferring the ETC1 data from 151 * accurately write it out into a KTX file (i.e. transferring the ETC1 data from
149 * the PKM to the KTX should produce an identical KTX to the one we have on file ) 152 * the PKM to the KTX should produce an identical KTX to the one we have on file )
150 */ 153 */
151 DEF_TEST(KtxReexportPKM, reporter) { 154 DEF_TEST(KtxReexportPKM, reporter) {
152 SkString pkmFilename = GetResourcePath("mandrill_128.pkm"); 155 SkString pkmFilename = GetResourcePath("mandrill_128.pkm");
153 156
154 // Load PKM file into a bitmap 157 // Load PKM file into a bitmap
155 SkBitmap etcBitmap; 158 SkBitmap etcBitmap;
156 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(pkmFilename.c_str())); 159 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(pkmFilename.c_str()));
157 if (nullptr == fileData) { 160 if (nullptr == fileData) {
158 SkDebugf("KtxReexportPKM: can't load test file %s\n", pkmFilename.c_str( )); 161 SkDebugf("KtxReexportPKM: can't load test file %s\n", pkmFilename.c_str( ));
159 return; 162 return;
160 } 163 }
161 164
162 bool installDiscardablePixelRefSuccess = 165 bool installDiscardablePixelRefSuccess =
163 SkDEPRECATED_InstallDiscardablePixelRef(fileData, &etcBitmap); 166 SkDEPRECATED_InstallDiscardablePixelRef(decoder_image_generator(fileData ), &etcBitmap);
164 if (!installDiscardablePixelRefSuccess) { 167 if (!installDiscardablePixelRefSuccess) {
165 ERRORF(reporter, "failed to create discardable pixelRef from KTX file"); 168 ERRORF(reporter, "failed to create discardable pixelRef from KTX file");
166 return; 169 return;
167 } 170 }
168 171
169 // Write the bitmap out to a KTX file. 172 // Write the bitmap out to a KTX file.
170 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0); 173 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0);
171 SkAutoDataUnref newKtxData(ktxDataPtr); 174 SkAutoDataUnref newKtxData(ktxDataPtr);
172 REPORTER_ASSERT(reporter, ktxDataPtr); 175 REPORTER_ASSERT(reporter, ktxDataPtr);
173 176
174 // See is this data is identical to data in existing ktx file. 177 // See is this data is identical to data in existing ktx file.
175 SkString ktxFilename = GetResourcePath("mandrill_128.ktx"); 178 SkString ktxFilename = GetResourcePath("mandrill_128.ktx");
176 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); 179 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str()));
177 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); 180 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData));
178 } 181 }
OLDNEW
« no previous file with comments | « src/ports/SkImageGenerator_skia.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698