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

Side by Side Diff: gm/multipicturedraw.cpp

Issue 1950523002: Remove GrLayerHoister (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Forgot to remove some files Created 4 years, 5 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 | « bench/nanobench.cpp ('k') | gyp/core.gypi » ('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 "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 SkPaint stroke; 53 SkPaint stroke;
54 stroke.setStyle(SkPaint::kStroke_Style); 54 stroke.setStyle(SkPaint::kStroke_Style);
55 stroke.setStrokeWidth(3); 55 stroke.setStrokeWidth(3);
56 56
57 SkPictureRecorder recorder; 57 SkPictureRecorder recorder;
58 SkRTreeFactory bbhFactory; 58 SkRTreeFactory bbhFactory;
59 59
60 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth), 60 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
61 SkIntToScalar(kPicHeight), 61 SkIntToScalar(kPicHeight),
62 &bbhFactory, 62 &bbhFactory);
63 SkPictureRecorder::kComputeSaveLa yerInfo_RecordFlag);
64 63
65 SkScalar xPos, yPos = 0; 64 SkScalar xPos, yPos = 0;
66 65
67 for (int y = 0; y < kNumHexY; ++y) { 66 for (int y = 0; y < kNumHexY; ++y) {
68 xPos = 0; 67 xPos = 0;
69 68
70 for (int x = 0; x < kNumHexX; ++x) { 69 for (int x = 0; x < kNumHexX; ++x) {
71 canvas->saveLayer(nullptr, nullptr); 70 canvas->saveLayer(nullptr, nullptr);
72 canvas->translate(xPos, yPos + ((x % 2) ? kRoot3Over2 * kHexSide : 0 )); 71 canvas->translate(xPos, yPos + ((x % 2) ? kRoot3Over2 * kHexSide : 0 ));
73 canvas->drawPath(hex, fill); 72 canvas->drawPath(hex, fill);
(...skipping 27 matching lines...) Expand all
101 greyFill.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); 100 greyFill.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY));
102 101
103 SkPaint stroke; 102 SkPaint stroke;
104 stroke.setStyle(SkPaint::kStroke_Style); 103 stroke.setStyle(SkPaint::kStroke_Style);
105 stroke.setStrokeWidth(3); 104 stroke.setStrokeWidth(3);
106 105
107 SkPictureRecorder recorder; 106 SkPictureRecorder recorder;
108 SkRTreeFactory bbhFactory; 107 SkRTreeFactory bbhFactory;
109 108
110 static const SkScalar kBig = 10000.0f; 109 static const SkScalar kBig = 10000.0f;
111 SkCanvas* canvas = recorder.beginRecording(kBig, kBig, &bbhFactory, 110 SkCanvas* canvas = recorder.beginRecording(kBig, kBig, &bbhFactory);
112 SkPictureRecorder::kComputeSaveLa yerInfo_RecordFlag);
113 111
114 canvas->saveLayer(nullptr, nullptr); 112 canvas->saveLayer(nullptr, nullptr);
115 113
116 SkScalar xPos = 0.0f, yPos = 0.0f; 114 SkScalar xPos = 0.0f, yPos = 0.0f;
117 115
118 for (int y = 0; yPos < kBig; ++y) { 116 for (int y = 0; yPos < kBig; ++y) {
119 xPos = 0; 117 xPos = 0;
120 118
121 for (int x = 0; xPos < kBig; ++x) { 119 for (int x = 0; xPos < kBig; ++x) {
122 canvas->save(); 120 canvas->save();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 156
159 SkPaint stroke; 157 SkPaint stroke;
160 stroke.setStyle(SkPaint::kStroke_Style); 158 stroke.setStyle(SkPaint::kStroke_Style);
161 stroke.setStrokeWidth(3); 159 stroke.setStrokeWidth(3);
162 160
163 SkPictureRecorder recorder; 161 SkPictureRecorder recorder;
164 SkRTreeFactory bbhFactory; 162 SkRTreeFactory bbhFactory;
165 163
166 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth), 164 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
167 SkIntToScalar(kPicHeight), 165 SkIntToScalar(kPicHeight),
168 &bbhFactory, 166 &bbhFactory);
169 SkPictureRecorder::kComputeSaveLa yerInfo_RecordFlag);
170 SkRect r = tri.getBounds(); 167 SkRect r = tri.getBounds();
171 r.outset(2.0f, 2.0f); // outset for stroke 168 r.outset(2.0f, 2.0f); // outset for stroke
172 canvas->clipRect(r); 169 canvas->clipRect(r);
173 // The saveLayer/restore block is to exercise layer hoisting 170 // The saveLayer/restore block is to exercise layer hoisting
174 canvas->saveLayer(nullptr, nullptr); 171 canvas->saveLayer(nullptr, nullptr);
175 canvas->drawPath(tri, fill); 172 canvas->drawPath(tri, fill);
176 canvas->drawPath(tri, stroke); 173 canvas->drawPath(tri, stroke);
177 canvas->restore(); 174 canvas->restore();
178 175
179 return recorder.finishRecordingAsPicture(); 176 return recorder.finishRecordingAsPicture();
180 } 177 }
181 178
182 static sk_sp<SkPicture> make_sub_picture(const SkPicture* tri) { 179 static sk_sp<SkPicture> make_sub_picture(const SkPicture* tri) {
183 SkPictureRecorder recorder; 180 SkPictureRecorder recorder;
184 SkRTreeFactory bbhFactory; 181 SkRTreeFactory bbhFactory;
185 182
186 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth), 183 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
187 SkIntToScalar(kPicHeight), 184 SkIntToScalar(kPicHeight),
188 &bbhFactory, 185 &bbhFactory);
189 SkPictureRecorder::kComputeSaveLa yerInfo_RecordFlag);
190 186
191 canvas->scale(1.0f/2.0f, 1.0f/2.0f); 187 canvas->scale(1.0f/2.0f, 1.0f/2.0f);
192 188
193 canvas->save(); 189 canvas->save();
194 canvas->translate(SkScalarHalf(kTriSide), 0); 190 canvas->translate(SkScalarHalf(kTriSide), 0);
195 canvas->drawPicture(tri); 191 canvas->drawPicture(tri);
196 canvas->restore(); 192 canvas->restore();
197 193
198 canvas->save(); 194 canvas->save();
199 canvas->translate(SkIntToScalar(kTriSide), 1.5f * kTriSide / kRoot3); 195 canvas->translate(SkIntToScalar(kTriSide), 1.5f * kTriSide / kRoot3);
(...skipping 13 matching lines...) Expand all
213 // shrinks it and replicates it 3 times then draws and appropriate number of 209 // shrinks it and replicates it 3 times then draws and appropriate number of
214 // copies of it. 210 // copies of it.
215 static sk_sp<SkPicture> make_sierpinski_picture() { 211 static sk_sp<SkPicture> make_sierpinski_picture() {
216 sk_sp<SkPicture> pic(make_tri_picture()); 212 sk_sp<SkPicture> pic(make_tri_picture());
217 213
218 SkPictureRecorder recorder; 214 SkPictureRecorder recorder;
219 SkRTreeFactory bbhFactory; 215 SkRTreeFactory bbhFactory;
220 216
221 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth), 217 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth),
222 SkIntToScalar(kPicHeight), 218 SkIntToScalar(kPicHeight),
223 &bbhFactory, 219 &bbhFactory);
224 SkPictureRecorder::kComputeSaveLa yerInfo_RecordFlag);
225 220
226 static const int kNumLevels = 4; 221 static const int kNumLevels = 4;
227 for (int i = 0; i < kNumLevels; ++i) { 222 for (int i = 0; i < kNumLevels; ++i) {
228 canvas->save(); 223 canvas->save();
229 canvas->translate(kPicWidth/2 - (i+1) * (kTriSide/2.0f), 0.0f); 224 canvas->translate(kPicWidth/2 - (i+1) * (kTriSide/2.0f), 0.0f);
230 for (int j = 0; j < i+1; ++j) { 225 for (int j = 0; j < i+1; ++j) {
231 canvas->drawPicture(pic); 226 canvas->drawPicture(pic);
232 canvas->translate(SkIntToScalar(kTriSide), 0); 227 canvas->translate(SkIntToScalar(kTriSide), 0);
233 } 228 }
234 canvas->restore(); 229 canvas->restore();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const SkPicture* pictures[kNumPictures], 350 const SkPicture* pictures[kNumPictures],
356 SkCanvas* dest, const SkMatrix& xform) { 351 SkCanvas* dest, const SkMatrix& xform) {
357 sk_sp<SkPicture> composite; 352 sk_sp<SkPicture> composite;
358 353
359 { 354 {
360 SkPictureRecorder recorder; 355 SkPictureRecorder recorder;
361 SkRTreeFactory bbhFactory; 356 SkRTreeFactory bbhFactory;
362 357
363 SkCanvas* pictureCanvas = recorder.beginRecording(SkIntToScalar(kPicWidt h), 358 SkCanvas* pictureCanvas = recorder.beginRecording(SkIntToScalar(kPicWidt h),
364 SkIntToScalar(kPicHeig ht), 359 SkIntToScalar(kPicHeig ht),
365 &bbhFactory, 360 &bbhFactory);
366 SkPictureRecorder::kCo mputeSaveLayerInfo_RecordFlag);
367 361
368 (*pfGen)(pictureCanvas, pictures); 362 (*pfGen)(pictureCanvas, pictures);
369 363
370 composite = recorder.finishRecordingAsPicture(); 364 composite = recorder.finishRecordingAsPicture();
371 } 365 }
372 366
373 mpd->add(dest, composite.get(), &xform); 367 mpd->add(dest, composite.get(), &xform);
374 } 368 }
375 369
376 typedef void(*PFLayoutMtd)(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd, 370 typedef void(*PFLayoutMtd)(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 MultiPictureDraw::kTiled_Layout);) 557 MultiPictureDraw::kTiled_Layout);)
564 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content, 558 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content,
565 MultiPictureDraw::kTiled_Layout);) 559 MultiPictureDraw::kTiled_Layout);)
566 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Conte nt, 560 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Conte nt,
567 MultiPictureDraw::kTiled_Layout);) 561 MultiPictureDraw::kTiled_Layout);)
568 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content, 562 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content,
569 MultiPictureDraw::kTiled_Layout);) 563 MultiPictureDraw::kTiled_Layout);)
570 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content, 564 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content,
571 MultiPictureDraw::kTiled_Layout);) 565 MultiPictureDraw::kTiled_Layout);)
572 } 566 }
OLDNEW
« no previous file with comments | « bench/nanobench.cpp ('k') | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698