Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: gm/drawregionmodes.cpp

Issue 2277053002: Add drawRegion() API to SkCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added shader to test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkBlurMaskFilter.h"
10 #include "SkCanvas.h"
11 #include "SkDashPathEffect.h"
12 #include "SkGradientShader.h"
13 #include "SkImageFilter.h"
14
15 class DrawRegionModesGM : public skiagm::GM {
16 public:
17 DrawRegionModesGM() {}
18
19 protected:
20 SkString onShortName() override {
21 return SkString("drawregionmodes");
22 }
23
24 SkISize onISize() override {
25 return SkISize::Make(375, 500);
26 }
27
28 void onOnceBeforeDraw() override {
29 fRegion.op( 50, 50, 100, 100, SkRegion::kUnion_Op);
30 fRegion.op( 50, 100, 150, 150, SkRegion::kUnion_Op);
31 }
32
33 void onDraw(SkCanvas* canvas) override {
34 canvas->clear(SK_ColorGREEN);
35
36 SkPaint paint;
37 paint.setStyle(SkPaint::kFill_Style);
38 paint.setColor(0xFFFF0000);
39 paint.setAntiAlias(true);
40
41 canvas->translate(-50.0f, 75.0f);
42 canvas->rotate(-45.0f);
43 canvas->drawRegion(fRegion, paint);
44
45 canvas->translate(125.0f, 125.0f);
46 paint.setImageFilter(SkImageFilter::MakeBlur(5.0f, 5.0f, nullptr, nullpt r));
47 canvas->drawRegion(fRegion, paint);
48
49 canvas->translate(-125.0f, 125.0f);
50 paint.setImageFilter(nullptr);
51 SkRect occluder = SkRect::MakeEmpty();
52 paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 5.0f, oc cluder, 0));
53 canvas->drawRegion(fRegion, paint);
54
55 canvas->translate(-125.0f, -125.0f);
56 paint.setMaskFilter(nullptr);
57 paint.setStyle(SkPaint::kStroke_Style);
58 float intervals[] = { 5.0f, 5.0f };
59 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 2.5f));
60 canvas->drawRegion(fRegion, paint);
61
62 canvas->setMatrix(SkMatrix::I());
63 canvas->translate(100, 325);
64 paint.setPathEffect(nullptr);
65 paint.setStyle(SkPaint::kFill_Style);
66 SkPoint points[] = { SkPoint::Make(50.0f, 50.0f), SkPoint::Make(150.0f, 150.0f) };
67 SkColor colors[] = { SK_ColorBLUE, SK_ColorYELLOW };
68 paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 2,
69 SkShader::kClamp_TileMode)) ;
70 canvas->drawRegion(fRegion, paint);
71 }
72
73 SkRegion fRegion;
74
75 private:
76 typedef skiagm::GM INHERITED;
77 };
78 DEF_GM( return new DrawRegionModesGM; )
OLDNEW
« no previous file with comments | « gm/drawregion.cpp ('k') | include/core/SkCanvas.h » ('j') | include/core/SkCanvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698