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

Side by Side Diff: tests/ClipCacheTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT 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 unified diff | Download patch
« no previous file with comments | « tests/ChecksumTest.cpp ('k') | tests/ClipStackTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 15 matching lines...) Expand all
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;
31 desc.fHeight = Y_SIZE; 31 desc.fHeight = Y_SIZE;
32 32
33 // We are initializing the texture with zeros here 33 // We are initializing the texture with zeros here
34 GrTexture* texture = context->textureProvider()->createTexture(desc, false, textureData, 0); 34 GrTexture* texture = context->textureProvider()->createTexture(desc, false, textureData, 0);
35 if (!texture) { 35 if (!texture) {
36 return NULL; 36 return nullptr;
37 } 37 }
38 38
39 return texture; 39 return texture;
40 } 40 }
41 41
42 // Ensure that the 'getConservativeBounds' calls are returning bounds clamped 42 // Ensure that the 'getConservativeBounds' calls are returning bounds clamped
43 // to the render target 43 // to the render target
44 static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* context) { 44 static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* context) {
45 45
46 static const int kXSize = 100; 46 static const int kXSize = 100;
47 static const int kYSize = 100; 47 static const int kYSize = 100;
48 48
49 GrSurfaceDesc desc; 49 GrSurfaceDesc desc;
50 desc.fFlags = kRenderTarget_GrSurfaceFlag; 50 desc.fFlags = kRenderTarget_GrSurfaceFlag;
51 desc.fConfig = kAlpha_8_GrPixelConfig; 51 desc.fConfig = kAlpha_8_GrPixelConfig;
52 desc.fWidth = kXSize; 52 desc.fWidth = kXSize;
53 desc.fHeight = kYSize; 53 desc.fHeight = kYSize;
54 54
55 GrTexture* texture = context->textureProvider()->createTexture(desc, false, NULL, 0); 55 GrTexture* texture = context->textureProvider()->createTexture(desc, false, nullptr, 0);
56 if (!texture) { 56 if (!texture) {
57 return; 57 return;
58 } 58 }
59 59
60 SkAutoTUnref<GrTexture> au(texture); 60 SkAutoTUnref<GrTexture> au(texture);
61 61
62 SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); 62 SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
63 SkRect screen; 63 SkRect screen;
64 64
65 screen = SkRect::MakeWH(SkIntToScalar(kXSize), 65 screen = SkRect::MakeWH(SkIntToScalar(kXSize),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 REPORTER_ASSERT(reporter, mask == cache.getLastMask()); 110 REPORTER_ASSERT(reporter, mask == cache.getLastMask());
111 111
112 SkIRect cacheBound; 112 SkIRect cacheBound;
113 cache.getLastBound(&cacheBound); 113 cache.getLastBound(&cacheBound);
114 REPORTER_ASSERT(reporter, bound == cacheBound); 114 REPORTER_ASSERT(reporter, bound == cacheBound);
115 } 115 }
116 116
117 static void check_empty_state(skiatest::Reporter* reporter, 117 static void check_empty_state(skiatest::Reporter* reporter,
118 const GrClipMaskCache& cache) { 118 const GrClipMaskCache& cache) {
119 REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID == cache.getLastClipGen ID()); 119 REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID == cache.getLastClipGen ID());
120 REPORTER_ASSERT(reporter, NULL == cache.getLastMask()); 120 REPORTER_ASSERT(reporter, nullptr == cache.getLastMask());
121 121
122 SkIRect emptyBound; 122 SkIRect emptyBound;
123 emptyBound.setEmpty(); 123 emptyBound.setEmpty();
124 124
125 SkIRect cacheBound; 125 SkIRect cacheBound;
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 ////////////////////////////////////////////////////////////////////////////////
(...skipping 18 matching lines...) Expand all
149 GrSurfaceDesc desc; 149 GrSurfaceDesc desc;
150 desc.fFlags = kRenderTarget_GrSurfaceFlag; 150 desc.fFlags = kRenderTarget_GrSurfaceFlag;
151 desc.fWidth = X_SIZE; 151 desc.fWidth = X_SIZE;
152 desc.fHeight = Y_SIZE; 152 desc.fHeight = Y_SIZE;
153 desc.fConfig = kSkia8888_GrPixelConfig; 153 desc.fConfig = kSkia8888_GrPixelConfig;
154 154
155 cache.acquireMask(clip1.getTopmostGenID(), desc, bound1); 155 cache.acquireMask(clip1.getTopmostGenID(), desc, bound1);
156 156
157 GrTexture* texture1 = cache.getLastMask(); 157 GrTexture* texture1 = cache.getLastMask();
158 REPORTER_ASSERT(reporter, texture1); 158 REPORTER_ASSERT(reporter, texture1);
159 if (NULL == texture1) { 159 if (nullptr == texture1) {
160 return; 160 return;
161 } 161 }
162 162
163 // check that the set took 163 // check that the set took
164 check_state(reporter, cache, clip1, texture1, bound1); 164 check_state(reporter, cache, clip1, texture1, bound1);
165 165
166 // push the state 166 // push the state
167 cache.push(); 167 cache.push();
168 168
169 // verify that the pushed state is initially empty 169 // verify that the pushed state is initially empty
170 check_empty_state(reporter, cache); 170 check_empty_state(reporter, cache);
171 171
172 // modify the new state 172 // modify the new state
173 SkIRect bound2; 173 SkIRect bound2;
174 bound2.set(-10, -10, 10, 10); 174 bound2.set(-10, -10, 10, 10);
175 175
176 SkClipStack clip2(bound2); 176 SkClipStack clip2(bound2);
177 177
178 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); 178 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2);
179 179
180 GrTexture* texture2 = cache.getLastMask(); 180 GrTexture* texture2 = cache.getLastMask();
181 REPORTER_ASSERT(reporter, texture2); 181 REPORTER_ASSERT(reporter, texture2);
182 if (NULL == texture2) { 182 if (nullptr == texture2) {
183 return; 183 return;
184 } 184 }
185 185
186 // check that the changes took 186 // check that the changes took
187 check_state(reporter, cache, clip2, texture2, bound2); 187 check_state(reporter, cache, clip2, texture2, bound2);
188 188
189 // check to make sure canReuse works 189 // check to make sure canReuse works
190 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); 190 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2));
191 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); 191 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1));
192 192
(...skipping 19 matching lines...) Expand all
212 #endif 212 #endif
213 } 213 }
214 214
215 DEF_GPUTEST(ClipCache, reporter, factory) { 215 DEF_GPUTEST(ClipCache, reporter, factory) {
216 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 216 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
217 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 217 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
218 if (!GrContextFactory::IsRenderingGLContext(glType)) { 218 if (!GrContextFactory::IsRenderingGLContext(glType)) {
219 continue; 219 continue;
220 } 220 }
221 GrContext* context = factory->get(glType); 221 GrContext* context = factory->get(glType);
222 if (NULL == context) { 222 if (nullptr == context) {
223 continue; 223 continue;
224 } 224 }
225 225
226 test_cache(reporter, context); 226 test_cache(reporter, context);
227 test_clip_bounds(reporter, context); 227 test_clip_bounds(reporter, context);
228 } 228 }
229 } 229 }
230 230
231 #endif 231 #endif
OLDNEW
« no previous file with comments | « tests/ChecksumTest.cpp ('k') | tests/ClipStackTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698