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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 DrawBitmapRectFlags flags) 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 void SkGPipeCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, | 862 void SkGPipeCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, |
863 const SkPaint* paint) { | 863 const SkPaint* paint) { |
864 NOTIFY_SETUP(this); | 864 NOTIFY_SETUP(this); |
865 if (this->commonDrawImage(image, kDrawImage_DrawOp, 0, sizeof(SkScalar) * 2,
paint)) { | 865 if (this->commonDrawImage(image, kDrawImage_DrawOp, 0, sizeof(SkScalar) * 2,
paint)) { |
866 fWriter.writeScalar(x); | 866 fWriter.writeScalar(x); |
867 fWriter.writeScalar(y); | 867 fWriter.writeScalar(y); |
868 } | 868 } |
869 } | 869 } |
870 | 870 |
871 void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, con
st SkRect& dst, | 871 void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, con
st SkRect& dst, |
872 const SkPaint* paint) { | 872 const SkPaint* paint SRC_RECT_CONSTRAINT_PAR
AM(constraint)) { |
873 NOTIFY_SETUP(this); | 873 NOTIFY_SETUP(this); |
| 874 |
| 875 SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint) |
874 unsigned flags = 0; | 876 unsigned flags = 0; |
875 size_t opBytesNeeded = sizeof(SkRect); // dst | 877 size_t opBytesNeeded = sizeof(SkRect); // dst |
876 if (src) { | 878 if (src) { |
877 flags |= kDrawBitmap_HasSrcRect_DrawOpFlag; | 879 flags |= kDrawBitmap_HasSrcRect_DrawOpFlag; |
878 opBytesNeeded += sizeof(SkRect); // src | 880 opBytesNeeded += sizeof(SkRect); // src |
879 } | 881 } |
880 if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded
, paint)) { | 882 if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded
, paint)) { |
881 if (src) { | 883 if (src) { |
882 fWriter.writeRect(*src); | 884 fWriter.writeRect(*src); |
883 } | 885 } |
884 fWriter.writeRect(dst); | 886 fWriter.writeRect(dst); |
| 887 fWriter.writeInt(constraint); |
885 } | 888 } |
886 } | 889 } |
887 | 890 |
888 void SkGPipeCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, | 891 void SkGPipeCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, |
889 const SkPaint* paint) { | 892 const SkPaint* paint) { |
890 NOTIFY_SETUP(this); | 893 NOTIFY_SETUP(this); |
891 size_t opBytesNeeded = sizeof(SkIRect) + sizeof(SkRect); // center + dst | 894 size_t opBytesNeeded = sizeof(SkIRect) + sizeof(SkRect); // center + dst |
892 if (this->commonDrawImage(image, kDrawImageNine_DrawOp, 0, opBytesNeeded, pa
int)) { | 895 if (this->commonDrawImage(image, kDrawImageNine_DrawOp, 0, opBytesNeeded, pa
int)) { |
893 fWriter.writeIRect(center); | 896 fWriter.writeIRect(center); |
894 fWriter.writeRect(dst); | 897 fWriter.writeRect(dst); |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 int32_t slot = this->find(img); | 1488 int32_t slot = this->find(img); |
1486 if (slot) { | 1489 if (slot) { |
1487 return slot; | 1490 return slot; |
1488 } | 1491 } |
1489 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. | 1492 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. |
1490 fBytesInCache += img->width() * img->height() * 4; | 1493 fBytesInCache += img->width() * img->height() * 4; |
1491 *fArray.append() = SkRef(img); | 1494 *fArray.append() = SkRef(img); |
1492 return fArray.count(); // slot is always index+1 | 1495 return fArray.count(); // slot is always index+1 |
1493 } | 1496 } |
1494 | 1497 |
OLD | NEW |