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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 row += decodedBitmap.rowBytes(); | 134 row += decodedBitmap.rowBytes(); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 /** | 138 /** |
139 * 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 |
140 * 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 |
141 * 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
) |
142 */ | 142 */ |
143 DEF_TEST(KtxReexportPKM, reporter) { | 143 DEF_TEST(KtxReexportPKM, reporter) { |
144 SkString resourcePath = GetResourcePath(); | 144 SkString pkmFilename = GetResourcePath("mandrill_128.pkm"); |
145 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128
.pkm"); | |
146 | 145 |
147 // Load PKM file into a bitmap | 146 // Load PKM file into a bitmap |
148 SkBitmap etcBitmap; | 147 SkBitmap etcBitmap; |
149 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())); | 148 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(pkmFilename.c_str())); |
150 REPORTER_ASSERT(reporter, NULL != fileData); | 149 REPORTER_ASSERT(reporter, NULL != fileData); |
151 | 150 |
152 bool installDiscardablePixelRefSuccess = | 151 bool installDiscardablePixelRefSuccess = |
153 SkInstallDiscardablePixelRef( | 152 SkInstallDiscardablePixelRef( |
154 SkDecodingImageGenerator::Create( | 153 SkDecodingImageGenerator::Create( |
155 fileData, SkDecodingImageGenerator::Options()), &etcBitmap); | 154 fileData, SkDecodingImageGenerator::Options()), &etcBitmap); |
156 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); | 155 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); |
157 | 156 |
158 // Write the bitmap out to a KTX file. | 157 // Write the bitmap out to a KTX file. |
159 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k
KTX_Type, 0); | 158 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k
KTX_Type, 0); |
160 SkAutoDataUnref newKtxData(ktxDataPtr); | 159 SkAutoDataUnref newKtxData(ktxDataPtr); |
161 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); | 160 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); |
162 | 161 |
163 // 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. |
164 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_
128.ktx"); | 163 SkString ktxFilename = GetResourcePath("mandrill_128.ktx"); |
165 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); | 164 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); |
166 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); | 165 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); |
167 } | 166 } |
OLD | NEW |