record drawfilters
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2303033002 Review-Url: https://codereview.chromium.org/2303033002
This commit is contained in:
parent
400a93bd6c
commit
6ae6969434
@ -57,12 +57,9 @@ protected:
|
|||||||
SkRect r = { 20, 20, 100, 100 };
|
SkRect r = { 20, 20, 100, 100 };
|
||||||
canvas->setDrawFilter(nullptr);
|
canvas->setDrawFilter(nullptr);
|
||||||
canvas->drawRect(r, p);
|
canvas->drawRect(r, p);
|
||||||
TestFilter redNoBlur;
|
canvas->setDrawFilter(new TestFilter)->unref();
|
||||||
canvas->setDrawFilter(&redNoBlur);
|
|
||||||
canvas->translate(120.0f, 40.0f);
|
canvas->translate(120.0f, 40.0f);
|
||||||
canvas->drawRect(r, p);
|
canvas->drawRect(r, p);
|
||||||
|
|
||||||
// Must unset if the DrawFilter is from the stack to avoid refcount errors!
|
|
||||||
canvas->setDrawFilter(nullptr);
|
canvas->setDrawFilter(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
#include "SkData.h"
|
#include "SkData.h"
|
||||||
|
#include "SkDrawFilter.h"
|
||||||
#include "SkImageFilter.h"
|
#include "SkImageFilter.h"
|
||||||
#include "SkLiteDL.h"
|
#include "SkLiteDL.h"
|
||||||
#include "SkMath.h"
|
#include "SkMath.h"
|
||||||
@ -52,7 +53,7 @@ static void make_threadsafe(SkPath* path, SkMatrix* matrix) {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#define TYPES(M) \
|
#define TYPES(M) \
|
||||||
M(Save) M(Restore) M(SaveLayer) \
|
M(SetDrawFilter) M(Save) M(Restore) M(SaveLayer) \
|
||||||
M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \
|
M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \
|
||||||
M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \
|
M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \
|
||||||
M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawRegion) M(DrawOval) M(DrawArc) \
|
M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawRegion) M(DrawOval) M(DrawArc) \
|
||||||
@ -75,6 +76,19 @@ namespace {
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(Op) == 4, "");
|
static_assert(sizeof(Op) == 4, "");
|
||||||
|
|
||||||
|
struct SetDrawFilter final : Op {
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
|
||||||
|
static const auto kType = Type::SetDrawFilter;
|
||||||
|
SetDrawFilter(SkDrawFilter* df) : drawFilter(sk_ref_sp(df)) {}
|
||||||
|
sk_sp<SkDrawFilter> drawFilter;
|
||||||
|
#endif
|
||||||
|
void draw(SkCanvas* c, const SkMatrix&) {
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
|
||||||
|
c->setDrawFilter(drawFilter.get());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct Save final : Op {
|
struct Save final : Op {
|
||||||
static const auto kType = Type::Save;
|
static const auto kType = Type::Save;
|
||||||
void draw(SkCanvas* c, const SkMatrix&) { c->save(); }
|
void draw(SkCanvas* c, const SkMatrix&) { c->save(); }
|
||||||
@ -566,6 +580,12 @@ inline void SkLiteDL::map(const Fn fns[], Args... args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
|
||||||
|
void SkLiteDL::setDrawFilter(SkDrawFilter* df) {
|
||||||
|
this->push<SetDrawFilter>(0, df);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void SkLiteDL:: save() { this->push <Save>(0); }
|
void SkLiteDL:: save() { this->push <Save>(0); }
|
||||||
void SkLiteDL::restore() { this->push<Restore>(0); }
|
void SkLiteDL::restore() { this->push<Restore>(0); }
|
||||||
void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
|
void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
|
||||||
|
@ -23,6 +23,10 @@ public:
|
|||||||
void makeThreadsafe();
|
void makeThreadsafe();
|
||||||
bool empty() const { return fUsed == 0; }
|
bool empty() const { return fUsed == 0; }
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
|
||||||
|
void setDrawFilter(SkDrawFilter*);
|
||||||
|
#endif
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, SkCanvas::SaveLayerFlags);
|
void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, SkCanvas::SaveLayerFlags);
|
||||||
void restore();
|
void restore();
|
||||||
|
@ -22,6 +22,13 @@ sk_sp<SkSurface> SkLiteRecorder::onNewSurface(const SkImageInfo&, const SkSurfac
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
|
||||||
|
SkDrawFilter* SkLiteRecorder::setDrawFilter(SkDrawFilter* df) {
|
||||||
|
fDL->setDrawFilter(df);
|
||||||
|
return SkCanvas::setDrawFilter(df);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void SkLiteRecorder::willSave() { fDL->save(); }
|
void SkLiteRecorder::willSave() { fDL->save(); }
|
||||||
SkCanvas::SaveLayerStrategy SkLiteRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
|
SkCanvas::SaveLayerStrategy SkLiteRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
|
||||||
fDL->saveLayer(rec.fBounds, rec.fPaint, rec.fBackdrop, rec.fSaveLayerFlags);
|
fDL->saveLayer(rec.fBounds, rec.fPaint, rec.fBackdrop, rec.fSaveLayerFlags);
|
||||||
|
@ -19,6 +19,10 @@ public:
|
|||||||
|
|
||||||
sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
|
sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
|
||||||
|
SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void willSave() override;
|
void willSave() override;
|
||||||
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
|
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
|
||||||
void willRestore() override;
|
void willRestore() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user