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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 289 |
290 paint.setShader(NULL); | 290 paint.setShader(NULL); |
291 paint.setAntiAlias(true); | 291 paint.setAntiAlias(true); |
292 paint.setStrokeWidth(SkIntToScalar(5)); | 292 paint.setStrokeWidth(SkIntToScalar(5)); |
293 canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fP
ts, paint); | 293 canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fP
ts, paint); |
294 | 294 |
295 canvas->translate(0, SkIntToScalar(300)); | 295 canvas->translate(0, SkIntToScalar(300)); |
296 | 296 |
297 paint.setAntiAlias(false); | 297 paint.setAntiAlias(false); |
298 paint.setShader(fShader1); | 298 paint.setShader(fShader1); |
| 299 { |
| 300 SkMatrix m; |
| 301 m.setSkew(1, 0); |
| 302 SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m
); |
| 303 paint.setShader(s)->unref(); |
| 304 } |
| 305 { |
| 306 static int gAngle; |
| 307 SkMatrix m; |
| 308 m.setRotate(SkIntToScalar(gAngle++)); |
| 309 SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m
); |
| 310 paint.setShader(s)->unref(); |
| 311 } |
299 patch.setBounds(fSize1.fX, fSize1.fY); | 312 patch.setBounds(fSize1.fX, fSize1.fY); |
300 drawpatches(canvas, paint, 10, 10, &patch); | 313 drawpatches(canvas, paint, 10, 10, &patch); |
| 314 |
| 315 this->inval(NULL); |
301 } | 316 } |
302 | 317 |
303 class PtClick : public Click { | 318 class PtClick : public Click { |
304 public: | 319 public: |
305 int fIndex; | 320 int fIndex; |
306 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} | 321 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} |
307 }; | 322 }; |
308 | 323 |
309 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { | 324 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { |
310 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); | 325 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); |
(...skipping 16 matching lines...) Expand all Loading... |
327 } | 342 } |
328 | 343 |
329 private: | 344 private: |
330 typedef SampleView INHERITED; | 345 typedef SampleView INHERITED; |
331 }; | 346 }; |
332 | 347 |
333 ////////////////////////////////////////////////////////////////////////////// | 348 ////////////////////////////////////////////////////////////////////////////// |
334 | 349 |
335 static SkView* MyFactory() { return new PatchView; } | 350 static SkView* MyFactory() { return new PatchView; } |
336 static SkViewRegister reg(MyFactory); | 351 static SkViewRegister reg(MyFactory); |
OLD | NEW |