Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: tests/ClipBoundsTest.cpp

Issue 1377943003: Remove separate cache for clip mask textures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/ClipBoundsTest.cpp
diff --git a/tests/ClipBoundsTest.cpp b/tests/ClipBoundsTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c9445729c55fd54c1bc80ce88b06ae69a3a49166
--- /dev/null
+++ b/tests/ClipBoundsTest.cpp
@@ -0,0 +1,115 @@
+/*
robertphillips 2015/09/30 12:33:06 Should we update the date ?
bsalomon 2015/09/30 19:59:40 Done.
+ * Copyright 2012 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"
+
+static const int X_SIZE = 12;
bsalomon 2015/09/29 19:28:09 This is just the old ClipCacheTest.cpp with all th
+static const int Y_SIZE = 12;
+
+////////////////////////////////////////////////////////////////////////////////
+// note: this is unused
robertphillips 2015/09/30 12:33:06 Can we delete this then ?
bsalomon 2015/09/30 19:59:40 Done, no idea why it was there.
+static GrTexture* create_texture(GrContext* context) {
+ unsigned char textureData[X_SIZE][Y_SIZE][4];
+
+ memset(textureData, 0, 4* X_SIZE * Y_SIZE);
+
+ GrSurfaceDesc desc;
+
+ // let Skia know we will be using this texture as a render target
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fWidth = X_SIZE;
+ desc.fHeight = Y_SIZE;
+
+ // We are initializing the texture with zeros here
+ GrTexture* texture = context->textureProvider()->createTexture(desc, false, textureData, 0);
+ if (!texture) {
+ return nullptr;
+ }
+
+ return texture;
+}
+
+// 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;
+
robertphillips 2015/09/30 12:33:06 Just SkAutoTUnref<GrTexture> texture( ... ?
+ GrTexture* texture = context->textureProvider()->createTexture(desc, false, nullptr, 0);
+ if (!texture) {
+ return;
+ }
+
+ SkAutoTUnref<GrTexture> au(texture);
+
+ SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
robertphillips 2015/09/30 12:33:06 SkRect screen = SkRect::Make(intScreen); ?
bsalomon 2015/09/30 19:59:40 Done.
+ SkRect screen;
+
+ screen = SkRect::MakeWH(SkIntToScalar(kXSize),
+ SkIntToScalar(kYSize));
+
+ 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<GrContextFactory::GLContextType>(type);
+ if (!GrContextFactory::IsRenderingGLContext(glType)) {
+ continue;
+ }
+ GrContext* context = factory->get(glType);
+ if (nullptr == context) {
+ continue;
+ }
+ test_clip_bounds(reporter, context);
+ }
+}
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698