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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Test.h"
|
|
|
|
// This is a GR test
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-08-06 05:32:12 +00:00
|
|
|
#include "GrClipStackClip.h"
|
2015-12-01 12:35:26 +00:00
|
|
|
#include "GrContext.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-10-03 15:36:16 +00:00
|
|
|
stack.clipRect(clipRect, SkMatrix::I(), SkCanvas::kReplace_Op, 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
|