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

Side by Side Diff: tools/filtermain.cpp

Issue 17101005: Rename SkDrawCommand subclasses (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated per review. Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/utils/debugger/SkDrawCommand.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "SkDebugCanvas.h" 8 #include "SkDebugCanvas.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkForceLinking.h" 10 #include "SkForceLinking.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // RESTORE 50 // RESTORE
51 // where the saveLayer's color can be moved into the drawBitmapRect 51 // where the saveLayer's color can be moved into the drawBitmapRect
52 static bool check_0(SkDebugCanvas* canvas, int curCommand) { 52 static bool check_0(SkDebugCanvas* canvas, int curCommand) {
53 if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() || 53 if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() ||
54 canvas->getSize() <= curCommand+2 || 54 canvas->getSize() <= curCommand+2 ||
55 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+1)->getT ype() || 55 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+1)->getT ype() ||
56 RESTORE != canvas->getDrawCommandAt(curCommand+2)->getType()) { 56 RESTORE != canvas->getDrawCommandAt(curCommand+2)->getType()) {
57 return false; 57 return false;
58 } 58 }
59 59
60 SaveLayer* saveLayer = (SaveLayer*) canvas->getDrawCommandAt(curCommand); 60 SkSaveLayerCommand* saveLayer =
61 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +1); 61 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand);
62 SkDrawBitmapRectCommand* dbmr =
63 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+1);
62 64
63 const SkPaint* saveLayerPaint = saveLayer->paint(); 65 const SkPaint* saveLayerPaint = saveLayer->paint();
64 SkPaint* dbmrPaint = dbmr->paint(); 66 SkPaint* dbmrPaint = dbmr->paint();
65 67
66 // For this optimization we only fold the saveLayer and drawBitmapRect 68 // For this optimization we only fold the saveLayer and drawBitmapRect
67 // together if the saveLayer's draw is simple (i.e., no fancy effects) 69 // together if the saveLayer's draw is simple (i.e., no fancy effects)
68 // and the only difference in the colors is their alpha value 70 // and the only difference in the colors is their alpha value
69 SkColor layerColor = saveLayerPaint->getColor() | 0xFF000000; // force opaqu e 71 SkColor layerColor = saveLayerPaint->getColor() | 0xFF000000; // force opaqu e
70 SkColor dbmrColor = dbmrPaint->getColor() | 0xFF000000; // force opaqu e 72 SkColor dbmrColor = dbmrPaint->getColor() | 0xFF000000; // force opaqu e
71 73
72 // If either operation lacks a paint then the collapse is trivial 74 // If either operation lacks a paint then the collapse is trivial
73 return NULL == saveLayerPaint || 75 return NULL == saveLayerPaint ||
74 NULL == dbmrPaint || 76 NULL == dbmrPaint ||
75 (is_simple(*saveLayerPaint) && dbmrColor == layerColor); 77 (is_simple(*saveLayerPaint) && dbmrColor == layerColor);
76 } 78 }
77 79
78 // Fold the saveLayer's alpha into the drawBitmapRect and remove the saveLayer 80 // Fold the saveLayer's alpha into the drawBitmapRect and remove the saveLayer
79 // and restore 81 // and restore
80 static void apply_0(SkDebugCanvas* canvas, int curCommand) { 82 static void apply_0(SkDebugCanvas* canvas, int curCommand) {
81 SaveLayer* saveLayer = (SaveLayer*) canvas->getDrawCommandAt(curCommand); 83 SkSaveLayerCommand* saveLayer =
84 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand);
82 const SkPaint* saveLayerPaint = saveLayer->paint(); 85 const SkPaint* saveLayerPaint = saveLayer->paint();
83 86
84 // if (NULL == saveLayerPaint) the dbmr's paint doesn't need to be changed 87 // if (NULL == saveLayerPaint) the dbmr's paint doesn't need to be changed
85 if (NULL != saveLayerPaint) { 88 if (NULL != saveLayerPaint) {
86 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCom mand+1); 89 SkDrawBitmapRectCommand* dbmr =
90 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+1);
87 SkPaint* dbmrPaint = dbmr->paint(); 91 SkPaint* dbmrPaint = dbmr->paint();
88 92
89 if (NULL == dbmrPaint) { 93 if (NULL == dbmrPaint) {
90 // if the DBMR doesn't have a paint just use the saveLayer's 94 // if the DBMR doesn't have a paint just use the saveLayer's
91 dbmr->setPaint(*saveLayerPaint); 95 dbmr->setPaint(*saveLayerPaint);
92 } else if (NULL != saveLayerPaint) { 96 } else if (NULL != saveLayerPaint) {
93 // Both paints are present so their alphas need to be combined 97 // Both paints are present so their alphas need to be combined
94 SkColor color = saveLayerPaint->getColor(); 98 SkColor color = saveLayerPaint->getColor();
95 int a0 = SkColorGetA(color); 99 int a0 = SkColorGetA(color);
96 100
(...skipping 24 matching lines...) Expand all
121 if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() || 125 if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() ||
122 canvas->getSize() <= curCommand+5 || 126 canvas->getSize() <= curCommand+5 ||
123 SAVE != canvas->getDrawCommandAt(curCommand+1)->getType() || 127 SAVE != canvas->getDrawCommandAt(curCommand+1)->getType() ||
124 CLIP_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || 128 CLIP_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
125 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+3)->getT ype() || 129 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+3)->getT ype() ||
126 RESTORE != canvas->getDrawCommandAt(curCommand+4)->getType() || 130 RESTORE != canvas->getDrawCommandAt(curCommand+4)->getType() ||
127 RESTORE != canvas->getDrawCommandAt(curCommand+5)->getType()) { 131 RESTORE != canvas->getDrawCommandAt(curCommand+5)->getType()) {
128 return false; 132 return false;
129 } 133 }
130 134
131 SaveLayer* saveLayer = (SaveLayer*) canvas->getDrawCommandAt(curCommand); 135 SkSaveLayerCommand* saveLayer =
132 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +3); 136 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand);
137 SkDrawBitmapRectCommand* dbmr =
138 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+3);
133 139
134 const SkPaint* saveLayerPaint = saveLayer->paint(); 140 const SkPaint* saveLayerPaint = saveLayer->paint();
135 SkPaint* dbmrPaint = dbmr->paint(); 141 SkPaint* dbmrPaint = dbmr->paint();
136 142
137 // For this optimization we only fold the saveLayer and drawBitmapRect 143 // For this optimization we only fold the saveLayer and drawBitmapRect
138 // together if the saveLayer's draw is simple (i.e., no fancy effects) and 144 // together if the saveLayer's draw is simple (i.e., no fancy effects) and
139 // and the only difference in the colors is that the saveLayer's can have 145 // and the only difference in the colors is that the saveLayer's can have
140 // an alpha while the drawBitmapRect's is opaque. 146 // an alpha while the drawBitmapRect's is opaque.
141 // TODO: it should be possible to fold them together even if they both 147 // TODO: it should be possible to fold them together even if they both
142 // have different non-255 alphas but this is low priority since we have 148 // have different non-255 alphas but this is low priority since we have
143 // never seen that case 149 // never seen that case
144 // If either operation lacks a paint then the collapse is trivial 150 // If either operation lacks a paint then the collapse is trivial
145 SkColor layerColor = saveLayerPaint->getColor() | 0xFF000000; // force opaqu e 151 SkColor layerColor = saveLayerPaint->getColor() | 0xFF000000; // force opaqu e
146 152
147 return NULL == saveLayerPaint || 153 return NULL == saveLayerPaint ||
148 NULL == dbmrPaint || 154 NULL == dbmrPaint ||
149 (is_simple(*saveLayerPaint) && dbmrPaint->getColor() == layerColor); 155 (is_simple(*saveLayerPaint) && dbmrPaint->getColor() == layerColor);
150 } 156 }
151 157
152 // Fold the saveLayer's alpha into the drawBitmapRect and remove the saveLayer 158 // Fold the saveLayer's alpha into the drawBitmapRect and remove the saveLayer
153 // and restore 159 // and restore
154 static void apply_1(SkDebugCanvas* canvas, int curCommand) { 160 static void apply_1(SkDebugCanvas* canvas, int curCommand) {
155 SaveLayer* saveLayer = (SaveLayer*) canvas->getDrawCommandAt(curCommand); 161 SkSaveLayerCommand* saveLayer =
162 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand);
156 const SkPaint* saveLayerPaint = saveLayer->paint(); 163 const SkPaint* saveLayerPaint = saveLayer->paint();
157 164
158 // if (NULL == saveLayerPaint) the dbmr's paint doesn't need to be changed 165 // if (NULL == saveLayerPaint) the dbmr's paint doesn't need to be changed
159 if (NULL != saveLayerPaint) { 166 if (NULL != saveLayerPaint) {
160 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCom mand+3); 167 SkDrawBitmapRectCommand* dbmr =
168 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+3);
161 SkPaint* dbmrPaint = dbmr->paint(); 169 SkPaint* dbmrPaint = dbmr->paint();
162 170
163 if (NULL == dbmrPaint) { 171 if (NULL == dbmrPaint) {
164 dbmr->setPaint(*saveLayerPaint); 172 dbmr->setPaint(*saveLayerPaint);
165 } else { 173 } else {
166 SkColor newColor = SkColorSetA(dbmrPaint->getColor(), 174 SkColor newColor = SkColorSetA(dbmrPaint->getColor(),
167 SkColorGetA(saveLayerPaint->getColor( ))); 175 SkColorGetA(saveLayerPaint->getColor( )));
168 dbmrPaint->setColor(newColor); 176 dbmrPaint->setColor(newColor);
169 } 177 }
170 } 178 }
(...skipping 10 matching lines...) Expand all
181 // where the rect is entirely within the clip and the clip is an intersect 189 // where the rect is entirely within the clip and the clip is an intersect
182 static bool check_2(SkDebugCanvas* canvas, int curCommand) { 190 static bool check_2(SkDebugCanvas* canvas, int curCommand) {
183 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || 191 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
184 canvas->getSize() <= curCommand+4 || 192 canvas->getSize() <= curCommand+4 ||
185 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || 193 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
186 DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || 194 DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
187 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { 195 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
188 return false; 196 return false;
189 } 197 }
190 198
191 ClipRect* cr = (ClipRect*) canvas->getDrawCommandAt(curCommand+1); 199 SkClipRectCommand* cr =
192 DrawRectC* dr = (DrawRectC*) canvas->getDrawCommandAt(curCommand+2); 200 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
201 SkDrawRectCommand* dr =
202 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2);
193 203
194 if (SkRegion::kIntersect_Op != cr->op()) { 204 if (SkRegion::kIntersect_Op != cr->op()) {
195 return false; 205 return false;
196 } 206 }
197 207
198 return cr->rect().contains(dr->rect()); 208 return cr->rect().contains(dr->rect());
199 } 209 }
200 210
201 // Remove everything but the drawRect 211 // Remove everything but the drawRect
202 static void apply_2(SkDebugCanvas* canvas, int curCommand) { 212 static void apply_2(SkDebugCanvas* canvas, int curCommand) {
(...skipping 11 matching lines...) Expand all
214 // where the rect entirely encloses the clip 224 // where the rect entirely encloses the clip
215 static bool check_3(SkDebugCanvas* canvas, int curCommand) { 225 static bool check_3(SkDebugCanvas* canvas, int curCommand) {
216 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || 226 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
217 canvas->getSize() <= curCommand+4 || 227 canvas->getSize() <= curCommand+4 ||
218 CLIP_RRECT != canvas->getDrawCommandAt(curCommand+1)->getType() || 228 CLIP_RRECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
219 DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || 229 DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
220 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { 230 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
221 return false; 231 return false;
222 } 232 }
223 233
224 ClipRRect* crr = (ClipRRect*) canvas->getDrawCommandAt(curCommand+1); 234 SkClipRRectCommand* crr =
225 DrawRectC* dr = (DrawRectC*) canvas->getDrawCommandAt(curCommand+2); 235 (SkClipRRectCommand*) canvas->getDrawCommandAt(curCommand+1);
236 SkDrawRectCommand* dr =
237 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2);
226 238
227 if (SkRegion::kIntersect_Op != crr->op()) { 239 if (SkRegion::kIntersect_Op != crr->op()) {
228 return false; 240 return false;
229 } 241 }
230 242
231 return dr->rect().contains(crr->rrect().rect()); 243 return dr->rect().contains(crr->rrect().rect());
232 } 244 }
233 245
234 // Replace everything with a drawRRect with the paint from the drawRect 246 // Replace everything with a drawRRect with the paint from the drawRect
235 // and the AA settings from the clipRRect 247 // and the AA settings from the clipRRect
236 static void apply_3(SkDebugCanvas* canvas, int curCommand) { 248 static void apply_3(SkDebugCanvas* canvas, int curCommand) {
237 249
238 canvas->deleteDrawCommandAt(curCommand+3); // restore 250 canvas->deleteDrawCommandAt(curCommand+3); // restore
239 251
240 ClipRRect* crr = (ClipRRect*) canvas->getDrawCommandAt(curCommand+1); 252 SkClipRRectCommand* crr =
241 DrawRectC* dr = (DrawRectC*) canvas->getDrawCommandAt(curCommand+2); 253 (SkClipRRectCommand*) canvas->getDrawCommandAt(curCommand+1);
254 SkDrawRectCommand* dr =
255 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2);
242 256
243 // TODO: could skip paint re-creation if the AA settings already match 257 // TODO: could skip paint re-creation if the AA settings already match
244 SkPaint newPaint = dr->paint(); 258 SkPaint newPaint = dr->paint();
245 newPaint.setAntiAlias(crr->doAA()); 259 newPaint.setAntiAlias(crr->doAA());
246 DrawRRect* drr = new DrawRRect(crr->rrect(), newPaint); 260 SkDrawRRectCommand* drr = new SkDrawRRectCommand(crr->rrect(), newPaint);
247 canvas->setDrawCommandAt(curCommand+2, drr); 261 canvas->setDrawCommandAt(curCommand+2, drr);
248 262
249 canvas->deleteDrawCommandAt(curCommand+1); // clipRRect 263 canvas->deleteDrawCommandAt(curCommand+1); // clipRRect
250 canvas->deleteDrawCommandAt(curCommand); // save 264 canvas->deleteDrawCommandAt(curCommand); // save
251 } 265 }
252 266
253 // Check for: 267 // Check for:
254 // SAVE 268 // SAVE
255 // CLIP_RECT 269 // CLIP_RECT
256 // DRAW_BITMAP_RECT_TO_RECT 270 // DRAW_BITMAP_RECT_TO_RECT
257 // RESTORE 271 // RESTORE
258 // where the rect and drawBitmapRect dst exactly match 272 // where the rect and drawBitmapRect dst exactly match
259 static bool check_4(SkDebugCanvas* canvas, int curCommand) { 273 static bool check_4(SkDebugCanvas* canvas, int curCommand) {
260 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || 274 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
261 canvas->getSize() <= curCommand+4 || 275 canvas->getSize() <= curCommand+4 ||
262 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || 276 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
263 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT ype() || 277 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT ype() ||
264 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { 278 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
265 return false; 279 return false;
266 } 280 }
267 281
268 ClipRect* cr = (ClipRect*) canvas->getDrawCommandAt(curCommand+1); 282 SkClipRectCommand* cr =
269 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curComman d+2); 283 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
284 SkDrawBitmapRectCommand* dbmr =
285 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
270 286
271 if (SkRegion::kIntersect_Op != cr->op()) { 287 if (SkRegion::kIntersect_Op != cr->op()) {
272 return false; 288 return false;
273 } 289 }
274 290
275 return dbmr->dstRect() == cr->rect(); 291 return dbmr->dstRect() == cr->rect();
276 } 292 }
277 293
278 // Remove everything but the drawBitmapRect 294 // Remove everything but the drawBitmapRect
279 static void apply_4(SkDebugCanvas* canvas, int curCommand) { 295 static void apply_4(SkDebugCanvas* canvas, int curCommand) {
280 canvas->deleteDrawCommandAt(curCommand+3); // restore 296 canvas->deleteDrawCommandAt(curCommand+3); // restore
281 // drawBitmapRectToRect 297 // drawBitmapRectToRect
282 canvas->deleteDrawCommandAt(curCommand+1); // clipRect 298 canvas->deleteDrawCommandAt(curCommand+1); // clipRect
283 canvas->deleteDrawCommandAt(curCommand); // save 299 canvas->deleteDrawCommandAt(curCommand); // save
284 } 300 }
285 301
286 // Check for: 302 // Check for:
287 // TRANSLATE 303 // TRANSLATE
288 // where the translate is zero 304 // where the translate is zero
289 static bool check_5(SkDebugCanvas* canvas, int curCommand) { 305 static bool check_5(SkDebugCanvas* canvas, int curCommand) {
290 if (TRANSLATE != canvas->getDrawCommandAt(curCommand)->getType()) { 306 if (TRANSLATE != canvas->getDrawCommandAt(curCommand)->getType()) {
291 return false; 307 return false;
292 } 308 }
293 309
294 Translate* t = (Translate*) canvas->getDrawCommandAt(curCommand); 310 SkTranslateCommand* t =
311 (SkTranslateCommand*) canvas->getDrawCommandAt(curCommand);
295 312
296 return 0 == t->x() && 0 == t->y(); 313 return 0 == t->x() && 0 == t->y();
297 } 314 }
298 315
299 // Just remove the translate 316 // Just remove the translate
300 static void apply_5(SkDebugCanvas* canvas, int curCommand) { 317 static void apply_5(SkDebugCanvas* canvas, int curCommand) {
301 canvas->deleteDrawCommandAt(curCommand); // translate 318 canvas->deleteDrawCommandAt(curCommand); // translate
302 } 319 }
303 320
304 // Check for: 321 // Check for:
305 // SCALE 322 // SCALE
306 // where the scale is 1,1 323 // where the scale is 1,1
307 static bool check_6(SkDebugCanvas* canvas, int curCommand) { 324 static bool check_6(SkDebugCanvas* canvas, int curCommand) {
308 if (SCALE != canvas->getDrawCommandAt(curCommand)->getType()) { 325 if (SCALE != canvas->getDrawCommandAt(curCommand)->getType()) {
309 return false; 326 return false;
310 } 327 }
311 328
312 Scale* s = (Scale*) canvas->getDrawCommandAt(curCommand); 329 SkScaleCommand* s = (SkScaleCommand*) canvas->getDrawCommandAt(curCommand);
313 330
314 return SK_Scalar1 == s->x() && SK_Scalar1 == s->y(); 331 return SK_Scalar1 == s->x() && SK_Scalar1 == s->y();
315 } 332 }
316 333
317 // Just remove the scale 334 // Just remove the scale
318 static void apply_6(SkDebugCanvas* canvas, int curCommand) { 335 static void apply_6(SkDebugCanvas* canvas, int curCommand) {
319 canvas->deleteDrawCommandAt(curCommand); // scale 336 canvas->deleteDrawCommandAt(curCommand); // scale
320 } 337 }
321 338
322 // Check for: 339 // Check for:
(...skipping 29 matching lines...) Expand all
352 CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() || 369 CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() ||
353 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getT ype() || 370 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getT ype() ||
354 RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() || 371 RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() ||
355 RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() || 372 RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() ||
356 RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() || 373 RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() ||
357 RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() || 374 RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() ||
358 RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) { 375 RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) {
359 return false; 376 return false;
360 } 377 }
361 378
362 ClipRect* clip0 = (ClipRect*) canvas->getDrawCommandAt(curCommand+1); 379 SkClipRectCommand* clip0 =
363 SaveLayer* saveLayer0 = (SaveLayer*) canvas->getDrawCommandAt(curCommand+2); 380 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
364 ClipRect* clip1 = (ClipRect*) canvas->getDrawCommandAt(curCommand+4); 381 SkSaveLayerCommand* saveLayer0 =
365 SaveLayer* saveLayer1 = (SaveLayer*) canvas->getDrawCommandAt(curCommand+5); 382 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+2);
366 ClipRect* clip2 = (ClipRect*) canvas->getDrawCommandAt(curCommand+7); 383 SkClipRectCommand* clip1 =
367 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +8); 384 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+4);
385 SkSaveLayerCommand* saveLayer1 =
386 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+5);
387 SkClipRectCommand* clip2 =
388 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+7);
389 SkDrawBitmapRectCommand* dbmr =
390 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+8);
368 391
369 if (clip0->doAA() || clip1->doAA() || clip2->doAA()) { 392 if (clip0->doAA() || clip1->doAA() || clip2->doAA()) {
370 return false; 393 return false;
371 } 394 }
372 395
373 if (SkRegion::kIntersect_Op != clip0->op() || 396 if (SkRegion::kIntersect_Op != clip0->op() ||
374 SkRegion::kIntersect_Op != clip1->op() || 397 SkRegion::kIntersect_Op != clip1->op() ||
375 SkRegion::kIntersect_Op != clip2->op()) { 398 SkRegion::kIntersect_Op != clip2->op()) {
376 return false; 399 return false;
377 } 400 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 449 }
427 } 450 }
428 451
429 return true; 452 return true;
430 } 453 }
431 454
432 // Reduce to a single drawBitmapRectToRect call by folding the clipRect's into 455 // Reduce to a single drawBitmapRectToRect call by folding the clipRect's into
433 // the src and dst Rects and the saveLayer paints into the drawBitmapRectToRect' s 456 // the src and dst Rects and the saveLayer paints into the drawBitmapRectToRect' s
434 // paint. 457 // paint.
435 static void apply_7(SkDebugCanvas* canvas, int curCommand) { 458 static void apply_7(SkDebugCanvas* canvas, int curCommand) {
436 SaveLayer* saveLayer0 = (SaveLayer*) canvas->getDrawCommandAt(curCommand+2); 459 SkSaveLayerCommand* saveLayer0 =
437 SaveLayer* saveLayer1 = (SaveLayer*) canvas->getDrawCommandAt(curCommand+5); 460 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+2);
438 ClipRect* clip2 = (ClipRect*) canvas->getDrawCommandAt(curCommand+7); 461 SkSaveLayerCommand* saveLayer1 =
439 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +8); 462 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+5);
463 SkClipRectCommand* clip2 =
464 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+7);
465 SkDrawBitmapRectCommand* dbmr =
466 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+8);
440 467
441 SkScalar newSrcLeft = dbmr->srcRect()->fLeft + clip2->rect().fLeft - dbmr->d stRect().fLeft; 468 SkScalar newSrcLeft = dbmr->srcRect()->fLeft + clip2->rect().fLeft - dbmr->d stRect().fLeft;
442 SkScalar newSrcTop = dbmr->srcRect()->fTop + clip2->rect().fTop - dbmr->dstR ect().fTop; 469 SkScalar newSrcTop = dbmr->srcRect()->fTop + clip2->rect().fTop - dbmr->dstR ect().fTop;
443 470
444 SkRect newSrc = SkRect::MakeXYWH(newSrcLeft, newSrcTop, 471 SkRect newSrc = SkRect::MakeXYWH(newSrcLeft, newSrcTop,
445 clip2->rect().width(), clip2->rect().height ()); 472 clip2->rect().width(), clip2->rect().height ());
446 473
447 dbmr->setSrcRect(newSrc); 474 dbmr->setSrcRect(newSrc);
448 dbmr->setDstRect(clip2->rect()); 475 dbmr->setDstRect(clip2->rect());
449 476
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect 535 // the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect
509 static bool check_8(SkDebugCanvas* canvas, int curCommand) { 536 static bool check_8(SkDebugCanvas* canvas, int curCommand) {
510 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || 537 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
511 canvas->getSize() <= curCommand+4 || 538 canvas->getSize() <= curCommand+4 ||
512 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || 539 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
513 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT ype() || 540 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT ype() ||
514 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { 541 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
515 return false; 542 return false;
516 } 543 }
517 544
518 ClipRect* clip = (ClipRect*) canvas->getDrawCommandAt(curCommand+1); 545 SkClipRectCommand* clip =
519 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +2); 546 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
547 SkDrawBitmapRectCommand* dbmr =
548 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
520 549
521 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) { 550 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) {
522 return false; 551 return false;
523 } 552 }
524 553
525 // The src->dest mapping needs to be 1-to-1 554 // The src->dest mapping needs to be 1-to-1
526 if (NULL == dbmr->srcRect()) { 555 if (NULL == dbmr->srcRect()) {
527 if (dbmr->bitmap().width() != dbmr->dstRect().width() || 556 if (dbmr->bitmap().width() != dbmr->dstRect().width() ||
528 dbmr->bitmap().height() != dbmr->dstRect().height()) { 557 dbmr->bitmap().height() != dbmr->dstRect().height()) {
529 return false; 558 return false;
530 } 559 }
531 } else { 560 } else {
532 if (dbmr->srcRect()->width() != dbmr->dstRect().width() || 561 if (dbmr->srcRect()->width() != dbmr->dstRect().width() ||
533 dbmr->srcRect()->height() != dbmr->dstRect().height()) { 562 dbmr->srcRect()->height() != dbmr->dstRect().height()) {
534 return false; 563 return false;
535 } 564 }
536 } 565 }
537 566
538 if (!dbmr->dstRect().contains(clip->rect())) { 567 if (!dbmr->dstRect().contains(clip->rect())) {
539 return false; 568 return false;
540 } 569 }
541 570
542 return true; 571 return true;
543 } 572 }
544 573
545 // Fold the clipRect into the drawBitmapRectToRect's src and dest rects 574 // Fold the clipRect into the drawBitmapRectToRect's src and dest rects
546 static void apply_8(SkDebugCanvas* canvas, int curCommand) { 575 static void apply_8(SkDebugCanvas* canvas, int curCommand) {
547 ClipRect* clip = (ClipRect*) canvas->getDrawCommandAt(curCommand+1); 576 SkClipRectCommand* clip =
548 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +2); 577 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
578 SkDrawBitmapRectCommand* dbmr =
579 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
549 580
550 SkScalar newSrcLeft, newSrcTop; 581 SkScalar newSrcLeft, newSrcTop;
551 582
552 if (NULL != dbmr->srcRect()) { 583 if (NULL != dbmr->srcRect()) {
553 newSrcLeft = dbmr->srcRect()->fLeft + clip->rect().fLeft - dbmr->dstRect ().fLeft; 584 newSrcLeft = dbmr->srcRect()->fLeft + clip->rect().fLeft - dbmr->dstRect ().fLeft;
554 newSrcTop = dbmr->srcRect()->fTop + clip->rect().fTop - dbmr->dstRect() .fTop; 585 newSrcTop = dbmr->srcRect()->fTop + clip->rect().fTop - dbmr->dstRect() .fTop;
555 } else { 586 } else {
556 newSrcLeft = clip->rect().fLeft - dbmr->dstRect().fLeft; 587 newSrcLeft = clip->rect().fLeft - dbmr->dstRect().fLeft;
557 newSrcTop = clip->rect().fTop - dbmr->dstRect().fTop; 588 newSrcTop = clip->rect().fTop - dbmr->dstRect().fTop;
558 } 589 }
(...skipping 19 matching lines...) Expand all
578 // clipRect is BW and encloses the DBMR2R's dest rect 609 // clipRect is BW and encloses the DBMR2R's dest rect
579 static bool check_9(SkDebugCanvas* canvas, int curCommand) { 610 static bool check_9(SkDebugCanvas* canvas, int curCommand) {
580 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || 611 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
581 canvas->getSize() <= curCommand+4 || 612 canvas->getSize() <= curCommand+4 ||
582 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || 613 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
583 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT ype() || 614 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT ype() ||
584 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { 615 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
585 return false; 616 return false;
586 } 617 }
587 618
588 ClipRect* clip = (ClipRect*) canvas->getDrawCommandAt(curCommand+1); 619 SkClipRectCommand* clip =
589 DrawBitmapRect* dbmr = (DrawBitmapRect*) canvas->getDrawCommandAt(curCommand +2); 620 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1);
621 SkDrawBitmapRectCommand* dbmr =
622 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2);
590 623
591 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) { 624 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) {
592 return false; 625 return false;
593 } 626 }
594 627
595 if (!clip->rect().contains(dbmr->dstRect())) { 628 if (!clip->rect().contains(dbmr->dstRect())) {
596 return false; 629 return false;
597 } 630 }
598 631
599 return true; 632 return true;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 839
807 SkGraphics::Term(); 840 SkGraphics::Term();
808 return 0; 841 return 0;
809 } 842 }
810 843
811 #if !defined SK_BUILD_FOR_IOS 844 #if !defined SK_BUILD_FOR_IOS
812 int main(int argc, char * const argv[]) { 845 int main(int argc, char * const argv[]) {
813 return tool_main(argc, (char**) argv); 846 return tool_main(argc, (char**) argv);
814 } 847 }
815 #endif 848 #endif
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDrawCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698