| 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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
| 11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
| 12 | 12 |
| 13 namespace skiagm { | 13 namespace skiagm { |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Test decoding an image from a PKM file and then | 16 * Test decoding an image from a PKM file and then |
| 17 * from compressed ETC1 data. | 17 * from compressed ETC1 data. |
| 18 */ | 18 */ |
| 19 class ETC1BitmapGM : public GM { | 19 class ETC1BitmapGM : public GM { |
| 20 public: | 20 public: |
| 21 ETC1BitmapGM() { } | 21 ETC1BitmapGM() { } |
| 22 virtual ~ETC1BitmapGM() { } | 22 virtual ~ETC1BitmapGM() { } |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 virtual SkString onShortName() SK_OVERRIDE { | 25 virtual SkString onShortName() SK_OVERRIDE { |
| 26 return SkString("etc1bitmap"); | 26 return SkString("etc1bitmap"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual SkISize onISize() SK_OVERRIDE { | 29 virtual SkISize onISize() SK_OVERRIDE { |
| 30 return make_isize(512, 512); | 30 return SkISize::Make(512, 512); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 33 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 34 | 34 |
| 35 SkBitmap bm; | 35 SkBitmap bm; |
| 36 SkString filename = SkOSPath::SkPathJoin( | 36 SkString filename = SkOSPath::SkPathJoin( |
| 37 INHERITED::gResourcePath.c_str(), "mandrill_512.pkm"); | 37 INHERITED::gResourcePath.c_str(), "mandrill_512.pkm"); |
| 38 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, | 38 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, |
| 39 SkBitmap::kARGB_8888_Config, | 39 SkBitmap::kARGB_8888_Config, |
| 40 SkImageDecoder::kDecodePixels_Mode)) { | 40 SkImageDecoder::kDecodePixels_Mode)) { |
| 41 SkDebugf("Could not decode the file. Did you forget to set the " | 41 SkDebugf("Could not decode the file. Did you forget to set the " |
| 42 "resourcePath?\n"); | 42 "resourcePath?\n"); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 canvas->drawBitmap(bm, 0, 0); | 45 canvas->drawBitmap(bm, 0, 0); |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 typedef GM INHERITED; | 49 typedef GM INHERITED; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace skiagm | 52 } // namespace skiagm |
| 53 | 53 |
| 54 ////////////////////////////////////////////////////////////////////////////// | 54 ////////////////////////////////////////////////////////////////////////////// |
| 55 | 55 |
| 56 DEF_GM( return SkNEW(skiagm::ETC1BitmapGM); ) | 56 DEF_GM( return SkNEW(skiagm::ETC1BitmapGM); ) |
| OLD | NEW |