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

Side by Side Diff: tests/PictureTest.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/PictureShaderTest.cpp ('k') | tests/PixelRefTest.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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 paint.setStyle(SkPaint::kStroke_Style); 156 paint.setStyle(SkPaint::kStroke_Style);
157 paint.setPathEffect(dash); 157 paint.setPathEffect(dash);
158 158
159 for (int i = 0; i < 50; ++i) { 159 for (int i = 0; i < 50; ++i) {
160 canvas->drawPath(path, paint); 160 canvas->drawPath(path, paint);
161 } 161 }
162 } 162 }
163 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 163 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
164 // path effects currently render an SkPicture undesireable for GPU rendering 164 // path effects currently render an SkPicture undesireable for GPU rendering
165 165
166 const char *reason = NULL; 166 const char *reason = nullptr;
167 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL, &reaso n)); 167 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr, &re ason));
168 REPORTER_ASSERT(reporter, reason); 168 REPORTER_ASSERT(reporter, reason);
169 169
170 canvas = recorder.beginRecording(100, 100); 170 canvas = recorder.beginRecording(100, 100);
171 { 171 {
172 SkPath path; 172 SkPath path;
173 173
174 path.moveTo(0, 0); 174 path.moveTo(0, 0);
175 path.lineTo(0, 50); 175 path.lineTo(0, 50);
176 path.lineTo(25, 25); 176 path.lineTo(25, 25);
177 path.lineTo(50, 50); 177 path.lineTo(50, 50);
178 path.lineTo(50, 0); 178 path.lineTo(50, 0);
179 path.close(); 179 path.close();
180 REPORTER_ASSERT(reporter, !path.isConvex()); 180 REPORTER_ASSERT(reporter, !path.isConvex());
181 181
182 SkPaint paint; 182 SkPaint paint;
183 paint.setAntiAlias(true); 183 paint.setAntiAlias(true);
184 for (int i = 0; i < 50; ++i) { 184 for (int i = 0; i < 50; ++i) {
185 canvas->drawPath(path, paint); 185 canvas->drawPath(path, paint);
186 } 186 }
187 } 187 }
188 picture.reset(recorder.endRecording()); 188 picture.reset(recorder.endRecording());
189 // A lot of small AA concave paths should be fine for GPU rendering 189 // A lot of small AA concave paths should be fine for GPU rendering
190 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL)); 190 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
191 191
192 canvas = recorder.beginRecording(100, 100); 192 canvas = recorder.beginRecording(100, 100);
193 { 193 {
194 SkPath path; 194 SkPath path;
195 195
196 path.moveTo(0, 0); 196 path.moveTo(0, 0);
197 path.lineTo(0, 100); 197 path.lineTo(0, 100);
198 path.lineTo(50, 50); 198 path.lineTo(50, 50);
199 path.lineTo(100, 100); 199 path.lineTo(100, 100);
200 path.lineTo(100, 0); 200 path.lineTo(100, 0);
201 path.close(); 201 path.close();
202 REPORTER_ASSERT(reporter, !path.isConvex()); 202 REPORTER_ASSERT(reporter, !path.isConvex());
203 203
204 SkPaint paint; 204 SkPaint paint;
205 paint.setAntiAlias(true); 205 paint.setAntiAlias(true);
206 for (int i = 0; i < 50; ++i) { 206 for (int i = 0; i < 50; ++i) {
207 canvas->drawPath(path, paint); 207 canvas->drawPath(path, paint);
208 } 208 }
209 } 209 }
210 picture.reset(recorder.endRecording()); 210 picture.reset(recorder.endRecording());
211 // A lot of large AA concave paths currently render an SkPicture undesireabl e for GPU rendering 211 // A lot of large AA concave paths currently render an SkPicture undesireabl e for GPU rendering
212 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); 212 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
213 213
214 canvas = recorder.beginRecording(100, 100); 214 canvas = recorder.beginRecording(100, 100);
215 { 215 {
216 SkPath path; 216 SkPath path;
217 217
218 path.moveTo(0, 0); 218 path.moveTo(0, 0);
219 path.lineTo(0, 50); 219 path.lineTo(0, 50);
220 path.lineTo(25, 25); 220 path.lineTo(25, 25);
221 path.lineTo(50, 50); 221 path.lineTo(50, 50);
222 path.lineTo(50, 0); 222 path.lineTo(50, 0);
223 path.close(); 223 path.close();
224 REPORTER_ASSERT(reporter, !path.isConvex()); 224 REPORTER_ASSERT(reporter, !path.isConvex());
225 225
226 SkPaint paint; 226 SkPaint paint;
227 paint.setAntiAlias(true); 227 paint.setAntiAlias(true);
228 paint.setStyle(SkPaint::kStroke_Style); 228 paint.setStyle(SkPaint::kStroke_Style);
229 paint.setStrokeWidth(0); 229 paint.setStrokeWidth(0);
230 for (int i = 0; i < 50; ++i) { 230 for (int i = 0; i < 50; ++i) {
231 canvas->drawPath(path, paint); 231 canvas->drawPath(path, paint);
232 } 232 }
233 } 233 }
234 picture.reset(recorder.endRecording()); 234 picture.reset(recorder.endRecording());
235 // hairline stroked AA concave paths are fine for GPU rendering 235 // hairline stroked AA concave paths are fine for GPU rendering
236 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL)); 236 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
237 237
238 canvas = recorder.beginRecording(100, 100); 238 canvas = recorder.beginRecording(100, 100);
239 { 239 {
240 SkPaint paint; 240 SkPaint paint;
241 SkScalar intervals [] = { 10, 20 }; 241 SkScalar intervals [] = { 10, 20 };
242 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); 242 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
243 paint.setPathEffect(pe)->unref(); 243 paint.setPathEffect(pe)->unref();
244 244
245 SkPoint points [2] = { { 0, 0 }, { 100, 0 } }; 245 SkPoint points [2] = { { 0, 0 }, { 100, 0 } };
246 246
247 for (int i = 0; i < 50; ++i) { 247 for (int i = 0; i < 50; ++i) {
248 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint); 248 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint);
249 } 249 }
250 } 250 }
251 picture.reset(recorder.endRecording()); 251 picture.reset(recorder.endRecording());
252 // fast-path dashed effects are fine for GPU rendering ... 252 // fast-path dashed effects are fine for GPU rendering ...
253 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL)); 253 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
254 254
255 canvas = recorder.beginRecording(100, 100); 255 canvas = recorder.beginRecording(100, 100);
256 { 256 {
257 SkPaint paint; 257 SkPaint paint;
258 SkScalar intervals [] = { 10, 20 }; 258 SkScalar intervals [] = { 10, 20 };
259 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); 259 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
260 paint.setPathEffect(pe)->unref(); 260 paint.setPathEffect(pe)->unref();
261 261
262 for (int i = 0; i < 50; ++i) { 262 for (int i = 0; i < 50; ++i) {
263 canvas->drawRect(SkRect::MakeWH(10, 10), paint); 263 canvas->drawRect(SkRect::MakeWH(10, 10), paint);
264 } 264 }
265 } 265 }
266 picture.reset(recorder.endRecording()); 266 picture.reset(recorder.endRecording());
267 // ... but only when applied to drawPoint() calls 267 // ... but only when applied to drawPoint() calls
268 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); 268 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
269 269
270 // Nest the previous picture inside a new one. 270 // Nest the previous picture inside a new one.
271 canvas = recorder.beginRecording(100, 100); 271 canvas = recorder.beginRecording(100, 100);
272 { 272 {
273 canvas->drawPicture(picture.get()); 273 canvas->drawPicture(picture.get());
274 } 274 }
275 picture.reset(recorder.endRecording()); 275 picture.reset(recorder.endRecording());
276 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); 276 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
277 } 277 }
278 278
279 #endif 279 #endif
280 280
281 static void test_savelayer_extraction(skiatest::Reporter* reporter) { 281 static void test_savelayer_extraction(skiatest::Reporter* reporter) {
282 static const int kWidth = 100; 282 static const int kWidth = 100;
283 static const int kHeight = 100; 283 static const int kHeight = 100;
284 284
285 // Create complex paint that the bounding box computation code can't 285 // Create complex paint that the bounding box computation code can't
286 // optimize away 286 // optimize away
287 SkScalar blueToRedMatrix[20] = { 0 }; 287 SkScalar blueToRedMatrix[20] = { 0 };
288 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1; 288 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1;
289 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueToRedM atrix)); 289 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueToRedM atrix));
290 SkAutoTUnref<SkImageFilter> filter(SkColorFilterImageFilter::Create(blueToRe d.get())); 290 SkAutoTUnref<SkImageFilter> filter(SkColorFilterImageFilter::Create(blueToRe d.get()));
291 291
292 SkPaint complexPaint; 292 SkPaint complexPaint;
293 complexPaint.setImageFilter(filter); 293 complexPaint.setImageFilter(filter);
294 294
295 SkAutoTUnref<SkPicture> pict, child; 295 SkAutoTUnref<SkPicture> pict, child;
296 SkRTreeFactory bbhFactory; 296 SkRTreeFactory bbhFactory;
297 297
298 { 298 {
299 SkPictureRecorder recorder; 299 SkPictureRecorder recorder;
300 300
301 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScal ar(kHeight), 301 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScal ar(kHeight),
302 &bbhFactory, 302 &bbhFactory,
303 SkPictureRecorder::kComputeSaveLay erInfo_RecordFlag); 303 SkPictureRecorder::kComputeSaveLay erInfo_RecordFlag);
304 304
305 c->saveLayer(NULL, &complexPaint); 305 c->saveLayer(nullptr, &complexPaint);
306 c->restore(); 306 c->restore();
307 307
308 child.reset(recorder.endRecording()); 308 child.reset(recorder.endRecording());
309 } 309 }
310 310
311 // create a picture with the structure: 311 // create a picture with the structure:
312 // 1) 312 // 1)
313 // SaveLayer 313 // SaveLayer
314 // Restore 314 // Restore
315 // 2) 315 // 2)
(...skipping 14 matching lines...) Expand all
330 // DrawPicture with Matrix & Paint (with SaveLayer/Restore pair) 330 // DrawPicture with Matrix & Paint (with SaveLayer/Restore pair)
331 // Restore 331 // Restore
332 { 332 {
333 SkPictureRecorder recorder; 333 SkPictureRecorder recorder;
334 334
335 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), 335 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth),
336 SkIntToScalar(kHeight), 336 SkIntToScalar(kHeight),
337 &bbhFactory, 337 &bbhFactory,
338 SkPictureRecorder::kComputeSaveLay erInfo_RecordFlag); 338 SkPictureRecorder::kComputeSaveLay erInfo_RecordFlag);
339 // 1) 339 // 1)
340 c->saveLayer(NULL, &complexPaint); // layer #0 340 c->saveLayer(nullptr, &complexPaint); // layer #0
341 c->restore(); 341 c->restore();
342 342
343 // 2) 343 // 2)
344 c->saveLayer(NULL, NULL); // layer #1 344 c->saveLayer(nullptr, nullptr); // layer #1
345 c->translate(kWidth / 2.0f, kHeight / 2.0f); 345 c->translate(kWidth / 2.0f, kHeight / 2.0f);
346 SkRect r = SkRect::MakeXYWH(0, 0, kWidth/2, kHeight/2); 346 SkRect r = SkRect::MakeXYWH(0, 0, kWidth/2, kHeight/2);
347 c->saveLayer(&r, &complexPaint); // layer #2 347 c->saveLayer(&r, &complexPaint); // layer #2
348 c->restore(); 348 c->restore();
349 c->restore(); 349 c->restore();
350 350
351 // 3) 351 // 3)
352 { 352 {
353 c->saveLayer(NULL, &complexPaint); // layer #3 353 c->saveLayer(nullptr, &complexPaint); // layer #3
354 c->restore(); 354 c->restore();
355 } 355 }
356 356
357 SkPaint layerPaint; 357 SkPaint layerPaint;
358 layerPaint.setColor(SK_ColorRED); // Non-alpha only to avoid SaveLayerD rawRestoreNooper 358 layerPaint.setColor(SK_ColorRED); // Non-alpha only to avoid SaveLayerD rawRestoreNooper
359 // 4) 359 // 4)
360 { 360 {
361 c->saveLayer(NULL, &layerPaint); // layer #4 361 c->saveLayer(nullptr, &layerPaint); // layer #4
362 c->drawPicture(child); // layer #5 inside picture 362 c->drawPicture(child); // layer #5 inside picture
363 c->restore(); 363 c->restore();
364 } 364 }
365 // 5 365 // 5
366 { 366 {
367 SkPaint picturePaint; 367 SkPaint picturePaint;
368 SkMatrix trans; 368 SkMatrix trans;
369 trans.setTranslate(10, 10); 369 trans.setTranslate(10, 10);
370 370
371 c->saveLayer(NULL, &layerPaint); // layer #6 371 c->saveLayer(nullptr, &layerPaint); // layer #6
372 c->drawPicture(child, &trans, &picturePaint); // layer #7 inside picture 372 c->drawPicture(child, &trans, &picturePaint); // layer #7 inside picture
373 c->restore(); 373 c->restore();
374 } 374 }
375 375
376 pict.reset(recorder.endRecording()); 376 pict.reset(recorder.endRecording());
377 } 377 }
378 378
379 // Now test out the SaveLayer extraction 379 // Now test out the SaveLayer extraction
380 if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) { 380 if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
381 const SkBigPicture* bp = pict->asSkBigPicture(); 381 const SkBigPicture* bp = pict->asSkBigPicture();
(...skipping 13 matching lines...) Expand all
395 const SkLayerInfo::BlockInfo& info3 = gpuData->block(3); 395 const SkLayerInfo::BlockInfo& info3 = gpuData->block(3);
396 396
397 // The parent/child layers appear in reverse order 397 // The parent/child layers appear in reverse order
398 const SkLayerInfo::BlockInfo& info4 = gpuData->block(5); 398 const SkLayerInfo::BlockInfo& info4 = gpuData->block(5);
399 const SkLayerInfo::BlockInfo& info5 = gpuData->block(4); 399 const SkLayerInfo::BlockInfo& info5 = gpuData->block(4);
400 400
401 // The parent/child layers appear in reverse order 401 // The parent/child layers appear in reverse order
402 const SkLayerInfo::BlockInfo& info6 = gpuData->block(7); 402 const SkLayerInfo::BlockInfo& info6 = gpuData->block(7);
403 const SkLayerInfo::BlockInfo& info7 = gpuData->block(6); 403 const SkLayerInfo::BlockInfo& info7 = gpuData->block(6);
404 404
405 REPORTER_ASSERT(reporter, NULL == info0.fPicture); 405 REPORTER_ASSERT(reporter, nullptr == info0.fPicture);
406 REPORTER_ASSERT(reporter, kWidth == info0.fBounds.width() && 406 REPORTER_ASSERT(reporter, kWidth == info0.fBounds.width() &&
407 kHeight == info0.fBounds.height()); 407 kHeight == info0.fBounds.height());
408 REPORTER_ASSERT(reporter, info0.fLocalMat.isIdentity()); 408 REPORTER_ASSERT(reporter, info0.fLocalMat.isIdentity());
409 REPORTER_ASSERT(reporter, info0.fPreMat.isIdentity()); 409 REPORTER_ASSERT(reporter, info0.fPreMat.isIdentity());
410 REPORTER_ASSERT(reporter, 0 == info0.fBounds.fLeft && 0 == info0.fBounds .fTop); 410 REPORTER_ASSERT(reporter, 0 == info0.fBounds.fLeft && 0 == info0.fBounds .fTop);
411 REPORTER_ASSERT(reporter, NULL != info0.fPaint); 411 REPORTER_ASSERT(reporter, nullptr != info0.fPaint);
412 REPORTER_ASSERT(reporter, !info0.fIsNested && !info0.fHasNestedLayers); 412 REPORTER_ASSERT(reporter, !info0.fIsNested && !info0.fHasNestedLayers);
413 413
414 REPORTER_ASSERT(reporter, NULL == info1.fPicture); 414 REPORTER_ASSERT(reporter, nullptr == info1.fPicture);
415 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.width() && 415 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.width() &&
416 kHeight/2.0 == info1.fBounds.height()); 416 kHeight/2.0 == info1.fBounds.height());
417 REPORTER_ASSERT(reporter, info1.fLocalMat.isIdentity()); 417 REPORTER_ASSERT(reporter, info1.fLocalMat.isIdentity());
418 REPORTER_ASSERT(reporter, info1.fPreMat.isIdentity()); 418 REPORTER_ASSERT(reporter, info1.fPreMat.isIdentity());
419 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.fLeft && 419 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.fLeft &&
420 kHeight/2.0 == info1.fBounds.fTop); 420 kHeight/2.0 == info1.fBounds.fTop);
421 REPORTER_ASSERT(reporter, NULL == info1.fPaint); 421 REPORTER_ASSERT(reporter, nullptr == info1.fPaint);
422 REPORTER_ASSERT(reporter, !info1.fIsNested && 422 REPORTER_ASSERT(reporter, !info1.fIsNested &&
423 info1.fHasNestedLayers); // has a nested SL 423 info1.fHasNestedLayers); // has a nested SL
424 424
425 REPORTER_ASSERT(reporter, NULL == info2.fPicture); 425 REPORTER_ASSERT(reporter, nullptr == info2.fPicture);
426 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.width() && 426 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.width() &&
427 kHeight / 2 == info2.fBounds.height()); // bou nd reduces size 427 kHeight / 2 == info2.fBounds.height()); // bou nd reduces size
428 REPORTER_ASSERT(reporter, !info2.fLocalMat.isIdentity()); 428 REPORTER_ASSERT(reporter, !info2.fLocalMat.isIdentity());
429 REPORTER_ASSERT(reporter, info2.fPreMat.isIdentity()); 429 REPORTER_ASSERT(reporter, info2.fPreMat.isIdentity());
430 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.fLeft && // tran slated 430 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.fLeft && // tran slated
431 kHeight / 2 == info2.fBounds.fTop); 431 kHeight / 2 == info2.fBounds.fTop);
432 REPORTER_ASSERT(reporter, NULL != info2.fPaint); 432 REPORTER_ASSERT(reporter, nullptr != info2.fPaint);
433 REPORTER_ASSERT(reporter, info2.fIsNested && !info2.fHasNestedLayers); / / is nested 433 REPORTER_ASSERT(reporter, info2.fIsNested && !info2.fHasNestedLayers); / / is nested
434 434
435 REPORTER_ASSERT(reporter, NULL == info3.fPicture); 435 REPORTER_ASSERT(reporter, nullptr == info3.fPicture);
436 REPORTER_ASSERT(reporter, kWidth == info3.fBounds.width() && 436 REPORTER_ASSERT(reporter, kWidth == info3.fBounds.width() &&
437 kHeight == info3.fBounds.height()); 437 kHeight == info3.fBounds.height());
438 REPORTER_ASSERT(reporter, info3.fLocalMat.isIdentity()); 438 REPORTER_ASSERT(reporter, info3.fLocalMat.isIdentity());
439 REPORTER_ASSERT(reporter, info3.fPreMat.isIdentity()); 439 REPORTER_ASSERT(reporter, info3.fPreMat.isIdentity());
440 REPORTER_ASSERT(reporter, 0 == info3.fBounds.fLeft && 0 == info3.fBounds .fTop); 440 REPORTER_ASSERT(reporter, 0 == info3.fBounds.fLeft && 0 == info3.fBounds .fTop);
441 REPORTER_ASSERT(reporter, info3.fPaint); 441 REPORTER_ASSERT(reporter, info3.fPaint);
442 REPORTER_ASSERT(reporter, !info3.fIsNested && !info3.fHasNestedLayers); 442 REPORTER_ASSERT(reporter, !info3.fIsNested && !info3.fHasNestedLayers);
443 443
444 REPORTER_ASSERT(reporter, NULL == info4.fPicture); 444 REPORTER_ASSERT(reporter, nullptr == info4.fPicture);
445 REPORTER_ASSERT(reporter, kWidth == info4.fBounds.width() && 445 REPORTER_ASSERT(reporter, kWidth == info4.fBounds.width() &&
446 kHeight == info4.fBounds.height()); 446 kHeight == info4.fBounds.height());
447 REPORTER_ASSERT(reporter, 0 == info4.fBounds.fLeft && 0 == info4.fBounds .fTop); 447 REPORTER_ASSERT(reporter, 0 == info4.fBounds.fLeft && 0 == info4.fBounds .fTop);
448 REPORTER_ASSERT(reporter, info4.fLocalMat.isIdentity()); 448 REPORTER_ASSERT(reporter, info4.fLocalMat.isIdentity());
449 REPORTER_ASSERT(reporter, info4.fPreMat.isIdentity()); 449 REPORTER_ASSERT(reporter, info4.fPreMat.isIdentity());
450 REPORTER_ASSERT(reporter, info4.fPaint); 450 REPORTER_ASSERT(reporter, info4.fPaint);
451 REPORTER_ASSERT(reporter, !info4.fIsNested && 451 REPORTER_ASSERT(reporter, !info4.fIsNested &&
452 info4.fHasNestedLayers); // has a nested SL 452 info4.fHasNestedLayers); // has a nested SL
453 453
454 REPORTER_ASSERT(reporter, child == info5.fPicture); // in a child pictur e 454 REPORTER_ASSERT(reporter, child == info5.fPicture); // in a child pictur e
455 REPORTER_ASSERT(reporter, kWidth == info5.fBounds.width() && 455 REPORTER_ASSERT(reporter, kWidth == info5.fBounds.width() &&
456 kHeight == info5.fBounds.height()); 456 kHeight == info5.fBounds.height());
457 REPORTER_ASSERT(reporter, 0 == info5.fBounds.fLeft && 0 == info5.fBounds .fTop); 457 REPORTER_ASSERT(reporter, 0 == info5.fBounds.fLeft && 0 == info5.fBounds .fTop);
458 REPORTER_ASSERT(reporter, info5.fLocalMat.isIdentity()); 458 REPORTER_ASSERT(reporter, info5.fLocalMat.isIdentity());
459 REPORTER_ASSERT(reporter, info5.fPreMat.isIdentity()); 459 REPORTER_ASSERT(reporter, info5.fPreMat.isIdentity());
460 REPORTER_ASSERT(reporter, NULL != info5.fPaint); 460 REPORTER_ASSERT(reporter, nullptr != info5.fPaint);
461 REPORTER_ASSERT(reporter, info5.fIsNested && !info5.fHasNestedLayers); / / is nested 461 REPORTER_ASSERT(reporter, info5.fIsNested && !info5.fHasNestedLayers); / / is nested
462 462
463 REPORTER_ASSERT(reporter, NULL == info6.fPicture); 463 REPORTER_ASSERT(reporter, nullptr == info6.fPicture);
464 REPORTER_ASSERT(reporter, kWidth-10 == info6.fBounds.width() && 464 REPORTER_ASSERT(reporter, kWidth-10 == info6.fBounds.width() &&
465 kHeight-10 == info6.fBounds.height()); 465 kHeight-10 == info6.fBounds.height());
466 REPORTER_ASSERT(reporter, 10 == info6.fBounds.fLeft && 10 == info6.fBoun ds.fTop); 466 REPORTER_ASSERT(reporter, 10 == info6.fBounds.fLeft && 10 == info6.fBoun ds.fTop);
467 REPORTER_ASSERT(reporter, info6.fLocalMat.isIdentity()); 467 REPORTER_ASSERT(reporter, info6.fLocalMat.isIdentity());
468 REPORTER_ASSERT(reporter, info6.fPreMat.isIdentity()); 468 REPORTER_ASSERT(reporter, info6.fPreMat.isIdentity());
469 REPORTER_ASSERT(reporter, info6.fPaint); 469 REPORTER_ASSERT(reporter, info6.fPaint);
470 REPORTER_ASSERT(reporter, !info6.fIsNested && 470 REPORTER_ASSERT(reporter, !info6.fIsNested &&
471 info6.fHasNestedLayers); // has a nested SL 471 info6.fHasNestedLayers); // has a nested SL
472 472
473 REPORTER_ASSERT(reporter, child == info7.fPicture); // in a child pictur e 473 REPORTER_ASSERT(reporter, child == info7.fPicture); // in a child pictur e
474 REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() && 474 REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() &&
475 kHeight == info7.fBounds.height()); 475 kHeight == info7.fBounds.height());
476 REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds .fTop); 476 REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds .fTop);
477 REPORTER_ASSERT(reporter, info7.fLocalMat.isIdentity()); 477 REPORTER_ASSERT(reporter, info7.fLocalMat.isIdentity());
478 REPORTER_ASSERT(reporter, info7.fPreMat.isIdentity()); 478 REPORTER_ASSERT(reporter, info7.fPreMat.isIdentity());
479 REPORTER_ASSERT(reporter, NULL != info7.fPaint); 479 REPORTER_ASSERT(reporter, nullptr != info7.fPaint);
480 REPORTER_ASSERT(reporter, info7.fIsNested && !info7.fHasNestedLayers); / / is nested 480 REPORTER_ASSERT(reporter, info7.fIsNested && !info7.fHasNestedLayers); / / is nested
481 } 481 }
482 } 482 }
483 483
484 static void test_has_text(skiatest::Reporter* reporter) { 484 static void test_has_text(skiatest::Reporter* reporter) {
485 SkPictureRecorder recorder; 485 SkPictureRecorder recorder;
486 486
487 SkCanvas* canvas = recorder.beginRecording(100,100); 487 SkCanvas* canvas = recorder.beginRecording(100,100);
488 { 488 {
489 canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint()); 489 canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 523 }
524 picture.reset(recorder.endRecording()); 524 picture.reset(recorder.endRecording());
525 REPORTER_ASSERT(reporter, picture->hasText()); 525 REPORTER_ASSERT(reporter, picture->hasText());
526 526
527 canvas = recorder.beginRecording(100,100); 527 canvas = recorder.beginRecording(100,100);
528 { 528 {
529 SkPath path; 529 SkPath path;
530 path.moveTo(0, 0); 530 path.moveTo(0, 0);
531 path.lineTo(50, 50); 531 path.lineTo(50, 50);
532 532
533 canvas->drawTextOnPath("Q", 1, path, NULL, SkPaint()); 533 canvas->drawTextOnPath("Q", 1, path, nullptr, SkPaint());
534 } 534 }
535 picture.reset(recorder.endRecording()); 535 picture.reset(recorder.endRecording());
536 REPORTER_ASSERT(reporter, picture->hasText()); 536 REPORTER_ASSERT(reporter, picture->hasText());
537 537
538 // Nest the previous picture inside a new one. 538 // Nest the previous picture inside a new one.
539 canvas = recorder.beginRecording(100,100); 539 canvas = recorder.beginRecording(100,100);
540 { 540 {
541 canvas->drawPicture(picture.get()); 541 canvas->drawPicture(picture.get());
542 } 542 }
543 picture.reset(recorder.endRecording()); 543 picture.reset(recorder.endRecording());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 } 661 }
662 662
663 // Test out SkPictureRecorder::partialReplay 663 // Test out SkPictureRecorder::partialReplay
664 DEF_TEST(PictureRecorder_replay, reporter) { 664 DEF_TEST(PictureRecorder_replay, reporter) {
665 // check save/saveLayer state 665 // check save/saveLayer state
666 { 666 {
667 SkPictureRecorder recorder; 667 SkPictureRecorder recorder;
668 668
669 SkCanvas* canvas = recorder.beginRecording(10, 10); 669 SkCanvas* canvas = recorder.beginRecording(10, 10);
670 670
671 canvas->saveLayer(NULL, NULL); 671 canvas->saveLayer(nullptr, nullptr);
672 672
673 SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&record er)); 673 SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&record er));
674 674
675 // The extra save and restore comes from the Copy process. 675 // The extra save and restore comes from the Copy process.
676 check_save_state(reporter, copy, 2, 1, 3); 676 check_save_state(reporter, copy, 2, 1, 3);
677 677
678 canvas->saveLayer(NULL, NULL); 678 canvas->saveLayer(nullptr, nullptr);
679 679
680 SkAutoTUnref<SkPicture> final(recorder.endRecording()); 680 SkAutoTUnref<SkPicture> final(recorder.endRecording());
681 681
682 check_save_state(reporter, final, 1, 2, 3); 682 check_save_state(reporter, final, 1, 2, 3);
683 683
684 // The copy shouldn't pick up any operations added after it was made 684 // The copy shouldn't pick up any operations added after it was made
685 check_save_state(reporter, copy, 2, 1, 3); 685 check_save_state(reporter, copy, 2, 1, 3);
686 } 686 }
687 687
688 // (partially) check leakage of draw ops 688 // (partially) check leakage of draw ops
(...skipping 23 matching lines...) Expand all
712 REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID()); 712 REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID());
713 713
714 // The snapshot shouldn't pick up any operations added after it was made 714 // The snapshot shouldn't pick up any operations added after it was made
715 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps()); 715 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps());
716 } 716 }
717 717
718 // Recreate the Android partialReplay test case 718 // Recreate the Android partialReplay test case
719 { 719 {
720 SkPictureRecorder recorder; 720 SkPictureRecorder recorder;
721 721
722 SkCanvas* canvas = recorder.beginRecording(4, 3, NULL, 0); 722 SkCanvas* canvas = recorder.beginRecording(4, 3, nullptr, 0);
723 create_imbalance(canvas); 723 create_imbalance(canvas);
724 724
725 int expectedSaveCount = canvas->getSaveCount(); 725 int expectedSaveCount = canvas->getSaveCount();
726 726
727 SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&record er)); 727 SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&record er));
728 check_balance(reporter, copy); 728 check_balance(reporter, copy);
729 729
730 REPORTER_ASSERT(reporter, expectedSaveCount = canvas->getSaveCount()); 730 REPORTER_ASSERT(reporter, expectedSaveCount = canvas->getSaveCount());
731 731
732 // End the recording of source to test the picture finalization 732 // End the recording of source to test the picture finalization
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); 897 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm));
898 REPORTER_ASSERT(reporter, picture1->equals(picture2)); 898 REPORTER_ASSERT(reporter, picture1->equals(picture2));
899 // Now test that a parse error was generated when trying to create a new SkP icture without 899 // Now test that a parse error was generated when trying to create a new SkP icture without
900 // providing a function to decode the bitmap. 900 // providing a function to decode the bitmap.
901 ErrorContext context; 901 ErrorContext context;
902 context.fErrors = 0; 902 context.fErrors = 0;
903 context.fReporter = reporter; 903 context.fReporter = reporter;
904 SkSetErrorCallback(assert_one_parse_error_cb, &context); 904 SkSetErrorCallback(assert_one_parse_error_cb, &context);
905 SkMemoryStream pictureStream(picture1); 905 SkMemoryStream pictureStream(picture1);
906 SkClearLastError(); 906 SkClearLastError();
907 SkAutoTUnref<SkPicture> pictureFromStream(SkPicture::CreateFromStream(&pictu reStream, NULL)); 907 SkAutoTUnref<SkPicture> pictureFromStream(SkPicture::CreateFromStream(&pictu reStream, nullptr));
908 REPORTER_ASSERT(reporter, pictureFromStream.get() != NULL); 908 REPORTER_ASSERT(reporter, pictureFromStream.get() != nullptr);
909 SkClearLastError(); 909 SkClearLastError();
910 SkSetErrorCallback(NULL, NULL); 910 SkSetErrorCallback(nullptr, nullptr);
911 } 911 }
912 912
913 static void test_clip_bound_opt(skiatest::Reporter* reporter) { 913 static void test_clip_bound_opt(skiatest::Reporter* reporter) {
914 // Test for crbug.com/229011 914 // Test for crbug.com/229011
915 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), 915 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4),
916 SkIntToScalar(2), SkIntToScalar(2)); 916 SkIntToScalar(2), SkIntToScalar(2));
917 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), 917 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7),
918 SkIntToScalar(1), SkIntToScalar(1)); 918 SkIntToScalar(1), SkIntToScalar(1));
919 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6), 919 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6),
920 SkIntToScalar(1), SkIntToScalar(1)); 920 SkIntToScalar(1), SkIntToScalar(1));
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 canvas->drawBitmap(mut, 0, 0); 1324 canvas->drawBitmap(mut, 0, 0);
1325 canvas->drawBitmap(immut, 800, 600); 1325 canvas->drawBitmap(immut, 800, 600);
1326 pic.reset(rec.endRecording()); 1326 pic.reset(rec.endRecording());
1327 } 1327 }
1328 1328
1329 // The picture shares the immutable pixels but copies the mutable ones. 1329 // The picture shares the immutable pixels but copies the mutable ones.
1330 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1330 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1331 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1331 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1332 1332
1333 // When the picture goes away, it's just our bitmaps holding the refs. 1333 // When the picture goes away, it's just our bitmaps holding the refs.
1334 pic.reset(NULL); 1334 pic.reset(nullptr);
1335 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1335 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1336 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1336 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1337 } 1337 }
1338 1338
1339 // getRecordingCanvas() should return a SkCanvas when recording, null when not r ecording. 1339 // getRecordingCanvas() should return a SkCanvas when recording, null when not r ecording.
1340 DEF_TEST(Picture_getRecordingCanvas, r) { 1340 DEF_TEST(Picture_getRecordingCanvas, r) {
1341 SkPictureRecorder rec; 1341 SkPictureRecorder rec;
1342 REPORTER_ASSERT(r, !rec.getRecordingCanvas()); 1342 REPORTER_ASSERT(r, !rec.getRecordingCanvas());
1343 for (int i = 0; i < 3; i++) { 1343 for (int i = 0; i < 3; i++) {
1344 rec.beginRecording(100, 100); 1344 rec.beginRecording(100, 100);
(...skipping 25 matching lines...) Expand all
1370 1370
1371 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1371 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1372 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam)); 1372 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam));
1373 1373
1374 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); 1374 REPORTER_ASSERT(r, SkToBool(deserializedPicture));
1375 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); 1375 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
1376 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); 1376 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
1377 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); 1377 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
1378 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); 1378 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
1379 } 1379 }
OLDNEW
« no previous file with comments | « tests/PictureShaderTest.cpp ('k') | tests/PixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698