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

Side by Side Diff: tests/PictureTest.cpp

Issue 14820021: Fix behavior of SkPicture::kUsePathBoundsForClip_RecordingFlag to handle inverse fills and all clip… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« src/core/SkPictureRecord.cpp ('K') | « src/core/SkPictureRecord.cpp ('k') | no next file » | 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 #include "Test.h" 7 #include "Test.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 { 442 {
443 // Test without call to endRecording 443 // Test without call to endRecording
444 SkPicture picture; 444 SkPicture picture;
445 picture.beginRecording(1, 1); 445 picture.beginRecording(1, 1);
446 SkPicture* destPicture = picture.clone(); 446 SkPicture* destPicture = picture.clone();
447 REPORTER_ASSERT(reporter, NULL != destPicture); 447 REPORTER_ASSERT(reporter, NULL != destPicture);
448 destPicture->unref(); 448 destPicture->unref();
449 } 449 }
450 } 450 }
451 451
452 static void test_clip_bound_opt(skiatest::Reporter* reporter) {
453 // Test for crbug.com/229011
454 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4),
455 SkIntToScalar(2), SkIntToScalar(2));
456 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7),
457 SkIntToScalar(1), SkIntToScalar(1));
458 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6),
459 SkIntToScalar(1), SkIntToScalar(1));
460
461 SkPath invPath;
462 invPath.addOval(rect1);
463 invPath.setFillType(SkPath::kInverseEvenOdd_FillType);
464 SkPath path;
465 path.addOval(rect2);
466 SkPath path2;
467 path2.addOval(rect3);
468 SkIRect clipBounds;
469 // Minimalist test set for 100% code coverage of
470 // SkPictureRecord::updateClipConservativelyUsingBounds
471 {
472 SkPicture picture;
473 SkCanvas* canvas = picture.beginRecording(10, 10,
474 SkPicture::kUsePathBoundsForClip_RecordingFlag);
475 canvas->clipPath(invPath, SkRegion::kIntersect_Op);
476 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
477 REPORTER_ASSERT(reporter, true == nonEmpty);
478 REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
479 REPORTER_ASSERT(reporter, 0 == clipBounds.fTop);
480 REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom);
481 REPORTER_ASSERT(reporter, 10 == clipBounds.fRight);
482 }
483 {
484 SkPicture picture;
485 SkCanvas* canvas = picture.beginRecording(10, 10,
486 SkPicture::kUsePathBoundsForClip_RecordingFlag);
487 canvas->clipPath(path, SkRegion::kIntersect_Op);
488 canvas->clipPath(invPath, SkRegion::kIntersect_Op);
489 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
490 REPORTER_ASSERT(reporter, true == nonEmpty);
491 REPORTER_ASSERT(reporter, 7 == clipBounds.fLeft);
492 REPORTER_ASSERT(reporter, 7 == clipBounds.fTop);
493 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
494 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
495 }
496 {
497 SkPicture picture;
498 SkCanvas* canvas = picture.beginRecording(10, 10,
499 SkPicture::kUsePathBoundsForClip_RecordingFlag);
500 canvas->clipPath(path, SkRegion::kIntersect_Op);
501 canvas->clipPath(invPath, SkRegion::kUnion_Op);
502 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
503 REPORTER_ASSERT(reporter, true == nonEmpty);
504 REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
505 REPORTER_ASSERT(reporter, 0 == clipBounds.fTop);
506 REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom);
507 REPORTER_ASSERT(reporter, 10 == clipBounds.fRight);
508 }
509 {
510 SkPicture picture;
511 SkCanvas* canvas = picture.beginRecording(10, 10,
512 SkPicture::kUsePathBoundsForClip_RecordingFlag);
513 canvas->clipPath(path, SkRegion::kDifference_Op);
514 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
515 REPORTER_ASSERT(reporter, true == nonEmpty);
516 REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
517 REPORTER_ASSERT(reporter, 0 == clipBounds.fTop);
518 REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom);
519 REPORTER_ASSERT(reporter, 10 == clipBounds.fRight);
520 }
521 {
522 SkPicture picture;
523 SkCanvas* canvas = picture.beginRecording(10, 10,
524 SkPicture::kUsePathBoundsForClip_RecordingFlag);
525 canvas->clipPath(path, SkRegion::kReverseDifference_Op);
526 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
527 // True clip is actually empty in this case, but the best
528 // determination we can make using only bounds as input is that the
529 // clip is included in the bounds of 'path'.
530 REPORTER_ASSERT(reporter, true == nonEmpty);
531 REPORTER_ASSERT(reporter, 7 == clipBounds.fLeft);
532 REPORTER_ASSERT(reporter, 7 == clipBounds.fTop);
533 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
534 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
535 }
536 {
537 SkPicture picture;
538 SkCanvas* canvas = picture.beginRecording(10, 10,
539 SkPicture::kUsePathBoundsForClip_RecordingFlag);
540 canvas->clipPath(path, SkRegion::kIntersect_Op);
541 canvas->clipPath(path2, SkRegion::kXOR_Op);
542 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
543 REPORTER_ASSERT(reporter, true == nonEmpty);
544 REPORTER_ASSERT(reporter, 6 == clipBounds.fLeft);
545 REPORTER_ASSERT(reporter, 6 == clipBounds.fTop);
546 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
547 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
548 }
549 }
550
452 static void TestPicture(skiatest::Reporter* reporter) { 551 static void TestPicture(skiatest::Reporter* reporter) {
453 #ifdef SK_DEBUG 552 #ifdef SK_DEBUG
454 test_deleting_empty_playback(); 553 test_deleting_empty_playback();
455 test_serializing_empty_picture(); 554 test_serializing_empty_picture();
456 #else 555 #else
457 test_bad_bitmap(); 556 test_bad_bitmap();
458 #endif 557 #endif
459 test_peephole(); 558 test_peephole();
460 test_gatherpixelrefs(reporter); 559 test_gatherpixelrefs(reporter);
461 test_bitmap_with_encoded_data(reporter); 560 test_bitmap_with_encoded_data(reporter);
462 test_clone_empty(reporter); 561 test_clone_empty(reporter);
562 test_clip_bound_opt(reporter);
463 } 563 }
464 564
465 #include "TestClassDef.h" 565 #include "TestClassDef.h"
466 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) 566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture)
OLDNEW
« src/core/SkPictureRecord.cpp ('K') | « src/core/SkPictureRecord.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698