Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d25d692 authored by Nader Jawad's avatar Nader Jawad
Browse files

Skip TransformCanvas calls for FunctorDrawables

Fix issue where attempts to render overscroll content
into the alpha 8 mask would crash if there are WebView
related Functors in the scene.

Provide implementations for getTypeName in SkDrawable instances
of FunctorDrawable.

Fixes: 203960959
Test: manual
Change-Id: Idf321d9bfcbe2b8ba1eb205eadcec95e55865305
parent b13cde5c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ namespace skiapipeline {
 */
class FunctorDrawable : public SkDrawable {
public:
    constexpr static const char* const TYPE_NAME = "FunctorDrawable";

    FunctorDrawable(int functor, SkCanvas* canvas)
            : mBounds(canvas->getLocalClipBounds())
            , mWebViewHandle(WebViewFunctorManager::instance().handleFor(functor)) {}
@@ -48,6 +50,8 @@ public:
        mWebViewHandle->onRemovedFromTree();
    }

    const char* getTypeName() const override { return TYPE_NAME; }

protected:
    virtual SkRect onGetBounds() override { return mBounds; }

+13 −1
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */
#include "TransformCanvas.h"

#include "FunctorDrawable.h"
#include "HolePunch.h"
#include "SkData.h"
#include "SkDrawable.h"
@@ -35,8 +37,18 @@ void TransformCanvas::onDrawAnnotation(const SkRect& rect, const char* key, SkDa
}

void TransformCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* 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 {
    return false;