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 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 //! kRectnagleImageWithAlpha_SrcType scaled down by half. | 59 //! kRectnagleImageWithAlpha_SrcType scaled down by half. |
60 kSmallRectangleImageWithAlpha_SrcType = 0x04, | 60 kSmallRectangleImageWithAlpha_SrcType = 0x04, |
61 //! kRectangleImage_SrcType drawn directly instead in an image. | 61 //! kRectangleImage_SrcType drawn directly instead in an image. |
62 kRectangle_SrcType = 0x08, | 62 kRectangle_SrcType = 0x08, |
63 //! Two rectangles, first on the right half, second on the bottom half. | 63 //! Two rectangles, first on the right half, second on the bottom half. |
64 kQuarterClear_SrcType = 0x10, | 64 kQuarterClear_SrcType = 0x10, |
65 //! kQuarterClear_SrcType in a layer. | 65 //! kQuarterClear_SrcType in a layer. |
66 kQuarterClearInLayer_SrcType = 0x20, | 66 kQuarterClearInLayer_SrcType = 0x20, |
67 //! A W/2xH/2 transparent image. | 67 //! A W/2xH/2 transparent image. |
68 kSmallTransparentImage_SrcType = 0x40, | 68 kSmallTransparentImage_SrcType = 0x40, |
69 //! kRectangleImage_SrcType drawn directly with a mask. | |
70 kRectangleWithMask_SrcType = 0x80, | |
69 | 71 |
70 kAll_SrcType = 0x7F, //!< All the source types. | 72 kAll_SrcType = 0xFF, //!< All the source types. |
71 kBasic_SrcType = 0x03, //!< Just basic source types. | 73 kBasic_SrcType = 0x03, //!< Just basic source types. |
72 }; | 74 }; |
73 | 75 |
74 SkBitmap fBG; | 76 SkBitmap fBG; |
75 SkBitmap fSrcB, fDstB, fTransparent; | 77 SkBitmap fSrcB, fDstB, fTransparent; |
76 | 78 |
77 /* The srcType argument indicates what to draw for the source part. Skia | 79 /* The srcType argument indicates what to draw for the source part. Skia |
78 * uses the implied shape of the drawing command and these modes | 80 * uses the implied shape of the drawing command and these modes |
79 * demonstrate that. | 81 * demonstrate that. |
80 */ | 82 */ |
(...skipping 24 matching lines...) Expand all Loading... | |
105 SkScalar halfH = SkIntToScalar(H) / 2; | 107 SkScalar halfH = SkIntToScalar(H) / 2; |
106 p.setColor(0xFF66AAFF); | 108 p.setColor(0xFF66AAFF); |
107 SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW, | 109 SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW, |
108 SkIntToScalar(H)); | 110 SkIntToScalar(H)); |
109 canvas->drawRect(r, p); | 111 canvas->drawRect(r, p); |
110 p.setColor(0xFFAA66FF); | 112 p.setColor(0xFFAA66FF); |
111 r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH); | 113 r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH); |
112 canvas->drawRect(r, p); | 114 canvas->drawRect(r, p); |
113 break; | 115 break; |
114 } | 116 } |
117 case kRectangleWithMask_SrcType: { | |
vandebo (ex-Chrome)
2013/12/17 23:11:03
This demonstrates the problem in the bug before th
| |
118 canvas->save(SkCanvas::kClip_SaveFlag); | |
119 restoreNeeded = true; | |
120 SkScalar w = SkIntToScalar(W); | |
121 SkScalar h = SkIntToScalar(H); | |
122 SkRect r = SkRect::MakeXYWH(x, y + h / 4, w, h * 23 / 60); | |
123 canvas->clipRect(r); | |
124 // Fall through. | |
125 } | |
115 case kRectangle_SrcType: { | 126 case kRectangle_SrcType: { |
116 SkScalar w = SkIntToScalar(W); | 127 SkScalar w = SkIntToScalar(W); |
117 SkScalar h = SkIntToScalar(H); | 128 SkScalar h = SkIntToScalar(H); |
118 SkRect r = SkRect::MakeXYWH(x + w / 3, y + h / 3, | 129 SkRect r = SkRect::MakeXYWH(x + w / 3, y + h / 3, |
119 w * 37 / 60, h * 37 / 60); | 130 w * 37 / 60, h * 37 / 60); |
120 p.setColor(0xFF66AAFF); | 131 p.setColor(0xFF66AAFF); |
121 canvas->drawRect(r, p); | 132 canvas->drawRect(r, p); |
122 break; | 133 break; |
123 } | 134 } |
124 case kSmallRectangleImageWithAlpha_SrcType: | 135 case kSmallRectangleImageWithAlpha_SrcType: |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 private: | 285 private: |
275 typedef GM INHERITED; | 286 typedef GM INHERITED; |
276 }; | 287 }; |
277 | 288 |
278 ////////////////////////////////////////////////////////////////////////////// | 289 ////////////////////////////////////////////////////////////////////////////// |
279 | 290 |
280 static GM* MyFactory(void*) { return new XfermodesGM; } | 291 static GM* MyFactory(void*) { return new XfermodesGM; } |
281 static GMRegistry reg(MyFactory); | 292 static GMRegistry reg(MyFactory); |
282 | 293 |
283 } | 294 } |
OLD | NEW |