Add missing onDrawDrawable() overrides to utility canvases
Change-Id: Ia5a7c523263e2c4744e0f3a743c6a4433760a4be
Reviewed-on: https://skia-review.googlesource.com/49770
Reviewed-by: Stan Iliev <stani@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 05cabad..c547fa2 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -6,6 +6,7 @@
*/
#include "SkData.h"
+#include "SkDrawable.h"
#include "SkDumpCanvas.h"
#include "SkImage.h"
#include "SkPatchUtils.h"
@@ -461,11 +462,22 @@
fNestLevel += 1;
this->INHERITED::onDrawPicture(picture, matrix, paint);
fNestLevel -= 1;
- this->dump(kDrawPicture_Verb, nullptr, "endPicture(%p) %f:%f:%f:%f", &picture,
+ this->dump(kDrawPicture_Verb, nullptr, "endPicture(%p) %f:%f:%f:%f", picture,
picture->cullRect().fLeft, picture->cullRect().fTop,
picture->cullRect().fRight, picture->cullRect().fBottom);
}
+void SkDumpCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
+ const auto bounds = drawable->getBounds();
+ this->dump(kDrawPicture_Verb, nullptr, "drawDrawable(%p) %f:%f:%f:%f", drawable,
+ bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
+ fNestLevel += 1;
+ this->INHERITED::onDrawDrawable(drawable, matrix);
+ fNestLevel -= 1;
+ this->dump(kDrawPicture_Verb, nullptr, "endDrawable(%p) %f:%f:%f:%f", drawable,
+ bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
+}
+
void SkDumpCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode,
const SkPaint& paint) {
this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] ...)",
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index ddf5187..9d2e8c9 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -307,6 +307,12 @@
this->INHERITED::onDrawPicture(picture, matrix, paint);
}
+void SkLuaCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
+ AUTO_LUA("drawDrawable");
+ // call through so we can see the nested ops
+ this->INHERITED::onDrawDrawable(drawable, matrix);
+}
+
void SkLuaCanvas::onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint& paint) {
AUTO_LUA("drawVertices");
lua.pushPaint(paint, "paint");
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 208f3b4..b1e92fb 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -282,6 +282,13 @@
}
}
+void SkNWayCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
+ Iter iter(fList);
+ while (iter.next()) {
+ iter->drawDrawable(drawable, matrix);
+ }
+}
+
void SkNWayCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
const SkPaint& paint) {
Iter iter(fList);
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp
index e504c72..6092058 100644
--- a/src/utils/SkPaintFilterCanvas.cpp
+++ b/src/utils/SkPaintFilterCanvas.cpp
@@ -172,6 +172,16 @@
}
}
+void SkPaintFilterCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
+ // There is no paint to filter in this case, but we can still filter on type.
+ // Subclasses need to unroll the drawable explicity (by overriding this method) in
+ // order to actually filter nested content.
+ AutoPaintFilter apf(this, kDrawable_Type, nullptr);
+ if (apf.shouldDraw()) {
+ this->INHERITED::onDrawDrawable(drawable, matrix);
+ }
+}
+
void SkPaintFilterCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) {
AutoPaintFilter apf(this, kText_Type, paint);