OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 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 copying an image from 8888 to 4444. | 16 * Test decoding an image from a PKM file and then |
| 17 * from compressed ETC1 data. |
17 */ | 18 */ |
18 class CopyTo4444GM : public GM { | 19 class ETC1BitmapGM : public GM { |
19 public: | 20 public: |
20 CopyTo4444GM() {} | 21 ETC1BitmapGM() { } |
| 22 virtual ~ETC1BitmapGM() { } |
21 | 23 |
22 protected: | 24 protected: |
23 virtual SkString onShortName() { | 25 virtual SkString onShortName() SK_OVERRIDE { |
24 return SkString("copyTo4444"); | 26 return SkString("etc1bitmap"); |
25 } | 27 } |
26 | 28 |
27 virtual SkISize onISize() { | 29 virtual SkISize onISize() SK_OVERRIDE { |
28 return make_isize(1024, 512); | 30 return make_isize(512, 512); |
29 } | 31 } |
30 | 32 |
31 virtual void onDraw(SkCanvas* canvas) { | 33 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
32 SkBitmap bm, bm4444; | 34 |
| 35 SkBitmap bm; |
33 SkString filename = SkOSPath::SkPathJoin( | 36 SkString filename = SkOSPath::SkPathJoin( |
34 INHERITED::gResourcePath.c_str(), "mandrill_512.png"); | 37 INHERITED::gResourcePath.c_str(), "mandrill_512.pkm"); |
35 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, | 38 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, |
36 SkBitmap::kARGB_8888_Config, | 39 SkBitmap::kARGB_8888_Config, |
37 SkImageDecoder::kDecodePixels_Mode)) { | 40 SkImageDecoder::kDecodePixels_Mode)) { |
38 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 " |
39 "resourcePath?\n"); | 42 "resourcePath?\n"); |
40 return; | 43 return; |
41 } | 44 } |
42 canvas->drawBitmap(bm, 0, 0); | 45 canvas->drawBitmap(bm, 0, 0); |
43 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType)); | |
44 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0); | |
45 } | 46 } |
46 | 47 |
47 private: | 48 private: |
48 typedef GM INHERITED; | 49 typedef GM INHERITED; |
49 }; | 50 }; |
50 | 51 |
| 52 } // namespace skiagm |
| 53 |
51 ////////////////////////////////////////////////////////////////////////////// | 54 ////////////////////////////////////////////////////////////////////////////// |
52 | 55 |
53 static GM* MyFactory(void*) { return new CopyTo4444GM; } | 56 DEF_GM( return SkNEW(skiagm::ETC1BitmapGM); ) |
54 static GMRegistry reg(MyFactory); | |
55 | |
56 } | |
OLD | NEW |