Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index 71f1e28638c7d1e6e10d9ce413868f313ffcff03..1d37e584193e83fa0979117b964cc6195ba15d77 100644 |
--- a/src/core/SkCanvas.cpp |
+++ b/src/core/SkCanvas.cpp |
@@ -1405,8 +1405,36 @@ |
LOOPER_END |
} |
+void SkCanvas::onDrawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint* paint) { |
+ if (gTreatSpriteAsBitmap) { |
+ this->save(); |
+ this->resetMatrix(); |
+ this->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), paint); |
+ this->restore(); |
+ return; |
+ } |
+ |
+ TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawSprite()"); |
+ if (bitmap.drawsNothing()) { |
+ return; |
+ } |
+ SkDEBUGCODE(bitmap.validate();) |
+ |
+ SkPaint tmp; |
+ if (nullptr == paint) { |
+ paint = &tmp; |
+ } |
+ |
+ LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) |
+ |
+ while (iter.next()) { |
+ const SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
+ iter.fDevice->drawBitmapAsSprite(iter, bitmap, pos.x(), pos.y(), looper.paint()); |
+ } |
+ LOOPER_END |
+} |
+ |
///////////////////////////////////////////////////////////////////////////// |
- |
void SkCanvas::translate(SkScalar dx, SkScalar dy) { |
SkMatrix m; |
m.setTranslate(dx, dy); |
@@ -1949,6 +1977,13 @@ |
this->onDrawBitmapNine(bitmap, center, dst, paint); |
} |
+void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint) { |
+ if (bitmap.drawsNothing()) { |
+ return; |
+ } |
+ this->onDrawSprite(bitmap, left, top, paint); |
+} |
+ |
void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], |
const SkColor colors[], int count, SkXfermode::Mode mode, |
const SkRect* cull, const SkPaint* paint) { |