| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkLayerInfo.h" | 8 #include "SkLayerInfo.h" |
| 9 #include "SkRecordDraw.h" | 9 #include "SkRecordDraw.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 DRAW(DrawBitmapRectToRectBleed, | 110 DRAW(DrawBitmapRectToRectBleed, |
| 111 drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, | 111 drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, |
| 112 SkCanvas::kBleed_DrawBitmapRectFlag)); | 112 SkCanvas::kBleed_DrawBitmapRectFlag)); |
| 113 DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); | 113 DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); |
| 114 DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); | 114 DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); |
| 115 DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint)); | 115 DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint)); |
| 116 DRAW(DrawOval, drawOval(r.oval, r.paint)); | 116 DRAW(DrawOval, drawOval(r.oval, r.paint)); |
| 117 DRAW(DrawPaint, drawPaint(r.paint)); | 117 DRAW(DrawPaint, drawPaint(r.paint)); |
| 118 DRAW(DrawPath, drawPath(r.path, r.paint)); | 118 DRAW(DrawPath, drawPath(r.path, r.paint)); |
| 119 DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); | 119 DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); |
| 120 DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint)); | 120 DRAW(DrawPicture, drawPicture(r.picture, &r.matrix, r.paint)); |
| 121 DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); | 121 DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); |
| 122 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); | 122 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); |
| 123 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); | 123 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); |
| 124 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); | 124 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); |
| 125 DRAW(DrawRect, drawRect(r.rect, r.paint)); | 125 DRAW(DrawRect, drawRect(r.rect, r.paint)); |
| 126 DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); | 126 DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); |
| 127 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); | 127 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); |
| 128 DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); | 128 DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); |
| 129 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.pa
int)); | 129 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.p
aint)); |
| 130 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
lors, | 130 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
lors, |
| 131 r.xmode.get(), r.indices, r.indexCount, r.paint)
); | 131 r.xmode.get(), r.indices, r.indexCount, r.paint)
); |
| 132 DRAW(DrawData, drawData(r.data, r.length)); | 132 DRAW(DrawData, drawData(r.data, r.length)); |
| 133 #undef DRAW | 133 #undef DRAW |
| 134 | 134 |
| 135 template <> void Draw::draw(const DrawDrawable& r) { | 135 template <> void Draw::draw(const DrawDrawable& r) { |
| 136 SkASSERT(r.index >= 0); | 136 SkASSERT(r.index >= 0); |
| 137 SkASSERT(r.index < fDrawableCount); | 137 SkASSERT(r.index < fDrawableCount); |
| 138 if (fDrawables) { | 138 if (fDrawables) { |
| 139 SkASSERT(NULL == fDrawablePicts); | 139 SkASSERT(NULL == fDrawablePicts); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 // FIXME: this method could use better bounds | 398 // FIXME: this method could use better bounds |
| 399 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } | 399 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } |
| 400 | 400 |
| 401 Bounds bounds(const Clear&) const { return fCullRect; } // Ignor
es the clip. | 401 Bounds bounds(const Clear&) const { return fCullRect; } // Ignor
es the clip. |
| 402 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } | 402 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } |
| 403 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp
s don't draw. | 403 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp
s don't draw. |
| 404 | 404 |
| 405 Bounds bounds(const DrawSprite& op) const { | 405 Bounds bounds(const DrawSprite& op) const { // Ignores the matrix. |
| 406 const SkBitmap& bm = op.bitmap; | 406 return Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.he
ight()); |
| 407 return Bounds::MakeXYWH(op.left, op.top, bm.width(), bm.height()); // I
gnores the matrix. | |
| 408 } | 407 } |
| 409 | 408 |
| 410 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect,
&op.paint); } | 409 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect,
&op.paint); } |
| 411 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval,
&op.paint); } | 410 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval,
&op.paint); } |
| 412 Bounds bounds(const DrawRRect& op) const { | 411 Bounds bounds(const DrawRRect& op) const { |
| 413 return this->adjustAndMap(op.rrect.rect(), &op.paint); | 412 return this->adjustAndMap(op.rrect.rect(), &op.paint); |
| 414 } | 413 } |
| 415 Bounds bounds(const DrawDRRect& op) const { | 414 Bounds bounds(const DrawDRRect& op) const { |
| 416 return this->adjustAndMap(op.outer.rect(), &op.paint); | 415 return this->adjustAndMap(op.outer.rect(), &op.paint); |
| 417 } | 416 } |
| 418 Bounds bounds(const DrawImage& op) const { | 417 Bounds bounds(const DrawImage& op) const { |
| 419 const SkImage* image = op.image; | 418 const SkImage* image = op.image; |
| 420 SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->h
eight()); | 419 SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->h
eight()); |
| 421 | 420 |
| 422 return this->adjustAndMap(rect, op.paint); | 421 return this->adjustAndMap(rect, op.paint); |
| 423 } | 422 } |
| 424 Bounds bounds(const DrawImageRect& op) const { | 423 Bounds bounds(const DrawImageRect& op) const { |
| 425 return this->adjustAndMap(op.dst, op.paint); | 424 return this->adjustAndMap(op.dst, op.paint); |
| 426 } | 425 } |
| 427 Bounds bounds(const DrawBitmapRectToRect& op) const { | 426 Bounds bounds(const DrawBitmapRectToRect& op) const { |
| 428 return this->adjustAndMap(op.dst, op.paint); | 427 return this->adjustAndMap(op.dst, op.paint); |
| 429 } | 428 } |
| 430 Bounds bounds(const DrawBitmapRectToRectBleed& op) const { | 429 Bounds bounds(const DrawBitmapRectToRectBleed& op) const { |
| 431 return this->adjustAndMap(op.dst, op.paint); | 430 return this->adjustAndMap(op.dst, op.paint); |
| 432 } | 431 } |
| 433 Bounds bounds(const DrawBitmapNine& op) const { | 432 Bounds bounds(const DrawBitmapNine& op) const { |
| 434 return this->adjustAndMap(op.dst, op.paint); | 433 return this->adjustAndMap(op.dst, op.paint); |
| 435 } | 434 } |
| 436 Bounds bounds(const DrawBitmap& op) const { | 435 Bounds bounds(const DrawBitmap& op) const { |
| 437 const SkBitmap& bm = op.bitmap; | 436 return this->adjustAndMap( |
| 438 return this->adjustAndMap(SkRect::MakeXYWH(op.left, op.top, bm.width(),
bm.height()), | 437 SkRect::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.h
eight()), |
| 439 op.paint); | 438 op.paint); |
| 440 } | 439 } |
| 441 Bounds bounds(const DrawBitmapMatrix& op) const { | 440 Bounds bounds(const DrawBitmapMatrix& op) const { |
| 442 const SkBitmap& bm = op.bitmap; | 441 SkRect dst = SkRect::MakeWH(op.bitmap.width(), op.bitmap.height()); |
| 443 SkRect dst = SkRect::MakeWH(bm.width(), bm.height()); | |
| 444 op.matrix.mapRect(&dst); | 442 op.matrix.mapRect(&dst); |
| 445 return this->adjustAndMap(dst, op.paint); | 443 return this->adjustAndMap(dst, op.paint); |
| 446 } | 444 } |
| 447 | 445 |
| 448 Bounds bounds(const DrawPath& op) const { | 446 Bounds bounds(const DrawPath& op) const { |
| 449 return op.path.isInverseFillType() ? fCurrentClipBounds | 447 return op.path.isInverseFillType() ? fCurrentClipBounds |
| 450 : this->adjustAndMap(op.path.getBound
s(), &op.paint); | 448 : this->adjustAndMap(op.path.getBound
s(), &op.paint); |
| 451 } | 449 } |
| 452 Bounds bounds(const DrawPoints& op) const { | 450 Bounds bounds(const DrawPoints& op) const { |
| 453 SkRect dst; | 451 SkRect dst; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 465 return this->adjustAndMap(dst, &op.paint); | 463 return this->adjustAndMap(dst, &op.paint); |
| 466 } | 464 } |
| 467 Bounds bounds(const DrawVertices& op) const { | 465 Bounds bounds(const DrawVertices& op) const { |
| 468 SkRect dst; | 466 SkRect dst; |
| 469 dst.set(op.vertices, op.vertexCount); | 467 dst.set(op.vertices, op.vertexCount); |
| 470 return this->adjustAndMap(dst, &op.paint); | 468 return this->adjustAndMap(dst, &op.paint); |
| 471 } | 469 } |
| 472 | 470 |
| 473 Bounds bounds(const DrawPicture& op) const { | 471 Bounds bounds(const DrawPicture& op) const { |
| 474 SkRect dst = op.picture->cullRect(); | 472 SkRect dst = op.picture->cullRect(); |
| 475 if (op.matrix) { | 473 op.matrix.mapRect(&dst); |
| 476 op.matrix->mapRect(&dst); | |
| 477 } | |
| 478 return this->adjustAndMap(dst, op.paint); | 474 return this->adjustAndMap(dst, op.paint); |
| 479 } | 475 } |
| 480 | 476 |
| 481 Bounds bounds(const DrawPosText& op) const { | 477 Bounds bounds(const DrawPosText& op) const { |
| 482 const int N = op.paint.countText(op.text, op.byteLength); | 478 const int N = op.paint.countText(op.text, op.byteLength); |
| 483 if (N == 0) { | 479 if (N == 0) { |
| 484 return Bounds::MakeEmpty(); | 480 return Bounds::MakeEmpty(); |
| 485 } | 481 } |
| 486 | 482 |
| 487 SkRect dst; | 483 SkRect dst; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); | 802 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); |
| 807 | 803 |
| 808 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 804 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
| 809 visitor.setCurrentOp(curOp); | 805 visitor.setCurrentOp(curOp); |
| 810 record.visit<void>(curOp, visitor); | 806 record.visit<void>(curOp, visitor); |
| 811 } | 807 } |
| 812 | 808 |
| 813 visitor.cleanUp(bbh); | 809 visitor.cleanUp(bbh); |
| 814 } | 810 } |
| 815 | 811 |
| OLD | NEW |