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

Side by Side Diff: gm/etc1bitmap.cpp

Issue 1567893002: Fix crash when ETC1 codec is not supported. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: better comment Created 4 years, 11 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 | no next file » | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 SkBitmap bm; 98 SkBitmap bm;
99 SkString filename = GetResourcePath("mandrill_128."); 99 SkString filename = GetResourcePath("mandrill_128.");
100 filename.append(this->fileExtension()); 100 filename.append(this->fileExtension());
101 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ; 101 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ;
102 if (nullptr == fileData) { 102 if (nullptr == fileData) {
103 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n"); 103 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n");
104 return; 104 return;
105 } 105 }
106 106
107 SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(fileData)); 107 SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(fileData));
108 if (nullptr == image) {
109 SkDebugf("Could not decode the ETC file. ETC may not be included in this platform.\n");
110 return;
111 }
108 canvas->drawImage(image, 0, 0); 112 canvas->drawImage(image, 0, 0);
109 } 113 }
110 114
111 private: 115 private:
112 typedef GM INHERITED; 116 typedef GM INHERITED;
113 }; 117 };
114 118
115 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file. 119 // This class specializes ETC1BitmapGM to load the mandrill_128.pkm file.
116 class ETC1Bitmap_PKM_GM : public ETC1BitmapGM { 120 class ETC1Bitmap_PKM_GM : public ETC1BitmapGM {
117 public: 121 public:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 216
213 ////////////////////////////////////////////////////////////////////////////// 217 //////////////////////////////////////////////////////////////////////////////
214 218
215 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;) 219 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;)
216 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;) 220 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;)
217 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;) 221 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;)
218 222
219 #ifndef SK_IGNORE_ETC1_SUPPORT 223 #ifndef SK_IGNORE_ETC1_SUPPORT
220 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;) 224 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;)
221 #endif // SK_IGNORE_ETC1_SUPPORT 225 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698