diff options
author | Brian Salomon <bsalomon@google.com> | 2017-03-13 17:57:28 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-13 22:01:06 +0000 |
commit | 9a7677273a3f270e6137d396e972c83c036a47a7 (patch) | |
tree | adbb840ffebb12282ac4a59bba7105ded9838afb /gm/windowrectangles.cpp | |
parent | 301c69c9167c9b7f4dd147e27d720f05522fe263 (diff) |
Remove origin from GrClipStackClip and GrWindowRectsState.
Change-Id: I993f426fee0f21cf1f529f58d242de3017253678
Reviewed-on: https://skia-review.googlesource.com/9623
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'gm/windowrectangles.cpp')
-rw-r--r-- | gm/windowrectangles.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
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<GrRenderTargetContext> 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)); |