Skip TransformCanvas calls for FunctorDrawables am: 2d25d69236
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16224979 Change-Id: I9c030b7439aa394a8bc9c5218c09e2a50cffba29
This commit is contained in:
@@ -34,6 +34,8 @@ namespace skiapipeline {
|
|||||||
*/
|
*/
|
||||||
class FunctorDrawable : public SkDrawable {
|
class FunctorDrawable : public SkDrawable {
|
||||||
public:
|
public:
|
||||||
|
constexpr static const char* const TYPE_NAME = "FunctorDrawable";
|
||||||
|
|
||||||
FunctorDrawable(int functor, SkCanvas* canvas)
|
FunctorDrawable(int functor, SkCanvas* canvas)
|
||||||
: mBounds(canvas->getLocalClipBounds())
|
: mBounds(canvas->getLocalClipBounds())
|
||||||
, mWebViewHandle(WebViewFunctorManager::instance().handleFor(functor)) {}
|
, mWebViewHandle(WebViewFunctorManager::instance().handleFor(functor)) {}
|
||||||
@@ -48,6 +50,8 @@ public:
|
|||||||
mWebViewHandle->onRemovedFromTree();
|
mWebViewHandle->onRemovedFromTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* getTypeName() const override { return TYPE_NAME; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual SkRect onGetBounds() override { return mBounds; }
|
virtual SkRect onGetBounds() override { return mBounds; }
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "TransformCanvas.h"
|
#include "TransformCanvas.h"
|
||||||
|
|
||||||
|
#include "FunctorDrawable.h"
|
||||||
#include "HolePunch.h"
|
#include "HolePunch.h"
|
||||||
#include "SkData.h"
|
#include "SkData.h"
|
||||||
#include "SkDrawable.h"
|
#include "SkDrawable.h"
|
||||||
@@ -35,7 +37,17 @@ void TransformCanvas::onDrawAnnotation(const SkRect& rect, const char* key, SkDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TransformCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
|
void TransformCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
|
||||||
drawable->draw(this, matrix);
|
// TransformCanvas filters all drawing commands while maintaining the current
|
||||||
|
// clip stack and transformation. We need to draw most SkDrawables, since their
|
||||||
|
// draw calls may call methods that affect the clip stack and transformation. (Any
|
||||||
|
// actual draw commands will then be filtered out.) But FunctorDrawables are used
|
||||||
|
// as leaf nodes which issue self-contained OpenGL/Vulkan commands. These won't
|
||||||
|
// affect the clip stack + transformation, and in some cases cause problems (e.g. if
|
||||||
|
// the surface only has an alpha channel). See b/203960959
|
||||||
|
const auto* drawableName = drawable->getTypeName();
|
||||||
|
if (drawableName == nullptr || strcmp(drawableName, FunctorDrawable::TYPE_NAME) != 0) {
|
||||||
|
drawable->draw(this, matrix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TransformCanvas::onFilter(SkPaint& paint) const {
|
bool TransformCanvas::onFilter(SkPaint& paint) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user