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

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

Issue 617393004: BBHs: void* data -> unsigned data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: The rest Created 6 years, 2 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 | « src/core/SkTileGrid.cpp ('k') | tests/BBoxHierarchyTest.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"
11 #include "SkRecordDraw.h" 11 #include "SkRecordDraw.h"
12 #include "SkRecords.h" 12 #include "SkRecords.h"
13 13
14 GrReplacements::ReplacementInfo* GrReplacements::newReplacement(uint32_t picture ID, 14 GrReplacements::ReplacementInfo* GrReplacements::newReplacement(uint32_t picture ID,
15 unsigned int sta rt, 15 unsigned int sta rt,
16 const SkMatrix& ctm) { 16 const SkMatrix& ctm) {
17 ReplacementInfo* replacement = SkNEW_ARGS(ReplacementInfo, (pictureID, start , ctm)); 17 ReplacementInfo* replacement = SkNEW_ARGS(ReplacementInfo, (pictureID, start , ctm));
18 fReplacementHash.add(replacement); 18 fReplacementHash.add(replacement);
19 return replacement; 19 return replacement;
20 } 20 }
21 21
22 void GrReplacements::freeAll() { 22 void GrReplacements::freeAll() {
23 SkTDynamicHash<ReplacementInfo, ReplacementInfo::Key>::Iter iter(&fReplaceme ntHash); 23 SkTDynamicHash<ReplacementInfo, ReplacementInfo::Key>::Iter iter(&fReplaceme ntHash);
24 24
25 for (; !iter.done(); ++iter) { 25 for (; !iter.done(); ++iter) {
26 ReplacementInfo* replacement = &(*iter); 26 ReplacementInfo* replacement = &(*iter);
27 SkDELETE(replacement); 27 SkDELETE(replacement);
28 } 28 }
29 29
30 fReplacementHash.reset(); 30 fReplacementHash.reset();
31 } 31 }
32 32
33 const GrReplacements::ReplacementInfo* GrReplacements::lookupByStart(uint32_t pi ctureID, 33 const GrReplacements::ReplacementInfo* GrReplacements::lookupByStart(uint32_t pi ctureID,
34 size_t star t, 34 size_t star t,
35 const SkMat rix& ctm) const { 35 const SkMat rix& ctm) const {
36 return fReplacementHash.find(ReplacementInfo::Key(pictureID, start, ctm)); 36 return fReplacementHash.find(ReplacementInfo::Key(pictureID, start, ctm));
37 } 37 }
38 38
39 static inline void draw_replacement_bitmap(const GrReplacements::ReplacementInfo * ri, 39 static inline void draw_replacement_bitmap(const GrReplacements::ReplacementInfo * ri,
40 SkCanvas* canvas, 40 SkCanvas* canvas,
41 const SkMatrix& initialMatrix) { 41 const SkMatrix& initialMatrix) {
42 SkRect src = SkRect::Make(ri->fSrcRect); 42 SkRect src = SkRect::Make(ri->fSrcRect);
43 SkRect dst = SkRect::MakeXYWH(SkIntToScalar(ri->fPos.fX), 43 SkRect dst = SkRect::MakeXYWH(SkIntToScalar(ri->fPos.fX),
44 SkIntToScalar(ri->fPos.fY), 44 SkIntToScalar(ri->fPos.fY),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 SkRect query = { 0, 0, 0, 0 }; 87 SkRect query = { 0, 0, 0, 0 };
88 (void)fCanvas->getClipBounds(&query); 88 (void)fCanvas->getClipBounds(&query);
89 89
90 bbh->search(query, &fOps); 90 bbh->search(query, &fOps);
91 91
92 for (fIndex = 0; fIndex < fOps.count(); ++fIndex) { 92 for (fIndex = 0; fIndex < fOps.count(); ++fIndex) {
93 if (fCallback && fCallback->abortDrawing()) { 93 if (fCallback && fCallback->abortDrawing()) {
94 return; 94 return;
95 } 95 }
96 96
97 record->visit<void>((uintptr_t)fOps[fIndex], *this); 97 record->visit<void>(fOps[fIndex], *this);
98 } 98 }
99 99
100 } else { 100 } else {
101 for (fIndex = 0; fIndex < (int) record->count(); ++fIndex) { 101 for (fIndex = 0; fIndex < (int) record->count(); ++fIndex) {
102 if (fCallback && fCallback->abortDrawing()) { 102 if (fCallback && fCallback->abortDrawing()) {
103 return; 103 return;
104 } 104 }
105 105
106 record->visit<void>(fIndex, *this); 106 record->visit<void>(fIndex, *this);
107 } 107 }
108 } 108 }
109 } 109 }
110 110
111 // Same as Draw for all ops except DrawPicture and SaveLayer. 111 // Same as Draw for all ops except DrawPicture and SaveLayer.
112 template <typename T> void operator()(const T& r) { 112 template <typename T> void operator()(const T& r) {
113 this->INHERITED::operator()(r); 113 this->INHERITED::operator()(r);
114 } 114 }
115 void operator()(const SkRecords::DrawPicture& dp) { 115 void operator()(const SkRecords::DrawPicture& dp) {
116 SkAutoCanvasMatrixPaint acmp(fCanvas, dp.matrix, dp.paint, dp.picture->c ullRect()); 116 SkAutoCanvasMatrixPaint acmp(fCanvas, dp.matrix, dp.paint, dp.picture->c ullRect());
117 117
118 // Draw sub-pictures with the same replacement list but a different pict ure 118 // Draw sub-pictures with the same replacement list but a different pict ure
119 ReplaceDraw draw(fCanvas, dp.picture, fReplacements, fInitialMatrix, fCa llback); 119 ReplaceDraw draw(fCanvas, dp.picture, fReplacements, fInitialMatrix, fCa llback);
120 120
121 draw.draw(); 121 draw.draw();
122 } 122 }
123 void operator()(const SkRecords::SaveLayer& sl) { 123 void operator()(const SkRecords::SaveLayer& sl) {
124 124
125 // For a saveLayer command, check if it can be replaced by a drawBitmap 125 // For a saveLayer command, check if it can be replaced by a drawBitmap
126 // call and, if so, draw it and then update the current op index accordi ngly. 126 // call and, if so, draw it and then update the current op index accordi ngly.
127 size_t startOffset; 127 size_t startOffset;
128 if (fOps.count()) { 128 if (fOps.count()) {
129 startOffset = (uintptr_t)fOps[fIndex]; 129 startOffset = fOps[fIndex];
130 } else { 130 } else {
131 startOffset = fIndex; 131 startOffset = fIndex;
132 } 132 }
133 133
134 const GrReplacements::ReplacementInfo* ri = fReplacements->lookupByStart ( 134 const GrReplacements::ReplacementInfo* ri = fReplacements->lookupByStart (
135 fPicture->uniqueID() , 135 fPicture->uniqueID() ,
136 startOffset, 136 startOffset,
137 fCanvas->getTotalMat rix()); 137 fCanvas->getTotalMat rix());
138 138
139 if (ri) { 139 if (ri) {
140 draw_replacement_bitmap(ri, fCanvas, fInitialMatrix); 140 draw_replacement_bitmap(ri, fCanvas, fInitialMatrix);
141 141
142 if (fPicture->fBBH.get()) { 142 if (fPicture->fBBH.get()) {
143 while ((uintptr_t)fOps[fIndex] < ri->fStop) { 143 while (fOps[fIndex] < ri->fStop) {
144 ++fIndex; 144 ++fIndex;
145 } 145 }
146 SkASSERT((uintptr_t)fOps[fIndex] == ri->fStop); 146 SkASSERT(fOps[fIndex] == ri->fStop);
147 } else { 147 } else {
148 fIndex = ri->fStop; 148 fIndex = ri->fStop;
149 } 149 }
150 return; 150 return;
151 } 151 }
152 152
153 // This is a fail for layer hoisting 153 // This is a fail for layer hoisting
154 this->INHERITED::operator()(sl); 154 this->INHERITED::operator()(sl);
155 } 155 }
156 156
157 private: 157 private:
158 SkCanvas* fCanvas; 158 SkCanvas* fCanvas;
159 const SkPicture* fPicture; 159 const SkPicture* fPicture;
160 const GrReplacements* fReplacements; 160 const GrReplacements* fReplacements;
161 const SkMatrix fInitialMatrix; 161 const SkMatrix fInitialMatrix;
162 SkDrawPictureCallback* fCallback; 162 SkDrawPictureCallback* fCallback;
163 163
164 SkTDArray<void*> fOps; 164 SkTDArray<unsigned> fOps;
165 int fIndex; 165 int fIndex;
166 166
167 typedef Draw INHERITED; 167 typedef Draw INHERITED;
168 }; 168 };
169 169
170 void GrRecordReplaceDraw(const SkPicture* picture, 170 void GrRecordReplaceDraw(const SkPicture* picture,
171 SkCanvas* canvas, 171 SkCanvas* canvas,
172 const GrReplacements* replacements, 172 const GrReplacements* replacements,
173 const SkMatrix& initialMatrix, 173 const SkMatrix& initialMatrix,
174 SkDrawPictureCallback* callback) { 174 SkDrawPictureCallback* callback) {
175 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); 175 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
176 176
177 ReplaceDraw draw(canvas, picture, replacements, initialMatrix, callback); 177 ReplaceDraw draw(canvas, picture, replacements, initialMatrix, callback);
178 178
179 draw.draw(); 179 draw.draw();
180 } 180 }
OLDNEW
« no previous file with comments | « src/core/SkTileGrid.cpp ('k') | tests/BBoxHierarchyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698