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

Side by Side Diff: tests/CanvasTest.cpp

Issue 214953003: split SkPictureRecorder out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: update to ToT (again) Created 6 years, 8 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
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 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 paint.setShader(shader)->unref(); 488 paint.setShader(shader)->unref();
489 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts, 489 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts,
490 NULL, NULL, NULL, 0, paint); 490 NULL, NULL, NULL, 0, paint);
491 } 491 }
492 // NYI: issue 240. 492 // NYI: issue 240.
493 TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep); 493 TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep);
494 494
495 static void DrawPictureTestStep(SkCanvas* canvas, 495 static void DrawPictureTestStep(SkCanvas* canvas,
496 skiatest::Reporter*, 496 skiatest::Reporter*,
497 CanvasTestStep*) { 497 CanvasTestStep*) {
498 SkPicture* testPicture = SkNEW_ARGS(SkPicture, ()); 498 SkPictureRecorder recorder;
499 SkAutoUnref aup(testPicture); 499 SkCanvas* testCanvas = recorder.beginRecording(kWidth, kHeight);
500 SkCanvas* testCanvas = testPicture->beginRecording(kWidth, kHeight);
501 testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1)); 500 testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
502 testCanvas->clipRect(kTestRect); 501 testCanvas->clipRect(kTestRect);
503 testCanvas->drawRect(kTestRect, kTestPaint); 502 testCanvas->drawRect(kTestRect, kTestPaint);
503 SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
504
504 canvas->drawPicture(*testPicture); 505 canvas->drawPicture(*testPicture);
505 } 506 }
506 TEST_STEP(DrawPicture, DrawPictureTestStep); 507 TEST_STEP(DrawPicture, DrawPictureTestStep);
507 508
508 static void SaveRestoreTestStep(SkCanvas* canvas, 509 static void SaveRestoreTestStep(SkCanvas* canvas,
509 skiatest::Reporter* reporter, 510 skiatest::Reporter* reporter,
510 CanvasTestStep* testStep) { 511 CanvasTestStep* testStep) {
511 int baseSaveCount = canvas->getSaveCount(); 512 int baseSaveCount = canvas->getSaveCount();
512 int n = canvas->save(); 513 int n = canvas->save();
513 REPORTER_ASSERT_MESSAGE(reporter, baseSaveCount == n, testStep->assertMessag e()); 514 REPORTER_ASSERT_MESSAGE(reporter, baseSaveCount == n, testStep->assertMessag e());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 716 }
716 717
717 public: 718 public:
718 719
719 static void TestPictureFlattenedObjectReuse(skiatest::Reporter* reporter, 720 static void TestPictureFlattenedObjectReuse(skiatest::Reporter* reporter,
720 CanvasTestStep* testStep, 721 CanvasTestStep* testStep,
721 uint32_t recordFlags) { 722 uint32_t recordFlags) {
722 // Verify that when a test step is executed twice, no extra resources 723 // Verify that when a test step is executed twice, no extra resources
723 // are flattened during the second execution 724 // are flattened during the second execution
724 testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat); 725 testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat);
725 SkPicture referencePicture; 726 SkPictureRecorder referenceRecorder;
726 SkCanvas* referenceCanvas = referencePicture.beginRecording(kWidth, 727 SkCanvas* referenceCanvas = referenceRecorder.beginRecording(kWidth,
727 kHeight, recordFlags); 728 kHeight, re cordFlags);
728 testStep->draw(referenceCanvas, reporter); 729 testStep->draw(referenceCanvas, reporter);
729 SkPicture testPicture; 730
730 SkCanvas* testCanvas = testPicture.beginRecording(kWidth, 731 SkPictureRecorder testRecorder;
731 kHeight, recordFlags); 732 SkCanvas* testCanvas = testRecorder.beginRecording(kWidth,
733 kHeight, recordFlags) ;
732 testStep->draw(testCanvas, reporter); 734 testStep->draw(testCanvas, reporter);
733 testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat); 735 testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat);
734 testStep->draw(testCanvas, reporter); 736 testStep->draw(testCanvas, reporter);
735 737
736 SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>( 738 SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(referen ceCanvas);
737 referenceCanvas); 739 SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(testCanvas);
738 SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(
739 testCanvas);
740 testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat); 740 testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat);
741 AssertFlattenedObjectsEqual(referenceRecord, testRecord, 741 AssertFlattenedObjectsEqual(referenceRecord, testRecord,
742 reporter, testStep); 742 reporter, testStep);
743 } 743 }
744 }; 744 };
745 745
746 static void TestPdfDevice(skiatest::Reporter* reporter, 746 static void TestPdfDevice(skiatest::Reporter* reporter,
747 CanvasTestStep* testStep) { 747 CanvasTestStep* testStep) {
748 SkISize pageSize = SkISize::Make(kWidth, kHeight); 748 SkISize pageSize = SkISize::Make(kWidth, kHeight);
749 SkPDFDevice device(pageSize, pageSize, SkMatrix::I()); 749 SkPDFDevice device(pageSize, pageSize, SkMatrix::I());
750 SkCanvas canvas(&device); 750 SkCanvas canvas(&device);
751 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); 751 testStep->setAssertMessageFormat(kPdfAssertMessageFormat);
752 testStep->draw(&canvas, reporter); 752 testStep->draw(&canvas, reporter);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 if (testStepArray()[testStep]->enablePdfTesting()) { 951 if (testStepArray()[testStep]->enablePdfTesting()) {
952 TestPdfDevice(reporter, testStepArray()[testStep]); 952 TestPdfDevice(reporter, testStepArray()[testStep]);
953 } 953 }
954 } 954 }
955 955
956 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global) 956 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global)
957 kTestBitmap.reset(); 957 kTestBitmap.reset();
958 958
959 test_newraster(reporter); 959 test_newraster(reporter);
960 } 960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698