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

Side by Side Diff: tests/KtxTest.cpp

Issue 322963002: hide SkBitmap::setConfig (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
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | tools/picture_utils.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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDecodingImageGenerator.h" 10 #include "SkDecodingImageGenerator.h"
11 #include "SkForceLinking.h" 11 #include "SkForceLinking.h"
12 #include "SkImageDecoder.h" 12 #include "SkImageDecoder.h"
13 #include "SkOSFile.h" 13 #include "SkOSFile.h"
14 #include "SkRandom.h" 14 #include "SkRandom.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "Test.h" 16 #include "Test.h"
17 17
18 __SK_FORCE_IMAGE_DECODER_LINKING; 18 __SK_FORCE_IMAGE_DECODER_LINKING;
19 19
20 /** 20 /**
21 * First, make sure that writing an 8-bit RGBA KTX file and then 21 * First, make sure that writing an 8-bit RGBA KTX file and then
22 * reading it produces the same bitmap. 22 * reading it produces the same bitmap.
23 */ 23 */
24 DEF_TEST(KtxReadWrite, reporter) { 24 DEF_TEST(KtxReadWrite, reporter) {
25 25
26 // Random number generator with explicit seed for reproducibility 26 // Random number generator with explicit seed for reproducibility
27 SkRandom rand(0x1005cbad); 27 SkRandom rand(0x1005cbad);
28 28
29 SkBitmap bm8888; 29 SkBitmap bm8888;
30 bm8888.setConfig(SkBitmap::kARGB_8888_Config, 128, 128); 30 bool pixelsAllocated = bm8888.allocN32Pixels(128, 128);
31
32 bool pixelsAllocated = bm8888.allocPixels();
33 REPORTER_ASSERT(reporter, pixelsAllocated); 31 REPORTER_ASSERT(reporter, pixelsAllocated);
34 32
35 uint8_t *pixels = reinterpret_cast<uint8_t*>(bm8888.getPixels()); 33 uint8_t *pixels = reinterpret_cast<uint8_t*>(bm8888.getPixels());
36 REPORTER_ASSERT(reporter, NULL != pixels); 34 REPORTER_ASSERT(reporter, NULL != pixels);
37 35
38 if (NULL == pixels) { 36 if (NULL == pixels) {
39 return; 37 return;
40 } 38 }
41 39
42 uint8_t *row = pixels; 40 uint8_t *row = pixels;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, NULL != ktxDataPtr); 160 REPORTER_ASSERT(reporter, NULL != 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 = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_ 128.ktx"); 163 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "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
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | tools/picture_utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698