csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 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" |
Mike Klein | 33d2055 | 2017-03-22 13:47:51 -0400 | [diff] [blame] | 9 | #include "sk_tool_utils.h" |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 10 | #include "SkClipStack.h" |
| 11 | #include "SkRRect.h" |
| 12 | |
| 13 | #if SK_SUPPORT_GPU |
| 14 | # include "GrAppliedClip.h" |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 15 | # include "GrFixedClip.h" |
| 16 | # include "GrReducedClip.h" |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 17 | # include "GrRenderTargetContext.h" |
| 18 | # include "GrRenderTargetContextPriv.h" |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 19 | # include "GrResourceProvider.h" |
| 20 | # include "effects/GrTextureDomain.h" |
| 21 | #endif |
| 22 | |
| 23 | constexpr static SkIRect kDeviceRect = {0, 0, 600, 600}; |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 24 | constexpr static SkIRect kCoverRect = {50, 50, 550, 550}; |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 25 | |
| 26 | namespace skiagm { |
| 27 | |
| 28 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | |
| 30 | class WindowRectanglesBaseGM : public GM { |
| 31 | protected: |
| 32 | virtual void onCoverClipStack(const SkClipStack&, SkCanvas*) = 0; |
| 33 | |
| 34 | private: |
| 35 | SkISize onISize() override { return SkISize::Make(kDeviceRect.width(), kDeviceRect.height()); } |
| 36 | void onDraw(SkCanvas*) final; |
| 37 | }; |
| 38 | |
| 39 | void WindowRectanglesBaseGM::onDraw(SkCanvas* canvas) { |
| 40 | sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 25); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 41 | |
| 42 | SkClipStack stack; |
Brian Salomon | a3b45d4 | 2016-10-03 11:36:16 -0400 | [diff] [blame] | 43 | stack.clipRect(SkRect::MakeXYWH(370.75, 80.25, 149, 100), SkMatrix::I(), |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 44 | kDifference_SkClipOp, false); |
Brian Salomon | a3b45d4 | 2016-10-03 11:36:16 -0400 | [diff] [blame] | 45 | stack.clipRect(SkRect::MakeXYWH(80.25, 420.75, 150, 100), SkMatrix::I(), |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 46 | kDifference_SkClipOp, true); |
Brian Salomon | a3b45d4 | 2016-10-03 11:36:16 -0400 | [diff] [blame] | 47 | stack.clipRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(200, 200, 200, 200), 60, 45), |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 48 | SkMatrix::I(), kDifference_SkClipOp, true); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 49 | |
| 50 | SkRRect nine; |
| 51 | nine.setNinePatch(SkRect::MakeXYWH(550 - 30.25 - 100, 370.75, 100, 150), 12, 35, 23, 20); |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 52 | stack.clipRRect(nine, SkMatrix::I(), kDifference_SkClipOp, true); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 53 | |
| 54 | SkRRect complx; |
| 55 | SkVector complxRadii[4] = {{6, 4}, {8, 12}, {16, 24}, {48, 32}}; |
| 56 | complx.setRectRadii(SkRect::MakeXYWH(80.25, 80.75, 100, 149), complxRadii); |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 57 | stack.clipRRect(complx, SkMatrix::I(), kDifference_SkClipOp, false); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 58 | |
| 59 | this->onCoverClipStack(stack, canvas); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 63 | |
| 64 | /** |
| 65 | * Draws a clip that will exercise window rectangles if they are supported. |
| 66 | */ |
| 67 | class WindowRectanglesGM : public WindowRectanglesBaseGM { |
| 68 | private: |
| 69 | SkString onShortName() final { return SkString("windowrectangles"); } |
| 70 | void onCoverClipStack(const SkClipStack&, SkCanvas*) final; |
| 71 | }; |
| 72 | |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 73 | void WindowRectanglesGM::onCoverClipStack(const SkClipStack& stack, SkCanvas* canvas) { |
| 74 | SkPaint paint; |
| 75 | paint.setColor(0xff00aa80); |
| 76 | |
| 77 | // Set up the canvas's clip to match our SkClipStack. |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 78 | SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); |
| 79 | for (const SkClipStack::Element* element = iter.next(); element; element = iter.next()) { |
Mike Reed | 598524d | 2017-03-08 13:13:44 -0500 | [diff] [blame] | 80 | SkClipOp op = element->getOp(); |
| 81 | bool isAA = element->isAA(); |
Brian Salomon | f3b46e5 | 2017-08-30 11:37:57 -0400 | [diff] [blame] | 82 | switch (element->getDeviceSpaceType()) { |
| 83 | case SkClipStack::Element::DeviceSpaceType::kPath: |
| 84 | canvas->clipPath(element->getDeviceSpacePath(), op, isAA); |
Mike Reed | 598524d | 2017-03-08 13:13:44 -0500 | [diff] [blame] | 85 | break; |
Brian Salomon | f3b46e5 | 2017-08-30 11:37:57 -0400 | [diff] [blame] | 86 | case SkClipStack::Element::DeviceSpaceType::kRRect: |
| 87 | canvas->clipRRect(element->getDeviceSpaceRRect(), op, isAA); |
Mike Reed | 598524d | 2017-03-08 13:13:44 -0500 | [diff] [blame] | 88 | break; |
Brian Salomon | f3b46e5 | 2017-08-30 11:37:57 -0400 | [diff] [blame] | 89 | case SkClipStack::Element::DeviceSpaceType::kRect: |
| 90 | canvas->clipRect(element->getDeviceSpaceRect(), op, isAA); |
Mike Reed | 598524d | 2017-03-08 13:13:44 -0500 | [diff] [blame] | 91 | break; |
Brian Salomon | f3b46e5 | 2017-08-30 11:37:57 -0400 | [diff] [blame] | 92 | case SkClipStack::Element::DeviceSpaceType::kEmpty: |
Mike Reed | 598524d | 2017-03-08 13:13:44 -0500 | [diff] [blame] | 93 | canvas->clipRect({ 0, 0, 0, 0 }, kIntersect_SkClipOp, false); |
| 94 | break; |
| 95 | } |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | canvas->drawRect(SkRect::Make(kCoverRect), paint); |
| 99 | } |
| 100 | |
| 101 | DEF_GM( return new WindowRectanglesGM(); ) |
| 102 | |
| 103 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 104 | |
| 105 | #if SK_SUPPORT_GPU |
| 106 | |
mtklein | 0a44107 | 2016-09-06 11:45:31 -0700 | [diff] [blame] | 107 | constexpr static int kNumWindows = 8; |
| 108 | |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 109 | /** |
| 110 | * Visualizes the mask (alpha or stencil) for a clip with several window rectangles. The purpose of |
| 111 | * this test is to verify that window rectangles are being used during clip mask generation, and to |
| 112 | * visualize where the window rectangles are placed. |
| 113 | * |
| 114 | * We use window rectangles when generating the clip mask because there is no need to invest time |
| 115 | * defining those regions where window rectangles will be in effect during the actual draw anyway. |
| 116 | * |
| 117 | * This test works by filling the entire clip mask with a small checkerboard pattern before drawing |
| 118 | * it, and then covering the mask with a solid color once it has been generated. The regions inside |
| 119 | * window rectangles or outside the scissor should still have the initial checkerboard intact. |
| 120 | */ |
| 121 | class WindowRectanglesMaskGM : public WindowRectanglesBaseGM { |
| 122 | private: |
| 123 | constexpr static int kMaskCheckerSize = 5; |
| 124 | SkString onShortName() final { return SkString("windowrectangles_mask"); } |
| 125 | void onCoverClipStack(const SkClipStack&, SkCanvas*) final; |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 126 | void visualizeAlphaMask(GrContext*, GrRenderTargetContext*, const GrReducedClip&, GrPaint&&); |
| 127 | void visualizeStencilMask(GrContext*, GrRenderTargetContext*, const GrReducedClip&, GrPaint&&); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 128 | void stencilCheckerboard(GrRenderTargetContext*, bool flip); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 129 | void fail(SkCanvas*); |
| 130 | }; |
| 131 | |
| 132 | /** |
| 133 | * Base class for GrClips that visualize a clip mask. |
| 134 | */ |
| 135 | class MaskOnlyClipBase : public GrClip { |
| 136 | private: |
| 137 | bool quickContains(const SkRect&) const final { return false; } |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 138 | bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const final { return false; } |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 139 | void getConservativeBounds(int width, int height, SkIRect* rect, bool* iior) const final { |
| 140 | rect->set(0, 0, width, height); |
| 141 | if (iior) { |
| 142 | *iior = false; |
| 143 | } |
| 144 | } |
| 145 | }; |
| 146 | |
| 147 | /** |
| 148 | * This class clips a cover by an alpha mask. We use it to visualize the alpha clip mask. |
| 149 | */ |
| 150 | class AlphaOnlyClip final : public MaskOnlyClipBase { |
| 151 | public: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 152 | AlphaOnlyClip(sk_sp<GrTextureProxy> mask, int x, int y) : fMask(mask), fX(x), fY(y) {} |
| 153 | |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 154 | private: |
Brian Salomon | 97180af | 2017-03-14 13:42:58 -0400 | [diff] [blame] | 155 | bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip* out, |
| 156 | SkRect* bounds) const override { |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 157 | int w = fMask->width(); |
| 158 | int h = fMask->height(); |
| 159 | out->addCoverageFP(GrDeviceSpaceTextureDecalFragmentProcessor::Make( |
| 160 | fMask, SkIRect::MakeWH(w, h), {fX, fY})); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 161 | return true; |
| 162 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 163 | sk_sp<GrTextureProxy> fMask; |
| 164 | int fX; |
| 165 | int fY; |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | /** |
| 169 | * This class clips a cover by the stencil clip bit. We use it to visualize the stencil mask. |
| 170 | */ |
| 171 | class StencilOnlyClip final : public MaskOnlyClipBase { |
| 172 | private: |
Brian Salomon | 97180af | 2017-03-14 13:42:58 -0400 | [diff] [blame] | 173 | bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip* out, |
| 174 | SkRect* bounds) const override { |
Robert Phillips | a4f792d | 2017-06-28 08:40:11 -0400 | [diff] [blame] | 175 | out->addStencilClip(SkClipStack::kEmptyGenID); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 176 | return true; |
| 177 | } |
| 178 | }; |
| 179 | |
| 180 | void WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack, SkCanvas* canvas) { |
| 181 | GrContext* ctx = canvas->getGrContext(); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 182 | GrRenderTargetContext* rtc = canvas->internal_private_accessTopLayerRenderTargetContext(); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 183 | |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 184 | if (!ctx || !rtc || rtc->priv().maxWindowRectangles() < kNumWindows) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 185 | this->fail(canvas); |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | const GrReducedClip reducedClip(stack, SkRect::Make(kCoverRect), kNumWindows); |
| 190 | |
| 191 | GrPaint paint; |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 192 | if (GrFSAAType::kNone == rtc->fsaaType()) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 193 | paint.setColor4f(GrColor4f(0, 0.25f, 1, 1)); |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 194 | this->visualizeAlphaMask(ctx, rtc, reducedClip, std::move(paint)); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 195 | } else { |
| 196 | paint.setColor4f(GrColor4f(1, 0.25f, 0.25f, 1)); |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 197 | this->visualizeStencilMask(ctx, rtc, reducedClip, std::move(paint)); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 198 | } |
| 199 | } |
| 200 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 201 | void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetContext* rtc, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 202 | const GrReducedClip& reducedClip, GrPaint&& paint) { |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 203 | const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2; |
| 204 | const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2; |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 205 | sk_sp<GrRenderTargetContext> maskRTC( |
Robert Phillips | dd3b3f4 | 2017-04-24 10:57:28 -0400 | [diff] [blame] | 206 | ctx->makeDeferredRenderTargetContextWithFallback(SkBackingFit::kExact, |
| 207 | kCoverRect.width() + padRight, |
| 208 | kCoverRect.height() + padBottom, |
| 209 | kAlpha_8_GrPixelConfig, nullptr)); |
Robert Phillips | c0192e3 | 2017-09-21 12:00:26 -0400 | [diff] [blame] | 210 | if (!maskRTC) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 211 | return; |
| 212 | } |
| 213 | |
| 214 | // Draw a checker pattern into the alpha mask so we can visualize the regions left untouched by |
| 215 | // the clip mask generation. |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 216 | this->stencilCheckerboard(maskRTC.get(), true); |
| 217 | maskRTC->clear(nullptr, GrColorPackA4(0xff), true); |
| 218 | maskRTC->priv().drawAndStencilRect(StencilOnlyClip(), &GrUserStencilSettings::kUnused, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 219 | SkRegion::kDifference_Op, false, GrAA::kNo, SkMatrix::I(), |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 220 | SkRect::MakeIWH(maskRTC->width(), maskRTC->height())); |
| 221 | reducedClip.drawAlphaClipMask(maskRTC.get()); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 222 | |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 223 | int x = kCoverRect.x() - kDeviceRect.x(), |
| 224 | y = kCoverRect.y() - kDeviceRect.y(); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 225 | |
| 226 | // Now visualize the alpha mask by drawing a rect over the area where it is defined. The regions |
| 227 | // inside window rectangles or outside the scissor should still have the initial checkerboard |
| 228 | // intact. (This verifies we didn't spend any time modifying those pixels in the mask.) |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 229 | AlphaOnlyClip clip(maskRTC->asTextureProxyRef(), x, y); |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 230 | rtc->drawRect(clip, std::move(paint), GrAA::kYes, SkMatrix::I(), |
Robert Phillips | 40fd7c9 | 2017-01-30 08:06:27 -0500 | [diff] [blame] | 231 | SkRect::Make(SkIRect::MakeXYWH(x, y, maskRTC->width(), maskRTC->height()))); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 234 | void WindowRectanglesMaskGM::visualizeStencilMask(GrContext* ctx, GrRenderTargetContext* rtc, |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 235 | const GrReducedClip& reducedClip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 236 | GrPaint&& paint) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 237 | // Draw a checker pattern into the stencil buffer so we can visualize the regions left untouched |
| 238 | // by the clip mask generation. |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 239 | this->stencilCheckerboard(rtc, false); |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 240 | reducedClip.drawStencilClipMask(ctx, rtc); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 241 | |
| 242 | // Now visualize the stencil mask by covering the entire render target. The regions inside |
Robert Phillips | 806be2d | 2017-06-28 15:23:59 -0400 | [diff] [blame] | 243 | // window rectangles or outside the scissor should still have the initial checkerboard intact. |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 244 | // (This verifies we didn't spend any time modifying those pixels in the mask.) |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 245 | rtc->drawPaint(StencilOnlyClip(), std::move(paint), SkMatrix::I()); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 248 | void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, bool flip) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 249 | constexpr static GrUserStencilSettings kSetClip( |
| 250 | GrUserStencilSettings::StaticInit< |
| 251 | 0, |
| 252 | GrUserStencilTest::kAlways, |
| 253 | 0, |
| 254 | GrUserStencilOp::kSetClipBit, |
| 255 | GrUserStencilOp::kKeep, |
| 256 | 0>() |
| 257 | ); |
| 258 | |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 259 | rtc->priv().clearStencilClip(GrFixedClip::Disabled(), false); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 260 | |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 261 | for (int y = 0; y < kDeviceRect.height(); y += kMaskCheckerSize) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 262 | for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize; |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 263 | x < kDeviceRect.width(); x += 2 * kMaskCheckerSize) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 264 | SkIRect checker = SkIRect::MakeXYWH(x, y, kMaskCheckerSize, kMaskCheckerSize); |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 265 | rtc->priv().stencilRect(GrNoClip(), &kSetClip, GrAAType::kNone, SkMatrix::I(), |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 266 | SkRect::Make(checker)); |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | void WindowRectanglesMaskGM::fail(SkCanvas* canvas) { |
| 272 | SkPaint paint; |
| 273 | paint.setAntiAlias(true); |
| 274 | paint.setTextAlign(SkPaint::kCenter_Align); |
| 275 | paint.setTextSize(20); |
| 276 | sk_tool_utils::set_portable_typeface(&paint); |
| 277 | |
| 278 | SkString errorMsg; |
| 279 | errorMsg.printf("Requires GPU with %i window rectangles", kNumWindows); |
| 280 | |
| 281 | canvas->clipRect(SkRect::Make(kCoverRect)); |
| 282 | canvas->clear(SK_ColorWHITE); |
Cary Clark | 2a475ea | 2017-04-28 15:35:12 -0400 | [diff] [blame] | 283 | canvas->drawString(errorMsg, SkIntToScalar(kCoverRect.centerX()), |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 284 | SkIntToScalar(kCoverRect.centerY() - 10), paint); |
| 285 | } |
| 286 | |
| 287 | DEF_GM( return new WindowRectanglesMaskGM(); ) |
| 288 | |
| 289 | #endif |
| 290 | |
| 291 | } |