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