aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/utils/SkNWayCanvas.h2
-rw-r--r--include/utils/SkPaintFilterCanvas.h15
-rw-r--r--src/utils/SkNWayCanvas.cpp7
-rw-r--r--src/utils/SkPaintFilterCanvas.cpp32
4 files changed, 54 insertions, 2 deletions
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index 6641395bd1..a3e567ef89 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -82,6 +82,8 @@ protected:
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
+ void onFlush() override;
+
class Iter;
private:
diff --git a/include/utils/SkPaintFilterCanvas.h b/include/utils/SkPaintFilterCanvas.h
index 5491721914..22a6016a11 100644
--- a/include/utils/SkPaintFilterCanvas.h
+++ b/include/utils/SkPaintFilterCanvas.h
@@ -23,8 +23,6 @@ public:
*/
SkPaintFilterCanvas(SkCanvas* canvas);
- GrContext* getGrContext() override { return fList[0]->getGrContext(); }
-
enum Type {
kPaint_Type,
kPoint_Type,
@@ -45,6 +43,10 @@ public:
kTypeCount
};
+ // Forwarded to the wrapped canvas.
+ SkISize getBaseLayerSize() const override { return proxy()->getBaseLayerSize(); }
+ GrContext* getGrContext() override { return proxy()->getGrContext(); }
+
protected:
/**
* Called with the paint that will be used to draw the specified type.
@@ -97,9 +99,18 @@ protected:
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
+ // Forwarded to the wrapped canvas.
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
+ bool onPeekPixels(SkPixmap* pixmap) override;
+ bool onAccessTopLayerPixels(SkPixmap* pixmap) override;
+ SkImageInfo onImageInfo() const override;
+ bool onGetProps(SkSurfaceProps* props) const override;
+
private:
class AutoPaintFilter;
+ SkCanvas* proxy() const { SkASSERT(fList.count() == 1); return fList[0]; }
+
typedef SkNWayCanvas INHERITED;
};
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index b1e92fb2be..c612c7d7e1 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -320,6 +320,13 @@ void SkNWayCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData
}
}
+void SkNWayCanvas::onFlush() {
+ Iter iter(fList);
+ while (iter.next()) {
+ iter->flush();
+ }
+}
+
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
SkDrawFilter* SkNWayCanvas::setDrawFilter(SkDrawFilter* filter) {
Iter iter(fList);
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp
index 6092058ee1..668ebe37a9 100644
--- a/src/utils/SkPaintFilterCanvas.cpp
+++ b/src/utils/SkPaintFilterCanvas.cpp
@@ -8,6 +8,8 @@
#include "SkPaintFilterCanvas.h"
#include "SkPaint.h"
+#include "SkPixmap.h"
+#include "SkSurface.h"
#include "SkTLazy.h"
class SkPaintFilterCanvas::AutoPaintFilter {
@@ -230,3 +232,33 @@ void SkPaintFilterCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkS
this->INHERITED::onDrawTextBlob(blob, x, y, *apf.paint());
}
}
+
+sk_sp<SkSurface> SkPaintFilterCanvas::onNewSurface(const SkImageInfo& info,
+ const SkSurfaceProps& props) {
+ return proxy()->makeSurface(info, &props);
+}
+
+bool SkPaintFilterCanvas::onPeekPixels(SkPixmap* pixmap) {
+ return proxy()->peekPixels(pixmap);
+}
+
+bool SkPaintFilterCanvas::onAccessTopLayerPixels(SkPixmap* pixmap) {
+ SkImageInfo info;
+ size_t rowBytes;
+
+ void* addr = proxy()->accessTopLayerPixels(&info, &rowBytes);
+ if (!addr) {
+ return false;
+ }
+
+ pixmap->reset(info, addr, rowBytes);
+ return true;
+}
+
+SkImageInfo SkPaintFilterCanvas::onImageInfo() const {
+ return proxy()->imageInfo();
+}
+
+bool SkPaintFilterCanvas::onGetProps(SkSurfaceProps* props) const {
+ return proxy()->getProps(props);
+}