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

Side by Side Diff: gm/rrectclipdrawpaint.cpp

Issue 2271053004: Convert drawPaint to drawRRect in simple cases (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix another msvs warning 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 | « no previous file | include/core/SkClipStack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkPath.h"
10 #include "SkGradientShader.h"
11
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) {
14 SkRRect rrect = SkRRect::MakeRectXY(SkRect::MakeXYWH(10.f, 10.f, 236.f, 236. f), 30.f, 40.f);
15
16 SkPaint p;
17 p.setColor(SK_ColorRED);
18
19 SkMatrix zoomOut;
20 zoomOut.setScale(0.7f, 0.7f, 128.f, 128.f);
21
22 const SkRect layerRect = SkRect::MakeWH(256.f, 256.f);
23 canvas->saveLayer(layerRect, nullptr);
24 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, true);
25 canvas->drawPaint(p);
26 canvas->restore();
27
28 canvas->concat(zoomOut);
29 p.setColor(SK_ColorBLUE);
30 canvas->saveLayer(layerRect, nullptr);
31 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, false);
32 canvas->drawPaint(p);
33 canvas->restore();
34
35 static constexpr SkPoint kPts[] = {{0.f, 0.f}, {256.f, 256.f}};
36 static constexpr SkColor kColors1[] = {SK_ColorCYAN, SK_ColorGREEN};
37 p.setShader(SkGradientShader::MakeLinear(kPts, kColors1, nullptr, 2,
38 SkShader::kClamp_TileMode));
39 canvas->concat(zoomOut);
40 canvas->saveLayer(layerRect, nullptr);
41 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, true);
42 canvas->drawPaint(p);
43 canvas->restore();
44
45 static constexpr SkColor kColors2[] = {SK_ColorMAGENTA, SK_ColorGRAY};
46 p.setShader(SkGradientShader::MakeRadial({128.f, 128.f}, 128.f, kColors2, nu llptr, 2,
47 SkShader::kClamp_TileMode));
48 canvas->concat(zoomOut);
49 canvas->saveLayer(layerRect, nullptr);
50 canvas->clipRRect(rrect, SkRegion::kIntersect_Op, false);
51 canvas->drawPaint(p);
52 canvas->restore();
53 }
OLDNEW
« no previous file with comments | « no previous file | include/core/SkClipStack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698