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

Side by Side Diff: src/gpu/GrRecordReplaceDraw.cpp

Issue 727363003: wip for drawables (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make the pictures in the array also const (the array already was const) Created 6 years, 1 month 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 | « src/gpu/GrLayerHoister.cpp ('k') | tests/RecordDrawTest.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 "GrRecordReplaceDraw.h" 8 #include "GrRecordReplaceDraw.h"
9 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 canvas->setMatrix(initialMatrix); 49 canvas->setMatrix(initialMatrix);
50 canvas->drawImageRect(ri->fImage, &src, dst, ri->fPaint); 50 canvas->drawImageRect(ri->fImage, &src, dst, ri->fPaint);
51 canvas->restore(); 51 canvas->restore();
52 } 52 }
53 53
54 // Used by GrRecordReplaceDraw. It intercepts nested drawPicture calls and 54 // Used by GrRecordReplaceDraw. It intercepts nested drawPicture calls and
55 // also draws them with replaced layers. 55 // also draws them with replaced layers.
56 class ReplaceDraw : public SkRecords::Draw { 56 class ReplaceDraw : public SkRecords::Draw {
57 public: 57 public:
58 ReplaceDraw(SkCanvas* canvas, 58 ReplaceDraw(SkCanvas* canvas,
59 SkPicture const* const drawablePicts[], int drawableCount,
59 const SkPicture* picture, 60 const SkPicture* picture,
60 const GrReplacements* replacements, 61 const GrReplacements* replacements,
61 const SkMatrix& initialMatrix, 62 const SkMatrix& initialMatrix,
62 SkDrawPictureCallback* callback) 63 SkDrawPictureCallback* callback)
63 : INHERITED(canvas) 64 : INHERITED(canvas, drawablePicts, drawableCount)
64 , fCanvas(canvas) 65 , fCanvas(canvas)
65 , fPicture(picture) 66 , fPicture(picture)
66 , fReplacements(replacements) 67 , fReplacements(replacements)
67 , fInitialMatrix(initialMatrix) 68 , fInitialMatrix(initialMatrix)
68 , fCallback(callback) 69 , fCallback(callback)
69 , fIndex(0) 70 , fIndex(0)
70 , fNumReplaced(0) { 71 , fNumReplaced(0) {
71 } 72 }
72 73
73 int draw() { 74 int draw() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 115 }
115 116
116 // Same as Draw for all ops except DrawPicture and SaveLayer. 117 // Same as Draw for all ops except DrawPicture and SaveLayer.
117 template <typename T> void operator()(const T& r) { 118 template <typename T> void operator()(const T& r) {
118 this->INHERITED::operator()(r); 119 this->INHERITED::operator()(r);
119 } 120 }
120 void operator()(const SkRecords::DrawPicture& dp) { 121 void operator()(const SkRecords::DrawPicture& dp) {
121 SkAutoCanvasMatrixPaint acmp(fCanvas, dp.matrix, dp.paint, dp.picture->c ullRect()); 122 SkAutoCanvasMatrixPaint acmp(fCanvas, dp.matrix, dp.paint, dp.picture->c ullRect());
122 123
123 // Draw sub-pictures with the same replacement list but a different pict ure 124 // Draw sub-pictures with the same replacement list but a different pict ure
124 ReplaceDraw draw(fCanvas, dp.picture, fReplacements, fInitialMatrix, fCa llback); 125 ReplaceDraw draw(fCanvas, this->drawablePicts(), this->drawableCount(),
126 dp.picture, fReplacements, fInitialMatrix, fCallback);
125 127
126 fNumReplaced += draw.draw(); 128 fNumReplaced += draw.draw();
127 } 129 }
128 void operator()(const SkRecords::SaveLayer& sl) { 130 void operator()(const SkRecords::SaveLayer& sl) {
129 131
130 // For a saveLayer command, check if it can be replaced by a drawBitmap 132 // For a saveLayer command, check if it can be replaced by a drawBitmap
131 // call and, if so, draw it and then update the current op index accordi ngly. 133 // call and, if so, draw it and then update the current op index accordi ngly.
132 size_t startOffset; 134 size_t startOffset;
133 if (fOps.count()) { 135 if (fOps.count()) {
134 startOffset = fOps[fIndex]; 136 startOffset = fOps[fIndex];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 typedef Draw INHERITED; 177 typedef Draw INHERITED;
176 }; 178 };
177 179
178 int GrRecordReplaceDraw(const SkPicture* picture, 180 int GrRecordReplaceDraw(const SkPicture* picture,
179 SkCanvas* canvas, 181 SkCanvas* canvas,
180 const GrReplacements* replacements, 182 const GrReplacements* replacements,
181 const SkMatrix& initialMatrix, 183 const SkMatrix& initialMatrix,
182 SkDrawPictureCallback* callback) { 184 SkDrawPictureCallback* callback) {
183 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); 185 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
184 186
185 ReplaceDraw draw(canvas, picture, replacements, initialMatrix, callback); 187 // TODO: drawablePicts?
188 ReplaceDraw draw(canvas, NULL, 0, picture, replacements, initialMatrix, call back);
186 189
187 return draw.draw(); 190 return draw.draw();
188 } 191 }
OLDNEW
« no previous file with comments | « src/gpu/GrLayerHoister.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698