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

Side by Side Diff: gm/windowrectangles.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/skbug1719.cpp ('k') | gyp/skia_for_android_framework_defines.gypi » ('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 "SkClipStack.h" 9 #include "SkClipStack.h"
10 #include "SkRRect.h" 10 #include "SkRRect.h"
(...skipping 24 matching lines...) Expand all
35 private: 35 private:
36 SkISize onISize() override { return SkISize::Make(kDeviceRect.width(), kDevi ceRect.height()); } 36 SkISize onISize() override { return SkISize::Make(kDeviceRect.width(), kDevi ceRect.height()); }
37 void onDraw(SkCanvas*) final; 37 void onDraw(SkCanvas*) final;
38 }; 38 };
39 39
40 void WindowRectanglesBaseGM::onDraw(SkCanvas* canvas) { 40 void WindowRectanglesBaseGM::onDraw(SkCanvas* canvas) {
41 sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 25); 41 sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 25);
42 canvas->saveLayer(SkRect::Make(kLayerRect), nullptr); 42 canvas->saveLayer(SkRect::Make(kLayerRect), nullptr);
43 43
44 SkClipStack stack; 44 SkClipStack stack;
45 stack.clipDevRect(SkRect::MakeXYWH(370.75, 80.25, 149, 100), SkRegion::kDiff erence_Op, false); 45 stack.clipDevRect(SkRect::MakeXYWH(370.75, 80.25, 149, 100), SkCanvas::kDiff erence_Op, false);
46 stack.clipDevRect(SkRect::MakeXYWH(80.25, 420.75, 150, 100), SkRegion::kDiff erence_Op, true); 46 stack.clipDevRect(SkRect::MakeXYWH(80.25, 420.75, 150, 100), SkCanvas::kDiff erence_Op, true);
47 stack.clipDevRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(200, 200, 200, 200), 60, 45), 47 stack.clipDevRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(200, 200, 200, 200), 60, 45),
48 SkRegion::kDifference_Op, true); 48 SkCanvas::kDifference_Op, true);
49 49
50 SkRRect nine; 50 SkRRect nine;
51 nine.setNinePatch(SkRect::MakeXYWH(550 - 30.25 - 100, 370.75, 100, 150), 12, 35, 23, 20); 51 nine.setNinePatch(SkRect::MakeXYWH(550 - 30.25 - 100, 370.75, 100, 150), 12, 35, 23, 20);
52 stack.clipDevRRect(nine, SkRegion::kDifference_Op, true); 52 stack.clipDevRRect(nine, SkCanvas::kDifference_Op, true);
53 53
54 SkRRect complx; 54 SkRRect complx;
55 SkVector complxRadii[4] = {{6, 4}, {8, 12}, {16, 24}, {48, 32}}; 55 SkVector complxRadii[4] = {{6, 4}, {8, 12}, {16, 24}, {48, 32}};
56 complx.setRectRadii(SkRect::MakeXYWH(80.25, 80.75, 100, 149), complxRadii); 56 complx.setRectRadii(SkRect::MakeXYWH(80.25, 80.75, 100, 149), complxRadii);
57 stack.clipDevRRect(complx, SkRegion::kDifference_Op, false); 57 stack.clipDevRRect(complx, SkCanvas::kDifference_Op, false);
58 58
59 this->onCoverClipStack(stack, canvas); 59 this->onCoverClipStack(stack, canvas);
60 60
61 canvas->restore(); 61 canvas->restore();
62 } 62 }
63 63
64 //////////////////////////////////////////////////////////////////////////////// //////////////////// 64 //////////////////////////////////////////////////////////////////////////////// ////////////////////
65 65
66 /** 66 /**
67 * Draws a clip that will exercise window rectangles if they are supported. 67 * Draws a clip that will exercise window rectangles if they are supported.
68 */ 68 */
69 class WindowRectanglesGM : public WindowRectanglesBaseGM { 69 class WindowRectanglesGM : public WindowRectanglesBaseGM {
70 private: 70 private:
71 SkString onShortName() final { return SkString("windowrectangles"); } 71 SkString onShortName() final { return SkString("windowrectangles"); }
72 void onCoverClipStack(const SkClipStack&, SkCanvas*) final; 72 void onCoverClipStack(const SkClipStack&, SkCanvas*) final;
73 }; 73 };
74 74
75 /** 75 /**
76 * This is a simple helper class for resetting a canvas's clip to our test’s SkC lipStack. 76 * This is a simple helper class for resetting a canvas's clip to our test’s SkC lipStack.
77 */ 77 */
78 class ReplayClipStackVisitor final : public SkCanvasClipVisitor { 78 class ReplayClipStackVisitor final : public SkCanvasClipVisitor {
79 public: 79 public:
80 typedef SkRegion::Op Op; 80 typedef SkCanvas::ClipOp Op;
81 ReplayClipStackVisitor(SkCanvas* canvas) : fCanvas(canvas) {} 81 ReplayClipStackVisitor(SkCanvas* canvas) : fCanvas(canvas) {}
82 void clipRect(const SkRect& r, Op op, bool aa) override { fCanvas->clipRect( r, op, aa); } 82 void clipRect(const SkRect& r, Op op, bool aa) override { fCanvas->clipRect( r, op, aa); }
83 void clipRRect(const SkRRect& rr, Op op, bool aa) override { fCanvas->clipRR ect(rr, op, aa); } 83 void clipRRect(const SkRRect& rr, Op op, bool aa) override { fCanvas->clipRR ect(rr, op, aa); }
84 void clipPath(const SkPath&, Op, bool) override { SkFAIL("Not implemented"); } 84 void clipPath(const SkPath&, Op, bool) override { SkFAIL("Not implemented"); }
85 private: 85 private:
86 SkCanvas* const fCanvas; 86 SkCanvas* const fCanvas;
87 }; 87 };
88 88
89 void WindowRectanglesGM::onCoverClipStack(const SkClipStack& stack, SkCanvas* ca nvas) { 89 void WindowRectanglesGM::onCoverClipStack(const SkClipStack& stack, SkCanvas* ca nvas) {
90 SkPaint paint; 90 SkPaint paint;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 canvas->clear(SK_ColorWHITE); 292 canvas->clear(SK_ColorWHITE);
293 canvas->drawText(errorMsg.c_str(), errorMsg.size(), SkIntToScalar(kCoverRect .centerX()), 293 canvas->drawText(errorMsg.c_str(), errorMsg.size(), SkIntToScalar(kCoverRect .centerX()),
294 SkIntToScalar(kCoverRect.centerY() - 10), paint); 294 SkIntToScalar(kCoverRect.centerY() - 10), paint);
295 } 295 }
296 296
297 DEF_GM( return new WindowRectanglesMaskGM(); ) 297 DEF_GM( return new WindowRectanglesMaskGM(); )
298 298
299 #endif 299 #endif
300 300
301 } 301 }
OLDNEW
« no previous file with comments | « gm/skbug1719.cpp ('k') | gyp/skia_for_android_framework_defines.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698