OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 namespace skiagm { | 10 namespace skiagm { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 virtual SkString onShortName() { | 55 virtual SkString onShortName() { |
56 return SkString("bitmapcopy"); | 56 return SkString("bitmapcopy"); |
57 } | 57 } |
58 | 58 |
59 virtual SkISize onISize() { | 59 virtual SkISize onISize() { |
60 return make_isize(540, 330); | 60 return make_isize(540, 330); |
61 } | 61 } |
62 | 62 |
63 virtual void onDraw(SkCanvas* canvas) { | 63 virtual void onDraw(SkCanvas* canvas) { |
64 SkPaint paint; | 64 SkPaint paint; |
65 SkScalar horizMargin = 10; | 65 SkScalar horizMargin(SkIntToScalar(10)); |
66 SkScalar vertMargin = 10; | 66 SkScalar vertMargin(SkIntToScalar(10)); |
67 | 67 |
68 SkBitmap src; | 68 SkBitmapDevice devTmp(SkBitmap::kARGB_8888_Config, 40, 40, false); |
69 src.allocN32Pixels(40, 40); | 69 SkCanvas canvasTmp(&devTmp); |
70 SkCanvas canvasTmp(src); | |
71 | 70 |
72 draw_checks(&canvasTmp, 40, 40); | 71 draw_checks(&canvasTmp, 40, 40); |
| 72 SkBitmap src = canvasTmp.getTopDevice()->accessBitmap(false); |
73 | 73 |
74 for (unsigned i = 0; i < NUM_CONFIGS; ++i) { | 74 for (unsigned i = 0; i < NUM_CONFIGS; ++i) { |
75 if (!src.deepCopyTo(&fDst[i], gConfigs[i])) { | 75 if (!src.deepCopyTo(&fDst[i], gConfigs[i])) { |
76 src.copyTo(&fDst[i], gConfigs[i]); | 76 src.copyTo(&fDst[i], gConfigs[i]); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 canvas->clear(0xFFDDDDDD); | 80 canvas->clear(0xFFDDDDDD); |
81 paint.setAntiAlias(true); | 81 paint.setAntiAlias(true); |
82 SkScalar width = SkIntToScalar(40); | 82 SkScalar width = SkIntToScalar(40); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 typedef GM INHERITED; | 121 typedef GM INHERITED; |
122 }; | 122 }; |
123 | 123 |
124 ////////////////////////////////////////////////////////////////////////////// | 124 ////////////////////////////////////////////////////////////////////////////// |
125 | 125 |
126 #ifndef SK_BUILD_FOR_ANDROID | 126 #ifndef SK_BUILD_FOR_ANDROID |
127 static GM* MyFactory(void*) { return new BitmapCopyGM; } | 127 static GM* MyFactory(void*) { return new BitmapCopyGM; } |
128 static GMRegistry reg(MyFactory); | 128 static GMRegistry reg(MyFactory); |
129 #endif | 129 #endif |
130 } | 130 } |
OLD | NEW |