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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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*) override; |
| 283 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& ds
t, |
| 284 const SkPaint*) override; |
283 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect&
dst, | 285 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect&
dst, |
284 const SkPaint*) override; | 286 const SkPaint*) override; |
285 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; |
286 void onDrawVertices(VertexMode vmode, int vertexCount, | 288 void onDrawVertices(VertexMode vmode, int vertexCount, |
287 const SkPoint vertices[], const SkPoint texs[], | 289 const SkPoint vertices[], const SkPoint texs[], |
288 const SkColor colors[], SkXfermode* xmode, | 290 const SkColor colors[], SkXfermode* xmode, |
289 const uint16_t indices[], int indexCount, | 291 const uint16_t indices[], int indexCount, |
290 const SkPaint&) override; | 292 const SkPaint&) override; |
291 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk
Color[], | 293 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk
Color[], |
292 int count, SkXfermode::Mode, const SkRect* cull, const SkPa
int*) override; | 294 int count, SkXfermode::Mode, const SkRect* cull, const SkPa
int*) override; |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 opBytesNeeded += sizeof(SkRect); // src | 878 opBytesNeeded += sizeof(SkRect); // src |
877 } | 879 } |
878 if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded
, paint)) { | 880 if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded
, paint)) { |
879 if (src) { | 881 if (src) { |
880 fWriter.writeRect(*src); | 882 fWriter.writeRect(*src); |
881 } | 883 } |
882 fWriter.writeRect(dst); | 884 fWriter.writeRect(dst); |
883 } | 885 } |
884 } | 886 } |
885 | 887 |
| 888 void SkGPipeCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, |
| 889 const SkPaint* paint) { |
| 890 NOTIFY_SETUP(this); |
| 891 size_t opBytesNeeded = sizeof(SkIRect) + sizeof(SkRect); // center + dst |
| 892 if (this->commonDrawImage(image, kDrawImageNine_DrawOp, 0, opBytesNeeded, pa
int)) { |
| 893 fWriter.writeIRect(center); |
| 894 fWriter.writeRect(dst); |
| 895 } |
| 896 } |
| 897 |
886 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, | 898 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, |
887 const SkPaint& paint) { | 899 const SkPaint& paint) { |
888 if (byteLength) { | 900 if (byteLength) { |
889 NOTIFY_SETUP(this); | 901 NOTIFY_SETUP(this); |
890 this->writePaint(paint); | 902 this->writePaint(paint); |
891 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar)))
{ | 903 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar)))
{ |
892 this->writeOp(kDrawText_DrawOp); | 904 this->writeOp(kDrawText_DrawOp); |
893 fWriter.write32(SkToU32(byteLength)); | 905 fWriter.write32(SkToU32(byteLength)); |
894 fWriter.writePad(text, byteLength); | 906 fWriter.writePad(text, byteLength); |
895 fWriter.writeScalar(x); | 907 fWriter.writeScalar(x); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 int32_t slot = this->find(img); | 1485 int32_t slot = this->find(img); |
1474 if (slot) { | 1486 if (slot) { |
1475 return slot; | 1487 return slot; |
1476 } | 1488 } |
1477 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. | 1489 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. |
1478 fBytesInCache += img->width() * img->height() * 4; | 1490 fBytesInCache += img->width() * img->height() * 4; |
1479 *fArray.append() = SkRef(img); | 1491 *fArray.append() = SkRef(img); |
1480 return fArray.count(); // slot is always index+1 | 1492 return fArray.count(); // slot is always index+1 |
1481 } | 1493 } |
1482 | 1494 |
OLD | NEW |