| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 xScale *= input.width() / (float) input.height(); | 141 xScale *= input.width() / (float) input.height(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1, | 144 SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1, |
| 145 xScale * input.width(), | 145 xScale * input.width(), |
| 146 yScale * input.height()); | 146 yScale * input.height()); |
| 147 | 147 |
| 148 canvas->clear(0xFFFFFFFF); | 148 canvas->clear(0xFFFFFFFF); |
| 149 canvas->drawBitmapRect(input, NULL, dst); | 149 canvas->drawBitmapRect(input, NULL, dst); |
| 150 | 150 |
| 151 if (NULL != srcRect) { | 151 if (srcRect) { |
| 152 SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1, | 152 SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1, |
| 153 srcRect->fTop * yScale + SK_Scalar1, | 153 srcRect->fTop * yScale + SK_Scalar1, |
| 154 srcRect->fRight * xScale + SK_Scalar1, | 154 srcRect->fRight * xScale + SK_Scalar1, |
| 155 srcRect->fBottom * yScale + SK_Scalar1); | 155 srcRect->fBottom * yScale + SK_Scalar1); |
| 156 SkPaint p; | 156 SkPaint p; |
| 157 p.setColor(SK_ColorRED); | 157 p.setColor(SK_ColorRED); |
| 158 p.setStyle(SkPaint::kStroke_Style); | 158 p.setStyle(SkPaint::kStroke_Style); |
| 159 | 159 |
| 160 canvas->drawRect(r, p); | 160 canvas->drawRect(r, p); |
| 161 } | 161 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void SkConcatCommand::execute(SkCanvas* canvas) { | 274 void SkConcatCommand::execute(SkCanvas* canvas) { |
| 275 canvas->concat(fMatrix); | 275 canvas->concat(fMatrix); |
| 276 } | 276 } |
| 277 | 277 |
| 278 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, | 278 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
| 279 const SkPaint* paint) | 279 const SkPaint* paint) |
| 280 : INHERITED(DRAW_BITMAP) { | 280 : INHERITED(DRAW_BITMAP) { |
| 281 fBitmap = bitmap; | 281 fBitmap = bitmap; |
| 282 fLeft = left; | 282 fLeft = left; |
| 283 fTop = top; | 283 fTop = top; |
| 284 if (NULL != paint) { | 284 if (paint) { |
| 285 fPaint = *paint; | 285 fPaint = *paint; |
| 286 fPaintPtr = &fPaint; | 286 fPaintPtr = &fPaint; |
| 287 } else { | 287 } else { |
| 288 fPaintPtr = NULL; | 288 fPaintPtr = NULL; |
| 289 } | 289 } |
| 290 | 290 |
| 291 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 291 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 292 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); | 292 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 293 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); | 293 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
| 294 if (NULL != paint) { | 294 if (paint) { |
| 295 fInfo.push(SkObjectParser::PaintToString(*paint)); | 295 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 void SkDrawBitmapCommand::execute(SkCanvas* canvas) { | 299 void SkDrawBitmapCommand::execute(SkCanvas* canvas) { |
| 300 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); | 300 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
| 301 } | 301 } |
| 302 | 302 |
| 303 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { | 303 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
| 304 render_bitmap(canvas, fBitmap); | 304 render_bitmap(canvas, fBitmap); |
| 305 return true; | 305 return true; |
| 306 } | 306 } |
| 307 | 307 |
| 308 SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, | 308 SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, |
| 309 const SkMatrix& matrix, | 309 const SkMatrix& matrix, |
| 310 const SkPaint* paint) | 310 const SkPaint* paint) |
| 311 : INHERITED(DRAW_BITMAP_MATRIX) { | 311 : INHERITED(DRAW_BITMAP_MATRIX) { |
| 312 fBitmap = bitmap; | 312 fBitmap = bitmap; |
| 313 fMatrix = matrix; | 313 fMatrix = matrix; |
| 314 if (NULL != paint) { | 314 if (paint) { |
| 315 fPaint = *paint; | 315 fPaint = *paint; |
| 316 fPaintPtr = &fPaint; | 316 fPaintPtr = &fPaint; |
| 317 } else { | 317 } else { |
| 318 fPaintPtr = NULL; | 318 fPaintPtr = NULL; |
| 319 } | 319 } |
| 320 | 320 |
| 321 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 321 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 322 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 322 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 323 if (NULL != paint) { | 323 if (paint) { |
| 324 fInfo.push(SkObjectParser::PaintToString(*paint)); | 324 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) { | 328 void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) { |
| 329 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); | 329 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { | 332 bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { |
| 333 render_bitmap(canvas, fBitmap); | 333 render_bitmap(canvas, fBitmap); |
| 334 return true; | 334 return true; |
| 335 } | 335 } |
| 336 | 336 |
| 337 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, | 337 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, |
| 338 const SkRect& dst, const SkPain
t* paint) | 338 const SkRect& dst, const SkPain
t* paint) |
| 339 : INHERITED(DRAW_BITMAP_NINE) { | 339 : INHERITED(DRAW_BITMAP_NINE) { |
| 340 fBitmap = bitmap; | 340 fBitmap = bitmap; |
| 341 fCenter = center; | 341 fCenter = center; |
| 342 fDst = dst; | 342 fDst = dst; |
| 343 if (NULL != paint) { | 343 if (paint) { |
| 344 fPaint = *paint; | 344 fPaint = *paint; |
| 345 fPaintPtr = &fPaint; | 345 fPaintPtr = &fPaint; |
| 346 } else { | 346 } else { |
| 347 fPaintPtr = NULL; | 347 fPaintPtr = NULL; |
| 348 } | 348 } |
| 349 | 349 |
| 350 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 350 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 351 fInfo.push(SkObjectParser::IRectToString(center)); | 351 fInfo.push(SkObjectParser::IRectToString(center)); |
| 352 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 352 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 353 if (NULL != paint) { | 353 if (paint) { |
| 354 fInfo.push(SkObjectParser::PaintToString(*paint)); | 354 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) { | 358 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) { |
| 359 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); | 359 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); |
| 360 } | 360 } |
| 361 | 361 |
| 362 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { | 362 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
| 363 render_bitmap(canvas, fBitmap); | 363 render_bitmap(canvas, fBitmap); |
| 364 return true; | 364 return true; |
| 365 } | 365 } |
| 366 | 366 |
| 367 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, | 367 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, |
| 368 const SkRect& dst, const SkPain
t* paint, | 368 const SkRect& dst, const SkPain
t* paint, |
| 369 SkCanvas::DrawBitmapRectFlags f
lags) | 369 SkCanvas::DrawBitmapRectFlags f
lags) |
| 370 : INHERITED(DRAW_BITMAP_RECT_TO_RECT) { | 370 : INHERITED(DRAW_BITMAP_RECT_TO_RECT) { |
| 371 fBitmap = bitmap; | 371 fBitmap = bitmap; |
| 372 if (NULL != src) { | 372 if (src) { |
| 373 fSrc = *src; | 373 fSrc = *src; |
| 374 } else { | 374 } else { |
| 375 fSrc.setEmpty(); | 375 fSrc.setEmpty(); |
| 376 } | 376 } |
| 377 fDst = dst; | 377 fDst = dst; |
| 378 | 378 |
| 379 if (NULL != paint) { | 379 if (paint) { |
| 380 fPaint = *paint; | 380 fPaint = *paint; |
| 381 fPaintPtr = &fPaint; | 381 fPaintPtr = &fPaint; |
| 382 } else { | 382 } else { |
| 383 fPaintPtr = NULL; | 383 fPaintPtr = NULL; |
| 384 } | 384 } |
| 385 fFlags = flags; | 385 fFlags = flags; |
| 386 | 386 |
| 387 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 387 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 388 if (NULL != src) { | 388 if (src) { |
| 389 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); | 389 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 390 } | 390 } |
| 391 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 391 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 392 if (NULL != paint) { | 392 if (paint) { |
| 393 fInfo.push(SkObjectParser::PaintToString(*paint)); | 393 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 394 } | 394 } |
| 395 fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: ")); | 395 fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: ")); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) { | 398 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) { |
| 399 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); | 399 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); |
| 400 } | 400 } |
| 401 | 401 |
| 402 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { | 402 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 506 } |
| 507 | 507 |
| 508 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, | 508 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, |
| 509 const SkMatrix* matrix, | 509 const SkMatrix* matrix, |
| 510 const SkPaint* paint) | 510 const SkPaint* paint) |
| 511 : INHERITED(DRAW_PICTURE) | 511 : INHERITED(DRAW_PICTURE) |
| 512 , fPicture(SkRef(picture)) | 512 , fPicture(SkRef(picture)) |
| 513 , fMatrixPtr(NULL) | 513 , fMatrixPtr(NULL) |
| 514 , fPaintPtr(NULL) { | 514 , fPaintPtr(NULL) { |
| 515 | 515 |
| 516 if (NULL != matrix) { | 516 if (matrix) { |
| 517 fMatrix = *matrix; | 517 fMatrix = *matrix; |
| 518 fMatrixPtr = &fMatrix; | 518 fMatrixPtr = &fMatrix; |
| 519 } | 519 } |
| 520 if (NULL != paint) { | 520 if (paint) { |
| 521 fPaint = *paint; | 521 fPaint = *paint; |
| 522 fPaintPtr = &fPaint; | 522 fPaintPtr = &fPaint; |
| 523 } | 523 } |
| 524 | 524 |
| 525 SkString* temp = new SkString; | 525 SkString* temp = new SkString; |
| 526 temp->appendf("SkPicture: L: %f T: %f R: %f B: %f", | 526 temp->appendf("SkPicture: L: %f T: %f R: %f B: %f", |
| 527 picture->cullRect().fLeft, picture->cullRect().fTop, | 527 picture->cullRect().fLeft, picture->cullRect().fTop, |
| 528 picture->cullRect().fRight, picture->cullRect().fBottom); | 528 picture->cullRect().fRight, picture->cullRect().fBottom); |
| 529 fInfo.push(temp); | 529 fInfo.push(temp); |
| 530 if (NULL != matrix) { | 530 if (matrix) { |
| 531 fInfo.push(SkObjectParser::MatrixToString(*matrix)); | 531 fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 532 } | 532 } |
| 533 if (NULL != paint) { | 533 if (paint) { |
| 534 fInfo.push(SkObjectParser::PaintToString(*paint)); | 534 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 | 537 |
| 538 void SkDrawPictureCommand::execute(SkCanvas* canvas) { | 538 void SkDrawPictureCommand::execute(SkCanvas* canvas) { |
| 539 canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr); | 539 canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr); |
| 540 } | 540 } |
| 541 | 541 |
| 542 bool SkDrawPictureCommand::render(SkCanvas* canvas) const { | 542 bool SkDrawPictureCommand::render(SkCanvas* canvas) const { |
| 543 canvas->clear(0xFFFFFFFF); | 543 canvas->clear(0xFFFFFFFF); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 render_drrect(canvas, fOuter, fInner); | 732 render_drrect(canvas, fOuter, fInner); |
| 733 return true; | 733 return true; |
| 734 } | 734 } |
| 735 | 735 |
| 736 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, | 736 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
| 737 const SkPaint* paint) | 737 const SkPaint* paint) |
| 738 : INHERITED(DRAW_SPRITE) { | 738 : INHERITED(DRAW_SPRITE) { |
| 739 fBitmap = bitmap; | 739 fBitmap = bitmap; |
| 740 fLeft = left; | 740 fLeft = left; |
| 741 fTop = top; | 741 fTop = top; |
| 742 if (NULL != paint) { | 742 if (paint) { |
| 743 fPaint = *paint; | 743 fPaint = *paint; |
| 744 fPaintPtr = &fPaint; | 744 fPaintPtr = &fPaint; |
| 745 } else { | 745 } else { |
| 746 fPaintPtr = NULL; | 746 fPaintPtr = NULL; |
| 747 } | 747 } |
| 748 | 748 |
| 749 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 749 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 750 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); | 750 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 751 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); | 751 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
| 752 if (NULL != paint) { | 752 if (paint) { |
| 753 fInfo.push(SkObjectParser::PaintToString(*paint)); | 753 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 754 } | 754 } |
| 755 } | 755 } |
| 756 | 756 |
| 757 void SkDrawSpriteCommand::execute(SkCanvas* canvas) { | 757 void SkDrawSpriteCommand::execute(SkCanvas* canvas) { |
| 758 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); | 758 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
| 759 } | 759 } |
| 760 | 760 |
| 761 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { | 761 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
| 762 render_bitmap(canvas, fBitmap); | 762 render_bitmap(canvas, fBitmap); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 784 } | 784 } |
| 785 | 785 |
| 786 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, | 786 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, |
| 787 const SkPath& path, const SkMat
rix* matrix, | 787 const SkPath& path, const SkMat
rix* matrix, |
| 788 const SkPaint& paint) | 788 const SkPaint& paint) |
| 789 : INHERITED(DRAW_TEXT_ON_PATH) { | 789 : INHERITED(DRAW_TEXT_ON_PATH) { |
| 790 fText = new char[byteLength]; | 790 fText = new char[byteLength]; |
| 791 memcpy(fText, text, byteLength); | 791 memcpy(fText, text, byteLength); |
| 792 fByteLength = byteLength; | 792 fByteLength = byteLength; |
| 793 fPath = path; | 793 fPath = path; |
| 794 if (NULL != matrix) { | 794 if (matrix) { |
| 795 fMatrix = *matrix; | 795 fMatrix = *matrix; |
| 796 } else { | 796 } else { |
| 797 fMatrix.setIdentity(); | 797 fMatrix.setIdentity(); |
| 798 } | 798 } |
| 799 fPaint = paint; | 799 fPaint = paint; |
| 800 | 800 |
| 801 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 801 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 802 fInfo.push(SkObjectParser::PathToString(path)); | 802 fInfo.push(SkObjectParser::PathToString(path)); |
| 803 if (NULL != matrix) { | 803 if (matrix) { |
| 804 fInfo.push(SkObjectParser::MatrixToString(*matrix)); | 804 fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 805 } | 805 } |
| 806 fInfo.push(SkObjectParser::PaintToString(paint)); | 806 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 807 } | 807 } |
| 808 | 808 |
| 809 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) { | 809 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) { |
| 810 canvas->drawTextOnPath(fText, fByteLength, fPath, | 810 canvas->drawTextOnPath(fText, fByteLength, fPath, |
| 811 fMatrix.isIdentity() ? NULL : &fMatrix, | 811 fMatrix.isIdentity() ? NULL : &fMatrix, |
| 812 fPaint); | 812 fPaint); |
| 813 } | 813 } |
| 814 | 814 |
| 815 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, | 815 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, |
| 816 const SkPoint vertices[], const SkP
oint texs[], | 816 const SkPoint vertices[], const SkP
oint texs[], |
| 817 const SkColor colors[], SkXfermode*
xfermode, | 817 const SkColor colors[], SkXfermode*
xfermode, |
| 818 const uint16_t indices[], int index
Count, | 818 const uint16_t indices[], int index
Count, |
| 819 const SkPaint& paint) | 819 const SkPaint& paint) |
| 820 : INHERITED(DRAW_VERTICES) { | 820 : INHERITED(DRAW_VERTICES) { |
| 821 fVmode = vmode; | 821 fVmode = vmode; |
| 822 | 822 |
| 823 fVertexCount = vertexCount; | 823 fVertexCount = vertexCount; |
| 824 | 824 |
| 825 fVertices = new SkPoint[vertexCount]; | 825 fVertices = new SkPoint[vertexCount]; |
| 826 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); | 826 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
| 827 | 827 |
| 828 if (NULL != texs) { | 828 if (texs) { |
| 829 fTexs = new SkPoint[vertexCount]; | 829 fTexs = new SkPoint[vertexCount]; |
| 830 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); | 830 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
| 831 } else { | 831 } else { |
| 832 fTexs = NULL; | 832 fTexs = NULL; |
| 833 } | 833 } |
| 834 | 834 |
| 835 if (NULL != colors) { | 835 if (colors) { |
| 836 fColors = new SkColor[vertexCount]; | 836 fColors = new SkColor[vertexCount]; |
| 837 memcpy(fColors, colors, vertexCount * sizeof(SkColor)); | 837 memcpy(fColors, colors, vertexCount * sizeof(SkColor)); |
| 838 } else { | 838 } else { |
| 839 fColors = NULL; | 839 fColors = NULL; |
| 840 } | 840 } |
| 841 | 841 |
| 842 fXfermode = xfermode; | 842 fXfermode = xfermode; |
| 843 if (NULL != fXfermode) { | 843 if (fXfermode) { |
| 844 fXfermode->ref(); | 844 fXfermode->ref(); |
| 845 } | 845 } |
| 846 | 846 |
| 847 if (indexCount > 0) { | 847 if (indexCount > 0) { |
| 848 fIndices = new uint16_t[indexCount]; | 848 fIndices = new uint16_t[indexCount]; |
| 849 memcpy(fIndices, indices, indexCount * sizeof(uint16_t)); | 849 memcpy(fIndices, indices, indexCount * sizeof(uint16_t)); |
| 850 } else { | 850 } else { |
| 851 fIndices = NULL; | 851 fIndices = NULL; |
| 852 } | 852 } |
| 853 | 853 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 canvas->save(); | 905 canvas->save(); |
| 906 } | 906 } |
| 907 | 907 |
| 908 void SkSaveCommand::trackSaveState(int* state) { | 908 void SkSaveCommand::trackSaveState(int* state) { |
| 909 (*state)++; | 909 (*state)++; |
| 910 } | 910 } |
| 911 | 911 |
| 912 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, | 912 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, |
| 913 SkCanvas::SaveFlags flags) | 913 SkCanvas::SaveFlags flags) |
| 914 : INHERITED(SAVE_LAYER) { | 914 : INHERITED(SAVE_LAYER) { |
| 915 if (NULL != bounds) { | 915 if (bounds) { |
| 916 fBounds = *bounds; | 916 fBounds = *bounds; |
| 917 } else { | 917 } else { |
| 918 fBounds.setEmpty(); | 918 fBounds.setEmpty(); |
| 919 } | 919 } |
| 920 | 920 |
| 921 if (NULL != paint) { | 921 if (paint) { |
| 922 fPaint = *paint; | 922 fPaint = *paint; |
| 923 fPaintPtr = &fPaint; | 923 fPaintPtr = &fPaint; |
| 924 } else { | 924 } else { |
| 925 fPaintPtr = NULL; | 925 fPaintPtr = NULL; |
| 926 } | 926 } |
| 927 fFlags = flags; | 927 fFlags = flags; |
| 928 | 928 |
| 929 if (NULL != bounds) { | 929 if (bounds) { |
| 930 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); | 930 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
| 931 } | 931 } |
| 932 if (NULL != paint) { | 932 if (paint) { |
| 933 fInfo.push(SkObjectParser::PaintToString(*paint)); | 933 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 934 } | 934 } |
| 935 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); | 935 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
| 936 } | 936 } |
| 937 | 937 |
| 938 void SkSaveLayerCommand::execute(SkCanvas* canvas) { | 938 void SkSaveLayerCommand::execute(SkCanvas* canvas) { |
| 939 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, | 939 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
| 940 fPaintPtr, | 940 fPaintPtr, |
| 941 fFlags); | 941 fFlags); |
| 942 } | 942 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 p.setColor(SK_ColorCYAN); | 1016 p.setColor(SK_ColorCYAN); |
| 1017 p.setStyle(SkPaint::kStroke_Style); | 1017 p.setStyle(SkPaint::kStroke_Style); |
| 1018 canvas->drawRect(fCullRect, p); | 1018 canvas->drawRect(fCullRect, p); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { } | 1021 SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { } |
| 1022 | 1022 |
| 1023 void SkPopCullCommand::execute(SkCanvas* canvas) { | 1023 void SkPopCullCommand::execute(SkCanvas* canvas) { |
| 1024 canvas->popCull(); | 1024 canvas->popCull(); |
| 1025 } | 1025 } |
| OLD | NEW |