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

Side by Side Diff: tests/RecorderTest.cpp

Issue 449933002: change drawPicture in SkRecord to just ref the picture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« src/core/SkRecords.h ('K') | « src/core/SkRecords.h ('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 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 9
10 #include "SkPictureRecorder.h"
10 #include "SkRecord.h" 11 #include "SkRecord.h"
11 #include "SkRecorder.h" 12 #include "SkRecorder.h"
12 #include "SkRecords.h" 13 #include "SkRecords.h"
13 #include "SkShader.h" 14 #include "SkShader.h"
14 15
15 #define COUNT(T) + 1 16 #define COUNT(T) + 1
16 static const int kRecordTypes = SK_RECORD_TYPES(COUNT); 17 static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
17 #undef COUNT 18 #undef COUNT
18 19
19 // Tallies the types of commands it sees into a histogram. 20 // Tallies the types of commands it sees into a histogram.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 61
61 REPORTER_ASSERT(r, paint.getShader()->unique()); 62 REPORTER_ASSERT(r, paint.getShader()->unique());
62 { 63 {
63 SkRecord record; 64 SkRecord record;
64 SkRecorder recorder(&record, 1920, 1080); 65 SkRecorder recorder(&record, 1920, 1080);
65 recorder.saveLayer(&bounds, &paint); 66 recorder.saveLayer(&bounds, &paint);
66 REPORTER_ASSERT(r, !paint.getShader()->unique()); 67 REPORTER_ASSERT(r, !paint.getShader()->unique());
67 } 68 }
68 REPORTER_ASSERT(r, paint.getShader()->unique()); 69 REPORTER_ASSERT(r, paint.getShader()->unique());
69 } 70 }
71
72 DEF_TEST(Recorder_RefPictures, r) {
73 SkAutoTUnref<SkPicture> pic;
74
75 {
76 SkPictureRecorder pr;
77 SkCanvas* canvas = pr.beginRecording(100, 100);
78 canvas->drawColor(SK_ColorRED);
79 pic.reset(pr.endRecording());
80 }
81 REPORTER_ASSERT(r, pic->unique());
82
83 {
84 SkRecord record;
85 SkRecorder recorder(&record, 100, 100);
86 recorder.drawPicture(pic);
87 // the recorder should now also be an owner
88 REPORTER_ASSERT(r, !pic->unique());
89 }
90 // the recorder destructor should have released us (back to unique)
91 REPORTER_ASSERT(r, pic->unique());
92 }
OLDNEW
« src/core/SkRecords.h ('K') | « src/core/SkRecords.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698