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

Commit dfdc3791 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "detect api version, and start respecting offsets" into pi-dev

parents 0ed26bc8 322bc57a
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@
#include "GraphicsJNI.h"
#include "GraphicsJNI.h"
#include "core_jni_helpers.h"
#include "core_jni_helpers.h"


#include <android/api-level.h>
#include <androidfw/ResourceTypes.h>
#include <androidfw/ResourceTypes.h>
#include <hwui/Canvas.h>
#include <hwui/Canvas.h>
#include <hwui/Paint.h>
#include <hwui/Paint.h>
@@ -467,6 +468,13 @@ static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle,
static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
                           jint meshWidth, jint meshHeight, jfloatArray jverts,
                           jint meshWidth, jint meshHeight, jfloatArray jverts,
                           jint vertIndex, jintArray jcolors, jint colorIndex, jlong paintHandle) {
                           jint vertIndex, jintArray jcolors, jint colorIndex, jlong paintHandle) {
    if (Canvas::GetApiLevel() < __ANDROID_API_P__) {
        // Before P we forgot to respect these. Now that we do respect them, explicitly
        // zero them for backward compatibility.
        vertIndex = 0;
        colorIndex = 0;
    }

    const int ptCount = (meshWidth + 1) * (meshHeight + 1);
    const int ptCount = (meshWidth + 1) * (meshHeight + 1);
    AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1));
    AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1));
    AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount);
    AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount);
@@ -474,7 +482,8 @@ static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbi
    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
    Bitmap& bitmap = android::bitmap::toBitmap(env, jbitmap);
    Bitmap& bitmap = android::bitmap::toBitmap(env, jbitmap);
    get_canvas(canvasHandle)->drawBitmapMesh(bitmap, meshWidth, meshHeight,
    get_canvas(canvasHandle)->drawBitmapMesh(bitmap, meshWidth, meshHeight,
                                             vertA.ptr(), colorA.ptr(), paint);
                                             vertA.ptr() + vertIndex*2,
                                             colorA.ptr() + colorIndex, paint);
}
}


static void drawTextChars(JNIEnv* env, jobject, jlong canvasHandle, jcharArray text,
static void drawTextChars(JNIEnv* env, jobject, jlong canvasHandle, jcharArray text,
+4 −0
Original line number Original line Diff line number Diff line
@@ -1490,6 +1490,10 @@ public class Canvas extends BaseCanvas {
     * across the top of the bitmap from left to right. A more general version of this method is
     * across the top of the bitmap from left to right. A more general version of this method is
     * drawVertices().
     * drawVertices().
     *
     *
     * Prior to API level {@value Build.VERSION_CODES#P} vertOffset and colorOffset were ignored,
     * effectively treating them as zeros. In API level {@value Build.VERSION_CODES#P} and above
     * these parameters will be respected.
     *
     * @param bitmap The bitmap to draw using the mesh
     * @param bitmap The bitmap to draw using the mesh
     * @param meshWidth The number of columns in the mesh. Nothing is drawn if this is 0
     * @param meshWidth The number of columns in the mesh. Nothing is drawn if this is 0
     * @param meshHeight The number of rows in the mesh. Nothing is drawn if this is 0
     * @param meshHeight The number of rows in the mesh. Nothing is drawn if this is 0
+2 −0
Original line number Original line Diff line number Diff line
@@ -276,6 +276,8 @@ public:
                        const SkPath& path, float hOffset, float vOffset, const Paint& paint,
                        const SkPath& path, float hOffset, float vOffset, const Paint& paint,
                        const Typeface* typeface);
                        const Typeface* typeface);


    static int GetApiLevel() { return sApiLevel; }

protected:
protected:
    void drawTextDecorations(float x, float y, float length, const SkPaint& paint);
    void drawTextDecorations(float x, float y, float length, const SkPaint& paint);