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

Side by Side Diff: tests/KtxTest.cpp

Issue 834633006: add ImageGenerator::NewFromData to porting layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add helper for SkInstallDiscardablePixelRef(SkData*, ...) Created 5 years, 11 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"
11 #include "SkDecodingImageGenerator.h" 11 #include "SkImageGenerator.h"
12 #include "SkForceLinking.h" 12 #include "SkForceLinking.h"
13 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
14 #include "SkOSFile.h" 14 #include "SkOSFile.h"
15 #include "SkRandom.h" 15 #include "SkRandom.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "Test.h" 17 #include "Test.h"
18 18
19 __SK_FORCE_IMAGE_DECODER_LINKING; 19 __SK_FORCE_IMAGE_DECODER_LINKING;
20 20
21 /** 21 /**
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // Load PKM file into a bitmap 145 // Load PKM file into a bitmap
146 SkBitmap etcBitmap; 146 SkBitmap etcBitmap;
147 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(pkmFilename.c_str())); 147 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(pkmFilename.c_str()));
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( 154 SkInstallDiscardablePixelRef(fileData, &etcBitmap);
155 SkDecodingImageGenerator::Create(
156 fileData, SkDecodingImageGenerator::Options()), &etcBitmap);
157 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); 155 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess);
158 156
159 // Write the bitmap out to a KTX file. 157 // Write the bitmap out to a KTX file.
160 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0); 158 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0);
161 SkAutoDataUnref newKtxData(ktxDataPtr); 159 SkAutoDataUnref newKtxData(ktxDataPtr);
162 REPORTER_ASSERT(reporter, ktxDataPtr); 160 REPORTER_ASSERT(reporter, ktxDataPtr);
163 161
164 // 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.
165 SkString ktxFilename = GetResourcePath("mandrill_128.ktx"); 163 SkString ktxFilename = GetResourcePath("mandrill_128.ktx");
166 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); 164 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str()));
167 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); 165 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData));
168 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698