skia2/tests/ClipBoundsTest.cpp
Michael Ludwig 8ba1e71a1f Revert "Add SkClipStack::replaceClip() separate from deprecated clip op"
This reverts commit 68587ae274.

Reason for revert: breaking path clipping tests in Android?

Original change's description:
> Add SkClipStack::replaceClip() separate from deprecated clip op
>
> The replaceClip functionality was added to allow Android to move off of
> generalized expanding clips. At the time, SkClipStack simply used the
> kReplace_SkClipOp to handle it. In order to remove those expanding ops,
> SkClipStack will need a proper implementation of replaceClip().
>
> The clip elements have an additional field to mark if
> it's a replace (and it's op will be kIntersect). Adds a temporary
> getRegionOp() function to unify elements that use this field vs.
> elements that use the deprecated clip op (i.e. if they were deserialized
> from an SKP that recorded an expanding op).
>
> Clients of SkClipOp that checked for replace ops use the new function
> instead of referring to the enum value directly.
>
> Bug: skia:10209
> Change-Id: I1c16c87fadb2becfe181db717c05e240ac87fd34
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436158
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>

TBR=robertphillips@google.com,brianosman@google.com,csmartdalton@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: If3f99a7d2f2df99c2b99d431d494ca28da66b1d8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10209
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436956
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-05 14:47:41 +00:00

58 lines
1.8 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/gpu/GrTypes.h"
// For the GrClipStack case, this is covered in GrClipStack_RectDeviceClip
#if defined(SK_DISABLE_NEW_GR_CLIP_STACK)
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "src/core/SkClipOpPriv.h"
#include "src/core/SkClipStack.h"
#include "src/gpu/GrClipStackClip.h"
#include "tests/Test.h"
// Ensure that the 'getConservativeBounds' calls are returning bounds clamped
// to the render target
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) {
static const int kXSize = 100;
static const int kYSize = 100;
const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
const SkRect screen = SkRect::Make(intScreen);
SkRect clipRect(screen);
clipRect.outset(10, 10);
// create a clip stack that will (trivially) reduce to a single rect that
// is larger than the screen
SkClipStack stack;
stack.clipRect(clipRect, SkMatrix::I(), kReplace_SkClipOp, false);
bool isIntersectionOfRects = true;
SkRect devStackBounds;
stack.getConservativeBounds(0, 0, kXSize, kYSize,
&devStackBounds,
&isIntersectionOfRects);
// make sure that the SkClipStack is behaving itself
REPORTER_ASSERT(reporter, screen == devStackBounds);
REPORTER_ASSERT(reporter, isIntersectionOfRects);
// wrap the SkClipStack in a GrClip
GrClipStackClip clipData({kXSize, kYSize}, &stack);
SkIRect devGrClipBound = clipData.getConservativeBounds();
// make sure that GrClip is behaving itself
REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
}
#endif // SK_DISABLE_NEW_GR_CLIP_STACK