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

Side by Side Diff: tests/PictureTest.cpp

Issue 12545009: Adding option in SkPicture to record device-space bounds of draw commands. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « 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"
11 #include "SkDevice.h"
11 #include "SkPaint.h" 12 #include "SkPaint.h"
12 #include "SkPicture.h" 13 #include "SkPicture.h"
13 #include "SkRandom.h" 14 #include "SkRandom.h"
14 #include "SkRRect.h" 15 #include "SkRRect.h"
15 #include "SkShader.h" 16 #include "SkShader.h"
16 #include "SkStream.h" 17 #include "SkStream.h"
17 18
18 #include "SkPictureUtils.h" 19 #include "SkPictureUtils.h"
19 20
20 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { 21 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 { 413 {
413 // Test without call to endRecording 414 // Test without call to endRecording
414 SkPicture picture; 415 SkPicture picture;
415 picture.beginRecording(1, 1); 416 picture.beginRecording(1, 1);
416 SkPicture* destPicture = picture.clone(); 417 SkPicture* destPicture = picture.clone();
417 REPORTER_ASSERT(reporter, NULL != destPicture); 418 REPORTER_ASSERT(reporter, NULL != destPicture);
418 destPicture->unref(); 419 destPicture->unref();
419 } 420 }
420 } 421 }
421 422
423 static void test_subregion_playback(skiatest::Reporter* reporter) {
reed1 2013/03/12 16:05:04 Can you simplify or document the complexity in thi
424 SkPicture picture;
425 SkCanvas* recordingCanvas = picture.beginRecording(6, 6);
426 SkPaint paint;
427 paint.setColor(SK_ColorWHITE);
428 SkRect rect = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), SK_Scalar 1, SK_Scalar1);
429 recordingCanvas->clear(SK_ColorTRANSPARENT);
430 recordingCanvas->drawRect(rect, paint);
431 picture.endRecording();
432 SkBitmap store;
433 store.setConfig(SkBitmap::kARGB_8888_Config, 3, 3);
434 store.allocPixels();
435 SkDevice device(store);
reed1 2013/03/12 16:05:04 minor, but can't you just pass store to the canvas
436 SkCanvas playbackCanvas(&device);
437 playbackCanvas.translate(SkIntToScalar(-3), SkIntToScalar(-3));
438 playbackCanvas.drawPicture(picture);
439 for (int x = 0; x < 3; x++) {
440 for (int y = 0; y < 3; y++) {
441 if (1 == x && 1 == y) {
442 REPORTER_ASSERT(reporter, SK_ColorWHITE == store.getColor(x,y));
443 } else {
444 REPORTER_ASSERT(reporter, SK_ColorTRANSPARENT == store.getColor( x,y));
445 }
446 }
447 }
448 }
449
422 static void TestPicture(skiatest::Reporter* reporter) { 450 static void TestPicture(skiatest::Reporter* reporter) {
423 #ifdef SK_DEBUG 451 #ifdef SK_DEBUG
424 test_deleting_empty_playback(); 452 test_deleting_empty_playback();
425 test_serializing_empty_picture(); 453 test_serializing_empty_picture();
426 #else 454 #else
427 test_bad_bitmap(); 455 test_bad_bitmap();
428 #endif 456 #endif
429 test_peephole(); 457 test_peephole();
430 test_gatherpixelrefs(reporter); 458 test_gatherpixelrefs(reporter);
431 test_bitmap_with_encoded_data(reporter); 459 test_bitmap_with_encoded_data(reporter);
432 test_clone_empty(reporter); 460 test_clone_empty(reporter);
461 test_subregion_playback(reporter);
433 } 462 }
434 463
435 #include "TestClassDef.h" 464 #include "TestClassDef.h"
436 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) 465 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture)
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698