| Index: src/core/SkLiteDL.cpp
|
| diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
|
| index 90f62c28f54d66fd8c469c188d53d44395d78751..283f4e686a81c15ad2ef19cc76eaac3d4d655da2 100644
|
| --- a/src/core/SkLiteDL.cpp
|
| +++ b/src/core/SkLiteDL.cpp
|
| @@ -6,6 +6,7 @@
|
| */
|
|
|
| #include "SkCanvas.h"
|
| +#include "SkImageFilter.h"
|
| #include "SkLiteDL.h"
|
| #include "SkMutex.h"
|
| #include "SkSpinlock.h"
|
| @@ -20,6 +21,22 @@ namespace {
|
|
|
| struct Save final : Op { void draw(SkCanvas* c) override { c-> save(); } };
|
| struct Restore final : Op { void draw(SkCanvas* c) override { c->restore(); } };
|
| + struct SaveLayer final : Op {
|
| + SaveLayer(const SkRect* bounds, const SkPaint* paint,
|
| + const SkImageFilter* backdrop, uint32_t flags) {
|
| + if (bounds) { this->bounds = *bounds; }
|
| + if (paint) { this->paint = *paint; }
|
| + this->backdrop = sk_ref_sp(backdrop);
|
| + this->flags = flags;
|
| + }
|
| + SkRect bounds = {SK_ScalarMin,SK_ScalarMin, SK_ScalarMax,SK_ScalarMax};
|
| + SkPaint paint;
|
| + sk_sp<const SkImageFilter> backdrop;
|
| + uint32_t flags;
|
| + void draw(SkCanvas* c) override {
|
| + c->saveLayer({ &bounds, &paint, backdrop.get(), flags });
|
| + }
|
| + };
|
|
|
| struct Concat final : Op {
|
| Concat(const SkMatrix& matrix) : matrix(matrix) {}
|
| @@ -32,6 +49,13 @@ namespace {
|
| void draw(SkCanvas* c) override { c->setMatrix(matrix); }
|
| };
|
|
|
| + struct ClipPath final : Op {
|
| + ClipPath(const SkPath& path, SkRegion::Op op, bool aa) : path(path), op(op), aa(aa) {}
|
| + SkPath path;
|
| + SkRegion::Op op;
|
| + bool aa;
|
| + void draw(SkCanvas* c) override { c->clipPath(path, op, aa); }
|
| + };
|
| struct ClipRect final : Op {
|
| ClipRect(const SkRect& rect, SkRegion::Op op, bool aa) : rect(rect), op(op), aa(aa) {}
|
| SkRect rect;
|
| @@ -39,20 +63,56 @@ namespace {
|
| bool aa;
|
| void draw(SkCanvas* c) override { c->clipRect(rect, op, aa); }
|
| };
|
| + struct ClipRRect final : Op {
|
| + ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) : rrect(rrect), op(op), aa(aa) {}
|
| + SkRRect rrect;
|
| + SkRegion::Op op;
|
| + bool aa;
|
| + void draw(SkCanvas* c) override { c->clipRRect(rrect, op, aa); }
|
| + };
|
| + struct ClipRegion final : Op {
|
| + ClipRegion(const SkRegion& region, SkRegion::Op op) : region(region), op(op) {}
|
| + SkRegion region;
|
| + SkRegion::Op op;
|
| + void draw(SkCanvas* c) override { c->clipRegion(region, op); }
|
| + };
|
|
|
| - struct DrawRect final : Op {
|
| - DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(paint) {}
|
| - SkRect rect;
|
| + struct DrawPaint final : Op {
|
| + DrawPaint(const SkPaint& paint) : paint(paint) {}
|
| SkPaint paint;
|
| - void draw(SkCanvas* c) override { c->drawRect(rect, paint); }
|
| + void draw(SkCanvas* c) override { c->drawPaint(paint); }
|
| };
|
| -
|
| struct DrawPath final : Op {
|
| DrawPath(const SkPath& path, const SkPaint& paint) : path(path), paint(paint) {}
|
| SkPath path;
|
| SkPaint paint;
|
| void draw(SkCanvas* c) override { c->drawPath(path, paint); }
|
| };
|
| + struct DrawRect final : Op {
|
| + DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(paint) {}
|
| + SkRect rect;
|
| + SkPaint paint;
|
| + void draw(SkCanvas* c) override { c->drawRect(rect, paint); }
|
| + };
|
| + struct DrawOval final : Op {
|
| + DrawOval(const SkRect& oval, const SkPaint& paint) : oval(oval), paint(paint) {}
|
| + SkRect oval;
|
| + SkPaint paint;
|
| + void draw(SkCanvas* c) override { c->drawOval(oval, paint); }
|
| + };
|
| + struct DrawRRect final : Op {
|
| + DrawRRect(const SkRRect& rrect, const SkPaint& paint) : rrect(rrect), paint(paint) {}
|
| + SkRRect rrect;
|
| + SkPaint paint;
|
| + void draw(SkCanvas* c) override { c->drawRRect(rrect, paint); }
|
| + };
|
| + struct DrawDRRect final : Op {
|
| + DrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint)
|
| + : outer(outer), inner(inner), paint(paint) {}
|
| + SkRRect outer, inner;
|
| + SkPaint paint;
|
| + void draw(SkCanvas* c) override { c->drawDRRect(outer, inner, paint); }
|
| + };
|
|
|
| template <typename T, typename... Args>
|
| static void* push(SkTDArray<uint8_t>* bytes, size_t pod, Args&&... args) {
|
| @@ -75,20 +135,45 @@ namespace {
|
|
|
| void SkLiteDL:: save() { push <Save>(&fBytes, 0); }
|
| void SkLiteDL::restore() { push<Restore>(&fBytes, 0); }
|
| +void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
|
| + const SkImageFilter* backdrop, uint32_t flags) {
|
| + push<SaveLayer>(&fBytes, 0, bounds, paint, backdrop, flags);
|
| +}
|
|
|
| void SkLiteDL:: concat(const SkMatrix& matrix) { push <Concat>(&fBytes, 0, matrix); }
|
| void SkLiteDL::setMatrix(const SkMatrix& matrix) { push<SetMatrix>(&fBytes, 0, matrix); }
|
|
|
| +void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) {
|
| + push<ClipPath>(&fBytes, 0, path, op, aa);
|
| +}
|
| void SkLiteDL::clipRect(const SkRect& rect, SkRegion::Op op, bool aa) {
|
| push<ClipRect>(&fBytes, 0, rect, op, aa);
|
| }
|
| +void SkLiteDL::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) {
|
| + push<ClipRRect>(&fBytes, 0, rrect, op, aa);
|
| +}
|
| +void SkLiteDL::clipRegion(const SkRegion& region, SkRegion::Op op) {
|
| + push<ClipRegion>(&fBytes, 0, region, op);
|
| +}
|
|
|
| -void SkLiteDL::drawRect(const SkRect& rect, const SkPaint& paint) {
|
| - push<DrawRect>(&fBytes, 0, rect, paint);
|
| +void SkLiteDL::drawPaint(const SkPaint& paint) {
|
| + push<DrawPaint>(&fBytes, 0, paint);
|
| }
|
| void SkLiteDL::drawPath(const SkPath& path, const SkPaint& paint) {
|
| push<DrawPath>(&fBytes, 0, path, paint);
|
| }
|
| +void SkLiteDL::drawRect(const SkRect& rect, const SkPaint& paint) {
|
| + push<DrawRect>(&fBytes, 0, rect, paint);
|
| +}
|
| +void SkLiteDL::drawOval(const SkRect& oval, const SkPaint& paint) {
|
| + push<DrawOval>(&fBytes, 0, oval, paint);
|
| +}
|
| +void SkLiteDL::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
| + push<DrawRRect>(&fBytes, 0, rrect, paint);
|
| +}
|
| +void SkLiteDL::drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
|
| + push<DrawDRRect>(&fBytes, 0, outer, inner, paint);
|
| +}
|
|
|
| void SkLiteDL::onDraw(SkCanvas* canvas) {
|
| map(&fBytes, [canvas](Op* op) { op->draw(canvas); });
|
|
|