From 9a7677273a3f270e6137d396e972c83c036a47a7 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 13 Mar 2017 17:57:28 -0400 Subject: Remove origin from GrClipStackClip and GrWindowRectsState. Change-Id: I993f426fee0f21cf1f529f58d242de3017253678 Reviewed-on: https://skia-review.googlesource.com/9623 Commit-Queue: Brian Salomon Reviewed-by: Chris Dalton --- gm/windowrectangles.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'gm/windowrectangles.cpp') diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp index c57ad7d560..b24febd71c 100644 --- a/gm/windowrectangles.cpp +++ b/gm/windowrectangles.cpp @@ -21,7 +21,6 @@ #endif constexpr static SkIRect kDeviceRect = {0, 0, 600, 600}; -constexpr static SkIRect kLayerRect = {25, 25, 575, 575}; constexpr static SkIRect kCoverRect = {50, 50, 550, 550}; namespace skiagm { @@ -39,7 +38,6 @@ private: void WindowRectanglesBaseGM::onDraw(SkCanvas* canvas) { sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 25); - canvas->saveLayer(SkRect::Make(kLayerRect), nullptr); SkClipStack stack; stack.clipRect(SkRect::MakeXYWH(370.75, 80.25, 149, 100), SkMatrix::I(), @@ -59,8 +57,6 @@ void WindowRectanglesBaseGM::onDraw(SkCanvas* canvas) { stack.clipRRect(complx, SkMatrix::I(), kDifference_SkClipOp, false); this->onCoverClipStack(stack, canvas); - - canvas->restore(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -200,10 +196,13 @@ void WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack, SkCanvas void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetContext* rtc, const GrReducedClip& reducedClip, GrPaint&& paint) { + const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2; + const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2; sk_sp maskRTC( - ctx->makeRenderTargetContextWithFallback(SkBackingFit::kExact, kLayerRect.width(), - kLayerRect.height(), kAlpha_8_GrPixelConfig, - nullptr)); + ctx->makeRenderTargetContextWithFallback(SkBackingFit::kExact, + kCoverRect.width() + padRight, + kCoverRect.height() + padBottom, + kAlpha_8_GrPixelConfig, nullptr)); if (!maskRTC || !ctx->resourceProvider()->attachStencilAttachment(maskRTC->accessRenderTarget())) { return; @@ -218,8 +217,8 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo SkRect::MakeIWH(maskRTC->width(), maskRTC->height())); reducedClip.drawAlphaClipMask(maskRTC.get()); - int x = kCoverRect.x() - kLayerRect.x(), - y = kCoverRect.y() - kLayerRect.y(); + int x = kCoverRect.x() - kDeviceRect.x(), + y = kCoverRect.y() - kDeviceRect.y(); // Now visualize the alpha mask by drawing a rect over the area where it is defined. The regions // inside window rectangles or outside the scissor should still have the initial checkerboard @@ -239,7 +238,7 @@ void WindowRectanglesMaskGM::visualizeStencilMask(GrContext* ctx, GrRenderTarget // Draw a checker pattern into the stencil buffer so we can visualize the regions left untouched // by the clip mask generation. this->stencilCheckerboard(rtc, false); - reducedClip.drawStencilClipMask(ctx, rtc, {kLayerRect.x(), kLayerRect.y()}); + reducedClip.drawStencilClipMask(ctx, rtc); // Now visualize the stencil mask by covering the entire render target. The regions inside // window rectangless or outside the scissor should still have the initial checkerboard intact. @@ -260,9 +259,9 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, boo rtc->priv().clearStencilClip(GrFixedClip::Disabled(), false); - for (int y = 0; y < kLayerRect.height(); y += kMaskCheckerSize) { + for (int y = 0; y < kDeviceRect.height(); y += kMaskCheckerSize) { for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize; - x < kLayerRect.width(); x += 2 * kMaskCheckerSize) { + x < kDeviceRect.width(); x += 2 * kMaskCheckerSize) { SkIRect checker = SkIRect::MakeXYWH(x, y, kMaskCheckerSize, kMaskCheckerSize); rtc->priv().stencilRect(GrNoClip(), &kSetClip, GrAAType::kNone, SkMatrix::I(), SkRect::Make(checker)); -- cgit v1.2.3