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

Side by Side Diff: gm/pictureimagegenerator.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 | « gm/pictureimagefilter.cpp ('k') | gm/pictureshader.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 2015 Google Inc. 2 * Copyright 2015 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 "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 SkISize onISize() override { 102 SkISize onISize() override {
103 return SkISize::Make(1160, 860); 103 return SkISize::Make(1160, 860);
104 } 104 }
105 105
106 void onOnceBeforeDraw() override { 106 void onOnceBeforeDraw() override {
107 const SkRect rect = SkRect::MakeWH(kPictureWidth, kPictureHeight); 107 const SkRect rect = SkRect::MakeWH(kPictureWidth, kPictureHeight);
108 SkPictureRecorder recorder; 108 SkPictureRecorder recorder;
109 SkCanvas* canvas = recorder.beginRecording(rect); 109 SkCanvas* canvas = recorder.beginRecording(rect);
110 draw_vector_logo(canvas, rect); 110 draw_vector_logo(canvas, rect);
111 fPicture.reset(recorder.endRecording()); 111 fPicture = recorder.finishRecordingAsPicture();
112 } 112 }
113 113
114 void onDraw(SkCanvas* canvas) override { 114 void onDraw(SkCanvas* canvas) override {
115 const struct { 115 const struct {
116 SkISize size; 116 SkISize size;
117 SkScalar scaleX, scaleY; 117 SkScalar scaleX, scaleY;
118 SkScalar opacity; 118 SkScalar opacity;
119 } configs[] = { 119 } configs[] = {
120 { SkISize::Make(200, 100), 1, 1, 1 }, 120 { SkISize::Make(200, 100), 1, 1, 1 },
121 { SkISize::Make(200, 200), 1, 1, 1 }, 121 { SkISize::Make(200, 200), 1, 1, 1 },
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 p.setColor(0xfff0f0f0); 164 p.setColor(0xfff0f0f0);
165 p.setAlpha(255); 165 p.setAlpha(255);
166 canvas->drawRect(SkRect::MakeXYWH(x, y, 166 canvas->drawRect(SkRect::MakeXYWH(x, y,
167 SkIntToScalar(bm.width()), 167 SkIntToScalar(bm.width()),
168 SkIntToScalar(bm.height())), p); 168 SkIntToScalar(bm.height())), p);
169 canvas->drawBitmap(bm, x, y); 169 canvas->drawBitmap(bm, x, y);
170 } 170 }
171 } 171 }
172 172
173 private: 173 private:
174 SkAutoTUnref<SkPicture> fPicture; 174 sk_sp<SkPicture> fPicture;
175 175
176 const SkScalar kPictureWidth = 200; 176 const SkScalar kPictureWidth = 200;
177 const SkScalar kPictureHeight = 100; 177 const SkScalar kPictureHeight = 100;
178 178
179 typedef skiagm::GM INHERITED; 179 typedef skiagm::GM INHERITED;
180 }; 180 };
181 181
182 DEF_GM(return new PictureGeneratorGM;) 182 DEF_GM(return new PictureGeneratorGM;)
OLDNEW
« no previous file with comments | « gm/pictureimagefilter.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698