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

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