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

Side by Side Diff: gm/rrectclipdrawpaint.cpp

Issue 2355483002: abstract name of clipping ops, to transtion to a more restricted set (Closed)
Patch Set: no need for ifdef for globals 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
« no previous file with comments | « gm/pathopsskpclip.cpp ('k') | gm/rrects.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "gm.h" 8 #include "gm.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
11 11
12 // Exercises code in GrDrawContext that attempts to replace a rrect clip/draw pa int with draw rrect. 12 // Exercises code in GrDrawContext that attempts to replace a rrect clip/draw pa int with draw rrect.
13 DEF_SIMPLE_GM(rrect_clip_draw_paint, canvas, 256, 256) { 13 DEF_SIMPLE_GM(rrect_clip_draw_paint, canvas, 256, 256) {
14 SkRRect rrect = SkRRect::MakeRectXY(SkRect::MakeXYWH(10.f, 10.f, 236.f, 236. f), 30.f, 40.f); 14 SkRRect rrect = SkRRect::MakeRectXY(SkRect::MakeXYWH(10.f, 10.f, 236.f, 236. f), 30.f, 40.f);
15 15
16 SkPaint p; 16 SkPaint p;
17 p.setColor(SK_ColorRED); 17 p.setColor(SK_ColorRED);
18 18
19 SkMatrix zoomOut; 19 SkMatrix zoomOut;
20 zoomOut.setScale(0.7f, 0.7f, 128.f, 128.f); 20 zoomOut.setScale(0.7f, 0.7f, 128.f, 128.f);
21 21
22 const SkRect layerRect = SkRect::MakeWH(256.f, 256.f); 22 const SkRect layerRect = SkRect::MakeWH(256.f, 256.f);
23 canvas->saveLayer(layerRect, nullptr); 23 canvas->saveLayer(layerRect, nullptr);
24 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, true); 24 canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, true);
25 canvas->drawPaint(p); 25 canvas->drawPaint(p);
26 canvas->restore(); 26 canvas->restore();
27 27
28 canvas->concat(zoomOut); 28 canvas->concat(zoomOut);
29 p.setColor(SK_ColorBLUE); 29 p.setColor(SK_ColorBLUE);
30 canvas->saveLayer(layerRect, nullptr); 30 canvas->saveLayer(layerRect, nullptr);
31 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, false); 31 canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, false);
32 canvas->drawPaint(p); 32 canvas->drawPaint(p);
33 canvas->restore(); 33 canvas->restore();
34 34
35 constexpr SkPoint kPts[] = {{0.f, 0.f}, {256.f, 256.f}}; 35 constexpr SkPoint kPts[] = {{0.f, 0.f}, {256.f, 256.f}};
36 constexpr SkColor kColors1[] = {SK_ColorCYAN, SK_ColorGREEN}; 36 constexpr SkColor kColors1[] = {SK_ColorCYAN, SK_ColorGREEN};
37 p.setShader(SkGradientShader::MakeLinear(kPts, kColors1, nullptr, 2, 37 p.setShader(SkGradientShader::MakeLinear(kPts, kColors1, nullptr, 2,
38 SkShader::kClamp_TileMode)); 38 SkShader::kClamp_TileMode));
39 canvas->concat(zoomOut); 39 canvas->concat(zoomOut);
40 canvas->saveLayer(layerRect, nullptr); 40 canvas->saveLayer(layerRect, nullptr);
41 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, true); 41 canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, true);
42 canvas->drawPaint(p); 42 canvas->drawPaint(p);
43 canvas->restore(); 43 canvas->restore();
44 44
45 constexpr SkColor kColors2[] = {SK_ColorMAGENTA, SK_ColorGRAY}; 45 constexpr SkColor kColors2[] = {SK_ColorMAGENTA, SK_ColorGRAY};
46 p.setShader(SkGradientShader::MakeRadial({128.f, 128.f}, 128.f, kColors2, nu llptr, 2, 46 p.setShader(SkGradientShader::MakeRadial({128.f, 128.f}, 128.f, kColors2, nu llptr, 2,
47 SkShader::kClamp_TileMode)); 47 SkShader::kClamp_TileMode));
48 canvas->concat(zoomOut); 48 canvas->concat(zoomOut);
49 canvas->saveLayer(layerRect, nullptr); 49 canvas->saveLayer(layerRect, nullptr);
50 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, false); 50 canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, false);
51 canvas->drawPaint(p); 51 canvas->drawPaint(p);
52 canvas->restore(); 52 canvas->restore();
53 } 53 }
OLDNEW
« no previous file with comments | « gm/pathopsskpclip.cpp ('k') | gm/rrects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698