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