OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 // This is a GR test | 9 // This is a GR test |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
11 #include "GrClipMaskManager.h" | 11 #include "GrClipMaskManager.h" |
12 #include "GrContextFactory.h" | 12 #include "GrContextFactory.h" |
13 #include "SkGpuDevice.h" | 13 #include "SkGpuDevice.h" |
14 | 14 |
15 static const int X_SIZE = 12; | 15 static const int X_SIZE = 12; |
16 static const int Y_SIZE = 12; | 16 static const int Y_SIZE = 12; |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
19 // note: this is unused | 19 // note: this is unused |
20 static GrTexture* createTexture(GrContext* context) { | 20 static GrTexture* create_texture(GrContext* context) { |
21 unsigned char textureData[X_SIZE][Y_SIZE][4]; | 21 unsigned char textureData[X_SIZE][Y_SIZE][4]; |
22 | 22 |
23 memset(textureData, 0, 4* X_SIZE * Y_SIZE); | 23 memset(textureData, 0, 4* X_SIZE * Y_SIZE); |
24 | 24 |
25 GrSurfaceDesc desc; | 25 GrSurfaceDesc desc; |
26 | 26 |
27 // let Skia know we will be using this texture as a render target | 27 // let Skia know we will be using this texture as a render target |
28 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 28 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
29 desc.fConfig = kSkia8888_GrPixelConfig; | 29 desc.fConfig = kSkia8888_GrPixelConfig; |
30 desc.fWidth = X_SIZE; | 30 desc.fWidth = X_SIZE; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 cache.getLastBound(&cacheBound); | 126 cache.getLastBound(&cacheBound); |
127 REPORTER_ASSERT(reporter, emptyBound == cacheBound); | 127 REPORTER_ASSERT(reporter, emptyBound == cacheBound); |
128 } | 128 } |
129 | 129 |
130 //////////////////////////////////////////////////////////////////////////////// | 130 //////////////////////////////////////////////////////////////////////////////// |
131 // basic test of the cache's base functionality: | 131 // basic test of the cache's base functionality: |
132 // push, pop, set, canReuse & getters | 132 // push, pop, set, canReuse & getters |
133 static void test_cache(skiatest::Reporter* reporter, GrContext* context) { | 133 static void test_cache(skiatest::Reporter* reporter, GrContext* context) { |
134 | 134 |
135 if (false) { // avoid bit rot, suppress warning | 135 if (false) { // avoid bit rot, suppress warning |
136 createTexture(context); | 136 create_texture(context); |
137 } | 137 } |
138 GrClipMaskCache cache; | 138 GrClipMaskCache cache(context->resourceProvider()); |
139 | |
140 cache.setContext(context); | |
141 | 139 |
142 // check initial state | 140 // check initial state |
143 check_empty_state(reporter, cache); | 141 check_empty_state(reporter, cache); |
144 | 142 |
145 // set the current state | 143 // set the current state |
146 SkIRect bound1; | 144 SkIRect bound1; |
147 bound1.set(0, 0, 100, 100); | 145 bound1.set(0, 0, 100, 100); |
148 | 146 |
149 SkClipStack clip1(bound1); | 147 SkClipStack clip1(bound1); |
150 | 148 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 if (NULL == context) { | 222 if (NULL == context) { |
225 continue; | 223 continue; |
226 } | 224 } |
227 | 225 |
228 test_cache(reporter, context); | 226 test_cache(reporter, context); |
229 test_clip_bounds(reporter, context); | 227 test_clip_bounds(reporter, context); |
230 } | 228 } |
231 } | 229 } |
232 | 230 |
233 #endif | 231 #endif |
OLD | NEW |