| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 break; | 70 break; |
| 71 } | 71 } |
| 72 SkDEBUGFAIL("DrawType UNUSED\n"); | 72 SkDEBUGFAIL("DrawType UNUSED\n"); |
| 73 return NULL; | 73 return NULL; |
| 74 } | 74 } |
| 75 | 75 |
| 76 SkString SkDrawCommand::toString() { | 76 SkString SkDrawCommand::toString() { |
| 77 return SkString(GetCommandString(fDrawType)); | 77 return SkString(GetCommandString(fDrawType)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 Clear::Clear(SkColor color) { | 80 SkClearCommand::SkClearCommand(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 SkClearCommand::execute(SkCanvas* canvas) { |
| 87 canvas->clear(fColor); | 87 canvas->clear(fColor); |
| 88 } | 88 } |
| 89 | 89 |
| 90 namespace { | 90 namespace { |
| 91 | 91 |
| 92 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { | 92 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { |
| 93 const SkISize& size = canvas->getDeviceSize(); | 93 const SkISize& size = canvas->getDeviceSize(); |
| 94 | 94 |
| 95 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object | 95 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object |
| 96 | 96 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 p.setColor(SK_ColorBLACK); | 166 p.setColor(SK_ColorBLACK); |
| 167 p.setStyle(SkPaint::kStroke_Style); | 167 p.setStyle(SkPaint::kStroke_Style); |
| 168 | 168 |
| 169 canvas->drawRRect(rrect, p); | 169 canvas->drawRRect(rrect, p); |
| 170 canvas->restore(); | 170 canvas->restore(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 | 175 |
| 176 ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA) { | 176 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) { |
| 177 fPath = path; | 177 fPath = path; |
| 178 fOp = op; | 178 fOp = op; |
| 179 fDoAA = doAA; | 179 fDoAA = doAA; |
| 180 fDrawType = CLIP_PATH; | 180 fDrawType = CLIP_PATH; |
| 181 | 181 |
| 182 fInfo.push(SkObjectParser::PathToString(path)); | 182 fInfo.push(SkObjectParser::PathToString(path)); |
| 183 fInfo.push(SkObjectParser::RegionOpToString(op)); | 183 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 184 fInfo.push(SkObjectParser::BoolToString(doAA)); | 184 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void ClipPath::execute(SkCanvas* canvas) { | 187 void SkClipPathCommand::execute(SkCanvas* canvas) { |
| 188 canvas->clipPath(fPath, fOp, fDoAA); | 188 canvas->clipPath(fPath, fOp, fDoAA); |
| 189 } | 189 } |
| 190 | 190 |
| 191 bool ClipPath::render(SkCanvas* canvas) const { | 191 bool SkClipPathCommand::render(SkCanvas* canvas) const { |
| 192 render_path(canvas, fPath); | 192 render_path(canvas, fPath); |
| 193 return true; | 193 return true; |
| 194 } | 194 } |
| 195 | 195 |
| 196 ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) { | 196 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) { |
| 197 fRegion = region; | 197 fRegion = region; |
| 198 fOp = op; | 198 fOp = op; |
| 199 fDrawType = CLIP_REGION; | 199 fDrawType = CLIP_REGION; |
| 200 | 200 |
| 201 fInfo.push(SkObjectParser::RegionToString(region)); | 201 fInfo.push(SkObjectParser::RegionToString(region)); |
| 202 fInfo.push(SkObjectParser::RegionOpToString(op)); | 202 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void ClipRegion::execute(SkCanvas* canvas) { | 205 void SkClipRegionCommand::execute(SkCanvas* canvas) { |
| 206 canvas->clipRegion(fRegion, fOp); | 206 canvas->clipRegion(fRegion, fOp); |
| 207 } | 207 } |
| 208 | 208 |
| 209 ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 209 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) { |
| 210 fRect = rect; | 210 fRect = rect; |
| 211 fOp = op; | 211 fOp = op; |
| 212 fDoAA = doAA; | 212 fDoAA = doAA; |
| 213 fDrawType = CLIP_RECT; | 213 fDrawType = CLIP_RECT; |
| 214 | 214 |
| 215 fInfo.push(SkObjectParser::RectToString(rect)); | 215 fInfo.push(SkObjectParser::RectToString(rect)); |
| 216 fInfo.push(SkObjectParser::RegionOpToString(op)); | 216 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 217 fInfo.push(SkObjectParser::BoolToString(doAA)); | 217 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void ClipRect::execute(SkCanvas* canvas) { | 220 void SkClipRectCommand::execute(SkCanvas* canvas) { |
| 221 canvas->clipRect(fRect, fOp, fDoAA); | 221 canvas->clipRect(fRect, fOp, fDoAA); |
| 222 } | 222 } |
| 223 | 223 |
| 224 ClipRRect::ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { | 224 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) { |
| 225 fRRect = rrect; | 225 fRRect = rrect; |
| 226 fOp = op; | 226 fOp = op; |
| 227 fDoAA = doAA; | 227 fDoAA = doAA; |
| 228 fDrawType = CLIP_RRECT; | 228 fDrawType = CLIP_RRECT; |
| 229 | 229 |
| 230 fInfo.push(SkObjectParser::RRectToString(rrect)); | 230 fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 231 fInfo.push(SkObjectParser::RegionOpToString(op)); | 231 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 232 fInfo.push(SkObjectParser::BoolToString(doAA)); | 232 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void ClipRRect::execute(SkCanvas* canvas) { | 235 void SkClipRRectCommand::execute(SkCanvas* canvas) { |
| 236 canvas->clipRRect(fRRect, fOp, fDoAA); | 236 canvas->clipRRect(fRRect, fOp, fDoAA); |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool ClipRRect::render(SkCanvas* canvas) const { | 239 bool SkClipRRectCommand::render(SkCanvas* canvas) const { |
| 240 render_rrect(canvas, fRRect); | 240 render_rrect(canvas, fRRect); |
| 241 return true; | 241 return true; |
| 242 } | 242 } |
| 243 | 243 |
| 244 Concat::Concat(const SkMatrix& matrix) { | 244 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) { |
| 245 fMatrix = matrix; | 245 fMatrix = matrix; |
| 246 fDrawType = CONCAT; | 246 fDrawType = CONCAT; |
| 247 | 247 |
| 248 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 248 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void Concat::execute(SkCanvas* canvas) { | 251 void SkConcatCommand::execute(SkCanvas* canvas) { |
| 252 canvas->concat(fMatrix); | 252 canvas->concat(fMatrix); |
| 253 } | 253 } |
| 254 | 254 |
| 255 DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, | 255 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
| 256 const SkPaint* paint) { | 256 const SkPaint* paint) { |
| 257 fBitmap = bitmap; | 257 fBitmap = bitmap; |
| 258 fLeft = left; | 258 fLeft = left; |
| 259 fTop = top; | 259 fTop = top; |
| 260 if (NULL != paint) { | 260 if (NULL != paint) { |
| 261 fPaint = *paint; | 261 fPaint = *paint; |
| 262 fPaintPtr = &fPaint; | 262 fPaintPtr = &fPaint; |
| 263 } else { | 263 } else { |
| 264 fPaintPtr = NULL; | 264 fPaintPtr = NULL; |
| 265 } | 265 } |
| 266 fDrawType = DRAW_BITMAP; | 266 fDrawType = DRAW_BITMAP; |
| 267 | 267 |
| 268 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 268 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 269 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); | 269 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 270 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); | 270 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
| 271 if (NULL != paint) { | 271 if (NULL != paint) { |
| 272 fInfo.push(SkObjectParser::PaintToString(*paint)); | 272 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 void DrawBitmap::execute(SkCanvas* canvas) { | 276 void SkDrawBitmapCommand::execute(SkCanvas* canvas) { |
| 277 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); | 277 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool DrawBitmap::render(SkCanvas* canvas) const { | 280 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
| 281 render_bitmap(canvas, fBitmap); | 281 render_bitmap(canvas, fBitmap); |
| 282 return true; | 282 return true; |
| 283 } | 283 } |
| 284 | 284 |
| 285 DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap, | 285 SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, |
| 286 const SkMatrix& matrix, | 286 const SkMatrix& matrix, |
| 287 const SkPaint* paint) { | 287 const SkPaint* paint) { |
| 288 fBitmap = bitmap; | 288 fBitmap = bitmap; |
| 289 fMatrix = matrix; | 289 fMatrix = matrix; |
| 290 if (NULL != paint) { | 290 if (NULL != paint) { |
| 291 fPaint = *paint; | 291 fPaint = *paint; |
| 292 fPaintPtr = &fPaint; | 292 fPaintPtr = &fPaint; |
| 293 } else { | 293 } else { |
| 294 fPaintPtr = NULL; | 294 fPaintPtr = NULL; |
| 295 } | 295 } |
| 296 fDrawType = DRAW_BITMAP_MATRIX; | 296 fDrawType = DRAW_BITMAP_MATRIX; |
| 297 | 297 |
| 298 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 298 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 299 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 299 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 300 if (NULL != paint) { | 300 if (NULL != paint) { |
| 301 fInfo.push(SkObjectParser::PaintToString(*paint)); | 301 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 void DrawBitmapMatrix::execute(SkCanvas* canvas) { | 305 void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) { |
| 306 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); | 306 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool DrawBitmapMatrix::render(SkCanvas* canvas) const { | 309 bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { |
| 310 render_bitmap(canvas, fBitmap); | 310 render_bitmap(canvas, fBitmap); |
| 311 return true; | 311 return true; |
| 312 } | 312 } |
| 313 | 313 |
| 314 DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 314 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, |
| 315 const SkRect& dst, const SkPaint* paint) { | 315 const SkRect& dst, const SkPain
t* paint) { |
| 316 fBitmap = bitmap; | 316 fBitmap = bitmap; |
| 317 fCenter = center; | 317 fCenter = center; |
| 318 fDst = dst; | 318 fDst = dst; |
| 319 if (NULL != paint) { | 319 if (NULL != paint) { |
| 320 fPaint = *paint; | 320 fPaint = *paint; |
| 321 fPaintPtr = &fPaint; | 321 fPaintPtr = &fPaint; |
| 322 } else { | 322 } else { |
| 323 fPaintPtr = NULL; | 323 fPaintPtr = NULL; |
| 324 } | 324 } |
| 325 fDrawType = DRAW_BITMAP_NINE; | 325 fDrawType = DRAW_BITMAP_NINE; |
| 326 | 326 |
| 327 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 327 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 328 fInfo.push(SkObjectParser::IRectToString(center)); | 328 fInfo.push(SkObjectParser::IRectToString(center)); |
| 329 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 329 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 330 if (NULL != paint) { | 330 if (NULL != paint) { |
| 331 fInfo.push(SkObjectParser::PaintToString(*paint)); | 331 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 void DrawBitmapNine::execute(SkCanvas* canvas) { | 335 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) { |
| 336 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); | 336 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); |
| 337 } | 337 } |
| 338 | 338 |
| 339 bool DrawBitmapNine::render(SkCanvas* canvas) const { | 339 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
| 340 render_bitmap(canvas, fBitmap); | 340 render_bitmap(canvas, fBitmap); |
| 341 return true; | 341 return true; |
| 342 } | 342 } |
| 343 | 343 |
| 344 DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, | 344 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, |
| 345 const SkRect& dst, const SkPaint* paint) { | 345 const SkRect& dst, const SkPain
t* paint) { |
| 346 fBitmap = bitmap; | 346 fBitmap = bitmap; |
| 347 if (NULL != src) { | 347 if (NULL != src) { |
| 348 fSrc = *src; | 348 fSrc = *src; |
| 349 } else { | 349 } else { |
| 350 fSrc.setEmpty(); | 350 fSrc.setEmpty(); |
| 351 } | 351 } |
| 352 fDst = dst; | 352 fDst = dst; |
| 353 | 353 |
| 354 if (NULL != paint) { | 354 if (NULL != paint) { |
| 355 fPaint = *paint; | 355 fPaint = *paint; |
| 356 fPaintPtr = &fPaint; | 356 fPaintPtr = &fPaint; |
| 357 } else { | 357 } else { |
| 358 fPaintPtr = NULL; | 358 fPaintPtr = NULL; |
| 359 } | 359 } |
| 360 fDrawType = DRAW_BITMAP_RECT_TO_RECT; | 360 fDrawType = DRAW_BITMAP_RECT_TO_RECT; |
| 361 | 361 |
| 362 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 362 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 363 if (NULL != src) { | 363 if (NULL != src) { |
| 364 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); | 364 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 365 } | 365 } |
| 366 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 366 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 367 if (NULL != paint) { | 367 if (NULL != paint) { |
| 368 fInfo.push(SkObjectParser::PaintToString(*paint)); | 368 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 void DrawBitmapRect::execute(SkCanvas* canvas) { | 372 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) { |
| 373 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr); | 373 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr); |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool DrawBitmapRect::render(SkCanvas* canvas) const { | 376 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
| 377 render_bitmap(canvas, fBitmap, this->srcRect()); | 377 render_bitmap(canvas, fBitmap, this->srcRect()); |
| 378 return true; | 378 return true; |
| 379 } | 379 } |
| 380 | 380 |
| 381 DrawData::DrawData(const void* data, size_t length) { | 381 SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length) { |
| 382 fData = new char[length]; | 382 fData = new char[length]; |
| 383 memcpy(fData, data, length); | 383 memcpy(fData, data, length); |
| 384 fLength = length; | 384 fLength = length; |
| 385 fDrawType = DRAW_DATA; | 385 fDrawType = DRAW_DATA; |
| 386 | 386 |
| 387 // TODO: add display of actual data? | 387 // TODO: add display of actual data? |
| 388 SkString* str = new SkString; | 388 SkString* str = new SkString; |
| 389 str->appendf("length: %d", (int) length); | 389 str->appendf("length: %d", (int) length); |
| 390 fInfo.push(str); | 390 fInfo.push(str); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void DrawData::execute(SkCanvas* canvas) { | 393 void SkDrawDataCommand::execute(SkCanvas* canvas) { |
| 394 canvas->drawData(fData, fLength); | 394 canvas->drawData(fData, fLength); |
| 395 } | 395 } |
| 396 | 396 |
| 397 BeginCommentGroup::BeginCommentGroup(const char* description) | 397 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
| 398 : INHERITED(BEGIN_COMMENT_GROUP) | 398 : INHERITED(BEGIN_COMMENT_GROUP) |
| 399 , fDescription(description) { | 399 , fDescription(description) { |
| 400 SkString* temp = new SkString; | 400 SkString* temp = new SkString; |
| 401 temp->appendf("Description: %s", description); | 401 temp->appendf("Description: %s", description); |
| 402 fInfo.push(temp); | 402 fInfo.push(temp); |
| 403 } | 403 } |
| 404 | 404 |
| 405 Comment::Comment(const char* kywd, const char* value) | 405 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
| 406 : INHERITED(COMMENT) | 406 : INHERITED(COMMENT) |
| 407 , fKywd(kywd) | 407 , fKywd(kywd) |
| 408 , fValue(value) { | 408 , fValue(value) { |
| 409 SkString* temp = new SkString; | 409 SkString* temp = new SkString; |
| 410 temp->appendf("%s: %s", kywd, value); | 410 temp->appendf("%s: %s", kywd, value); |
| 411 fInfo.push(temp); | 411 fInfo.push(temp); |
| 412 } | 412 } |
| 413 | 413 |
| 414 EndCommentGroup::EndCommentGroup() : INHERITED(END_COMMENT_GROUP) { | 414 SkEndCommentGroupCommand::SkEndCommentGroupCommand() : INHERITED(END_COMMENT_GRO
UP) { |
| 415 } | 415 } |
| 416 | 416 |
| 417 DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) { | 417 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) { |
| 418 fOval = oval; | 418 fOval = oval; |
| 419 fPaint = paint; | 419 fPaint = paint; |
| 420 fDrawType = DRAW_OVAL; | 420 fDrawType = DRAW_OVAL; |
| 421 | 421 |
| 422 fInfo.push(SkObjectParser::RectToString(oval)); | 422 fInfo.push(SkObjectParser::RectToString(oval)); |
| 423 fInfo.push(SkObjectParser::PaintToString(paint)); | 423 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 424 } | 424 } |
| 425 | 425 |
| 426 void DrawOval::execute(SkCanvas* canvas) { | 426 void SkDrawOvalCommand::execute(SkCanvas* canvas) { |
| 427 canvas->drawOval(fOval, fPaint); | 427 canvas->drawOval(fOval, fPaint); |
| 428 } | 428 } |
| 429 | 429 |
| 430 bool DrawOval::render(SkCanvas* canvas) const { | 430 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { |
| 431 canvas->clear(0xFFFFFFFF); | 431 canvas->clear(0xFFFFFFFF); |
| 432 canvas->save(); | 432 canvas->save(); |
| 433 | 433 |
| 434 xlate_and_scale_to_bounds(canvas, fOval); | 434 xlate_and_scale_to_bounds(canvas, fOval); |
| 435 | 435 |
| 436 SkPaint p; | 436 SkPaint p; |
| 437 p.setColor(SK_ColorBLACK); | 437 p.setColor(SK_ColorBLACK); |
| 438 p.setStyle(SkPaint::kStroke_Style); | 438 p.setStyle(SkPaint::kStroke_Style); |
| 439 | 439 |
| 440 canvas->drawOval(fOval, p); | 440 canvas->drawOval(fOval, p); |
| 441 canvas->restore(); | 441 canvas->restore(); |
| 442 | 442 |
| 443 return true; | 443 return true; |
| 444 } | 444 } |
| 445 | 445 |
| 446 DrawPaint::DrawPaint(const SkPaint& paint) { | 446 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) { |
| 447 fPaint = paint; | 447 fPaint = paint; |
| 448 fDrawType = DRAW_PAINT; | 448 fDrawType = DRAW_PAINT; |
| 449 | 449 |
| 450 fInfo.push(SkObjectParser::PaintToString(paint)); | 450 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void DrawPaint::execute(SkCanvas* canvas) { | 453 void SkDrawPaintCommand::execute(SkCanvas* canvas) { |
| 454 canvas->drawPaint(fPaint); | 454 canvas->drawPaint(fPaint); |
| 455 } | 455 } |
| 456 | 456 |
| 457 bool DrawPaint::render(SkCanvas* canvas) const { | 457 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
| 458 canvas->clear(0xFFFFFFFF); | 458 canvas->clear(0xFFFFFFFF); |
| 459 canvas->drawPaint(fPaint); | 459 canvas->drawPaint(fPaint); |
| 460 return true; | 460 return true; |
| 461 } | 461 } |
| 462 | 462 |
| 463 DrawPath::DrawPath(const SkPath& path, const SkPaint& paint) { | 463 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) { |
| 464 fPath = path; | 464 fPath = path; |
| 465 fPaint = paint; | 465 fPaint = paint; |
| 466 fDrawType = DRAW_PATH; | 466 fDrawType = DRAW_PATH; |
| 467 | 467 |
| 468 fInfo.push(SkObjectParser::PathToString(path)); | 468 fInfo.push(SkObjectParser::PathToString(path)); |
| 469 fInfo.push(SkObjectParser::PaintToString(paint)); | 469 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void DrawPath::execute(SkCanvas* canvas) { | 472 void SkDrawPathCommand::execute(SkCanvas* canvas) { |
| 473 canvas->drawPath(fPath, fPaint); | 473 canvas->drawPath(fPath, fPaint); |
| 474 } | 474 } |
| 475 | 475 |
| 476 bool DrawPath::render(SkCanvas* canvas) const { | 476 bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
| 477 render_path(canvas, fPath); | 477 render_path(canvas, fPath); |
| 478 return true; | 478 return true; |
| 479 } | 479 } |
| 480 | 480 |
| 481 DrawPicture::DrawPicture(SkPicture& picture) : | 481 SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture) : |
| 482 fPicture(picture) { | 482 fPicture(picture) { |
| 483 fDrawType = DRAW_PICTURE; | 483 fDrawType = DRAW_PICTURE; |
| 484 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); | 484 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void DrawPicture::execute(SkCanvas* canvas) { | 487 void SkDrawPictureCommand::execute(SkCanvas* canvas) { |
| 488 canvas->drawPicture(fPicture); | 488 canvas->drawPicture(fPicture); |
| 489 } | 489 } |
| 490 | 490 |
| 491 DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count, | 491 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, |
| 492 const SkPoint pts[], const SkPaint& paint) { | 492 const SkPoint pts[], const SkPaint& pai
nt) { |
| 493 fMode = mode; | 493 fMode = mode; |
| 494 fCount = count; | 494 fCount = count; |
| 495 fPts = new SkPoint[count]; | 495 fPts = new SkPoint[count]; |
| 496 memcpy(fPts, pts, count * sizeof(SkPoint)); | 496 memcpy(fPts, pts, count * sizeof(SkPoint)); |
| 497 fPaint = paint; | 497 fPaint = paint; |
| 498 fDrawType = DRAW_POINTS; | 498 fDrawType = DRAW_POINTS; |
| 499 | 499 |
| 500 fInfo.push(SkObjectParser::PointsToString(pts, count)); | 500 fInfo.push(SkObjectParser::PointsToString(pts, count)); |
| 501 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, | 501 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, |
| 502 "Points: ")); | 502 "Points: ")); |
| 503 fInfo.push(SkObjectParser::PointModeToString(mode)); | 503 fInfo.push(SkObjectParser::PointModeToString(mode)); |
| 504 fInfo.push(SkObjectParser::PaintToString(paint)); | 504 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 505 } | 505 } |
| 506 | 506 |
| 507 void DrawPoints::execute(SkCanvas* canvas) { | 507 void SkDrawPointsCommand::execute(SkCanvas* canvas) { |
| 508 canvas->drawPoints(fMode, fCount, fPts, fPaint); | 508 canvas->drawPoints(fMode, fCount, fPts, fPaint); |
| 509 } | 509 } |
| 510 | 510 |
| 511 bool DrawPoints::render(SkCanvas* canvas) const { | 511 bool SkDrawPointsCommand::render(SkCanvas* canvas) const { |
| 512 canvas->clear(0xFFFFFFFF); | 512 canvas->clear(0xFFFFFFFF); |
| 513 canvas->save(); | 513 canvas->save(); |
| 514 | 514 |
| 515 SkRect bounds; | 515 SkRect bounds; |
| 516 | 516 |
| 517 bounds.setEmpty(); | 517 bounds.setEmpty(); |
| 518 for (unsigned int i = 0; i < fCount; ++i) { | 518 for (unsigned int i = 0; i < fCount; ++i) { |
| 519 bounds.growToInclude(fPts[i].fX, fPts[i].fY); | 519 bounds.growToInclude(fPts[i].fX, fPts[i].fY); |
| 520 } | 520 } |
| 521 | 521 |
| 522 xlate_and_scale_to_bounds(canvas, bounds); | 522 xlate_and_scale_to_bounds(canvas, bounds); |
| 523 | 523 |
| 524 SkPaint p; | 524 SkPaint p; |
| 525 p.setColor(SK_ColorBLACK); | 525 p.setColor(SK_ColorBLACK); |
| 526 p.setStyle(SkPaint::kStroke_Style); | 526 p.setStyle(SkPaint::kStroke_Style); |
| 527 | 527 |
| 528 canvas->drawPoints(fMode, fCount, fPts, p); | 528 canvas->drawPoints(fMode, fCount, fPts, p); |
| 529 canvas->restore(); | 529 canvas->restore(); |
| 530 | 530 |
| 531 return true; | 531 return true; |
| 532 } | 532 } |
| 533 | 533 |
| 534 DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[
], | 534 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, |
| 535 const SkPaint& paint) { | 535 const SkPoint pos[], const SkPaint& p
aint) { |
| 536 size_t numPts = paint.countText(text, byteLength); | 536 size_t numPts = paint.countText(text, byteLength); |
| 537 | 537 |
| 538 fText = new char[byteLength]; | 538 fText = new char[byteLength]; |
| 539 memcpy(fText, text, byteLength); | 539 memcpy(fText, text, byteLength); |
| 540 fByteLength = byteLength; | 540 fByteLength = byteLength; |
| 541 | 541 |
| 542 fPos = new SkPoint[numPts]; | 542 fPos = new SkPoint[numPts]; |
| 543 memcpy(fPos, pos, numPts * sizeof(SkPoint)); | 543 memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
| 544 | 544 |
| 545 fPaint = paint; | 545 fPaint = paint; |
| 546 fDrawType = DRAW_POS_TEXT; | 546 fDrawType = DRAW_POS_TEXT; |
| 547 | 547 |
| 548 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 548 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 549 // TODO(chudy): Test that this works. | 549 // TODO(chudy): Test that this works. |
| 550 fInfo.push(SkObjectParser::PointsToString(pos, 1)); | 550 fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 551 fInfo.push(SkObjectParser::PaintToString(paint)); | 551 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 552 } | 552 } |
| 553 | 553 |
| 554 void DrawPosText::execute(SkCanvas* canvas) { | 554 void SkDrawPosTextCommand::execute(SkCanvas* canvas) { |
| 555 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 555 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
| 556 } | 556 } |
| 557 | 557 |
| 558 | 558 |
| 559 DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength, | 559 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, |
| 560 const SkScalar xpos[], SkScalar constY, | 560 const SkScalar xpos[], SkScalar con
stY, |
| 561 const SkPaint& paint) { | 561 const SkPaint& paint) { |
| 562 size_t numPts = paint.countText(text, byteLength); | 562 size_t numPts = paint.countText(text, byteLength); |
| 563 | 563 |
| 564 fText = new char[byteLength]; | 564 fText = new char[byteLength]; |
| 565 memcpy(fText, text, byteLength); | 565 memcpy(fText, text, byteLength); |
| 566 fByteLength = byteLength; | 566 fByteLength = byteLength; |
| 567 | 567 |
| 568 fXpos = new SkScalar[numPts]; | 568 fXpos = new SkScalar[numPts]; |
| 569 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); | 569 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
| 570 | 570 |
| 571 fConstY = constY; | 571 fConstY = constY; |
| 572 fPaint = paint; | 572 fPaint = paint; |
| 573 fDrawType = DRAW_POS_TEXT_H; | 573 fDrawType = DRAW_POS_TEXT_H; |
| 574 | 574 |
| 575 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 575 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 576 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); | 576 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 577 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); | 577 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 578 fInfo.push(SkObjectParser::PaintToString(paint)); | 578 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void DrawPosTextH::execute(SkCanvas* canvas) { | 581 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) { |
| 582 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); | 582 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
| 583 } | 583 } |
| 584 | 584 |
| 585 DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) { | 585 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) { |
| 586 fRect = rect; | 586 fRect = rect; |
| 587 fPaint = paint; | 587 fPaint = paint; |
| 588 fDrawType = DRAW_RECT; | 588 fDrawType = DRAW_RECT; |
| 589 | 589 |
| 590 fInfo.push(SkObjectParser::RectToString(rect)); | 590 fInfo.push(SkObjectParser::RectToString(rect)); |
| 591 fInfo.push(SkObjectParser::PaintToString(paint)); | 591 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void DrawRectC::execute(SkCanvas* canvas) { | 594 void SkDrawRectCommand::execute(SkCanvas* canvas) { |
| 595 canvas->drawRect(fRect, fPaint); | 595 canvas->drawRect(fRect, fPaint); |
| 596 } | 596 } |
| 597 | 597 |
| 598 DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) { | 598 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) { |
| 599 fRRect = rrect; | 599 fRRect = rrect; |
| 600 fPaint = paint; | 600 fPaint = paint; |
| 601 fDrawType = DRAW_RRECT; | 601 fDrawType = DRAW_RRECT; |
| 602 | 602 |
| 603 fInfo.push(SkObjectParser::RRectToString(rrect)); | 603 fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 604 fInfo.push(SkObjectParser::PaintToString(paint)); | 604 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 605 } | 605 } |
| 606 | 606 |
| 607 void DrawRRect::execute(SkCanvas* canvas) { | 607 void SkDrawRRectCommand::execute(SkCanvas* canvas) { |
| 608 canvas->drawRRect(fRRect, fPaint); | 608 canvas->drawRRect(fRRect, fPaint); |
| 609 } | 609 } |
| 610 | 610 |
| 611 bool DrawRRect::render(SkCanvas* canvas) const { | 611 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
| 612 render_rrect(canvas, fRRect); | 612 render_rrect(canvas, fRRect); |
| 613 return true; | 613 return true; |
| 614 } | 614 } |
| 615 | 615 |
| 616 DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top, | 616 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
| 617 const SkPaint* paint) { | 617 const SkPaint* paint) { |
| 618 fBitmap = bitmap; | 618 fBitmap = bitmap; |
| 619 fLeft = left; | 619 fLeft = left; |
| 620 fTop = top; | 620 fTop = top; |
| 621 if (NULL != paint) { | 621 if (NULL != paint) { |
| 622 fPaint = *paint; | 622 fPaint = *paint; |
| 623 fPaintPtr = &fPaint; | 623 fPaintPtr = &fPaint; |
| 624 } else { | 624 } else { |
| 625 fPaintPtr = NULL; | 625 fPaintPtr = NULL; |
| 626 } | 626 } |
| 627 fDrawType = DRAW_SPRITE; | 627 fDrawType = DRAW_SPRITE; |
| 628 | 628 |
| 629 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 629 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 630 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); | 630 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 631 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); | 631 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
| 632 if (NULL != paint) { | 632 if (NULL != paint) { |
| 633 fInfo.push(SkObjectParser::PaintToString(*paint)); | 633 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 | 636 |
| 637 void DrawSprite::execute(SkCanvas* canvas) { | 637 void SkDrawSpriteCommand::execute(SkCanvas* canvas) { |
| 638 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); | 638 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
| 639 } | 639 } |
| 640 | 640 |
| 641 bool DrawSprite::render(SkCanvas* canvas) const { | 641 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
| 642 render_bitmap(canvas, fBitmap); | 642 render_bitmap(canvas, fBitmap); |
| 643 return true; | 643 return true; |
| 644 } | 644 } |
| 645 | 645 |
| 646 DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y
, | 646 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, |
| 647 const SkPaint& paint) { | 647 const SkPaint& paint) { |
| 648 fText = new char[byteLength]; | 648 fText = new char[byteLength]; |
| 649 memcpy(fText, text, byteLength); | 649 memcpy(fText, text, byteLength); |
| 650 fByteLength = byteLength; | 650 fByteLength = byteLength; |
| 651 fX = x; | 651 fX = x; |
| 652 fY = y; | 652 fY = y; |
| 653 fPaint = paint; | 653 fPaint = paint; |
| 654 fDrawType = DRAW_TEXT; | 654 fDrawType = DRAW_TEXT; |
| 655 | 655 |
| 656 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 656 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 657 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); | 657 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
| 658 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); | 658 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
| 659 fInfo.push(SkObjectParser::PaintToString(paint)); | 659 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 660 } | 660 } |
| 661 | 661 |
| 662 void DrawTextC::execute(SkCanvas* canvas) { | 662 void SkDrawTextCommand::execute(SkCanvas* canvas) { |
| 663 canvas->drawText(fText, fByteLength, fX, fY, fPaint); | 663 canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
| 664 } | 664 } |
| 665 | 665 |
| 666 DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength, | 666 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, |
| 667 const SkPath& path, const SkMatrix* matrix, | 667 const SkPath& path, const SkMat
rix* matrix, |
| 668 const SkPaint& paint) { | 668 const SkPaint& paint) { |
| 669 fText = new char[byteLength]; | 669 fText = new char[byteLength]; |
| 670 memcpy(fText, text, byteLength); | 670 memcpy(fText, text, byteLength); |
| 671 fByteLength = byteLength; | 671 fByteLength = byteLength; |
| 672 fPath = path; | 672 fPath = path; |
| 673 if (NULL != matrix) { | 673 if (NULL != matrix) { |
| 674 fMatrix = *matrix; | 674 fMatrix = *matrix; |
| 675 } else { | 675 } else { |
| 676 fMatrix.setIdentity(); | 676 fMatrix.setIdentity(); |
| 677 } | 677 } |
| 678 fPaint = paint; | 678 fPaint = paint; |
| 679 fDrawType = DRAW_TEXT_ON_PATH; | 679 fDrawType = DRAW_TEXT_ON_PATH; |
| 680 | 680 |
| 681 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 681 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 682 fInfo.push(SkObjectParser::PathToString(path)); | 682 fInfo.push(SkObjectParser::PathToString(path)); |
| 683 if (NULL != matrix) { | 683 if (NULL != matrix) { |
| 684 fInfo.push(SkObjectParser::MatrixToString(*matrix)); | 684 fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 685 } | 685 } |
| 686 fInfo.push(SkObjectParser::PaintToString(paint)); | 686 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 687 } | 687 } |
| 688 | 688 |
| 689 void DrawTextOnPath::execute(SkCanvas* canvas) { | 689 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) { |
| 690 canvas->drawTextOnPath(fText, fByteLength, fPath, | 690 canvas->drawTextOnPath(fText, fByteLength, fPath, |
| 691 fMatrix.isIdentity() ? NULL : &fMatrix, | 691 fMatrix.isIdentity() ? NULL : &fMatrix, |
| 692 fPaint); | 692 fPaint); |
| 693 } | 693 } |
| 694 | 694 |
| 695 DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, | 695 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, |
| 696 const SkPoint vertices[], const SkPoint texs[], | 696 const SkPoint vertices[], const SkP
oint texs[], |
| 697 const SkColor colors[], SkXfermode* xfermode, | 697 const SkColor colors[], SkXfermode*
xfermode, |
| 698 const uint16_t indices[], int indexCount, | 698 const uint16_t indices[], int index
Count, |
| 699 const SkPaint& paint) { | 699 const SkPaint& paint) { |
| 700 fVmode = vmode; | 700 fVmode = vmode; |
| 701 | 701 |
| 702 fVertexCount = vertexCount; | 702 fVertexCount = vertexCount; |
| 703 | 703 |
| 704 fVertices = new SkPoint[vertexCount]; | 704 fVertices = new SkPoint[vertexCount]; |
| 705 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); | 705 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
| 706 | 706 |
| 707 if (NULL != texs) { | 707 if (NULL != texs) { |
| 708 fTexs = new SkPoint[vertexCount]; | 708 fTexs = new SkPoint[vertexCount]; |
| 709 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); | 709 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 732 | 732 |
| 733 fIndexCount = indexCount; | 733 fIndexCount = indexCount; |
| 734 fPaint = paint; | 734 fPaint = paint; |
| 735 fDrawType = DRAW_VERTICES; | 735 fDrawType = DRAW_VERTICES; |
| 736 | 736 |
| 737 // TODO(chudy) | 737 // TODO(chudy) |
| 738 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); | 738 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
| 739 fInfo.push(SkObjectParser::PaintToString(paint)); | 739 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 740 } | 740 } |
| 741 | 741 |
| 742 DrawVertices::~DrawVertices() { | 742 SkDrawVerticesCommand::~SkDrawVerticesCommand() { |
| 743 delete [] fVertices; | 743 delete [] fVertices; |
| 744 delete [] fTexs; | 744 delete [] fTexs; |
| 745 delete [] fColors; | 745 delete [] fColors; |
| 746 SkSafeUnref(fXfermode); | 746 SkSafeUnref(fXfermode); |
| 747 delete [] fIndices; | 747 delete [] fIndices; |
| 748 } | 748 } |
| 749 | 749 |
| 750 void DrawVertices::execute(SkCanvas* canvas) { | 750 void SkDrawVerticesCommand::execute(SkCanvas* canvas) { |
| 751 canvas->drawVertices(fVmode, fVertexCount, fVertices, | 751 canvas->drawVertices(fVmode, fVertexCount, fVertices, |
| 752 fTexs, fColors, fXfermode, fIndices, | 752 fTexs, fColors, fXfermode, fIndices, |
| 753 fIndexCount, fPaint); | 753 fIndexCount, fPaint); |
| 754 } | 754 } |
| 755 | 755 |
| 756 Restore::Restore() { | 756 SkRestoreCommand::SkRestoreCommand() { |
| 757 fDrawType = RESTORE; | 757 fDrawType = RESTORE; |
| 758 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 758 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
| 759 } | 759 } |
| 760 | 760 |
| 761 void Restore::execute(SkCanvas* canvas) { | 761 void SkRestoreCommand::execute(SkCanvas* canvas) { |
| 762 canvas->restore(); | 762 canvas->restore(); |
| 763 } | 763 } |
| 764 | 764 |
| 765 void Restore::trackSaveState(int* state) { | 765 void SkRestoreCommand::trackSaveState(int* state) { |
| 766 (*state)--; | 766 (*state)--; |
| 767 } | 767 } |
| 768 | 768 |
| 769 Rotate::Rotate(SkScalar degrees) { | 769 SkRotateCommand::SkRotateCommand(SkScalar degrees) { |
| 770 fDegrees = degrees; | 770 fDegrees = degrees; |
| 771 fDrawType = ROTATE; | 771 fDrawType = ROTATE; |
| 772 | 772 |
| 773 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); | 773 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
| 774 } | 774 } |
| 775 | 775 |
| 776 void Rotate::execute(SkCanvas* canvas) { | 776 void SkRotateCommand::execute(SkCanvas* canvas) { |
| 777 canvas->rotate(fDegrees); | 777 canvas->rotate(fDegrees); |
| 778 } | 778 } |
| 779 | 779 |
| 780 Save::Save(SkCanvas::SaveFlags flags) { | 780 SkSaveCommand::SkSaveCommand(SkCanvas::SaveFlags flags) { |
| 781 fFlags = flags; | 781 fFlags = flags; |
| 782 fDrawType = SAVE; | 782 fDrawType = SAVE; |
| 783 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); | 783 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
| 784 } | 784 } |
| 785 | 785 |
| 786 void Save::execute(SkCanvas* canvas) { | 786 void SkSaveCommand::execute(SkCanvas* canvas) { |
| 787 canvas->save(fFlags); | 787 canvas->save(fFlags); |
| 788 } | 788 } |
| 789 | 789 |
| 790 void Save::trackSaveState(int* state) { | 790 void SkSaveCommand::trackSaveState(int* state) { |
| 791 (*state)++; | 791 (*state)++; |
| 792 } | 792 } |
| 793 | 793 |
| 794 SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint, | 794 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, |
| 795 SkCanvas::SaveFlags flags) { | 795 SkCanvas::SaveFlags flags) { |
| 796 if (NULL != bounds) { | 796 if (NULL != bounds) { |
| 797 fBounds = *bounds; | 797 fBounds = *bounds; |
| 798 } else { | 798 } else { |
| 799 fBounds.setEmpty(); | 799 fBounds.setEmpty(); |
| 800 } | 800 } |
| 801 | 801 |
| 802 if (NULL != paint) { | 802 if (NULL != paint) { |
| 803 fPaint = *paint; | 803 fPaint = *paint; |
| 804 fPaintPtr = &fPaint; | 804 fPaintPtr = &fPaint; |
| 805 } else { | 805 } else { |
| 806 fPaintPtr = NULL; | 806 fPaintPtr = NULL; |
| 807 } | 807 } |
| 808 fFlags = flags; | 808 fFlags = flags; |
| 809 fDrawType = SAVE_LAYER; | 809 fDrawType = SAVE_LAYER; |
| 810 | 810 |
| 811 if (NULL != bounds) { | 811 if (NULL != bounds) { |
| 812 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); | 812 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
| 813 } | 813 } |
| 814 if (NULL != paint) { | 814 if (NULL != paint) { |
| 815 fInfo.push(SkObjectParser::PaintToString(*paint)); | 815 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 816 } | 816 } |
| 817 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); | 817 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
| 818 } | 818 } |
| 819 | 819 |
| 820 void SaveLayer::execute(SkCanvas* canvas) { | 820 void SkSaveLayerCommand::execute(SkCanvas* canvas) { |
| 821 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, | 821 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
| 822 fPaintPtr, | 822 fPaintPtr, |
| 823 fFlags); | 823 fFlags); |
| 824 } | 824 } |
| 825 | 825 |
| 826 void SaveLayer::trackSaveState(int* state) { | 826 void SkSaveLayerCommand::trackSaveState(int* state) { |
| 827 (*state)++; | 827 (*state)++; |
| 828 } | 828 } |
| 829 | 829 |
| 830 Scale::Scale(SkScalar sx, SkScalar sy) { | 830 SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) { |
| 831 fSx = sx; | 831 fSx = sx; |
| 832 fSy = sy; | 832 fSy = sy; |
| 833 fDrawType = SCALE; | 833 fDrawType = SCALE; |
| 834 | 834 |
| 835 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); | 835 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 836 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); | 836 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
| 837 } | 837 } |
| 838 | 838 |
| 839 void Scale::execute(SkCanvas* canvas) { | 839 void SkScaleCommand::execute(SkCanvas* canvas) { |
| 840 canvas->scale(fSx, fSy); | 840 canvas->scale(fSx, fSy); |
| 841 } | 841 } |
| 842 | 842 |
| 843 SetMatrix::SetMatrix(const SkMatrix& matrix) { | 843 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) { |
| 844 fMatrix = matrix; | 844 fMatrix = matrix; |
| 845 fDrawType = SET_MATRIX; | 845 fDrawType = SET_MATRIX; |
| 846 | 846 |
| 847 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 847 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 848 } | 848 } |
| 849 | 849 |
| 850 void SetMatrix::execute(SkCanvas* canvas) { | 850 void SkSetMatrixCommand::execute(SkCanvas* canvas) { |
| 851 canvas->setMatrix(fMatrix); | 851 canvas->setMatrix(fMatrix); |
| 852 } | 852 } |
| 853 | 853 |
| 854 Skew::Skew(SkScalar sx, SkScalar sy) { | 854 SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) { |
| 855 fSx = sx; | 855 fSx = sx; |
| 856 fSy = sy; | 856 fSy = sy; |
| 857 fDrawType = SKEW; | 857 fDrawType = SKEW; |
| 858 | 858 |
| 859 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); | 859 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 860 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); | 860 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
| 861 } | 861 } |
| 862 | 862 |
| 863 void Skew::execute(SkCanvas* canvas) { | 863 void SkSkewCommand::execute(SkCanvas* canvas) { |
| 864 canvas->skew(fSx, fSy); | 864 canvas->skew(fSx, fSy); |
| 865 } | 865 } |
| 866 | 866 |
| 867 Translate::Translate(SkScalar dx, SkScalar dy) { | 867 SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) { |
| 868 fDx = dx; | 868 fDx = dx; |
| 869 fDy = dy; | 869 fDy = dy; |
| 870 fDrawType = TRANSLATE; | 870 fDrawType = TRANSLATE; |
| 871 | 871 |
| 872 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); | 872 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 873 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); | 873 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
| 874 } | 874 } |
| 875 | 875 |
| 876 void Translate::execute(SkCanvas* canvas) { | 876 void SkTranslateCommand::execute(SkCanvas* canvas) { |
| 877 canvas->translate(fDx, fDy); | 877 canvas->translate(fDx, fDy); |
| 878 } | 878 } |
| OLD | NEW |