| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 const SkPoint texCoords[4], SkXfermode* xmode, | 269 const SkPoint texCoords[4], SkXfermode* xmode, |
| 270 const SkPaint& paint) override; | 270 const SkPaint& paint) override; |
| 271 void onDrawPaint(const SkPaint&) override; | 271 void onDrawPaint(const SkPaint&) override; |
| 272 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain
t&) override; | 272 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain
t&) override; |
| 273 void onDrawRect(const SkRect&, const SkPaint&) override; | 273 void onDrawRect(const SkRect&, const SkPaint&) override; |
| 274 void onDrawOval(const SkRect&, const SkPaint&) override; | 274 void onDrawOval(const SkRect&, const SkPaint&) override; |
| 275 void onDrawRRect(const SkRRect&, const SkPaint&) override; | 275 void onDrawRRect(const SkRRect&, const SkPaint&) override; |
| 276 void onDrawPath(const SkPath&, const SkPaint&) override; | 276 void onDrawPath(const SkPath&, const SkPaint&) override; |
| 277 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain
t*) override; | 277 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain
t*) override; |
| 278 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
const SkPaint*, | 278 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
const SkPaint*, |
| 279 DrawBitmapRectFlags flags) override; | 279 SK_VIRTUAL_CONSTRAINT_TYPE) override; |
| 280 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*
) override; | 280 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*
) override; |
| 281 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, | 281 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
| 282 const SkPaint*) override; | 282 const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) o
verride; |
| 283 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& ds
t, | 283 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& ds
t, |
| 284 const SkPaint*) override; | 284 const SkPaint*) override; |
| 285 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect&
dst, | 285 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect&
dst, |
| 286 const SkPaint*) override; | 286 const SkPaint*) override; |
| 287 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) overri
de; | 287 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) overri
de; |
| 288 void onDrawVertices(VertexMode vmode, int vertexCount, | 288 void onDrawVertices(VertexMode vmode, int vertexCount, |
| 289 const SkPoint vertices[], const SkPoint texs[], | 289 const SkPoint vertices[], const SkPoint texs[], |
| 290 const SkColor colors[], SkXfermode* xmode, | 290 const SkColor colors[], SkXfermode* xmode, |
| 291 const uint16_t indices[], int indexCount, | 291 const uint16_t indices[], int indexCount, |
| 292 const SkPaint&) override; | 292 const SkPaint&) override; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 NOTIFY_SETUP(this); | 784 NOTIFY_SETUP(this); |
| 785 size_t opBytesNeeded = sizeof(SkScalar) * 2; | 785 size_t opBytesNeeded = sizeof(SkScalar) * 2; |
| 786 | 786 |
| 787 if (this->commonDrawBitmap(bm, kDrawBitmap_DrawOp, 0, opBytesNeeded, paint))
{ | 787 if (this->commonDrawBitmap(bm, kDrawBitmap_DrawOp, 0, opBytesNeeded, paint))
{ |
| 788 fWriter.writeScalar(left); | 788 fWriter.writeScalar(left); |
| 789 fWriter.writeScalar(top); | 789 fWriter.writeScalar(top); |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 | 792 |
| 793 void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, cons
t SkRect& dst, | 793 void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, cons
t SkRect& dst, |
| 794 const SkPaint* paint, DrawBitmapRectFlags d
bmrFlags) { | 794 const SkPaint* paint, |
| 795 SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint
) { |
| 796 SrcRectConstraint constraint = (SrcRectConstraint)legacyConstraint; |
| 797 |
| 795 NOTIFY_SETUP(this); | 798 NOTIFY_SETUP(this); |
| 796 size_t opBytesNeeded = sizeof(SkRect); | 799 size_t opBytesNeeded = sizeof(SkRect); |
| 797 bool hasSrc = src != NULL; | 800 bool hasSrc = src != NULL; |
| 798 unsigned flags; | 801 unsigned flags; |
| 799 if (hasSrc) { | 802 if (hasSrc) { |
| 800 flags = kDrawBitmap_HasSrcRect_DrawOpFlag; | 803 flags = kDrawBitmap_HasSrcRect_DrawOpFlag; |
| 801 opBytesNeeded += sizeof(int32_t) * 4; | 804 opBytesNeeded += sizeof(int32_t) * 4; |
| 802 } else { | 805 } else { |
| 803 flags = 0; | 806 flags = 0; |
| 804 } | 807 } |
| 805 if (dbmrFlags & kBleed_DrawBitmapRectFlag) { | 808 if (kFast_SrcRectConstraint == constraint) { |
| 806 flags |= kDrawBitmap_Bleed_DrawOpFlag; | 809 flags |= kDrawBitmap_Bleed_DrawOpFlag; |
| 807 } | 810 } |
| 808 | 811 |
| 809 if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesN
eeded, paint)) { | 812 if (this->commonDrawBitmap(bm, kDrawBitmapRect_DrawOp, flags, opBytesNeeded,
paint)) { |
| 810 if (hasSrc) { | 813 if (hasSrc) { |
| 811 fWriter.writeRect(*src); | 814 fWriter.writeRect(*src); |
| 812 } | 815 } |
| 813 fWriter.writeRect(dst); | 816 fWriter.writeRect(dst); |
| 814 } | 817 } |
| 815 } | 818 } |
| 816 | 819 |
| 817 void SkGPipeCanvas::onDrawBitmapNine(const SkBitmap& bm, const SkIRect& center, | 820 void SkGPipeCanvas::onDrawBitmapNine(const SkBitmap& bm, const SkIRect& center, |
| 818 const SkRect& dst, const SkPaint* paint) { | 821 const SkRect& dst, const SkPaint* paint) { |
| 819 NOTIFY_SETUP(this); | 822 NOTIFY_SETUP(this); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 void SkGPipeCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, | 865 void SkGPipeCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, |
| 863 const SkPaint* paint) { | 866 const SkPaint* paint) { |
| 864 NOTIFY_SETUP(this); | 867 NOTIFY_SETUP(this); |
| 865 if (this->commonDrawImage(image, kDrawImage_DrawOp, 0, sizeof(SkScalar) * 2,
paint)) { | 868 if (this->commonDrawImage(image, kDrawImage_DrawOp, 0, sizeof(SkScalar) * 2,
paint)) { |
| 866 fWriter.writeScalar(x); | 869 fWriter.writeScalar(x); |
| 867 fWriter.writeScalar(y); | 870 fWriter.writeScalar(y); |
| 868 } | 871 } |
| 869 } | 872 } |
| 870 | 873 |
| 871 void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, con
st SkRect& dst, | 874 void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, con
st SkRect& dst, |
| 872 const SkPaint* paint) { | 875 const SkPaint* paint SRC_RECT_CONSTRAINT_PAR
AM(constraint)) { |
| 873 NOTIFY_SETUP(this); | 876 NOTIFY_SETUP(this); |
| 877 |
| 878 SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint) |
| 874 unsigned flags = 0; | 879 unsigned flags = 0; |
| 875 size_t opBytesNeeded = sizeof(SkRect); // dst | 880 size_t opBytesNeeded = sizeof(SkRect); // dst |
| 876 if (src) { | 881 if (src) { |
| 877 flags |= kDrawBitmap_HasSrcRect_DrawOpFlag; | 882 flags |= kDrawBitmap_HasSrcRect_DrawOpFlag; |
| 878 opBytesNeeded += sizeof(SkRect); // src | 883 opBytesNeeded += sizeof(SkRect); // src |
| 879 } | 884 } |
| 880 if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded
, paint)) { | 885 if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded
, paint)) { |
| 881 if (src) { | 886 if (src) { |
| 882 fWriter.writeRect(*src); | 887 fWriter.writeRect(*src); |
| 883 } | 888 } |
| 884 fWriter.writeRect(dst); | 889 fWriter.writeRect(dst); |
| 890 fWriter.writeInt(constraint); |
| 885 } | 891 } |
| 886 } | 892 } |
| 887 | 893 |
| 888 void SkGPipeCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, | 894 void SkGPipeCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, |
| 889 const SkPaint* paint) { | 895 const SkPaint* paint) { |
| 890 NOTIFY_SETUP(this); | 896 NOTIFY_SETUP(this); |
| 891 size_t opBytesNeeded = sizeof(SkIRect) + sizeof(SkRect); // center + dst | 897 size_t opBytesNeeded = sizeof(SkIRect) + sizeof(SkRect); // center + dst |
| 892 if (this->commonDrawImage(image, kDrawImageNine_DrawOp, 0, opBytesNeeded, pa
int)) { | 898 if (this->commonDrawImage(image, kDrawImageNine_DrawOp, 0, opBytesNeeded, pa
int)) { |
| 893 fWriter.writeIRect(center); | 899 fWriter.writeIRect(center); |
| 894 fWriter.writeRect(dst); | 900 fWriter.writeRect(dst); |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 int32_t slot = this->find(img); | 1491 int32_t slot = this->find(img); |
| 1486 if (slot) { | 1492 if (slot) { |
| 1487 return slot; | 1493 return slot; |
| 1488 } | 1494 } |
| 1489 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. | 1495 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. |
| 1490 fBytesInCache += img->width() * img->height() * 4; | 1496 fBytesInCache += img->width() * img->height() * 4; |
| 1491 *fArray.append() = SkRef(img); | 1497 *fArray.append() = SkRef(img); |
| 1492 return fArray.count(); // slot is always index+1 | 1498 return fArray.count(); // slot is always index+1 |
| 1493 } | 1499 } |
| 1494 | 1500 |
| OLD | NEW |