| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |