diff options
author | msarett <msarett@google.com> | 2016-08-16 09:31:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-16 09:31:08 -0700 |
commit | 168820625c35a8c19f66c661efcbce7a5e334837 (patch) | |
tree | d2af91d684ed335271850941a5bccedd84346c73 /src/core/SkRecorder.cpp | |
parent | c4d2f907311fca08303c254b2488bd7990fa2f32 (diff) |
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
Diffstat (limited to 'src/core/SkRecorder.cpp')
-rw-r--r-- | src/core/SkRecorder.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index 7ffb1f4c44..b961c7d1e7 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -206,21 +206,17 @@ void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, } } +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 @@ void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center, 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, |