skia2/tests/ClipBoundsTest.cpp
cdalton 846c051a48 Convert GrClip to an abstract base class
Converts GrClip to an abstract base class and adds a "GrFixedClip"
implementation. GrFixedClip denotes a clip implemented with fixed-
function hardware. GrFixedClip allows us to remove the stateful
"fClipMode" member from GrClipMaskManager, and in the future will
be able to nicely encapsulate window rectangles.

After this change GrClipMaskManager is just a wrapper around
GrDrawTarget. We may want to consider removing it altogether.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1971343002

Review-Url: https://codereview.chromium.org/1971343002
2016-05-13 10:25:00 -07:00

56 lines
1.7 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 "Test.h"
// This is a GR test
#if SK_SUPPORT_GPU
#include "GrClipMaskManager.h"
#include "GrContext.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.clipDevRect(clipRect, SkRegion::kReplace_Op, 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