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

Commit f285efe7 authored by Angel Aguayo's avatar Angel Aguayo Committed by Android (Google) Code Review
Browse files

Merge "Exposed SkCanvas::drawMesh"

parents 8a871ae8 90c46ee5
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public abstract class BaseCanvas {
    // These are also implemented in RecordingCanvas so that we can
    // selectively apply on them
    // Everything below here is copy/pasted from Canvas.java
    // The JNI registration is handled by android_view_Canvas.cpp
    // The JNI registration is handled by android_graphics_Canvas.cpp
    // ---------------------------------------------------------------------------

    public void drawArc(float left, float top, float right, float bottom, float startAngle,
@@ -667,6 +667,17 @@ public abstract class BaseCanvas {
                indices, indexOffset, indexCount, paint.getNativeInstance());
    }

    /**
     * @hide
     */
    public void drawMesh(Mesh mesh, BlendMode blendMode, Paint paint) {
        if (!isHardwareAccelerated() && onHwFeatureInSwMode()) {
            throw new RuntimeException("software rendering doesn't support meshes");
        }
        nDrawMesh(this.mNativeCanvasWrapper, mesh.getNativeWrapperInstance(),
                blendMode.getXfermode().porterDuffMode, paint.getNativeInstance());
    }

    /**
     * @hide
     */
@@ -801,6 +812,9 @@ public abstract class BaseCanvas {
            int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset,
            short[] indices, int indexOffset, int indexCount, long nativePaint);

    private static native void nDrawMesh(
            long nativeCanvas, long nativeMesh, int mode, long nativePaint);

    private static native void nDrawGlyphs(long nativeCanvas, int[] glyphIds, float[] positions,
            int glyphIdStart, int positionStart, int glyphCount, long nativeFont, long nativePaint);

+10 −0
Original line number Diff line number Diff line
@@ -606,6 +606,12 @@ public class BaseRecordingCanvas extends Canvas {
                indices, indexOffset, indexCount, paint.getNativeInstance());
    }

    @Override
    public final void drawMesh(Mesh mesh, BlendMode blendMode, Paint paint) {
        nDrawMesh(mNativeCanvasWrapper, mesh.getNativeWrapperInstance(),
                blendMode.getXfermode().porterDuffMode, paint.getNativeInstance());
    }

    /**
     * @hide
     */
@@ -707,6 +713,10 @@ public class BaseRecordingCanvas extends Canvas {
            int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset,
            long nativePaint);

    @FastNative
    private static native void nDrawMesh(
            long canvasHandle, long nativeMesh, int mode, long nativePaint);

    @FastNative
    private static native void nDrawVertices(long nativeCanvas, int mode, int n, float[] verts,
            int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset,
+9 −5
Original line number Diff line number Diff line
@@ -196,7 +196,6 @@ public class Mesh {
        }
        nativeUpdateUniforms(
                mNativeMeshWrapper, uniformName, value1, value2, value3, value4, count);
        nativeUpdateMesh(mNativeMeshWrapper);
    }

    private void setUniform(String uniformName, float[] values, boolean isColor) {
@@ -208,7 +207,6 @@ public class Mesh {
        }

        nativeUpdateUniforms(mNativeMeshWrapper, uniformName, values, isColor);
        nativeUpdateMesh(mNativeMeshWrapper);
    }

    /**
@@ -271,7 +269,14 @@ public class Mesh {
            throw new NullPointerException("The uniform values parameter must not be null");
        }
        nativeUpdateUniforms(mNativeMeshWrapper, uniformName, values);
        nativeUpdateMesh(mNativeMeshWrapper);
    }

    /**
     * @hide so only calls from module can utilize it
     */
    long getNativeWrapperInstance() {
        nativeUpdateMesh(mNativeMeshWrapper, mIsIndexed);
        return mNativeMeshWrapper;
    }

    private void setIntUniform(
@@ -282,7 +287,6 @@ public class Mesh {

        nativeUpdateUniforms(
                mNativeMeshWrapper, uniformName, value1, value2, value3, value4, count);
        nativeUpdateMesh(mNativeMeshWrapper);
    }

    private Mesh(long nativeMeshWrapper, boolean isIndexed) {
@@ -313,5 +317,5 @@ public class Mesh {

    private static native void nativeUpdateUniforms(long builder, String uniformName, int[] values);

    private static native void nativeUpdateMesh(long nativeMeshWrapper);
    private static native void nativeUpdateMesh(long nativeMeshWrapper, boolean mIsIndexed);
}
+2 −0
Original line number Diff line number Diff line
@@ -340,6 +340,8 @@ cc_defaults {
        "jni/Graphics.cpp",
        "jni/ImageDecoder.cpp",
        "jni/Interpolator.cpp",
        "jni/MeshSpecification.cpp",
        "jni/Mesh.cpp",
        "jni/MaskFilter.cpp",
        "jni/NinePatch.cpp",
        "jni/NinePatchPeeker.cpp",
+1 −0
Original line number Diff line number Diff line
@@ -52,3 +52,4 @@ X(DrawShadowRec)
X(DrawVectorDrawable)
X(DrawRippleDrawable)
X(DrawWebView)
X(DrawMesh)
Loading