diff options
author | mtklein <mtklein@chromium.org> | 2016-08-18 15:42:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-18 15:42:32 -0700 |
commit | 5fa47f4fd13b3158de4599414c86d17649c2dd1c (patch) | |
tree | 729c8339c1d6a1488fc57a3102e78c7bf119b89f /src/core/SkLiteDL.cpp | |
parent | abe795e4db533c2e230be0c2be868754e5a02a7e (diff) |
Fast path translate() in SkCanvas and SkLiteDL.
This adds didTranslate() so that SkLiteDL (and other canvas recorders)
can record the translate rather than the full concat.
It also adds a case to SkMatrix::preTranslate() to fast path
translate x translate -> translate (i.e. +=).
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255283002
Review-Url: https://codereview.chromium.org/2255283002
Diffstat (limited to 'src/core/SkLiteDL.cpp')
-rw-r--r-- | src/core/SkLiteDL.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp index c634d4825a..c3bf976a88 100644 --- a/src/core/SkLiteDL.cpp +++ b/src/core/SkLiteDL.cpp @@ -52,7 +52,7 @@ static void make_threadsafe(SkPath* path, SkMatrix* matrix) { namespace { #define TYPES(M) \ M(Save) M(Restore) M(SaveLayer) \ - M(Concat) M(SetMatrix) M(TranslateZ) \ + M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \ M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \ M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawOval) M(DrawRRect) M(DrawDRRect) \ M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) M(DrawShadowedPicture) \ @@ -115,6 +115,14 @@ namespace { } void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } }; + struct Translate final : Op { + static const auto kType = Type::Translate; + Translate(SkScalar dx, SkScalar dy) : dx(dx), dy(dy) {} + SkScalar dx,dy; + void draw(SkCanvas* c, const SkMatrix&) { + c->translate(dx, dy); + } + }; struct TranslateZ final : Op { static const auto kType = Type::TranslateZ; TranslateZ(SkScalar dz) : dz(dz) {} @@ -539,8 +547,9 @@ void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint, this->push<SaveLayer>(0, bounds, paint, backdrop, flags); } -void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, matrix); } -void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, matrix); } +void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, matrix); } +void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, matrix); } +void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx, dy); } void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); } void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) { |