2015-10-02 14:49:05 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#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"
|
2015-10-02 14:49:05 +00:00
|
|
|
|
|
|
|
// Ensure that the 'getConservativeBounds' calls are returning bounds clamped
|
|
|
|
// to the render target
|
2016-04-12 16:59:58 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) {
|
2015-10-02 14:49:05 +00:00
|
|
|
static const int kXSize = 100;
|
|
|
|
static const int kYSize = 100;
|
|
|
|
|
2016-04-28 16:55:15 +00:00
|
|
|
const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
|
|
|
|
const SkRect screen = SkRect::Make(intScreen);
|
2015-10-02 14:49:05 +00:00
|
|
|
|
|
|
|
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;
|
2016-12-09 14:00:50 +00:00
|
|
|
stack.clipRect(clipRect, SkMatrix::I(), kReplace_SkClipOp, false);
|
2015-10-02 14:49:05 +00:00
|
|
|
|
|
|
|
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
|
2020-06-11 14:29:00 +00:00
|
|
|
GrClipStackClip clipData({kXSize, kYSize}, &stack);
|
2015-10-02 14:49:05 +00:00
|
|
|
|
2020-06-11 14:29:00 +00:00
|
|
|
SkIRect devGrClipBound = clipData.getConservativeBounds();
|
2015-10-02 14:49:05 +00:00
|
|
|
|
|
|
|
// make sure that GrClip is behaving itself
|
|
|
|
REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
|
|
|
|
}
|