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 | 8 |
9 #include "Test.h" | 9 #include "Test.h" |
10 // This is a GR test | 10 // This is a GR test |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 REPORTER_ASSERT(reporter, intScreen == devGrClipDataBound); | 98 REPORTER_ASSERT(reporter, intScreen == devGrClipDataBound); |
99 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 99 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
100 } | 100 } |
101 | 101 |
102 //////////////////////////////////////////////////////////////////////////////// | 102 //////////////////////////////////////////////////////////////////////////////// |
103 // verify that the top state of the stack matches the passed in state | 103 // verify that the top state of the stack matches the passed in state |
104 static void check_state(skiatest::Reporter* reporter, | 104 static void check_state(skiatest::Reporter* reporter, |
105 const GrClipMaskCache& cache, | 105 const GrClipMaskCache& cache, |
106 const SkClipStack& clip, | 106 const SkClipStack& clip, |
107 GrTexture* mask, | 107 GrTexture* mask, |
108 const GrIRect& bound) { | 108 const SkIRect& bound) { |
109 SkClipStack cacheClip; | 109 SkClipStack cacheClip; |
110 REPORTER_ASSERT(reporter, clip.getTopmostGenID() == cache.getLastClipGenID()
); | 110 REPORTER_ASSERT(reporter, clip.getTopmostGenID() == cache.getLastClipGenID()
); |
111 | 111 |
112 REPORTER_ASSERT(reporter, mask == cache.getLastMask()); | 112 REPORTER_ASSERT(reporter, mask == cache.getLastMask()); |
113 | 113 |
114 GrIRect cacheBound; | 114 SkIRect cacheBound; |
115 cache.getLastBound(&cacheBound); | 115 cache.getLastBound(&cacheBound); |
116 REPORTER_ASSERT(reporter, bound == cacheBound); | 116 REPORTER_ASSERT(reporter, bound == cacheBound); |
117 } | 117 } |
118 | 118 |
119 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
120 // basic test of the cache's base functionality: | 120 // basic test of the cache's base functionality: |
121 // push, pop, set, canReuse & getters | 121 // push, pop, set, canReuse & getters |
122 static void test_cache(skiatest::Reporter* reporter, GrContext* context) { | 122 static void test_cache(skiatest::Reporter* reporter, GrContext* context) { |
123 | 123 |
124 if (false) { // avoid bit rot, suppress warning | 124 if (false) { // avoid bit rot, suppress warning |
125 createTexture(context); | 125 createTexture(context); |
126 } | 126 } |
127 GrClipMaskCache cache; | 127 GrClipMaskCache cache; |
128 | 128 |
129 cache.setContext(context); | 129 cache.setContext(context); |
130 | 130 |
131 SkClipStack emptyClip; | 131 SkClipStack emptyClip; |
132 emptyClip.reset(); | 132 emptyClip.reset(); |
133 | 133 |
134 GrIRect emptyBound; | 134 SkIRect emptyBound; |
135 emptyBound.setEmpty(); | 135 emptyBound.setEmpty(); |
136 | 136 |
137 // check initial state | 137 // check initial state |
138 check_state(reporter, cache, emptyClip, NULL, emptyBound); | 138 check_state(reporter, cache, emptyClip, NULL, emptyBound); |
139 | 139 |
140 // set the current state | 140 // set the current state |
141 GrIRect bound1; | 141 SkIRect bound1; |
142 bound1.set(0, 0, 100, 100); | 142 bound1.set(0, 0, 100, 100); |
143 | 143 |
144 SkClipStack clip1(bound1); | 144 SkClipStack clip1(bound1); |
145 | 145 |
146 GrTextureDesc desc; | 146 GrTextureDesc desc; |
147 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 147 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
148 desc.fWidth = X_SIZE; | 148 desc.fWidth = X_SIZE; |
149 desc.fHeight = Y_SIZE; | 149 desc.fHeight = Y_SIZE; |
150 desc.fConfig = kSkia8888_GrPixelConfig; | 150 desc.fConfig = kSkia8888_GrPixelConfig; |
151 | 151 |
(...skipping 10 matching lines...) Expand all Loading... |
162 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | 162 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
163 | 163 |
164 // push the state | 164 // push the state |
165 cache.push(); | 165 cache.push(); |
166 | 166 |
167 // verify that the pushed state is initially empty | 167 // verify that the pushed state is initially empty |
168 check_state(reporter, cache, emptyClip, NULL, emptyBound); | 168 check_state(reporter, cache, emptyClip, NULL, emptyBound); |
169 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | 169 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
170 | 170 |
171 // modify the new state | 171 // modify the new state |
172 GrIRect bound2; | 172 SkIRect bound2; |
173 bound2.set(-10, -10, 10, 10); | 173 bound2.set(-10, -10, 10, 10); |
174 | 174 |
175 SkClipStack clip2(bound2); | 175 SkClipStack clip2(bound2); |
176 | 176 |
177 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); | 177 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); |
178 | 178 |
179 GrTexture* texture2 = cache.getLastMask(); | 179 GrTexture* texture2 = cache.getLastMask(); |
180 REPORTER_ASSERT(reporter, texture2); | 180 REPORTER_ASSERT(reporter, texture2); |
181 if (NULL == texture2) { | 181 if (NULL == texture2) { |
182 return; | 182 return; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 test_cache(reporter, context); | 234 test_cache(reporter, context); |
235 test_clip_bounds(reporter, context); | 235 test_clip_bounds(reporter, context); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 //////////////////////////////////////////////////////////////////////////////// | 239 //////////////////////////////////////////////////////////////////////////////// |
240 #include "TestClassDef.h" | 240 #include "TestClassDef.h" |
241 DEFINE_GPUTESTCLASS("ClipCache", ClipCacheTestClass, TestClipCache) | 241 DEFINE_GPUTESTCLASS("ClipCache", ClipCacheTestClass, TestClipCache) |
242 | 242 |
243 #endif | 243 #endif |
OLD | NEW |