5ec26ae9bf
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1728093005 DOCS_PREVIEW= https://skia.org/?cl=1728093005 Committed: https://skia.googlesource.com/skia/+/57599fe6c0336feaeeeb9b1996e77b70219b483c CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1728093005
70 lines
2.0 KiB
C++
70 lines
2.0 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, context) {
|
|
static const int kXSize = 100;
|
|
static const int kYSize = 100;
|
|
|
|
GrSurfaceDesc desc;
|
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
|
desc.fConfig = kAlpha_8_GrPixelConfig;
|
|
desc.fWidth = kXSize;
|
|
desc.fHeight = kYSize;
|
|
|
|
SkAutoTUnref<GrTexture> texture(
|
|
context->textureProvider()->createTexture(desc, SkBudgeted::kYes, nullptr, 0));
|
|
if (!texture) {
|
|
return;
|
|
}
|
|
|
|
SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
|
|
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
|
|
GrClip clipData;
|
|
clipData.setClipStack(&stack);
|
|
|
|
SkIRect devGrClipBound;
|
|
clipData.getConservativeBounds(texture->width(), texture->height(),
|
|
&devGrClipBound,
|
|
&isIntersectionOfRects);
|
|
|
|
// make sure that GrClip is behaving itself
|
|
REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
|
|
REPORTER_ASSERT(reporter, isIntersectionOfRects);
|
|
}
|
|
|
|
#endif
|