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

Commit ad6c1ed8 authored by Doris Liu's avatar Doris Liu Committed by Android (Google) Code Review
Browse files

Merge "Private API to turn off anti-aliasing for VectorDrawable"

parents ac74dc42 6b184d7a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@ static void setAllowCaching(JNIEnv*, jobject, jlong treePtr, jboolean allowCachi
    tree->setAllowCaching(allowCaching);
}

static void setAntiAlias(JNIEnv*, jobject, jlong treePtr, jboolean aa) {
    VectorDrawable::Tree* tree = reinterpret_cast<VectorDrawable::Tree*>(treePtr);
    tree->setAntiAlias(aa);
}

/**
 * Draw
 */
@@ -363,6 +368,7 @@ static const JNINativeMethod gMethods[] = {
        {"nSetRendererViewportSize", "(JFF)V", (void*)setTreeViewportSize},
        {"nSetRootAlpha", "(JF)Z", (void*)setRootAlpha},
        {"nGetRootAlpha", "(J)F", (void*)getRootAlpha},
        {"nSetAntiAlias", "(JZ)V", (void*)setAntiAlias},
        {"nSetAllowCaching", "(JZ)V", (void*)setAllowCaching},

        {"nCreateFullPath", "()J", (void*)createEmptyFullPath},
+9 −0
Original line number Diff line number Diff line
@@ -896,6 +896,13 @@ public class VectorDrawable extends Drawable {
        return mVectorState.getNativeRenderer();
    }

    /**
     * @hide
     */
    public void setAntiAlias(boolean aa) {
        nSetAntiAlias(mVectorState.mNativeTree.get(), aa);
    }

    static class VectorDrawableState extends ConstantState {
        // Variables below need to be copied (deep copy if applicable) for mutation.
        int[] mThemeAttrs;
@@ -2269,6 +2276,8 @@ public class VectorDrawable extends Drawable {
    @FastNative
    private static native float nGetRootAlpha(long rendererPtr);
    @FastNative
    private static native void nSetAntiAlias(long rendererPtr, boolean aa);
    @FastNative
    private static native void nSetAllowCaching(long rendererPtr, boolean allowCaching);

    @FastNative
+2 −2
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ void FullPath::draw(SkCanvas* outCanvas, bool useStagingData) {

    if (needsFill) {
        paint.setStyle(SkPaint::Style::kFill_Style);
        paint.setAntiAlias(true);
        paint.setAntiAlias(mAntiAlias);
        outCanvas->drawPath(renderPath, paint);
    }

@@ -182,7 +182,7 @@ void FullPath::draw(SkCanvas* outCanvas, bool useStagingData) {
    }
    if (needsStroke) {
        paint.setStyle(SkPaint::Style::kStroke_Style);
        paint.setAntiAlias(true);
        paint.setAntiAlias(mAntiAlias);
        paint.setStrokeJoin(SkPaint::Join(properties.getStrokeLineJoin()));
        paint.setStrokeCap(SkPaint::Cap(properties.getStrokeLineCap()));
        paint.setStrokeMiter(properties.getStrokeMiterLimit());
+13 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public:
    virtual void onPropertyChanged(Properties* properties) = 0;
    virtual ~Node() {}
    virtual void syncProperties() = 0;
    virtual void setAntiAlias(bool aa) = 0;

protected:
    std::string mName;
@@ -354,6 +355,7 @@ public:
            }
        }
    }
    virtual void setAntiAlias(bool aa) { mAntiAlias = aa; }

protected:
    const SkPath& getUpdatedPath(bool useStagingData, SkPath* tempStagingPath) override;
@@ -365,6 +367,8 @@ private:

    // Intermediate data for drawing, render thread only
    SkPath mTrimmedSkPath;
    // Default to use AntiAlias
    bool mAntiAlias = true;
};

class ANDROID_API ClipPath : public Path {
@@ -373,6 +377,7 @@ public:
    ClipPath(const char* path, size_t strLength) : Path(path, strLength) {}
    ClipPath() : Path() {}
    void draw(SkCanvas* outCanvas, bool useStagingData) override;
    virtual void setAntiAlias(bool aa) {}
};

class ANDROID_API Group : public Node {
@@ -476,6 +481,12 @@ public:
        }
    }

    virtual void setAntiAlias(bool aa) {
        for (auto& child : mChildren) {
            child->setAntiAlias(aa);
        }
    }

private:
    GroupProperties mProperties = GroupProperties(this);
    GroupProperties mStagingProperties = GroupProperties(this);
@@ -641,6 +652,8 @@ public:
     */
    void updateCache(sp<skiapipeline::VectorDrawableAtlas>& atlas, GrContext* context);

    void setAntiAlias(bool aa) { mRootNode->setAntiAlias(aa); }

private:
    class Cache {
    public: