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

Side by Side Diff: debugger/SkDrawCommand.cpp

Issue 15907023: Make SkDrawCommands lighter weight (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review comments 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 | « debugger/SkDrawCommand.h ('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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 8
9 9
10 #include "SkDrawCommand.h" 10 #include "SkDrawCommand.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 Clear::Clear(SkColor color) { 80 Clear::Clear(SkColor color) {
81 fColor = color; 81 fColor = color;
82 fDrawType = DRAW_CLEAR; 82 fDrawType = DRAW_CLEAR;
83 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); 83 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
84 } 84 }
85 85
86 void Clear::execute(SkCanvas* canvas) { 86 void Clear::execute(SkCanvas* canvas) {
87 canvas->clear(fColor); 87 canvas->clear(fColor);
88 } 88 }
89 89
90 ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bit map) { 90 namespace {
91
92 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
93 const SkISize& size = canvas->getDeviceSize();
94
95 canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f);
96 if (bounds.width() > bounds.height()) {
97 canvas->scale(SkDoubleToScalar((0.9*size.fWidth)/bounds.width()),
djsollen 2013/06/06 21:17:00 make this a variable
robertphillips 2013/06/07 00:00:17 Done.
98 SkDoubleToScalar((0.9*size.fHeight)/bounds.width()));
99 } else {
100 canvas->scale(SkDoubleToScalar((0.9*size.fWidth)/bounds.height()),
101 SkDoubleToScalar((0.9*size.fHeight)/bounds.height()));
102 }
103 canvas->translate(-bounds.centerX(), -bounds.centerY());
104 }
105
106
107 void render_path(SkCanvas* canvas, const SkPath& path) {
108 canvas->clear(0xFFFFFFFF);
109 canvas->save();
110
111 const SkRect& bounds = path.getBounds();
112
113 xlate_and_scale_to_bounds(canvas, bounds);
114
115 SkPaint p;
116 p.setColor(SK_ColorBLACK);
117 p.setStyle(SkPaint::kStroke_Style);
118
119 canvas->drawPath(path, p);
120 canvas->restore();
121 }
122
123 void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRec t = NULL) {
124 const SkISize& size = canvas->getDeviceSize();
125
126 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width();
127 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height();
128
129 if (input.width() > input.height()) {
130 yScale *= input.height() / (float) input.width();
131 } else {
132 xScale *= input.width() / (float) input.height();
133 }
134
135 SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1,
136 xScale * input.width(),
137 yScale * input.height());
138
139 canvas->clear(0xFFFFFFFF);
140 canvas->drawBitmapRect(input, NULL, dst);
141
142 if (NULL != srcRect) {
143 SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
144 srcRect->fTop * yScale + SK_Scalar1,
145 srcRect->fRight * xScale + SK_Scalar1,
146 srcRect->fBottom * yScale + SK_Scalar1);
147 SkPaint p;
148 p.setColor(SK_ColorRED);
149 p.setStyle(SkPaint::kStroke_Style);
150
151 canvas->drawRect(r, p);
152 }
153 }
154
155 void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
156 canvas->clear(0xFFFFFFFF);
157 canvas->save();
158
159 const SkRect& bounds = rrect.getBounds();
160
161 xlate_and_scale_to_bounds(canvas, bounds);
162
163 SkPaint p;
164 p.setColor(SK_ColorBLACK);
165 p.setStyle(SkPaint::kStroke_Style);
166
167 canvas->drawRRect(rrect, p);
168 canvas->restore();
169 }
170
171 };
172
173
174 ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
91 fPath = path; 175 fPath = path;
92 fOp = op; 176 fOp = op;
93 fDoAA = doAA; 177 fDoAA = doAA;
94 fDrawType = CLIP_PATH; 178 fDrawType = CLIP_PATH;
95 fBitmap = bitmap;
96 179
97 fInfo.push(SkObjectParser::PathToString(path)); 180 fInfo.push(SkObjectParser::PathToString(path));
98 fInfo.push(SkObjectParser::RegionOpToString(op)); 181 fInfo.push(SkObjectParser::RegionOpToString(op));
99 fInfo.push(SkObjectParser::BoolToString(doAA)); 182 fInfo.push(SkObjectParser::BoolToString(doAA));
100 } 183 }
101 184
102 void ClipPath::execute(SkCanvas* canvas) { 185 void ClipPath::execute(SkCanvas* canvas) {
103 canvas->clipPath(fPath, fOp, fDoAA); 186 canvas->clipPath(fPath, fOp, fDoAA);
104 } 187 }
105 188
106 const SkBitmap* ClipPath::getBitmap() const { 189 bool ClipPath::render(SkCanvas* canvas) const {
107 return &fBitmap; 190 render_path(canvas, fPath);
191 return true;
108 } 192 }
109 193
110 ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) { 194 ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
111 fRegion = region; 195 fRegion = region;
112 fOp = op; 196 fOp = op;
113 fDrawType = CLIP_REGION; 197 fDrawType = CLIP_REGION;
114 198
115 fInfo.push(SkObjectParser::RegionToString(region)); 199 fInfo.push(SkObjectParser::RegionToString(region));
116 fInfo.push(SkObjectParser::RegionOpToString(op)); 200 fInfo.push(SkObjectParser::RegionOpToString(op));
117 } 201 }
(...skipping 25 matching lines...) Expand all
143 227
144 fInfo.push(SkObjectParser::RRectToString(rrect)); 228 fInfo.push(SkObjectParser::RRectToString(rrect));
145 fInfo.push(SkObjectParser::RegionOpToString(op)); 229 fInfo.push(SkObjectParser::RegionOpToString(op));
146 fInfo.push(SkObjectParser::BoolToString(doAA)); 230 fInfo.push(SkObjectParser::BoolToString(doAA));
147 } 231 }
148 232
149 void ClipRRect::execute(SkCanvas* canvas) { 233 void ClipRRect::execute(SkCanvas* canvas) {
150 canvas->clipRRect(fRRect, fOp, fDoAA); 234 canvas->clipRRect(fRRect, fOp, fDoAA);
151 } 235 }
152 236
237 bool ClipRRect::render(SkCanvas* canvas) const {
238 render_rrect(canvas, fRRect);
239 return true;
240 }
241
153 Concat::Concat(const SkMatrix& matrix) { 242 Concat::Concat(const SkMatrix& matrix) {
154 fMatrix = matrix; 243 fMatrix = matrix;
155 fDrawType = CONCAT; 244 fDrawType = CONCAT;
156 245
157 fInfo.push(SkObjectParser::MatrixToString(matrix)); 246 fInfo.push(SkObjectParser::MatrixToString(matrix));
158 } 247 }
159 248
160 void Concat::execute(SkCanvas* canvas) { 249 void Concat::execute(SkCanvas* canvas) {
161 canvas->concat(fMatrix); 250 canvas->concat(fMatrix);
162 } 251 }
163 252
164 DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 253 DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
165 const SkPaint* paint, SkBitmap& resizedBitmap) { 254 const SkPaint* paint) {
166 fBitmap = bitmap; 255 fBitmap = bitmap;
167 fLeft = left; 256 fLeft = left;
168 fTop = top; 257 fTop = top;
169 if (NULL != paint) { 258 if (NULL != paint) {
170 fPaint = *paint; 259 fPaint = *paint;
171 fPaintPtr = &fPaint; 260 fPaintPtr = &fPaint;
172 } else { 261 } else {
173 fPaintPtr = NULL; 262 fPaintPtr = NULL;
174 } 263 }
175 fDrawType = DRAW_BITMAP; 264 fDrawType = DRAW_BITMAP;
176 fResizedBitmap = resizedBitmap;
177 265
178 fInfo.push(SkObjectParser::BitmapToString(bitmap)); 266 fInfo.push(SkObjectParser::BitmapToString(bitmap));
179 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); 267 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
180 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); 268 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
181 if (NULL != paint) { 269 if (NULL != paint) {
182 fInfo.push(SkObjectParser::PaintToString(*paint)); 270 fInfo.push(SkObjectParser::PaintToString(*paint));
183 } 271 }
184 } 272 }
185 273
186 void DrawBitmap::execute(SkCanvas* canvas) { 274 void DrawBitmap::execute(SkCanvas* canvas) {
187 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); 275 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr);
188 } 276 }
189 277
190 const SkBitmap* DrawBitmap::getBitmap() const { 278 bool DrawBitmap::render(SkCanvas* canvas) const {
191 return &fResizedBitmap; 279 render_bitmap(canvas, fBitmap);
280 return true;
192 } 281 }
193 282
194 DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap, 283 DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
195 const SkMatrix& matrix, 284 const SkMatrix& matrix,
196 const SkPaint* paint, 285 const SkPaint* paint) {
197 SkBitmap& resizedBitmap) {
198 fBitmap = bitmap; 286 fBitmap = bitmap;
199 fMatrix = matrix; 287 fMatrix = matrix;
200 if (NULL != paint) { 288 if (NULL != paint) {
201 fPaint = *paint; 289 fPaint = *paint;
202 fPaintPtr = &fPaint; 290 fPaintPtr = &fPaint;
203 } else { 291 } else {
204 fPaintPtr = NULL; 292 fPaintPtr = NULL;
205 } 293 }
206 fDrawType = DRAW_BITMAP_MATRIX; 294 fDrawType = DRAW_BITMAP_MATRIX;
207 fResizedBitmap = resizedBitmap;
208 295
209 fInfo.push(SkObjectParser::BitmapToString(bitmap)); 296 fInfo.push(SkObjectParser::BitmapToString(bitmap));
210 fInfo.push(SkObjectParser::MatrixToString(matrix)); 297 fInfo.push(SkObjectParser::MatrixToString(matrix));
211 if (NULL != paint) { 298 if (NULL != paint) {
212 fInfo.push(SkObjectParser::PaintToString(*paint)); 299 fInfo.push(SkObjectParser::PaintToString(*paint));
213 } 300 }
214 } 301 }
215 302
216 void DrawBitmapMatrix::execute(SkCanvas* canvas) { 303 void DrawBitmapMatrix::execute(SkCanvas* canvas) {
217 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); 304 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
218 } 305 }
219 306
220 const SkBitmap* DrawBitmapMatrix::getBitmap() const { 307 bool DrawBitmapMatrix::render(SkCanvas* canvas) const {
221 return &fResizedBitmap; 308 render_bitmap(canvas, fBitmap);
309 return true;
222 } 310 }
223 311
224 DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 312 DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
225 const SkRect& dst, const SkPaint* paint, 313 const SkRect& dst, const SkPaint* paint) {
226 SkBitmap& resizedBitmap) {
227 fBitmap = bitmap; 314 fBitmap = bitmap;
228 fCenter = center; 315 fCenter = center;
229 fDst = dst; 316 fDst = dst;
230 if (NULL != paint) { 317 if (NULL != paint) {
231 fPaint = *paint; 318 fPaint = *paint;
232 fPaintPtr = &fPaint; 319 fPaintPtr = &fPaint;
233 } else { 320 } else {
234 fPaintPtr = NULL; 321 fPaintPtr = NULL;
235 } 322 }
236 fDrawType = DRAW_BITMAP_NINE; 323 fDrawType = DRAW_BITMAP_NINE;
237 fResizedBitmap = resizedBitmap;
238 324
239 fInfo.push(SkObjectParser::BitmapToString(bitmap)); 325 fInfo.push(SkObjectParser::BitmapToString(bitmap));
240 fInfo.push(SkObjectParser::IRectToString(center)); 326 fInfo.push(SkObjectParser::IRectToString(center));
241 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); 327 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
242 if (NULL != paint) { 328 if (NULL != paint) {
243 fInfo.push(SkObjectParser::PaintToString(*paint)); 329 fInfo.push(SkObjectParser::PaintToString(*paint));
244 } 330 }
245 } 331 }
246 332
247 void DrawBitmapNine::execute(SkCanvas* canvas) { 333 void DrawBitmapNine::execute(SkCanvas* canvas) {
248 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); 334 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr);
249 } 335 }
250 336
251 const SkBitmap* DrawBitmapNine::getBitmap() const { 337 bool DrawBitmapNine::render(SkCanvas* canvas) const {
252 return &fResizedBitmap; 338 render_bitmap(canvas, fBitmap);
339 return true;
253 } 340 }
254 341
255 DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 342 DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
256 const SkRect& dst, const SkPaint* paint, 343 const SkRect& dst, const SkPaint* paint) {
257 SkBitmap& resizedBitmap) {
258 fBitmap = bitmap; 344 fBitmap = bitmap;
259 if (NULL != src) { 345 if (NULL != src) {
260 fSrc = *src; 346 fSrc = *src;
261 } else { 347 } else {
262 fSrc.setEmpty(); 348 fSrc.setEmpty();
263 } 349 }
264 fDst = dst; 350 fDst = dst;
265 351
266 if (NULL != paint) { 352 if (NULL != paint) {
267 fPaint = *paint; 353 fPaint = *paint;
268 fPaintPtr = &fPaint; 354 fPaintPtr = &fPaint;
269 } else { 355 } else {
270 fPaintPtr = NULL; 356 fPaintPtr = NULL;
271 } 357 }
272 fDrawType = DRAW_BITMAP_RECT_TO_RECT; 358 fDrawType = DRAW_BITMAP_RECT_TO_RECT;
273 fResizedBitmap = resizedBitmap;
274 359
275 fInfo.push(SkObjectParser::BitmapToString(bitmap)); 360 fInfo.push(SkObjectParser::BitmapToString(bitmap));
276 if (NULL != src) { 361 if (NULL != src) {
277 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); 362 fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
278 } 363 }
279 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); 364 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
280 if (NULL != paint) { 365 if (NULL != paint) {
281 fInfo.push(SkObjectParser::PaintToString(*paint)); 366 fInfo.push(SkObjectParser::PaintToString(*paint));
282 } 367 }
283 } 368 }
284 369
285 void DrawBitmapRect::execute(SkCanvas* canvas) { 370 void DrawBitmapRect::execute(SkCanvas* canvas) {
286 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr); 371 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr);
287 } 372 }
288 373
289 const SkBitmap* DrawBitmapRect::getBitmap() const { 374 bool DrawBitmapRect::render(SkCanvas* canvas) const {
290 return &fResizedBitmap; 375 render_bitmap(canvas, fBitmap, this->srcRect());
376 return true;
291 } 377 }
292 378
293 DrawData::DrawData(const void* data, size_t length) { 379 DrawData::DrawData(const void* data, size_t length) {
294 fData = new char[length]; 380 fData = new char[length];
295 memcpy(fData, data, length); 381 memcpy(fData, data, length);
296 fLength = length; 382 fLength = length;
297 fDrawType = DRAW_DATA; 383 fDrawType = DRAW_DATA;
298 384
299 // TODO: add display of actual data? 385 // TODO: add display of actual data?
300 SkString* str = new SkString; 386 SkString* str = new SkString;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 fDrawType = DRAW_OVAL; 418 fDrawType = DRAW_OVAL;
333 419
334 fInfo.push(SkObjectParser::RectToString(oval)); 420 fInfo.push(SkObjectParser::RectToString(oval));
335 fInfo.push(SkObjectParser::PaintToString(paint)); 421 fInfo.push(SkObjectParser::PaintToString(paint));
336 } 422 }
337 423
338 void DrawOval::execute(SkCanvas* canvas) { 424 void DrawOval::execute(SkCanvas* canvas) {
339 canvas->drawOval(fOval, fPaint); 425 canvas->drawOval(fOval, fPaint);
340 } 426 }
341 427
428 bool DrawOval::render(SkCanvas* canvas) const {
429 canvas->clear(0xFFFFFFFF);
430 canvas->save();
431
432 xlate_and_scale_to_bounds(canvas, fOval);
433
434 SkPaint p;
435 p.setColor(SK_ColorBLACK);
436 p.setStyle(SkPaint::kStroke_Style);
437
438 canvas->drawOval(fOval, p);
439 canvas->restore();
440
441 return true;
442 }
443
342 DrawPaint::DrawPaint(const SkPaint& paint) { 444 DrawPaint::DrawPaint(const SkPaint& paint) {
343 fPaint = paint; 445 fPaint = paint;
344 fDrawType = DRAW_PAINT; 446 fDrawType = DRAW_PAINT;
345 447
346 fInfo.push(SkObjectParser::PaintToString(paint)); 448 fInfo.push(SkObjectParser::PaintToString(paint));
347 } 449 }
348 450
349 void DrawPaint::execute(SkCanvas* canvas) { 451 void DrawPaint::execute(SkCanvas* canvas) {
350 canvas->drawPaint(fPaint); 452 canvas->drawPaint(fPaint);
351 } 453 }
352 454
353 DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) { 455 bool DrawPaint::render(SkCanvas* canvas) const {
456 canvas->clear(0xFFFFFFFF);
457 canvas->drawPaint(fPaint);
458 return true;
459 }
460
461 DrawPath::DrawPath(const SkPath& path, const SkPaint& paint) {
354 fPath = path; 462 fPath = path;
355 fPaint = paint; 463 fPaint = paint;
356 fBitmap = bitmap;
357 fDrawType = DRAW_PATH; 464 fDrawType = DRAW_PATH;
358 465
359 fInfo.push(SkObjectParser::PathToString(path)); 466 fInfo.push(SkObjectParser::PathToString(path));
360 fInfo.push(SkObjectParser::PaintToString(paint)); 467 fInfo.push(SkObjectParser::PaintToString(paint));
361 } 468 }
362 469
363 void DrawPath::execute(SkCanvas* canvas) { 470 void DrawPath::execute(SkCanvas* canvas) {
364 canvas->drawPath(fPath, fPaint); 471 canvas->drawPath(fPath, fPaint);
365 } 472 }
366 473
367 const SkBitmap* DrawPath::getBitmap() const { 474 bool DrawPath::render(SkCanvas* canvas) const {
368 return &fBitmap; 475 render_path(canvas, fPath);
476 return true;
369 } 477 }
370 478
371 DrawPicture::DrawPicture(SkPicture& picture) : 479 DrawPicture::DrawPicture(SkPicture& picture) :
372 fPicture(picture) { 480 fPicture(picture) {
373 fDrawType = DRAW_PICTURE; 481 fDrawType = DRAW_PICTURE;
374 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); 482 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
375 } 483 }
376 484
377 void DrawPicture::execute(SkCanvas* canvas) { 485 void DrawPicture::execute(SkCanvas* canvas) {
378 canvas->drawPicture(fPicture); 486 canvas->drawPicture(fPicture);
(...skipping 12 matching lines...) Expand all
391 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count) , 499 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count) ,
392 "Points: ")); 500 "Points: "));
393 fInfo.push(SkObjectParser::PointModeToString(mode)); 501 fInfo.push(SkObjectParser::PointModeToString(mode));
394 fInfo.push(SkObjectParser::PaintToString(paint)); 502 fInfo.push(SkObjectParser::PaintToString(paint));
395 } 503 }
396 504
397 void DrawPoints::execute(SkCanvas* canvas) { 505 void DrawPoints::execute(SkCanvas* canvas) {
398 canvas->drawPoints(fMode, fCount, fPts, fPaint); 506 canvas->drawPoints(fMode, fCount, fPts, fPaint);
399 } 507 }
400 508
509 bool DrawPoints::render(SkCanvas* canvas) const {
510 canvas->clear(0xFFFFFFFF);
511 canvas->save();
512
513 SkRect bounds;
514
515 bounds.setEmpty();
516 for (unsigned int i = 0; i < fCount; ++i) {
517 bounds.growToInclude(fPts[i].fX, fPts[i].fY);
518 }
519
520 xlate_and_scale_to_bounds(canvas, bounds);
521
522 SkPaint p;
523 p.setColor(SK_ColorBLACK);
524 p.setStyle(SkPaint::kStroke_Style);
525
526 canvas->drawPoints(fMode, fCount, fPts, p);
527 canvas->restore();
528
529 return true;
530 }
531
401 DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[ ], 532 DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[ ],
402 const SkPaint& paint) { 533 const SkPaint& paint) {
403 size_t numPts = paint.countText(text, byteLength); 534 size_t numPts = paint.countText(text, byteLength);
404 535
405 fText = new char[byteLength]; 536 fText = new char[byteLength];
406 memcpy(fText, text, byteLength); 537 memcpy(fText, text, byteLength);
407 fByteLength = byteLength; 538 fByteLength = byteLength;
408 539
409 fPos = new SkPoint[numPts]; 540 fPos = new SkPoint[numPts];
410 memcpy(fPos, pos, numPts * sizeof(SkPoint)); 541 memcpy(fPos, pos, numPts * sizeof(SkPoint));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 fDrawType = DRAW_RRECT; 599 fDrawType = DRAW_RRECT;
469 600
470 fInfo.push(SkObjectParser::RRectToString(rrect)); 601 fInfo.push(SkObjectParser::RRectToString(rrect));
471 fInfo.push(SkObjectParser::PaintToString(paint)); 602 fInfo.push(SkObjectParser::PaintToString(paint));
472 } 603 }
473 604
474 void DrawRRect::execute(SkCanvas* canvas) { 605 void DrawRRect::execute(SkCanvas* canvas) {
475 canvas->drawRRect(fRRect, fPaint); 606 canvas->drawRRect(fRRect, fPaint);
476 } 607 }
477 608
609 bool DrawRRect::render(SkCanvas* canvas) const {
610 render_rrect(canvas, fRRect);
611 return true;
612 }
613
478 DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top, 614 DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
479 const SkPaint* paint, SkBitmap& resizedBitmap) { 615 const SkPaint* paint) {
480 fBitmap = bitmap; 616 fBitmap = bitmap;
481 fLeft = left; 617 fLeft = left;
482 fTop = top; 618 fTop = top;
483 if (NULL != paint) { 619 if (NULL != paint) {
484 fPaint = *paint; 620 fPaint = *paint;
485 fPaintPtr = &fPaint; 621 fPaintPtr = &fPaint;
486 } else { 622 } else {
487 fPaintPtr = NULL; 623 fPaintPtr = NULL;
488 } 624 }
489 fDrawType = DRAW_SPRITE; 625 fDrawType = DRAW_SPRITE;
490 fResizedBitmap = resizedBitmap;
491 626
492 fInfo.push(SkObjectParser::BitmapToString(bitmap)); 627 fInfo.push(SkObjectParser::BitmapToString(bitmap));
493 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); 628 fInfo.push(SkObjectParser::IntToString(left, "Left: "));
494 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); 629 fInfo.push(SkObjectParser::IntToString(top, "Top: "));
495 if (NULL != paint) { 630 if (NULL != paint) {
496 fInfo.push(SkObjectParser::PaintToString(*paint)); 631 fInfo.push(SkObjectParser::PaintToString(*paint));
497 } 632 }
498 } 633 }
499 634
500 void DrawSprite::execute(SkCanvas* canvas) { 635 void DrawSprite::execute(SkCanvas* canvas) {
501 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); 636 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr);
502 } 637 }
503 638
504 const SkBitmap* DrawSprite::getBitmap() const { 639 bool DrawSprite::render(SkCanvas* canvas) const {
505 return &fResizedBitmap; 640 render_bitmap(canvas, fBitmap);
641 return true;
506 } 642 }
507 643
508 DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y , 644 DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y ,
509 const SkPaint& paint) { 645 const SkPaint& paint) {
510 fText = new char[byteLength]; 646 fText = new char[byteLength];
511 memcpy(fText, text, byteLength); 647 memcpy(fText, text, byteLength);
512 fByteLength = byteLength; 648 fByteLength = byteLength;
513 fX = x; 649 fX = x;
514 fY = y; 650 fY = y;
515 fPaint = paint; 651 fPaint = paint;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 fDy = dy; 867 fDy = dy;
732 fDrawType = TRANSLATE; 868 fDrawType = TRANSLATE;
733 869
734 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); 870 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
735 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); 871 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
736 } 872 }
737 873
738 void Translate::execute(SkCanvas* canvas) { 874 void Translate::execute(SkCanvas* canvas) {
739 canvas->translate(fDx, fDy); 875 canvas->translate(fDx, fDy);
740 } 876 }
OLDNEW
« no previous file with comments | « debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698