Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: gm/etc1bitmap.cpp

Issue 559093003: Revert of Added test for non cached ETC1 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/SkGr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual SkString onShortName() SK_OVERRIDE { 84 virtual SkString onShortName() SK_OVERRIDE {
85 SkString str = SkString("etc1bitmap_"); 85 SkString str = SkString("etc1bitmap_");
86 str.append(this->fileExtension()); 86 str.append(this->fileExtension());
87 if (this->isVolatile()) {
88 str.append("_volatile");
89 }
90 return str; 87 return str;
91 } 88 }
92 89
93 virtual SkISize onISize() SK_OVERRIDE { 90 virtual SkISize onISize() SK_OVERRIDE {
94 return SkISize::Make(128, 128); 91 return SkISize::Make(128, 128);
95 } 92 }
96 93
97 virtual bool isVolatile() const { return false; }
98
99 virtual SkString fileExtension() const = 0; 94 virtual SkString fileExtension() const = 0;
100 95
101 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 96 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
102 SkBitmap bm; 97 SkBitmap bm;
103 SkString filename = GetResourcePath("mandrill_128."); 98 SkString filename = GetResourcePath("mandrill_128.");
104 filename.append(this->fileExtension()); 99 filename.append(this->fileExtension());
105 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ; 100 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ;
106 if (NULL == fileData) { 101 if (NULL == fileData) {
107 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");
108 return; 103 return;
109 } 104 }
110 105
111 if (!SkInstallDiscardablePixelRef( 106 if (!SkInstallDiscardablePixelRef(
112 SkDecodingImageGenerator::Create( 107 SkDecodingImageGenerator::Create(
113 fileData, SkDecodingImageGenerator::Options()), &bm)) { 108 fileData, SkDecodingImageGenerator::Options()), &bm)) {
114 SkDebugf("Could not install discardable pixel ref.\n"); 109 SkDebugf("Could not install discardable pixel ref.\n");
115 return; 110 return;
116 } 111 }
117 112
118 bm.setIsVolatile(this->isVolatile());
119
120 canvas->drawBitmap(bm, 0, 0); 113 canvas->drawBitmap(bm, 0, 0);
121 } 114 }
122 115
123 private: 116 private:
124 typedef GM INHERITED; 117 typedef GM INHERITED;
125 }; 118 };
126 119
127 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file. 120 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file.
128 class ETC1Bitmap_PKM_GM : public ETC1BitmapGM { 121 class ETC1Bitmap_PKM_GM : public ETC1BitmapGM {
129 public: 122 public:
130 ETC1Bitmap_PKM_GM() : ETC1BitmapGM() { } 123 ETC1Bitmap_PKM_GM() : ETC1BitmapGM() { }
131 virtual ~ETC1Bitmap_PKM_GM() { } 124 virtual ~ETC1Bitmap_PKM_GM() { }
132 125
133 protected: 126 protected:
134 127
135 virtual SkString fileExtension() const SK_OVERRIDE { return SkString("pkm"); } 128 virtual SkString fileExtension() const SK_OVERRIDE { return SkString("pkm"); }
136 129
137 private: 130 private:
138 typedef ETC1BitmapGM INHERITED; 131 typedef ETC1BitmapGM INHERITED;
139 };
140
141 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file in a vo latile bitmap.
142 class ETC1Bitmap_PKM_VOLATILE_GM : public ETC1BitmapGM {
143 public:
144 ETC1Bitmap_PKM_VOLATILE_GM() : ETC1BitmapGM() { }
145 virtual ~ETC1Bitmap_PKM_VOLATILE_GM() { }
146
147 protected:
148
149 virtual SkString fileExtension() const SK_OVERRIDE { return SkString("pkm"); }
150 virtual bool isVolatile() const SK_OVERRIDE { return true; }
151
152 private:
153 typedef ETC1BitmapGM INHERITED;
154 }; 132 };
155 133
156 // This class specializes ETC1BitmapGM to load the mandrill_128.ktx file. 134 // This class specializes ETC1BitmapGM to load the mandrill_128.ktx file.
157 class ETC1Bitmap_KTX_GM : public ETC1BitmapGM { 135 class ETC1Bitmap_KTX_GM : public ETC1BitmapGM {
158 public: 136 public:
159 ETC1Bitmap_KTX_GM() : ETC1BitmapGM() { } 137 ETC1Bitmap_KTX_GM() : ETC1BitmapGM() { }
160 virtual ~ETC1Bitmap_KTX_GM() { } 138 virtual ~ETC1Bitmap_KTX_GM() { }
161 139
162 protected: 140 protected:
163 141
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 private: 217 private:
240 typedef GM INHERITED; 218 typedef GM INHERITED;
241 }; 219 };
242 #endif // SK_IGNORE_ETC1_SUPPORT 220 #endif // SK_IGNORE_ETC1_SUPPORT
243 221
244 } // namespace skiagm 222 } // namespace skiagm
245 223
246 ////////////////////////////////////////////////////////////////////////////// 224 //////////////////////////////////////////////////////////////////////////////
247 225
248 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); ) 226 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); )
249 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_VOLATILE_GM); )
250 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); ) 227 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); )
251 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_R11_KTX_GM); ) 228 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_R11_KTX_GM); )
252 229
253 #ifndef SK_IGNORE_ETC1_SUPPORT 230 #ifndef SK_IGNORE_ETC1_SUPPORT
254 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); ) 231 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); )
255 #endif // SK_IGNORE_ETC1_SUPPORT 232 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « no previous file | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698