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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SrcRectConstraint) override; | 279 SrcRectConstraint) 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*, SrcRectConstraint) override; | 282 const SkPaint*, SrcRectConstraint) override; |
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; | |
288 void onDrawVertices(VertexMode vmode, int vertexCount, | 287 void onDrawVertices(VertexMode vmode, int vertexCount, |
289 const SkPoint vertices[], const SkPoint texs[], | 288 const SkPoint vertices[], const SkPoint texs[], |
290 const SkColor colors[], SkXfermode* xmode, | 289 const SkColor colors[], SkXfermode* xmode, |
291 const uint16_t indices[], int indexCount, | 290 const uint16_t indices[], int indexCount, |
292 const SkPaint&) override; | 291 const SkPaint&) override; |
293 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk
Color[], | 292 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk
Color[], |
294 int count, SkXfermode::Mode, const SkRect* cull, const SkPa
int*) override; | 293 int count, SkXfermode::Mode, const SkRect* cull, const SkPa
int*) override; |
295 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; | 294 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
296 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; | 295 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
297 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; | 296 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 820 |
822 if (this->commonDrawBitmap(bm, kDrawBitmapNine_DrawOp, 0, opBytesNeeded, pai
nt)) { | 821 if (this->commonDrawBitmap(bm, kDrawBitmapNine_DrawOp, 0, opBytesNeeded, pai
nt)) { |
823 fWriter.write32(center.fLeft); | 822 fWriter.write32(center.fLeft); |
824 fWriter.write32(center.fTop); | 823 fWriter.write32(center.fTop); |
825 fWriter.write32(center.fRight); | 824 fWriter.write32(center.fRight); |
826 fWriter.write32(center.fBottom); | 825 fWriter.write32(center.fBottom); |
827 fWriter.writeRect(dst); | 826 fWriter.writeRect(dst); |
828 } | 827 } |
829 } | 828 } |
830 | 829 |
831 void SkGPipeCanvas::onDrawSprite(const SkBitmap& bm, int left, int top, const Sk
Paint* paint) { | |
832 NOTIFY_SETUP(this); | |
833 size_t opBytesNeeded = sizeof(int32_t) * 2; | |
834 | |
835 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint))
{ | |
836 fWriter.write32(left); | |
837 fWriter.write32(top); | |
838 } | |
839 } | |
840 | |
841 bool SkGPipeCanvas::commonDrawImage(const SkImage* image, DrawOps op, unsigned f
lags, | 830 bool SkGPipeCanvas::commonDrawImage(const SkImage* image, DrawOps op, unsigned f
lags, |
842 size_t opBytesNeeded, const SkPaint* paint)
{ | 831 size_t opBytesNeeded, const SkPaint* paint)
{ |
843 if (fDone) { | 832 if (fDone) { |
844 return false; | 833 return false; |
845 } | 834 } |
846 | 835 |
847 if (paint != nullptr) { | 836 if (paint != nullptr) { |
848 flags |= kDrawBitmap_HasPaint_DrawOpFlag; | 837 flags |= kDrawBitmap_HasPaint_DrawOpFlag; |
849 this->writePaint(*paint); | 838 this->writePaint(*paint); |
850 } | 839 } |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 int32_t slot = this->find(img); | 1475 int32_t slot = this->find(img); |
1487 if (slot) { | 1476 if (slot) { |
1488 return slot; | 1477 return slot; |
1489 } | 1478 } |
1490 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. | 1479 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. |
1491 fBytesInCache += img->width() * img->height() * 4; | 1480 fBytesInCache += img->width() * img->height() * 4; |
1492 *fArray.append() = SkRef(img); | 1481 *fArray.append() = SkRef(img); |
1493 return fArray.count(); // slot is always index+1 | 1482 return fArray.count(); // slot is always index+1 |
1494 } | 1483 } |
1495 | 1484 |
OLD | NEW |