| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkDecodingImageGenerator.h" | 10 #include "SkDecodingImageGenerator.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 SkAutoDataUnref encodedData(SkImageEncoder::EncodeData(bm8888, SkImageEncode
r::kKTX_Type, 0)); | 55 SkAutoDataUnref encodedData(SkImageEncoder::EncodeData(bm8888, SkImageEncode
r::kKTX_Type, 0)); |
| 56 REPORTER_ASSERT(reporter, NULL != encodedData); | 56 REPORTER_ASSERT(reporter, NULL != encodedData); |
| 57 | 57 |
| 58 SkAutoTUnref<SkMemoryStream> stream(SkNEW_ARGS(SkMemoryStream, (encodedData)
)); | 58 SkAutoTUnref<SkMemoryStream> stream(SkNEW_ARGS(SkMemoryStream, (encodedData)
)); |
| 59 REPORTER_ASSERT(reporter, NULL != stream); | 59 REPORTER_ASSERT(reporter, NULL != stream); |
| 60 | 60 |
| 61 SkBitmap decodedBitmap; | 61 SkBitmap decodedBitmap; |
| 62 bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitma
p); | 62 bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitma
p); |
| 63 REPORTER_ASSERT(reporter, imageDecodeSuccess); | 63 REPORTER_ASSERT(reporter, imageDecodeSuccess); |
| 64 | 64 |
| 65 REPORTER_ASSERT(reporter, decodedBitmap.config() == bm8888.config()); | 65 REPORTER_ASSERT(reporter, decodedBitmap.colorType() == bm8888.colorType()); |
| 66 REPORTER_ASSERT(reporter, decodedBitmap.alphaType() == bm8888.alphaType()); | 66 REPORTER_ASSERT(reporter, decodedBitmap.alphaType() == bm8888.alphaType()); |
| 67 REPORTER_ASSERT(reporter, decodedBitmap.width() == bm8888.width()); | 67 REPORTER_ASSERT(reporter, decodedBitmap.width() == bm8888.width()); |
| 68 REPORTER_ASSERT(reporter, decodedBitmap.height() == bm8888.height()); | 68 REPORTER_ASSERT(reporter, decodedBitmap.height() == bm8888.height()); |
| 69 REPORTER_ASSERT(reporter, !(decodedBitmap.empty())); | 69 REPORTER_ASSERT(reporter, !(decodedBitmap.empty())); |
| 70 | 70 |
| 71 uint8_t *decodedPixels = reinterpret_cast<uint8_t*>(decodedBitmap.getPixels(
)); | 71 uint8_t *decodedPixels = reinterpret_cast<uint8_t*>(decodedBitmap.getPixels(
)); |
| 72 REPORTER_ASSERT(reporter, NULL != decodedPixels); | 72 REPORTER_ASSERT(reporter, NULL != decodedPixels); |
| 73 REPORTER_ASSERT(reporter, decodedBitmap.getSize() == bm8888.getSize()); | 73 REPORTER_ASSERT(reporter, decodedBitmap.getSize() == bm8888.getSize()); |
| 74 | 74 |
| 75 if (NULL == decodedPixels) { | 75 if (NULL == decodedPixels) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |