Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: src/core/SkCanvas.cpp

Issue 1529803004: Revert of remove drawSprite from canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698