OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkInterpolator.h" | 10 #include "SkInterpolator.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 canvas->drawRRect(create_circle(offset), p); | 104 canvas->drawRRect(create_circle(offset), p); |
105 break; | 105 break; |
106 case kConvexPath_Geometry: // fall thru | 106 case kConvexPath_Geometry: // fall thru |
107 case kRectAndConvex_Geometry: | 107 case kRectAndConvex_Geometry: |
108 canvas->drawPath(create_convex_path(offset), p); | 108 canvas->drawPath(create_convex_path(offset), p); |
109 break; | 109 break; |
110 case kConcavePath_Geometry: // fall thru | 110 case kConcavePath_Geometry: // fall thru |
111 case kRectAndConcave_Geometry: | 111 case kRectAndConcave_Geometry: |
112 canvas->drawPath(create_concave_path(offset), p); | 112 canvas->drawPath(create_concave_path(offset), p); |
113 break; | 113 break; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 class ClipDrawMatchView : public SampleView { | 117 class ClipDrawMatchView : public SampleView { |
118 public: | 118 public: |
119 ClipDrawMatchView() : fTrans(2, 5), fGeom(kRect_Geometry), fClipFirst(true),
fSign(1) { | 119 ClipDrawMatchView() : fTrans(2, 5), fGeom(kRect_Geometry), fClipFirst(true),
fSign(1) { |
120 SkScalar values[2]; | 120 SkScalar values[2]; |
121 | 121 |
122 fTrans.setRepeatCount(999); | 122 fTrans.setRepeatCount(999); |
123 values[0] = values[1] = 0; | 123 values[0] = values[1] = 0; |
124 fTrans.setKeyFrame(0, GetMSecs() + 1000, values); | 124 fTrans.setKeyFrame(0, GetMSecs() + 1000, values); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 r.offset(fSign * kXlate, fSign * kXlate); | 195 r.offset(fSign * kXlate, fSign * kXlate); |
196 canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces
shader clips | 196 canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces
shader clips |
197 canvas->clipPath(create_convex_path(offset), SkRegion::kIntersect_Op
, useAA); | 197 canvas->clipPath(create_convex_path(offset), SkRegion::kIntersect_Op
, useAA); |
198 } break; | 198 } break; |
199 case kRectAndConcave_Geometry: { | 199 case kRectAndConcave_Geometry: { |
200 SkRect r = create_rect(offset); | 200 SkRect r = create_rect(offset); |
201 r.offset(fSign * kXlate, fSign * kXlate); | 201 r.offset(fSign * kXlate, fSign * kXlate); |
202 canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces
shader clips | 202 canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces
shader clips |
203 canvas->clipPath(create_concave_path(offset), SkRegion::kIntersect_O
p, useAA); | 203 canvas->clipPath(create_concave_path(offset), SkRegion::kIntersect_O
p, useAA); |
204 } break; | 204 } break; |
205 } | 205 } |
206 | 206 |
207 SkISize size = canvas->getDeviceSize(); | 207 SkISize size = canvas->getDeviceSize(); |
208 SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar(
size.height())); | 208 SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar(
size.height())); |
209 | 209 |
210 SkPaint p; | 210 SkPaint p; |
211 p.setColor(SK_ColorRED); | 211 p.setColor(SK_ColorRED); |
212 | 212 |
213 canvas->drawRect(bigR, p); | 213 canvas->drawRect(bigR, p); |
214 canvas->restoreToCount(count); | 214 canvas->restoreToCount(count); |
215 } | 215 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 int fSign; | 254 int fSign; |
255 const double fStart = SkTime::GetMSecs(); | 255 const double fStart = SkTime::GetMSecs(); |
256 | 256 |
257 typedef SampleView INHERITED; | 257 typedef SampleView INHERITED; |
258 }; | 258 }; |
259 | 259 |
260 ////////////////////////////////////////////////////////////////////////////// | 260 ////////////////////////////////////////////////////////////////////////////// |
261 | 261 |
262 static SkView* MyFactory() { return new ClipDrawMatchView; } | 262 static SkView* MyFactory() { return new ClipDrawMatchView; } |
263 static SkViewRegister reg(MyFactory); | 263 static SkViewRegister reg(MyFactory); |
OLD | NEW |