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

Commit b1b375ee authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Add an API to query maximum bitmap/texture size on Canvas."

parents a7987101 f61970fc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -7605,6 +7605,8 @@ package android.graphics {
    method public int getHeight();
    method public void getMatrix(android.graphics.Matrix);
    method public final android.graphics.Matrix getMatrix();
    method public int getMaximumBitmapHeight();
    method public int getMaximumBitmapWidth();
    method public int getSaveCount();
    method public int getWidth();
    method public boolean isHardwareAccelerated();
+13 −0
Original line number Diff line number Diff line
@@ -189,6 +189,19 @@ class GLES20Canvas extends HardwareCanvas {
        return mHeight;
    }

    @Override
    public int getMaximumBitmapWidth() {
        return nGetMaximumTextureWidth();
    }

    @Override
    public int getMaximumBitmapHeight() {
        return nGetMaximumTextureHeight();
    }

    private static native int nGetMaximumTextureWidth();
    private static native int nGetMaximumTextureHeight();    

    ///////////////////////////////////////////////////////////////////////////
    // Setup
    ///////////////////////////////////////////////////////////////////////////
+11 −0
Original line number Diff line number Diff line
@@ -161,6 +161,14 @@ static bool android_view_GLES20Canvas_callDrawGLFunction(JNIEnv* env, jobject cl
    return renderer->callDrawGLFunction(functor, dirty);
}

static jint android_view_GLES20Canvas_getMaxTextureWidth(JNIEnv* env, jobject clazz) {
    return Caches::getInstance().maxTextureSize;
}

static jint android_view_GLES20Canvas_getMaxTextureHeight(JNIEnv* env, jobject clazz) {
    return Caches::getInstance().maxTextureSize;
}

// ----------------------------------------------------------------------------
// State
// ----------------------------------------------------------------------------
@@ -803,6 +811,9 @@ static JNINativeMethod gMethods[] = {
    { "nDrawLayer",              "(IIFFI)V",   (void*) android_view_GLES20Canvas_drawLayer },
    { "nCopyLayer",              "(II)Z",      (void*) android_view_GLES20Canvas_copyLayer },

    { "nGetMaximumTextureWidth",  "()I",       (void*) android_view_GLES20Canvas_getMaxTextureWidth },
    { "nGetMaximumTextureHeight", "()I",       (void*) android_view_GLES20Canvas_getMaxTextureHeight },

#endif
};

+27 −1
Original line number Diff line number Diff line
@@ -74,6 +74,10 @@ public class Canvas {
     */
    public static final int DIRECTION_RTL = 1;

    // Maximum bitmap size as defined in Skia's native code
    // (see SkCanvas.cpp, SkDraw.cpp)
    private static final int MAXMIMUM_BITMAP_SIZE = 32766;

    // This field is used to finalize the native Canvas properly
    @SuppressWarnings({"UnusedDeclaration"})
    private final CanvasFinalizer mFinalizer;
@@ -260,6 +264,28 @@ public class Canvas {
        mScreenDensity = density;
    }

    /**
     * Returns the maximum allowed width for bitmaps drawn with this canvas.
     * Attempting to draw with a bitmap wider than this value will result
     * in an error.
     * 
     * @see #getMaximumBitmapHeight() 
     */
    public int getMaximumBitmapWidth() {
        return MAXMIMUM_BITMAP_SIZE;
    }
    
    /**
     * Returns the maximum allowed height for bitmaps drawn with this canvas.
     * Attempting to draw with a bitmap taller than this value will result
     * in an error.
     * 
     * @see #getMaximumBitmapWidth() 
     */
    public int getMaximumBitmapHeight() {
        return MAXMIMUM_BITMAP_SIZE;
    }

    // the SAVE_FLAG constants must match their native equivalents

    /** restore the current matrix when restore() is called */
+9 −0
Original line number Diff line number Diff line
@@ -30,6 +30,15 @@
        android:label="HwUi"
        android:hardwareAccelerated="true">

        <activity
                android:name="MaxBitmapSizeActivity"
                android:label="_MaxBitmapSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
                android:name="TimeDialogActivity"
                android:label="_TimeDialog">
Loading