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

Side by Side Diff: tests/RecorderTest.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage Created 4 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
« no previous file with comments | « tests/RecordDrawTest.cpp ('k') | tests/SerializationTest.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 9
10 #include "SkPictureRecorder.h" 10 #include "SkPictureRecorder.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SkRecord record; 65 SkRecord record;
66 SkRecorder recorder(&record, 1920, 1080); 66 SkRecorder recorder(&record, 1920, 1080);
67 recorder.saveLayer(&bounds, &paint); 67 recorder.saveLayer(&bounds, &paint);
68 REPORTER_ASSERT(r, !paint.getShader()->unique()); 68 REPORTER_ASSERT(r, !paint.getShader()->unique());
69 } 69 }
70 REPORTER_ASSERT(r, paint.getShader()->unique()); 70 REPORTER_ASSERT(r, paint.getShader()->unique());
71 } 71 }
72 72
73 DEF_TEST(Recorder_drawImage_takeReference, reporter) { 73 DEF_TEST(Recorder_drawImage_takeReference, reporter) {
74 74
75 SkAutoTUnref<SkImage> image; 75 sk_sp<SkImage> image;
76 { 76 {
77 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100)) ; 77 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100)) ;
78 surface->getCanvas()->clear(SK_ColorGREEN); 78 surface->getCanvas()->clear(SK_ColorGREEN);
79 image.reset(surface->newImageSnapshot()); 79 image = surface->makeImageSnapshot();
80 } 80 }
81 { 81 {
82 SkRecord record; 82 SkRecord record;
83 SkRecorder recorder(&record, 100, 100); 83 SkRecorder recorder(&record, 100, 100);
84 84
85 // DrawImage is supposed to take a reference 85 // DrawImage is supposed to take a reference
86 recorder.drawImage(image.get(), 0, 0); 86 recorder.drawImage(image, 0, 0);
87 REPORTER_ASSERT(reporter, !image->unique()); 87 REPORTER_ASSERT(reporter, !image->unique());
88 88
89 Tally tally; 89 Tally tally;
90 tally.apply(record); 90 tally.apply(record);
91 91
92 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage>()); 92 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage>());
93 } 93 }
94 REPORTER_ASSERT(reporter, image->unique()); 94 REPORTER_ASSERT(reporter, image->unique());
95 95
96 { 96 {
97 SkRecord record; 97 SkRecord record;
98 SkRecorder recorder(&record, 100, 100); 98 SkRecorder recorder(&record, 100, 100);
99 99
100 // DrawImageRect is supposed to take a reference 100 // DrawImageRect is supposed to take a reference
101 recorder.drawImageRect(image.get(), SkRect::MakeWH(100, 100), nullptr); 101 recorder.drawImageRect(image, SkRect::MakeWH(100, 100), nullptr);
102 REPORTER_ASSERT(reporter, !image->unique()); 102 REPORTER_ASSERT(reporter, !image->unique());
103 103
104 Tally tally; 104 Tally tally;
105 tally.apply(record); 105 tally.apply(record);
106 106
107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); 107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>());
108 } 108 }
109 REPORTER_ASSERT(reporter, image->unique()); 109 REPORTER_ASSERT(reporter, image->unique());
110 } 110 }
OLDNEW
« no previous file with comments | « tests/RecordDrawTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698