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.
|
|
|
|
*/
|
|
|
|
|
2018-03-12 17:46:21 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
2015-10-02 14:49:05 +00:00
|
|
|
// This is a GR test
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-08-06 05:32:12 +00:00
|
|
|
#include "GrClipStackClip.h"
|
2018-03-12 17:46:21 +00:00
|
|
|
#include "SkClipOpPriv.h"
|
|
|
|
#include "SkClipStack.h"
|
|
|
|
#include "SkMatrix.h"
|
|
|
|
#include "SkRect.h"
|
|
|
|
#include "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
|
2016-05-13 17:25:00 +00:00
|
|
|
GrClipStackClip clipData(&stack);
|
2015-10-02 14:49:05 +00:00
|
|
|
|
|
|
|
SkIRect devGrClipBound;
|
2016-04-28 16:55:15 +00:00
|
|
|
clipData.getConservativeBounds(kXSize, kYSize,
|
2015-10-02 14:49:05 +00:00
|
|
|
&devGrClipBound,
|
|
|
|
&isIntersectionOfRects);
|
|
|
|
|
|
|
|
// make sure that GrClip is behaving itself
|
|
|
|
REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
|
|
|
|
REPORTER_ASSERT(reporter, isIntersectionOfRects);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|