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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
robertphillips 2015/09/30 12:33:06 Should we update the date ?
bsalomon 2015/09/30 19:59:40 Done.
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Test.h"
9 // This is a GR test
10 #if SK_SUPPORT_GPU
11 #include "GrClipMaskManager.h"
12 #include "GrContextFactory.h"
13 #include "SkGpuDevice.h"
14
15 static const int X_SIZE = 12;
bsalomon 2015/09/29 19:28:09 This is just the old ClipCacheTest.cpp with all th
16 static const int Y_SIZE = 12;
17
18 ////////////////////////////////////////////////////////////////////////////////
19 // 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.
20 static GrTexture* create_texture(GrContext* context) {
21 unsigned char textureData[X_SIZE][Y_SIZE][4];
22
23 memset(textureData, 0, 4* X_SIZE * Y_SIZE);
24
25 GrSurfaceDesc desc;
26
27 // let Skia know we will be using this texture as a render target
28 desc.fFlags = kRenderTarget_GrSurfaceFlag;
29 desc.fConfig = kSkia8888_GrPixelConfig;
30 desc.fWidth = X_SIZE;
31 desc.fHeight = Y_SIZE;
32
33 // We are initializing the texture with zeros here
34 GrTexture* texture = context->textureProvider()->createTexture(desc, false, textureData, 0);
35 if (!texture) {
36 return nullptr;
37 }
38
39 return texture;
40 }
41
42 // Ensure that the 'getConservativeBounds' calls are returning bounds clamped
43 // to the render target
44 static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* context) {
45
46 static const int kXSize = 100;
47 static const int kYSize = 100;
48
49 GrSurfaceDesc desc;
50 desc.fFlags = kRenderTarget_GrSurfaceFlag;
51 desc.fConfig = kAlpha_8_GrPixelConfig;
52 desc.fWidth = kXSize;
53 desc.fHeight = kYSize;
54
robertphillips 2015/09/30 12:33:06 Just SkAutoTUnref<GrTexture> texture( ... ?
55 GrTexture* texture = context->textureProvider()->createTexture(desc, false, nullptr, 0);
56 if (!texture) {
57 return;
58 }
59
60 SkAutoTUnref<GrTexture> au(texture);
61
62 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.
63 SkRect screen;
64
65 screen = SkRect::MakeWH(SkIntToScalar(kXSize),
66 SkIntToScalar(kYSize));
67
68 SkRect clipRect(screen);
69 clipRect.outset(10, 10);
70
71 // create a clip stack that will (trivially) reduce to a single rect that
72 // is larger than the screen
73 SkClipStack stack;
74 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false);
75
76 bool isIntersectionOfRects = true;
77 SkRect devStackBounds;
78
79 stack.getConservativeBounds(0, 0, kXSize, kYSize,
80 &devStackBounds,
81 &isIntersectionOfRects);
82
83 // make sure that the SkClipStack is behaving itself
84 REPORTER_ASSERT(reporter, screen == devStackBounds);
85 REPORTER_ASSERT(reporter, isIntersectionOfRects);
86
87 // wrap the SkClipStack in a GrClip
88 GrClip clipData;
89 clipData.setClipStack(&stack);
90
91 SkIRect devGrClipBound;
92 clipData.getConservativeBounds(texture,
93 &devGrClipBound,
94 &isIntersectionOfRects);
95
96 // make sure that GrClip is behaving itself
97 REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
98 REPORTER_ASSERT(reporter, isIntersectionOfRects);
99 }
100
101 DEF_GPUTEST(GrClipBounds, reporter, factory) {
102 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
103 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
104 if (!GrContextFactory::IsRenderingGLContext(glType)) {
105 continue;
106 }
107 GrContext* context = factory->get(glType);
108 if (nullptr == context) {
109 continue;
110 }
111 test_clip_bounds(reporter, context);
112 }
113 }
114
115 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698