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 30 matching lines...) Expand all Loading... |
41 paint.setColor(SK_ColorYELLOW); | 41 paint.setColor(SK_ColorYELLOW); |
42 canvas->drawRectCoords(SkIntToScalar(width / 2), SkIntToScalar(height / 2), | 42 canvas->drawRectCoords(SkIntToScalar(width / 2), SkIntToScalar(height / 2), |
43 SkIntToScalar(width), SkIntToScalar(height), paint); | 43 SkIntToScalar(width), SkIntToScalar(height), paint); |
44 } | 44 } |
45 | 45 |
46 class BitmapCopyGM : public GM { | 46 class BitmapCopyGM : public GM { |
47 public: | 47 public: |
48 SkBitmap fDst[NUM_CONFIGS]; | 48 SkBitmap fDst[NUM_CONFIGS]; |
49 | 49 |
50 BitmapCopyGM() { | 50 BitmapCopyGM() { |
51 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); | 51 this->setBGColor(0xFFDDDDDD); |
52 } | 52 } |
53 | 53 |
54 protected: | 54 protected: |
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 SkISize::Make(540, 330); | 60 return SkISize::Make(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 = 10; |
66 SkScalar vertMargin = 10; | 66 SkScalar vertMargin = 10; |
67 | 67 |
68 SkBitmap src; | 68 SkBitmap src; |
69 src.allocN32Pixels(40, 40); | 69 src.allocN32Pixels(40, 40); |
70 SkCanvas canvasTmp(src); | 70 SkCanvas canvasTmp(src); |
71 | 71 |
72 draw_checks(&canvasTmp, 40, 40); | 72 draw_checks(&canvasTmp, 40, 40); |
73 | 73 |
74 for (unsigned i = 0; i < NUM_CONFIGS; ++i) { | 74 for (unsigned i = 0; i < NUM_CONFIGS; ++i) { |
75 src.copyTo(&fDst[i], gColorTypes[i]); | 75 src.copyTo(&fDst[i], gColorTypes[i]); |
76 } | 76 } |
77 | 77 |
78 canvas->clear(sk_tool_utils::color_to_565(0xFFDDDDDD)); | 78 canvas->clear(0xFFDDDDDD); |
79 paint.setAntiAlias(true); | 79 paint.setAntiAlias(true); |
80 sk_tool_utils::set_portable_typeface_always(&paint); | 80 sk_tool_utils::set_portable_typeface(&paint); |
81 | 81 |
82 SkScalar width = SkIntToScalar(40); | 82 SkScalar width = SkIntToScalar(40); |
83 SkScalar height = SkIntToScalar(40); | 83 SkScalar height = SkIntToScalar(40); |
84 if (paint.getFontSpacing() > height) { | 84 if (paint.getFontSpacing() > height) { |
85 height = paint.getFontSpacing(); | 85 height = paint.getFontSpacing(); |
86 } | 86 } |
87 for (unsigned i = 0; i < NUM_CONFIGS; i++) { | 87 for (unsigned i = 0; i < NUM_CONFIGS; i++) { |
88 const char* name = gColorTypeNames[src.colorType()]; | 88 const char* name = gColorTypeNames[src.colorType()]; |
89 SkScalar textWidth = paint.measureText(name, strlen(name)); | 89 SkScalar textWidth = paint.measureText(name, strlen(name)); |
90 if (textWidth > width) { | 90 if (textWidth > width) { |
(...skipping 25 matching lines...) Expand all Loading... |
116 | 116 |
117 private: | 117 private: |
118 typedef GM INHERITED; | 118 typedef GM INHERITED; |
119 }; | 119 }; |
120 | 120 |
121 ////////////////////////////////////////////////////////////////////////////// | 121 ////////////////////////////////////////////////////////////////////////////// |
122 | 122 |
123 static GM* MyFactory(void*) { return new BitmapCopyGM; } | 123 static GM* MyFactory(void*) { return new BitmapCopyGM; } |
124 static GMRegistry reg(MyFactory); | 124 static GMRegistry reg(MyFactory); |
125 } | 125 } |
OLD | NEW |