Loading core/java/android/view/TextureView.java +11 −3 Original line number Diff line number Diff line Loading @@ -649,12 +649,18 @@ public class TextureView extends View { * pixels outside the dirty rectangle will be preserved by the next call * to lockCanvas(). * * This method can return null if the underlying surface texture is not * available (see {@link #isAvailable()} or if the surface texture is * already connected to an image producer (for instance: the camera, * OpenGL, a media player, etc.) * * @param dirty Area of the surface that will be modified. * @return A Canvas used to draw into the surface. * * @see #lockCanvas() * @see #unlockCanvasAndPost(android.graphics.Canvas) * @see #isAvailable() */ public Canvas lockCanvas(Rect dirty) { if (!isAvailable()) return null; Loading @@ -664,7 +670,9 @@ public class TextureView extends View { } synchronized (mNativeWindowLock) { nLockCanvas(mNativeWindow, mCanvas, dirty); if (!nLockCanvas(mNativeWindow, mCanvas, dirty)) { return null; } } mSaveCount = mCanvas.save(); Loading Loading @@ -803,6 +811,6 @@ public class TextureView extends View { private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture, int width, int height); private static native void nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas); } core/jni/android_view_TextureView.cpp +9 −5 Original line number Diff line number Diff line Loading @@ -134,11 +134,11 @@ static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCa SkSafeUnref(previousCanvas); } static void android_view_TextureView_lockCanvas(JNIEnv* env, jobject, static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject, jint nativeWindow, jobject canvas, jobject dirtyRect) { if (!nativeWindow) { return; return false; } ANativeWindow_Buffer buffer; Loading @@ -154,7 +154,8 @@ static void android_view_TextureView_lockCanvas(JNIEnv* env, jobject, } sp<ANativeWindow> window((ANativeWindow*) nativeWindow); native_window_lock(window.get(), &buffer, &rect); int32_t status = native_window_lock(window.get(), &buffer, &rect); if (status) return false; ssize_t bytesCount = buffer.stride * bytesPerPixel(buffer.format); Loading Loading @@ -184,6 +185,8 @@ static void android_view_TextureView_lockCanvas(JNIEnv* env, jobject, INVOKEV(dirtyRect, gRectClassInfo.set, int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); } return true; } static void android_view_TextureView_unlockCanvasAndPost(JNIEnv* env, jobject, Loading Loading @@ -213,7 +216,7 @@ static JNINativeMethod gMethods[] = { { "nDestroyNativeWindow", "()V", (void*) android_view_TextureView_destroyNativeWindow }, { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)V", { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", (void*) android_view_TextureView_lockCanvas }, { "nUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)V", (void*) android_view_TextureView_unlockCanvasAndPost }, Loading Loading @@ -241,7 +244,8 @@ int register_android_view_TextureView(JNIEnv* env) { GET_FIELD_ID(gRectClassInfo.bottom, clazz, "bottom", "I"); FIND_CLASS(clazz, "android/graphics/Canvas"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); GET_FIELD_ID(gCanvasClassInfo.mSurfaceFormat, clazz, "mSurfaceFormat", "I"); Loading Loading
core/java/android/view/TextureView.java +11 −3 Original line number Diff line number Diff line Loading @@ -649,12 +649,18 @@ public class TextureView extends View { * pixels outside the dirty rectangle will be preserved by the next call * to lockCanvas(). * * This method can return null if the underlying surface texture is not * available (see {@link #isAvailable()} or if the surface texture is * already connected to an image producer (for instance: the camera, * OpenGL, a media player, etc.) * * @param dirty Area of the surface that will be modified. * @return A Canvas used to draw into the surface. * * @see #lockCanvas() * @see #unlockCanvasAndPost(android.graphics.Canvas) * @see #isAvailable() */ public Canvas lockCanvas(Rect dirty) { if (!isAvailable()) return null; Loading @@ -664,7 +670,9 @@ public class TextureView extends View { } synchronized (mNativeWindowLock) { nLockCanvas(mNativeWindow, mCanvas, dirty); if (!nLockCanvas(mNativeWindow, mCanvas, dirty)) { return null; } } mSaveCount = mCanvas.save(); Loading Loading @@ -803,6 +811,6 @@ public class TextureView extends View { private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture, int width, int height); private static native void nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas); }
core/jni/android_view_TextureView.cpp +9 −5 Original line number Diff line number Diff line Loading @@ -134,11 +134,11 @@ static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCa SkSafeUnref(previousCanvas); } static void android_view_TextureView_lockCanvas(JNIEnv* env, jobject, static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject, jint nativeWindow, jobject canvas, jobject dirtyRect) { if (!nativeWindow) { return; return false; } ANativeWindow_Buffer buffer; Loading @@ -154,7 +154,8 @@ static void android_view_TextureView_lockCanvas(JNIEnv* env, jobject, } sp<ANativeWindow> window((ANativeWindow*) nativeWindow); native_window_lock(window.get(), &buffer, &rect); int32_t status = native_window_lock(window.get(), &buffer, &rect); if (status) return false; ssize_t bytesCount = buffer.stride * bytesPerPixel(buffer.format); Loading Loading @@ -184,6 +185,8 @@ static void android_view_TextureView_lockCanvas(JNIEnv* env, jobject, INVOKEV(dirtyRect, gRectClassInfo.set, int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); } return true; } static void android_view_TextureView_unlockCanvasAndPost(JNIEnv* env, jobject, Loading Loading @@ -213,7 +216,7 @@ static JNINativeMethod gMethods[] = { { "nDestroyNativeWindow", "()V", (void*) android_view_TextureView_destroyNativeWindow }, { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)V", { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", (void*) android_view_TextureView_lockCanvas }, { "nUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)V", (void*) android_view_TextureView_unlockCanvasAndPost }, Loading Loading @@ -241,7 +244,8 @@ int register_android_view_TextureView(JNIEnv* env) { GET_FIELD_ID(gRectClassInfo.bottom, clazz, "bottom", "I"); FIND_CLASS(clazz, "android/graphics/Canvas"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); GET_FIELD_ID(gCanvasClassInfo.mSurfaceFormat, clazz, "mSurfaceFormat", "I"); Loading