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

Side by Side Diff: tests/RecordingXfermodeTest.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder 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/RecordReplaceDrawTest.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 "../include/core/SkCanvas.h" 10 #include "../include/core/SkCanvas.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 virtual const SkBitmap& recordAndReplay(const Drawer& drawer, 107 virtual const SkBitmap& recordAndReplay(const Drawer& drawer,
108 const SkRect& intoClip, 108 const SkRect& intoClip,
109 SkXfermode::Mode mode) { 109 SkXfermode::Mode mode) {
110 SkRTreeFactory factory; 110 SkRTreeFactory factory;
111 SkPictureRecorder recorder; 111 SkPictureRecorder recorder;
112 SkRect canvasRect(SkRect::MakeWH(SkIntToScalar(fWidth),SkIntToScalar(fHe ight))); 112 SkRect canvasRect(SkRect::MakeWH(SkIntToScalar(fWidth),SkIntToScalar(fHe ight)));
113 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(fWidth), 113 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(fWidth),
114 SkIntToScalar(fHeight), 114 SkIntToScalar(fHeight),
115 &factory); 115 &factory);
116 drawer.draw(canvas, canvasRect, mode); 116 drawer.draw(canvas, canvasRect, mode);
117 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 117 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
118 118
119 SkCanvas replayCanvas(fBitmap); 119 SkCanvas replayCanvas(fBitmap);
120 replayCanvas.clear(0xffffffff); 120 replayCanvas.clear(0xffffffff);
121 replayCanvas.clipRect(intoClip); 121 replayCanvas.clipRect(intoClip);
122 picture->playback(&replayCanvas); 122 picture->playback(&replayCanvas);
123 return fBitmap; 123 return fBitmap;
124 } 124 }
125 125
126 private: 126 private:
127 SkBitmap fBitmap; 127 SkBitmap fBitmap;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 errors.appendf("For SkXfermode %d %s: SkPictureRecorder bitmap is wrong\n", 164 errors.appendf("For SkXfermode %d %s: SkPictureRecorder bitmap is wrong\n",
165 iMode, SkXfermode::ModeName(mode)); 165 iMode, SkXfermode::ModeName(mode));
166 } 166 }
167 #endif 167 #endif
168 } 168 }
169 169
170 #if !FINEGRAIN 170 #if !FINEGRAIN
171 REPORTER_ASSERT_MESSAGE(reporter, 0 == numErrors, errors.c_str()); 171 REPORTER_ASSERT_MESSAGE(reporter, 0 == numErrors, errors.c_str());
172 #endif 172 #endif
173 } 173 }
OLDNEW
« no previous file with comments | « tests/RecordReplaceDrawTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698