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

Side by Side Diff: gm/pictureshadertile.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/pictureshader.cpp ('k') | gm/recordopts.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 "gm.h" 8 #include "gm.h"
9 9
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 SkISize onISize() override { 90 SkISize onISize() override {
91 return SkISize::Make(800, 600); 91 return SkISize::Make(800, 600);
92 } 92 }
93 93
94 void onOnceBeforeDraw() override { 94 void onOnceBeforeDraw() override {
95 SkPictureRecorder recorder; 95 SkPictureRecorder recorder;
96 SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPicture Size); 96 SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPicture Size);
97 draw_scene(pictureCanvas, kPictureSize); 97 draw_scene(pictureCanvas, kPictureSize);
98 sk_sp<SkPicture> picture(recorder.endRecording()); 98 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
99 99
100 SkPoint offset = SkPoint::Make(100, 100); 100 SkPoint offset = SkPoint::Make(100, 100);
101 pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), off set.y(), 101 pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), off set.y(),
102 kPictureSize, k PictureSize)); 102 kPictureSize, k PictureSize));
103 pictureCanvas->translate(offset.x(), offset.y()); 103 pictureCanvas->translate(offset.x(), offset.y());
104 draw_scene(pictureCanvas, kPictureSize); 104 draw_scene(pictureCanvas, kPictureSize);
105 sk_sp<SkPicture> offsetPicture(recorder.endRecording()); 105 sk_sp<SkPicture> offsetPicture(recorder.finishRecordingAsPicture());
106 106
107 for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) { 107 for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) {
108 SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize, 108 SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize,
109 tiles[i].y * kPictureSize, 109 tiles[i].y * kPictureSize,
110 tiles[i].w * kPictureSize, 110 tiles[i].w * kPictureSize,
111 tiles[i].h * kPictureSize); 111 tiles[i].h * kPictureSize);
112 SkMatrix localMatrix; 112 SkMatrix localMatrix;
113 localMatrix.setTranslate(tiles[i].offsetX * kPictureSize, 113 localMatrix.setTranslate(tiles[i].offsetX * kPictureSize,
114 tiles[i].offsetY * kPictureSize); 114 tiles[i].offsetY * kPictureSize);
115 localMatrix.postScale(kFillSize / (2 * kPictureSize), 115 localMatrix.postScale(kFillSize / (2 * kPictureSize),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 } 148 }
149 149
150 private: 150 private:
151 sk_sp<SkShader> fShaders[SK_ARRAY_COUNT(tiles)]; 151 sk_sp<SkShader> fShaders[SK_ARRAY_COUNT(tiles)];
152 152
153 typedef GM INHERITED; 153 typedef GM INHERITED;
154 }; 154 };
155 155
156 DEF_GM(return new PictureShaderTileGM;) 156 DEF_GM(return new PictureShaderTileGM;)
OLDNEW
« no previous file with comments | « gm/pictureshader.cpp ('k') | gm/recordopts.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698