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
|
|
|
|
#include "GrClipMaskManager.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;
|
|
|
|
|
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
|
|
|
desc.fConfig = kAlpha_8_GrPixelConfig;
|
|
|
|
desc.fWidth = kXSize;
|
|
|
|
desc.fHeight = kYSize;
|
|
|
|
|
|
|
|
SkAutoTUnref<GrTexture> texture(
|
2016-04-05 19:59:06 +00:00
|
|
|
ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgeted::kYes, nullptr, 0));
|
2015-10-02 14:49:05 +00:00
|
|
|
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;
|
2015-12-01 20:51:26 +00:00
|
|
|
clipData.getConservativeBounds(texture->width(), texture->height(),
|
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
|