| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 /** | 74 /** |
| 75 * Test decoding an image from a PKM or KTX file and then | 75 * Test decoding an image from a PKM or KTX file and then |
| 76 * from compressed ETC1 data. | 76 * from compressed ETC1 data. |
| 77 */ | 77 */ |
| 78 class ETC1BitmapGM : public GM { | 78 class ETC1BitmapGM : public GM { |
| 79 public: | 79 public: |
| 80 ETC1BitmapGM() { } | 80 ETC1BitmapGM() { } |
| 81 virtual ~ETC1BitmapGM() { } | 81 virtual ~ETC1BitmapGM() { } |
| 82 | 82 |
| 83 protected: | 83 protected: |
| 84 SkString onShortName() SK_OVERRIDE { | 84 SkString onShortName() override { |
| 85 SkString str = SkString("etc1bitmap_"); | 85 SkString str = SkString("etc1bitmap_"); |
| 86 str.append(this->fileExtension()); | 86 str.append(this->fileExtension()); |
| 87 return str; | 87 return str; |
| 88 } | 88 } |
| 89 | 89 |
| 90 SkISize onISize() SK_OVERRIDE { | 90 SkISize onISize() override { |
| 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) SK_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 (NULL == 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); |
| 112 } | 112 } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 typedef GM INHERITED; | 115 typedef GM INHERITED; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file. | 118 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file. |
| 119 class ETC1Bitmap_PKM_GM : public ETC1BitmapGM { | 119 class ETC1Bitmap_PKM_GM : public ETC1BitmapGM { |
| 120 public: | 120 public: |
| 121 ETC1Bitmap_PKM_GM() : ETC1BitmapGM() { } | 121 ETC1Bitmap_PKM_GM() : ETC1BitmapGM() { } |
| 122 virtual ~ETC1Bitmap_PKM_GM() { } | 122 virtual ~ETC1Bitmap_PKM_GM() { } |
| 123 | 123 |
| 124 protected: | 124 protected: |
| 125 | 125 |
| 126 SkString fileExtension() const SK_OVERRIDE { return SkString("pkm"); } | 126 SkString fileExtension() const override { return SkString("pkm"); } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 typedef ETC1BitmapGM INHERITED; | 129 typedef ETC1BitmapGM INHERITED; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 // This class specializes ETC1BitmapGM to load the mandrill_128.ktx file. | 132 // This class specializes ETC1BitmapGM to load the mandrill_128.ktx file. |
| 133 class ETC1Bitmap_KTX_GM : public ETC1BitmapGM { | 133 class ETC1Bitmap_KTX_GM : public ETC1BitmapGM { |
| 134 public: | 134 public: |
| 135 ETC1Bitmap_KTX_GM() : ETC1BitmapGM() { } | 135 ETC1Bitmap_KTX_GM() : ETC1BitmapGM() { } |
| 136 virtual ~ETC1Bitmap_KTX_GM() { } | 136 virtual ~ETC1Bitmap_KTX_GM() { } |
| 137 | 137 |
| 138 protected: | 138 protected: |
| 139 | 139 |
| 140 SkString fileExtension() const SK_OVERRIDE { return SkString("ktx"); } | 140 SkString fileExtension() const override { return SkString("ktx"); } |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 typedef ETC1BitmapGM INHERITED; | 143 typedef ETC1BitmapGM INHERITED; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 // This class specializes ETC1BitmapGM to load the mandrill_128.r11.ktx file. | 146 // This class specializes ETC1BitmapGM to load the mandrill_128.r11.ktx file. |
| 147 class ETC1Bitmap_R11_KTX_GM : public ETC1BitmapGM { | 147 class ETC1Bitmap_R11_KTX_GM : public ETC1BitmapGM { |
| 148 public: | 148 public: |
| 149 ETC1Bitmap_R11_KTX_GM() : ETC1BitmapGM() { } | 149 ETC1Bitmap_R11_KTX_GM() : ETC1BitmapGM() { } |
| 150 virtual ~ETC1Bitmap_R11_KTX_GM() { } | 150 virtual ~ETC1Bitmap_R11_KTX_GM() { } |
| 151 | 151 |
| 152 protected: | 152 protected: |
| 153 | 153 |
| 154 SkString fileExtension() const SK_OVERRIDE { return SkString("r11.ktx"); } | 154 SkString fileExtension() const override { return SkString("r11.ktx"); } |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 typedef ETC1BitmapGM INHERITED; | 157 typedef ETC1BitmapGM INHERITED; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 #ifndef SK_IGNORE_ETC1_SUPPORT | 160 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 161 /** | 161 /** |
| 162 * Test decoding an image from a PKM file and then | 162 * Test decoding an image from a PKM file and then |
| 163 * from non-power-of-two compressed ETC1 data. First slice | 163 * from non-power-of-two compressed ETC1 data. First slice |
| 164 * off a row and column of blocks in order to make it non-power | 164 * off a row and column of blocks in order to make it non-power |
| 165 * of two. | 165 * of two. |
| 166 */ | 166 */ |
| 167 class ETC1Bitmap_NPOT_GM : public GM { | 167 class ETC1Bitmap_NPOT_GM : public GM { |
| 168 public: | 168 public: |
| 169 ETC1Bitmap_NPOT_GM() { } | 169 ETC1Bitmap_NPOT_GM() { } |
| 170 virtual ~ETC1Bitmap_NPOT_GM() { } | 170 virtual ~ETC1Bitmap_NPOT_GM() { } |
| 171 | 171 |
| 172 protected: | 172 protected: |
| 173 SkString onShortName() SK_OVERRIDE { | 173 SkString onShortName() override { |
| 174 return SkString("etc1bitmap_npot"); | 174 return SkString("etc1bitmap_npot"); |
| 175 } | 175 } |
| 176 | 176 |
| 177 SkISize onISize() SK_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) SK_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 (NULL == 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()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 219 | 219 |
| 220 ////////////////////////////////////////////////////////////////////////////// | 220 ////////////////////////////////////////////////////////////////////////////// |
| 221 | 221 |
| 222 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); ) | 222 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); ) |
| 223 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); ) | 223 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); ) |
| 224 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_R11_KTX_GM); ) | 224 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_R11_KTX_GM); ) |
| 225 | 225 |
| 226 #ifndef SK_IGNORE_ETC1_SUPPORT | 226 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 227 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); ) | 227 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); ) |
| 228 #endif // SK_IGNORE_ETC1_SUPPORT | 228 #endif // SK_IGNORE_ETC1_SUPPORT |
| OLD | NEW |