OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 return SkString("copyTo4444"); | 24 return SkString("copyTo4444"); |
25 } | 25 } |
26 | 26 |
27 virtual SkISize onISize() { | 27 virtual SkISize onISize() { |
28 return SkISize::Make(1024, 512); | 28 return SkISize::Make(1024, 512); |
29 } | 29 } |
30 | 30 |
31 virtual void onDraw(SkCanvas* canvas) { | 31 virtual void onDraw(SkCanvas* canvas) { |
32 SkBitmap bm, bm4444; | 32 SkBitmap bm, bm4444; |
33 SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mand
rill_512.png"); | 33 SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mand
rill_512.png"); |
34 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, | 34 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, kN32_SkColorType, |
35 SkBitmap::kARGB_8888_Config, | |
36 SkImageDecoder::kDecodePixels_Mode)) { | 35 SkImageDecoder::kDecodePixels_Mode)) { |
37 SkDebugf("Could not decode the file. Did you forget to set the " | 36 SkDebugf("Could not decode the file. Did you forget to set the " |
38 "resourcePath?\n"); | 37 "resourcePath?\n"); |
39 return; | 38 return; |
40 } | 39 } |
41 canvas->drawBitmap(bm, 0, 0); | 40 canvas->drawBitmap(bm, 0, 0); |
42 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType)); | 41 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType)); |
43 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0); | 42 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0); |
44 } | 43 } |
45 | 44 |
46 private: | 45 private: |
47 typedef GM INHERITED; | 46 typedef GM INHERITED; |
48 }; | 47 }; |
49 | 48 |
50 ////////////////////////////////////////////////////////////////////////////// | 49 ////////////////////////////////////////////////////////////////////////////// |
51 | 50 |
52 static GM* MyFactory(void*) { return new CopyTo4444GM; } | 51 static GM* MyFactory(void*) { return new CopyTo4444GM; } |
53 static GMRegistry reg(MyFactory); | 52 static GMRegistry reg(MyFactory); |
54 | 53 |
55 } | 54 } |
OLD | NEW |