From 473addf17617d441edb44e501786cdd97d3ebdfb Mon Sep 17 00:00:00 2001 From: bsalomon Date: Fri, 2 Oct 2015 07:49:05 -0700 Subject: Remove separate cache for clip mask textures Review URL: https://codereview.chromium.org/1377943003 --- tests/ClipBoundsTest.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/ClipBoundsTest.cpp (limited to 'tests/ClipBoundsTest.cpp') diff --git a/tests/ClipBoundsTest.cpp b/tests/ClipBoundsTest.cpp new file mode 100644 index 0000000000..781ee877a6 --- /dev/null +++ b/tests/ClipBoundsTest.cpp @@ -0,0 +1,85 @@ + +/* + * 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 "GrContextFactory.h" +#include "SkGpuDevice.h" + +// Ensure that the 'getConservativeBounds' calls are returning bounds clamped +// to the render target +static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* 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 texture( + context->textureProvider()->createTexture(desc, false, 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, + &devGrClipBound, + &isIntersectionOfRects); + + // make sure that GrClip is behaving itself + REPORTER_ASSERT(reporter, intScreen == devGrClipBound); + REPORTER_ASSERT(reporter, isIntersectionOfRects); +} + +DEF_GPUTEST(GrClipBounds, reporter, factory) { + for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { + GrContextFactory::GLContextType glType = static_cast(type); + if (!GrContextFactory::IsRenderingGLContext(glType)) { + continue; + } + GrContext* context = factory->get(glType); + if (nullptr == context) { + continue; + } + test_clip_bounds(reporter, context); + } +} + +#endif -- cgit v1.2.3