| 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 9 #include "SkData.h" | 10 #include "SkData.h" |
| 10 #include "SkDecodingImageGenerator.h" | 11 #include "SkDecodingImageGenerator.h" |
| 11 #include "SkForceLinking.h" | 12 #include "SkForceLinking.h" |
| 12 #include "SkImageDecoder.h" | 13 #include "SkImageDecoder.h" |
| 13 #include "SkOSFile.h" | 14 #include "SkOSFile.h" |
| 14 #include "SkRandom.h" | 15 #include "SkRandom.h" |
| 15 #include "SkStream.h" | 16 #include "SkStream.h" |
| 16 #include "Test.h" | 17 #include "Test.h" |
| 17 | 18 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 row += decodedBitmap.rowBytes(); | 134 row += decodedBitmap.rowBytes(); |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 137 /** | 138 /** |
| 138 * Finally, make sure that if we get ETC1 data from a PKM file that we can then | 139 * Finally, make sure that if we get ETC1 data from a PKM file that we can then |
| 139 * accurately write it out into a KTX file (i.e. transferring the ETC1 data from | 140 * accurately write it out into a KTX file (i.e. transferring the ETC1 data from |
| 140 * the PKM to the KTX should produce an identical KTX to the one we have on file
) | 141 * the PKM to the KTX should produce an identical KTX to the one we have on file
) |
| 141 */ | 142 */ |
| 142 DEF_TEST(KtxReexportPKM, reporter) { | 143 DEF_TEST(KtxReexportPKM, reporter) { |
| 143 SkString resourcePath = skiatest::Test::GetResourcePath(); | 144 SkString resourcePath = GetResourcePath(); |
| 144 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128
.pkm"); | 145 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128
.pkm"); |
| 145 | 146 |
| 146 // Load PKM file into a bitmap | 147 // Load PKM file into a bitmap |
| 147 SkBitmap etcBitmap; | 148 SkBitmap etcBitmap; |
| 148 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())); | 149 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())); |
| 149 REPORTER_ASSERT(reporter, NULL != fileData); | 150 REPORTER_ASSERT(reporter, NULL != fileData); |
| 150 | 151 |
| 151 bool installDiscardablePixelRefSuccess = | 152 bool installDiscardablePixelRefSuccess = |
| 152 SkInstallDiscardablePixelRef( | 153 SkInstallDiscardablePixelRef( |
| 153 SkDecodingImageGenerator::Create( | 154 SkDecodingImageGenerator::Create( |
| 154 fileData, SkDecodingImageGenerator::Options()), &etcBitmap); | 155 fileData, SkDecodingImageGenerator::Options()), &etcBitmap); |
| 155 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); | 156 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); |
| 156 | 157 |
| 157 // Write the bitmap out to a KTX file. | 158 // Write the bitmap out to a KTX file. |
| 158 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k
KTX_Type, 0); | 159 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k
KTX_Type, 0); |
| 159 SkAutoDataUnref newKtxData(ktxDataPtr); | 160 SkAutoDataUnref newKtxData(ktxDataPtr); |
| 160 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); | 161 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); |
| 161 | 162 |
| 162 // See is this data is identical to data in existing ktx file. | 163 // See is this data is identical to data in existing ktx file. |
| 163 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_
128.ktx"); | 164 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_
128.ktx"); |
| 164 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); | 165 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); |
| 165 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); | 166 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); |
| 166 } | 167 } |
| OLD | NEW |