OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 /** | 21 /** |
22 * First, make sure that writing an 8-bit RGBA KTX file and then | 22 * First, make sure that writing an 8-bit RGBA KTX file and then |
23 * reading it produces the same bitmap. | 23 * reading it produces the same bitmap. |
24 */ | 24 */ |
25 DEF_TEST(KtxReadWrite, reporter) { | 25 DEF_TEST(KtxReadWrite, reporter) { |
26 | 26 |
27 // Random number generator with explicit seed for reproducibility | 27 // Random number generator with explicit seed for reproducibility |
28 SkRandom rand(0x1005cbad); | 28 SkRandom rand(0x1005cbad); |
29 | 29 |
30 SkBitmap bm8888; | 30 SkBitmap bm8888; |
31 bool pixelsAllocated = bm8888.allocN32Pixels(128, 128); | 31 bm8888.allocN32Pixels(128, 128); |
32 REPORTER_ASSERT(reporter, pixelsAllocated); | |
33 | 32 |
34 uint8_t *pixels = reinterpret_cast<uint8_t*>(bm8888.getPixels()); | 33 uint8_t *pixels = reinterpret_cast<uint8_t*>(bm8888.getPixels()); |
35 REPORTER_ASSERT(reporter, NULL != pixels); | 34 REPORTER_ASSERT(reporter, NULL != pixels); |
36 | 35 |
37 if (NULL == pixels) { | 36 if (NULL == pixels) { |
38 return; | 37 return; |
39 } | 38 } |
40 | 39 |
41 uint8_t *row = pixels; | 40 uint8_t *row = pixels; |
42 for (int y = 0; y < bm8888.height(); ++y) { | 41 for (int y = 0; y < bm8888.height(); ++y) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Write the bitmap out to a KTX file. | 159 // Write the bitmap out to a KTX file. |
161 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k
KTX_Type, 0); | 160 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k
KTX_Type, 0); |
162 SkAutoDataUnref newKtxData(ktxDataPtr); | 161 SkAutoDataUnref newKtxData(ktxDataPtr); |
163 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); | 162 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); |
164 | 163 |
165 // See is this data is identical to data in existing ktx file. | 164 // See is this data is identical to data in existing ktx file. |
166 SkString ktxFilename = GetResourcePath("mandrill_128.ktx"); | 165 SkString ktxFilename = GetResourcePath("mandrill_128.ktx"); |
167 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); | 166 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); |
168 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); | 167 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); |
169 } | 168 } |
OLD | NEW |