OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 | 8 |
9 #include "gm.h" | 9 #include "gm.h" |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 /** | 72 /** |
73 * This GM tests convex polygon clips. | 73 * This GM tests convex polygon clips. |
74 */ | 74 */ |
75 class ConvexPolyClip : public GM { | 75 class ConvexPolyClip : public GM { |
76 public: | 76 public: |
77 ConvexPolyClip() { | 77 ConvexPolyClip() { |
78 this->setBGColor(0xFFFFFFFF); | 78 this->setBGColor(0xFFFFFFFF); |
79 } | 79 } |
80 | 80 |
81 protected: | 81 protected: |
82 virtual SkString onShortName() SK_OVERRIDE { | 82 SkString onShortName() SK_OVERRIDE { |
83 return SkString("convex_poly_clip"); | 83 return SkString("convex_poly_clip"); |
84 } | 84 } |
85 | 85 |
86 virtual SkISize onISize() SK_OVERRIDE { | 86 SkISize onISize() SK_OVERRIDE { |
87 // When benchmarking the saveLayer set of draws is skipped. | 87 // When benchmarking the saveLayer set of draws is skipped. |
88 int w = 435; | 88 int w = 435; |
89 if (kBench_Mode != this->getMode()) { | 89 if (kBench_Mode != this->getMode()) { |
90 w *= 2; | 90 w *= 2; |
91 } | 91 } |
92 return SkISize::Make(w, 540); | 92 return SkISize::Make(w, 540); |
93 } | 93 } |
94 | 94 |
95 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 95 void onOnceBeforeDraw() SK_OVERRIDE { |
96 SkPath tri; | 96 SkPath tri; |
97 tri.moveTo(5.f, 5.f); | 97 tri.moveTo(5.f, 5.f); |
98 tri.lineTo(100.f, 20.f); | 98 tri.lineTo(100.f, 20.f); |
99 tri.lineTo(15.f, 100.f); | 99 tri.lineTo(15.f, 100.f); |
100 | 100 |
101 fClips.addToTail()->setPath(tri); | 101 fClips.addToTail()->setPath(tri); |
102 | 102 |
103 SkPath hexagon; | 103 SkPath hexagon; |
104 static const SkScalar kRadius = 45.f; | 104 static const SkScalar kRadius = 45.f; |
105 const SkPoint center = { kRadius, kRadius }; | 105 const SkPoint center = { kRadius, kRadius }; |
(...skipping 22 matching lines...) Expand all Loading... |
128 SkRect rect = SkRect::MakeLTRB(10.f, 12.f, 80.f, 86.f); | 128 SkRect rect = SkRect::MakeLTRB(10.f, 12.f, 80.f, 86.f); |
129 rotRect.addRect(rect); | 129 rotRect.addRect(rect); |
130 SkMatrix rotM; | 130 SkMatrix rotM; |
131 rotM.setRotate(23.f, rect.centerX(), rect.centerY()); | 131 rotM.setRotate(23.f, rect.centerX(), rect.centerY()); |
132 rotRect.transform(rotM); | 132 rotRect.transform(rotM); |
133 fClips.addToTail()->setPath(rotRect); | 133 fClips.addToTail()->setPath(rotRect); |
134 | 134 |
135 fBmp = make_bmp(100, 100); | 135 fBmp = make_bmp(100, 100); |
136 } | 136 } |
137 | 137 |
138 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 138 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
139 SkScalar y = 0; | 139 SkScalar y = 0; |
140 static const SkScalar kMargin = 10.f; | 140 static const SkScalar kMargin = 10.f; |
141 | 141 |
142 SkPaint bgPaint; | 142 SkPaint bgPaint; |
143 bgPaint.setAlpha(0x15); | 143 bgPaint.setAlpha(0x15); |
144 SkISize size = canvas->getDeviceSize(); | 144 SkISize size = canvas->getDeviceSize(); |
145 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(size.fWidth), | 145 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(size.fWidth), |
146 SkIntToScalar(size.fHeight)); | 146 SkIntToScalar(size.fHeight)); |
147 canvas->drawBitmapRectToRect(fBmp, NULL, dstRect, &bgPaint); | 147 canvas->drawBitmapRectToRect(fBmp, NULL, dstRect, &bgPaint); |
148 | 148 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 SkTLList<Clip> fClips; | 295 SkTLList<Clip> fClips; |
296 SkBitmap fBmp; | 296 SkBitmap fBmp; |
297 | 297 |
298 typedef GM INHERITED; | 298 typedef GM INHERITED; |
299 }; | 299 }; |
300 | 300 |
301 DEF_GM( return SkNEW(ConvexPolyClip); ) | 301 DEF_GM( return SkNEW(ConvexPolyClip); ) |
302 | 302 |
303 } | 303 } |
OLD | NEW |