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

Side by Side Diff: samplecode/SampleTiling.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 | « samplecode/SamplePictFile.cpp ('k') | src/c/sk_surface.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 static const SkColorType gColorTypes[] = { 49 static const SkColorType gColorTypes[] = {
50 kN32_SkColorType, 50 kN32_SkColorType,
51 kRGB_565_SkColorType, 51 kRGB_565_SkColorType,
52 }; 52 };
53 static const int gWidth = 32; 53 static const int gWidth = 32;
54 static const int gHeight = 32; 54 static const int gHeight = 32;
55 55
56 class TilingView : public SampleView { 56 class TilingView : public SampleView {
57 SkAutoTUnref<SkPicture> fTextPicture; 57 sk_sp<SkPicture> fTextPicture;
58 SkAutoTUnref<SkDrawLooper> fLooper; 58 SkAutoTUnref<SkDrawLooper> fLooper;
59 public: 59 public:
60 TilingView() 60 TilingView()
61 : fLooper(SkBlurDrawLooper::Create(0x88000000, 61 : fLooper(SkBlurDrawLooper::Create(0x88000000,
62 SkBlurMask::ConvertRadiusToSigma( SkIntToScalar(1)), 62 SkBlurMask::ConvertRadiusToSigma( SkIntToScalar(1)),
63 SkIntToScalar(2), SkIntToScalar(2 ))) { 63 SkIntToScalar(2), SkIntToScalar(2 ))) {
64 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { 64 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
65 makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight); 65 makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight);
66 } 66 }
67 } 67 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); 146 str.printf("%s, %s", gConfigNames[i], gFilterNames[j]);
147 textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh t() * 2 / 3, p); 147 textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh t() * 2 / 3, p);
148 } 148 }
149 149
150 y += r.height() * 4 / 3; 150 y += r.height() * 4 / 3;
151 } 151 }
152 } 152 }
153 153
154 if (textCanvas) { 154 if (textCanvas) {
155 SkASSERT(nullptr == fTextPicture); 155 SkASSERT(nullptr == fTextPicture);
156 fTextPicture.reset(recorder.endRecording()); 156 fTextPicture = recorder.finishRecordingAsPicture();
157 } 157 }
158 158
159 SkASSERT(fTextPicture); 159 SkASSERT(fTextPicture);
160 canvas->drawPicture(fTextPicture); 160 canvas->drawPicture(fTextPicture.get());
161 } 161 }
162 162
163 private: 163 private:
164 typedef SampleView INHERITED; 164 typedef SampleView INHERITED;
165 }; 165 };
166 166
167 ////////////////////////////////////////////////////////////////////////////// 167 //////////////////////////////////////////////////////////////////////////////
168 168
169 static SkView* MyFactory() { return new TilingView; } 169 static SkView* MyFactory() { return new TilingView; }
170 static SkViewRegister reg(MyFactory); 170 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SamplePictFile.cpp ('k') | src/c/sk_surface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698