| 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 if (!GetResourceAsBitmap("mandrill_512.png", &bm)) { | 35 SkString pngFilename = GetResourcePath("mandrill_512.png"); |
| 36 if (!SkImageDecoder::DecodeFile(pngFilename.c_str(), &bm, kN32_SkColorTy
pe, |
| 37 SkImageDecoder::kDecodePixels_Mode)) { |
| 36 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 " |
| 37 "resourcePath?\n"); | 39 "resourcePath?\n"); |
| 38 return; | 40 return; |
| 39 } | 41 } |
| 40 canvas->drawBitmap(bm, 0, 0); | 42 canvas->drawBitmap(bm, 0, 0); |
| 41 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType)); | 43 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType)); |
| 42 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0); | 44 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0); |
| 43 } | 45 } |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 typedef GM INHERITED; | 48 typedef GM INHERITED; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 ////////////////////////////////////////////////////////////////////////////// | 51 ////////////////////////////////////////////////////////////////////////////// |
| 50 | 52 |
| 51 static GM* MyFactory(void*) { return new CopyTo4444GM; } | 53 static GM* MyFactory(void*) { return new CopyTo4444GM; } |
| 52 static GMRegistry reg(MyFactory); | 54 static GMRegistry reg(MyFactory); |
| 53 | 55 |
| 54 } | 56 } |
| OLD | NEW |