skia2/tests/ClipBoundsTest.cpp
Ben Wagner b607a8fbf0 IWYU for some test files starting with 'C'.
Change-Id: Iea274ae52da8b4b87ec55222c856f40a0d88c4e0
Reviewed-on: https://skia-review.googlesource.com/113746
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-on: https://skia-review.googlesource.com/113944
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-03-13 15:16:22 +00:00

61 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 "SkTypes.h"
// This is a GR test
#if SK_SUPPORT_GPU
#include "GrClipStackClip.h"
#include "SkClipOpPriv.h"
#include "SkClipStack.h"
#include "SkMatrix.h"
#include "SkRect.h"
#include "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(&stack);
SkIRect devGrClipBound;
clipData.getConservativeBounds(kXSize, kYSize,
&devGrClipBound,
&isIntersectionOfRects);
// make sure that GrClip is behaving itself
REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
REPORTER_ASSERT(reporter, isIntersectionOfRects);
}
#endif