Plumb more SkPaintFilterCanvas virtuals

SkNWayCanvas cannot support virtuals which imply one-to-one proxying,
but SkPaintFilterCanvas can (and should).

Change-Id: If966aa4ec3fcc79e6355a82cc299fd1877e4cf53
Reviewed-on: https://skia-review.googlesource.com/58842
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2017-10-12 11:08:46 -04:00 committed by Skia Commit-Bot
parent 20d479c088
commit 1ba5b6baa8
4 changed files with 54 additions and 2 deletions

View File

@ -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:

View File

@ -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;
};

View File

@ -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);

View File

@ -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);
}