| 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 |
| 10 #include "Resources.h" |
| 9 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 12 #include "SkData.h" |
| 11 #include "SkDecodingImageGenerator.h" | 13 #include "SkDecodingImageGenerator.h" |
| 12 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
| 13 #include "SkOSFile.h" | 15 #include "SkOSFile.h" |
| 14 | 16 |
| 15 #ifndef SK_IGNORE_ETC1_SUPPORT | 17 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 16 | 18 |
| 17 #include "etc1.h" | 19 #include "etc1.h" |
| 18 | 20 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 88 } |
| 87 | 89 |
| 88 virtual SkISize onISize() SK_OVERRIDE { | 90 virtual SkISize onISize() SK_OVERRIDE { |
| 89 return SkISize::Make(128, 128); | 91 return SkISize::Make(128, 128); |
| 90 } | 92 } |
| 91 | 93 |
| 92 virtual SkString fileExtension() const = 0; | 94 virtual SkString fileExtension() const = 0; |
| 93 | 95 |
| 94 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 96 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 95 SkBitmap bm; | 97 SkBitmap bm; |
| 96 SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mand
rill_128."); | 98 SkString resourcePath = GetResourcePath(); |
| 99 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill
_128."); |
| 97 filename.append(this->fileExtension()); | 100 filename.append(this->fileExtension()); |
| 98 | 101 |
| 99 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()))
; | 102 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()))
; |
| 100 if (NULL == fileData) { | 103 if (NULL == fileData) { |
| 101 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); | 104 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); |
| 102 return; | 105 return; |
| 103 } | 106 } |
| 104 | 107 |
| 105 if (!SkInstallDiscardablePixelRef( | 108 if (!SkInstallDiscardablePixelRef( |
| 106 SkDecodingImageGenerator::Create( | 109 SkDecodingImageGenerator::Create( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 protected: | 162 protected: |
| 160 virtual SkString onShortName() SK_OVERRIDE { | 163 virtual SkString onShortName() SK_OVERRIDE { |
| 161 return SkString("etc1bitmap_npot"); | 164 return SkString("etc1bitmap_npot"); |
| 162 } | 165 } |
| 163 | 166 |
| 164 virtual SkISize onISize() SK_OVERRIDE { | 167 virtual SkISize onISize() SK_OVERRIDE { |
| 165 return SkISize::Make(124, 124); | 168 return SkISize::Make(124, 124); |
| 166 } | 169 } |
| 167 | 170 |
| 168 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 171 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 169 | |
| 170 SkBitmap bm; | 172 SkBitmap bm; |
| 171 SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mand
rill_128.pkm"); | 173 SkString resourcePath = GetResourcePath(); |
| 174 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill
_128.pkm"); |
| 172 | 175 |
| 173 SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str())); | 176 SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str())); |
| 174 if (NULL == fileData) { | 177 if (NULL == fileData) { |
| 175 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); | 178 SkDebugf("Could not open the file. Did you forget to set the resourc
ePath?\n"); |
| 176 return; | 179 return; |
| 177 } | 180 } |
| 178 | 181 |
| 179 SkAutoMalloc am(fileData->size()); | 182 SkAutoMalloc am(fileData->size()); |
| 180 memcpy(am.get(), fileData->data(), fileData->size()); | 183 memcpy(am.get(), fileData->data(), fileData->size()); |
| 181 | 184 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 209 } // namespace skiagm | 212 } // namespace skiagm |
| 210 | 213 |
| 211 ////////////////////////////////////////////////////////////////////////////// | 214 ////////////////////////////////////////////////////////////////////////////// |
| 212 | 215 |
| 213 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); ) | 216 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); ) |
| 214 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); ) | 217 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); ) |
| 215 | 218 |
| 216 #ifndef SK_IGNORE_ETC1_SUPPORT | 219 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 217 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); ) | 220 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); ) |
| 218 #endif // SK_IGNORE_ETC1_SUPPORT | 221 #endif // SK_IGNORE_ETC1_SUPPORT |
| OLD | NEW |