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

Side by Side Diff: tests/KtxTest.cpp

Issue 338493005: stop using SkBitmap::Config (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDecodingImageGenerator.h" 10 #include "SkDecodingImageGenerator.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 0xFF, 0xFF, 0xFF, 0x80};// Pixel 4 108 0xFF, 0xFF, 0xFF, 0x80};// Pixel 4
109 109
110 SkAutoTUnref<SkMemoryStream> stream( 110 SkAutoTUnref<SkMemoryStream> stream(
111 SkNEW_ARGS(SkMemoryStream, (kHalfWhiteKTX, sizeof(kHalfWhiteKTX)))); 111 SkNEW_ARGS(SkMemoryStream, (kHalfWhiteKTX, sizeof(kHalfWhiteKTX))));
112 REPORTER_ASSERT(reporter, NULL != stream); 112 REPORTER_ASSERT(reporter, NULL != stream);
113 113
114 SkBitmap decodedBitmap; 114 SkBitmap decodedBitmap;
115 bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitma p); 115 bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitma p);
116 REPORTER_ASSERT(reporter, imageDecodeSuccess); 116 REPORTER_ASSERT(reporter, imageDecodeSuccess);
117 117
118 REPORTER_ASSERT(reporter, decodedBitmap.config() == SkBitmap::kARGB_8888_Con fig); 118 REPORTER_ASSERT(reporter, decodedBitmap.colorType() == kN32_SkColorType);
119 REPORTER_ASSERT(reporter, decodedBitmap.alphaType() == kPremul_SkAlphaType); 119 REPORTER_ASSERT(reporter, decodedBitmap.alphaType() == kPremul_SkAlphaType);
120 REPORTER_ASSERT(reporter, decodedBitmap.width() == 2); 120 REPORTER_ASSERT(reporter, decodedBitmap.width() == 2);
121 REPORTER_ASSERT(reporter, decodedBitmap.height() == 2); 121 REPORTER_ASSERT(reporter, decodedBitmap.height() == 2);
122 REPORTER_ASSERT(reporter, !(decodedBitmap.empty())); 122 REPORTER_ASSERT(reporter, !(decodedBitmap.empty()));
123 123
124 uint8_t *decodedPixels = reinterpret_cast<uint8_t*>(decodedBitmap.getPixels( )); 124 uint8_t *decodedPixels = reinterpret_cast<uint8_t*>(decodedBitmap.getPixels( ));
125 REPORTER_ASSERT(reporter, NULL != decodedPixels); 125 REPORTER_ASSERT(reporter, NULL != decodedPixels);
126 126
127 uint8_t *row = decodedPixels; 127 uint8_t *row = decodedPixels;
128 for (int j = 0; j < decodedBitmap.height(); ++j) { 128 for (int j = 0; j < decodedBitmap.height(); ++j) {
(...skipping 28 matching lines...) Expand all
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, SkImageEncoder::k KTX_Type, 0);
159 SkAutoDataUnref newKtxData(ktxDataPtr); 159 SkAutoDataUnref newKtxData(ktxDataPtr);
160 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); 160 REPORTER_ASSERT(reporter, NULL != 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 = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_ 128.ktx"); 163 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "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