| 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 "gm.h" | 8 #include "gm.h" |
| 9 | 9 |
| 10 #include "Resources.h" | 10 #include "Resources.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 return SkISize::Make(128, 128); | 91 return SkISize::Make(128, 128); |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual SkString fileExtension() const = 0; | 94 virtual SkString fileExtension() const = 0; |
| 95 | 95 |
| 96 void onDraw(SkCanvas* canvas) override { | 96 void onDraw(SkCanvas* canvas) override { |
| 97 SkBitmap bm; | 97 SkBitmap bm; |
| 98 SkString filename = GetResourcePath("mandrill_128."); | 98 SkString filename = GetResourcePath("mandrill_128."); |
| 99 filename.append(this->fileExtension()); | 99 filename.append(this->fileExtension()); |
| 100 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()))
; | 100 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()))
; |
| 101 if (NULL == fileData) { | 101 if (nullptr == fileData) { |
| 102 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); | 102 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); |
| 103 return; | 103 return; |
| 104 } | 104 } |
| 105 | 105 |
| 106 if (!SkInstallDiscardablePixelRef(fileData, &bm)) { | 106 if (!SkInstallDiscardablePixelRef(fileData, &bm)) { |
| 107 SkDebugf("Could not install discardable pixel ref.\n"); | 107 SkDebugf("Could not install discardable pixel ref.\n"); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 | 110 |
| 111 canvas->drawBitmap(bm, 0, 0); | 111 canvas->drawBitmap(bm, 0, 0); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 SkISize onISize() override { | 177 SkISize onISize() override { |
| 178 return SkISize::Make(124, 124); | 178 return SkISize::Make(124, 124); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void onDraw(SkCanvas* canvas) override { | 181 void onDraw(SkCanvas* canvas) override { |
| 182 SkBitmap bm; | 182 SkBitmap bm; |
| 183 SkString pkmFilename = GetResourcePath("mandrill_128.pkm"); | 183 SkString pkmFilename = GetResourcePath("mandrill_128.pkm"); |
| 184 SkAutoDataUnref fileData(SkData::NewFromFileName(pkmFilename.c_str())); | 184 SkAutoDataUnref fileData(SkData::NewFromFileName(pkmFilename.c_str())); |
| 185 if (NULL == fileData) { | 185 if (nullptr == fileData) { |
| 186 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); | 186 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 | 189 |
| 190 SkAutoMalloc am(fileData->size()); | 190 SkAutoMalloc am(fileData->size()); |
| 191 memcpy(am.get(), fileData->data(), fileData->size()); | 191 memcpy(am.get(), fileData->data(), fileData->size()); |
| 192 | 192 |
| 193 int width, height; | 193 int width, height; |
| 194 if (!slice_etc1_data(am.get(), &width, &height)) { | 194 if (!slice_etc1_data(am.get(), &width, &height)) { |
| 195 SkDebugf("ETC1 Data is poorly formatted.\n"); | 195 SkDebugf("ETC1 Data is poorly formatted.\n"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 219 | 219 |
| 220 ////////////////////////////////////////////////////////////////////////////// | 220 ////////////////////////////////////////////////////////////////////////////// |
| 221 | 221 |
| 222 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;) | 222 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;) |
| 223 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;) | 223 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;) |
| 224 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;) | 224 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;) |
| 225 | 225 |
| 226 #ifndef SK_IGNORE_ETC1_SUPPORT | 226 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 227 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;) | 227 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;) |
| 228 #endif // SK_IGNORE_ETC1_SUPPORT | 228 #endif // SK_IGNORE_ETC1_SUPPORT |
| OLD | NEW |