Add onDrawBitmapLattice(), avoid unnecessary bitmap->image copy
out/Release/nanobench --match Lattice --config gpu --ms 3000
3.42ms -> 17.2us
For reference, a loop over drawBitmapRects (which is what
Android currently does) is about 13us.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2205273003
Review-Url: https://codereview.chromium.org/2205273003
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 7ffb1f4..b961c7d 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -206,21 +206,17 @@
}
}
+void SkRecorder::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice,
+ const SkRect& dst, const SkPaint* paint) {
+ sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
+ this->onDrawImageLattice(image.get(), lattice, dst, paint);
+}
+
void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint) {
APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top);
}
-void SkRecorder::onDrawImageLattice(const SkImage* image,
- const Lattice& lattice,
- const SkRect& dst,
- const SkPaint* paint) {
- APPEND(DrawImageLattice, this->copy(paint), sk_ref_sp(image),
- lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
- lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount), dst);
-}
-
-
void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint);
@@ -231,6 +227,13 @@
APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst);
}
+void SkRecorder::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
+ const SkPaint* paint) {
+ APPEND(DrawImageLattice, this->copy(paint), sk_ref_sp(image),
+ lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
+ lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount), dst);
+}
+
void SkRecorder::onDrawText(const void* text, size_t byteLength,
SkScalar x, SkScalar y, const SkPaint& paint) {
APPEND(DrawText,