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

Side by Side Diff: tests/MatrixClipCollapseTest.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/Matrix44Test.cpp ('k') | tests/MatrixTest.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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDebugCanvas.h" 10 #include "SkDebugCanvas.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 r.setRects(rects, 2); 185 r.setRects(rects, 2);
186 canvas->clipRegion(r, SkRegion::kIntersect_Op); 186 canvas->clipRegion(r, SkRegion::kIntersect_Op);
187 break; 187 break;
188 } 188 }
189 default: 189 default:
190 SkASSERT(0); 190 SkASSERT(0);
191 } 191 }
192 } 192 }
193 193
194 static void add_clip(ClipType clip, MatType mat, SkTDArray<DrawType>* expected) { 194 static void add_clip(ClipType clip, MatType mat, SkTDArray<DrawType>* expected) {
195 if (NULL == expected) { 195 if (nullptr == expected) {
196 // expected is NULL if this clip will be fused into later clips 196 // expected is nullptr if this clip will be fused into later clips
197 return; 197 return;
198 } 198 }
199 199
200 switch (clip) { 200 switch (clip) {
201 case kNone_ClipType: 201 case kNone_ClipType:
202 break; 202 break;
203 case kRect_ClipType: 203 case kRect_ClipType:
204 *expected->append() = CONCAT; 204 *expected->append() = CONCAT;
205 *expected->append() = CLIP_RECT; 205 *expected->append() = CLIP_RECT;
206 break; 206 break;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 m.setTranslate(1.0f, 1.0f); 248 m.setTranslate(1.0f, 1.0f);
249 canvas->setMatrix(m); 249 canvas->setMatrix(m);
250 break; 250 break;
251 } 251 }
252 default: 252 default:
253 SkASSERT(0); 253 SkASSERT(0);
254 } 254 }
255 } 255 }
256 256
257 static void add_mat(MatType mat, SkTDArray<DrawType>* expected) { 257 static void add_mat(MatType mat, SkTDArray<DrawType>* expected) {
258 if (NULL == expected) { 258 if (nullptr == expected) {
259 // expected is NULL if this matrix call will be fused into later ones 259 // expected is nullptr if this matrix call will be fused into later ones
260 return; 260 return;
261 } 261 }
262 262
263 switch (mat) { 263 switch (mat) {
264 case kNone_MatType: 264 case kNone_MatType:
265 break; 265 break;
266 case kTranslate_MatType: // fall thru 266 case kTranslate_MatType: // fall thru
267 case kScale_MatType: // fall thru 267 case kScale_MatType: // fall thru
268 case kSkew_MatType: // fall thru 268 case kSkew_MatType: // fall thru
269 case kRotate_MatType: // fall thru 269 case kRotate_MatType: // fall thru
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 SkTDArray<DrawType>* expected, int accumulatedClips) { 468 SkTDArray<DrawType>* expected, int accumulatedClips) {
469 bool needsSaveRestore = kNone_DrawOpType != draw && 469 bool needsSaveRestore = kNone_DrawOpType != draw &&
470 (kNone_MatType != mat || kNone_ClipType != clip); 470 (kNone_MatType != mat || kNone_ClipType != clip);
471 471
472 if (kNone_MatType != mat || kNone_ClipType != clip) { 472 if (kNone_MatType != mat || kNone_ClipType != clip) {
473 *expected->append() = SAVE; 473 *expected->append() = SAVE;
474 } 474 }
475 (*emitMC)(canvas, mat, clip, kSaveLayer_DrawOpType, expected, accumulatedCli ps+1); 475 (*emitMC)(canvas, mat, clip, kSaveLayer_DrawOpType, expected, accumulatedCli ps+1);
476 *expected->append() = SAVE_LAYER; 476 *expected->append() = SAVE_LAYER;
477 // TODO: widen testing to exercise saveLayer's parameters 477 // TODO: widen testing to exercise saveLayer's parameters
478 canvas->saveLayer(NULL, NULL); 478 canvas->saveLayer(nullptr, nullptr);
479 if (needsSaveRestore) { 479 if (needsSaveRestore) {
480 *expected->append() = SAVE; 480 *expected->append() = SAVE;
481 } 481 }
482 (*emitMC)(canvas, mat, clip, draw, expected, 1); 482 (*emitMC)(canvas, mat, clip, draw, expected, 1);
483 emit_draw(canvas, draw, expected); 483 emit_draw(canvas, draw, expected);
484 if (needsSaveRestore) { 484 if (needsSaveRestore) {
485 *expected->append() = RESTORE; 485 *expected->append() = RESTORE;
486 } 486 }
487 canvas->restore(); 487 canvas->restore();
488 *expected->append() = RESTORE; 488 *expected->append() = RESTORE;
(...skipping 17 matching lines...) Expand all
506 SkTDArray<DrawType>* expected, int accumulatedClips) { 506 SkTDArray<DrawType>* expected, int accumulatedClips) {
507 bool needsSaveRestore = kNone_DrawOpType != draw && 507 bool needsSaveRestore = kNone_DrawOpType != draw &&
508 (kNone_MatType != mat || kNone_ClipType != clip); 508 (kNone_MatType != mat || kNone_ClipType != clip);
509 509
510 if (kNone_MatType != mat || kNone_ClipType != clip) { 510 if (kNone_MatType != mat || kNone_ClipType != clip) {
511 *expected->append() = SAVE; 511 *expected->append() = SAVE;
512 } 512 }
513 (*emitMC)(canvas, mat, clip, kSaveLayer_DrawOpType, expected, accumulatedCli ps+1); 513 (*emitMC)(canvas, mat, clip, kSaveLayer_DrawOpType, expected, accumulatedCli ps+1);
514 *expected->append() = SAVE_LAYER; 514 *expected->append() = SAVE_LAYER;
515 // TODO: widen testing to exercise saveLayer's parameters 515 // TODO: widen testing to exercise saveLayer's parameters
516 canvas->saveLayer(NULL, NULL); 516 canvas->saveLayer(nullptr, nullptr);
517 (*emitMC)(canvas, mat, clip, kSaveLayer_DrawOpType, expected, 1); 517 (*emitMC)(canvas, mat, clip, kSaveLayer_DrawOpType, expected, 1);
518 if (kNone_MatType != mat || kNone_ClipType != clip) { 518 if (kNone_MatType != mat || kNone_ClipType != clip) {
519 *expected->append() = SAVE; 519 *expected->append() = SAVE;
520 } 520 }
521 *expected->append() = SAVE_LAYER; 521 *expected->append() = SAVE_LAYER;
522 // TODO: widen testing to exercise saveLayer's parameters 522 // TODO: widen testing to exercise saveLayer's parameters
523 canvas->saveLayer(NULL, NULL); 523 canvas->saveLayer(nullptr, nullptr);
524 if (needsSaveRestore) { 524 if (needsSaveRestore) {
525 *expected->append() = SAVE; 525 *expected->append() = SAVE;
526 } 526 }
527 (*emitMC)(canvas, mat, clip, draw, expected, 1); 527 (*emitMC)(canvas, mat, clip, draw, expected, 1);
528 emit_draw(canvas, draw, expected); 528 emit_draw(canvas, draw, expected);
529 if (needsSaveRestore) { 529 if (needsSaveRestore) {
530 *expected->append() = RESTORE; 530 *expected->append() = RESTORE;
531 } 531 }
532 canvas->restore(); // for saveLayer 532 canvas->restore(); // for saveLayer
533 *expected->append() = RESTORE; // for saveLayer 533 *expected->append() = RESTORE; // for saveLayer
(...skipping 28 matching lines...) Expand all
562 // Save 562 // Save
563 // some body 563 // some body
564 // Restore 564 // Restore
565 // matrix & clip calls (will be ignored) 565 // matrix & clip calls (will be ignored)
566 // Restore 566 // Restore
567 // Note: the outer save/restore are provided by beginRecording/endRecording 567 // Note: the outer save/restore are provided by beginRecording/endRecording
568 static void emit_struct1(SkCanvas* canvas, 568 static void emit_struct1(SkCanvas* canvas,
569 PFEmitMC emitMC, MatType mat, ClipType clip, 569 PFEmitMC emitMC, MatType mat, ClipType clip,
570 PFEmitBody emitBody, DrawOpType draw, 570 PFEmitBody emitBody, DrawOpType draw,
571 SkTDArray<DrawType>* expected) { 571 SkTDArray<DrawType>* expected) {
572 (*emitMC)(canvas, mat, clip, draw, NULL, 0); // these get fused into later o ps 572 (*emitMC)(canvas, mat, clip, draw, nullptr, 0); // these get fused into late r ops
573 canvas->save(); 573 canvas->save();
574 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1); 574 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1);
575 canvas->restore(); 575 canvas->restore();
576 (*emitMC)(canvas, mat, clip, draw, NULL, 0); // these will get removed 576 (*emitMC)(canvas, mat, clip, draw, nullptr, 0); // these will get removed
577 } 577 }
578 578
579 // Emit: 579 // Emit:
580 // Save 580 // Save
581 // matrix & clip calls 581 // matrix & clip calls
582 // Save 582 // Save
583 // some body 583 // some body
584 // Restore 584 // Restore
585 // Save 585 // Save
586 // some body 586 // some body
587 // Restore 587 // Restore
588 // matrix & clip calls (will be ignored) 588 // matrix & clip calls (will be ignored)
589 // Restore 589 // Restore
590 // Note: the outer save/restore are provided by beginRecording/endRecording 590 // Note: the outer save/restore are provided by beginRecording/endRecording
591 static void emit_struct2(SkCanvas* canvas, 591 static void emit_struct2(SkCanvas* canvas,
592 PFEmitMC emitMC, MatType mat, ClipType clip, 592 PFEmitMC emitMC, MatType mat, ClipType clip,
593 PFEmitBody emitBody, DrawOpType draw, 593 PFEmitBody emitBody, DrawOpType draw,
594 SkTDArray<DrawType>* expected) { 594 SkTDArray<DrawType>* expected) {
595 (*emitMC)(canvas, mat, clip, draw, NULL, 1); // these will get fused into la ter ops 595 (*emitMC)(canvas, mat, clip, draw, nullptr, 1); // these will get fused into later ops
596 canvas->save(); 596 canvas->save();
597 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1); 597 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1);
598 canvas->restore(); 598 canvas->restore();
599 canvas->save(); 599 canvas->save();
600 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1); 600 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1);
601 canvas->restore(); 601 canvas->restore();
602 (*emitMC)(canvas, mat, clip, draw, NULL, 1); // these will get removed 602 (*emitMC)(canvas, mat, clip, draw, nullptr, 1); // these will get removed
603 } 603 }
604 604
605 // Emit: 605 // Emit:
606 // Save 606 // Save
607 // matrix & clip calls 607 // matrix & clip calls
608 // Save 608 // Save
609 // some body 609 // some body
610 // Restore 610 // Restore
611 // Save 611 // Save
612 // matrix & clip calls 612 // matrix & clip calls
613 // Save 613 // Save
614 // some body 614 // some body
615 // Restore 615 // Restore
616 // Restore 616 // Restore
617 // matrix & clip calls (will be ignored) 617 // matrix & clip calls (will be ignored)
618 // Restore 618 // Restore
619 // Note: the outer save/restore are provided by beginRecording/endRecording 619 // Note: the outer save/restore are provided by beginRecording/endRecording
620 static void emit_struct3(SkCanvas* canvas, 620 static void emit_struct3(SkCanvas* canvas,
621 PFEmitMC emitMC, MatType mat, ClipType clip, 621 PFEmitMC emitMC, MatType mat, ClipType clip,
622 PFEmitBody emitBody, DrawOpType draw, 622 PFEmitBody emitBody, DrawOpType draw,
623 SkTDArray<DrawType>* expected) { 623 SkTDArray<DrawType>* expected) {
624 (*emitMC)(canvas, mat, clip, draw, NULL, 0); // these will get fused into la ter ops 624 (*emitMC)(canvas, mat, clip, draw, nullptr, 0); // these will get fused into later ops
625 canvas->save(); 625 canvas->save();
626 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1); 626 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 1);
627 canvas->restore(); 627 canvas->restore();
628 canvas->save(); 628 canvas->save();
629 (*emitMC)(canvas, mat, clip, draw, NULL, 1); // these will get fused int o later ops 629 (*emitMC)(canvas, mat, clip, draw, nullptr, 1); // these will get fused into later ops
630 canvas->save(); 630 canvas->save();
631 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 2); 631 (*emitBody)(canvas, emitMC, mat, clip, draw, expected, 2);
632 canvas->restore(); 632 canvas->restore();
633 canvas->restore(); 633 canvas->restore();
634 (*emitMC)(canvas, mat, clip, draw, NULL, 0); // these will get removed 634 (*emitMC)(canvas, mat, clip, draw, nullptr, 0); // these will get removed
635 } 635 }
636 636
637 ////////////////////////////////////////////////////////////////////////////// 637 //////////////////////////////////////////////////////////////////////////////
638 638
639 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 639 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
640 static void print(const SkTDArray<DrawType>& expected, const SkTDArray<DrawType> & actual) { 640 static void print(const SkTDArray<DrawType>& expected, const SkTDArray<DrawType> & actual) {
641 SkDebugf("\n\nexpected %d --- actual %d\n", expected.count(), actual.count() ); 641 SkDebugf("\n\nexpected %d --- actual %d\n", expected.count(), actual.count() );
642 int max = SkMax32(expected.count(), actual.count()); 642 int max = SkMax32(expected.count(), actual.count());
643 643
644 for (int i = 0; i < max; ++i) { 644 for (int i = 0; i < max; ++i) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } 721 }
722 } 722 }
723 } 723 }
724 } 724 }
725 725
726 DEF_TEST(MatrixClipCollapse, reporter) { 726 DEF_TEST(MatrixClipCollapse, reporter) {
727 test_collapse(reporter); 727 test_collapse(reporter);
728 } 728 }
729 729
730 #endif 730 #endif
OLDNEW
« no previous file with comments | « tests/Matrix44Test.cpp ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698