Loading core/java/android/view/GLRenderer.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -1097,9 +1097,10 @@ public class GLRenderer extends HardwareRenderer { } } @Override @Override void setup(int width, int height) { void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) { if (validate()) { if (validate()) { mCanvas.setViewport(width, height); mCanvas.setViewport(width, height); mCanvas.initializeLight(lightX, lightY, lightZ, lightRadius); mWidth = width; mWidth = width; mHeight = height; mHeight = height; } } Loading core/java/android/view/HardwareRenderer.java +18 −8 Original line number Original line Diff line number Diff line Loading @@ -273,12 +273,16 @@ public abstract class HardwareRenderer { * * * @param width Width of the drawing surface. * @param width Width of the drawing surface. * @param height Height of the drawing surface. * @param height Height of the drawing surface. * @param lightX X position of the shadow casting light * @param lightY Y position of the shadow casting light * @param lightZ Z position of the shadow casting light * @param lightRadius radius of the shadow casting light */ */ abstract void setup(int width, int height); abstract void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius); /** /** * Gets the current width of the surface. This is the width that the surface * Gets the current width of the surface. This is the width that the surface * was last set to in a call to {@link #setup(int, int)}. * was last set to in a call to {@link #setup(int, int, float, float, float, float)}. * * * @return the current width of the surface * @return the current width of the surface */ */ Loading @@ -286,7 +290,7 @@ public abstract class HardwareRenderer { /** /** * Gets the current height of the surface. This is the height that the surface * Gets the current height of the surface. This is the height that the surface * was last set to in a call to {@link #setup(int, int)}. * was last set to in a call to {@link #setup(int, int, float, float, float, float)}. * * * @return the current width of the surface * @return the current width of the surface */ */ Loading @@ -310,9 +314,6 @@ public abstract class HardwareRenderer { * whenever system properties are modified. Implementations can use this * whenever system properties are modified. Implementations can use this * to trigger live updates of the renderer based on properties. * to trigger live updates of the renderer based on properties. * * * @param surface The surface to update with the new properties. * Can be null. * * @return True if a property has changed. * @return True if a property has changed. */ */ abstract boolean loadSystemProperties(); abstract boolean loadSystemProperties(); Loading Loading @@ -443,17 +444,18 @@ public abstract class HardwareRenderer { * @param width The width of the drawing surface. * @param width The width of the drawing surface. * @param height The height of the drawing surface. * @param height The height of the drawing surface. * @param surface The surface to hardware accelerate * @param surface The surface to hardware accelerate * @param metrics The display metrics used to draw the output. * * * @return true if the surface was initialized, false otherwise. Returning * @return true if the surface was initialized, false otherwise. Returning * false might mean that the surface was already initialized. * false might mean that the surface was already initialized. */ */ boolean initializeIfNeeded(int width, int height, Surface surface) boolean initializeIfNeeded(int width, int height, Surface surface, DisplayMetrics metrics) throws OutOfResourcesException { throws OutOfResourcesException { if (isRequested()) { if (isRequested()) { // We lost the gl context, so recreate it. // We lost the gl context, so recreate it. if (!isEnabled()) { if (!isEnabled()) { if (initialize(surface)) { if (initialize(surface)) { setup(width, height); setup(width, height, metrics); return true; return true; } } } } Loading @@ -461,6 +463,14 @@ public abstract class HardwareRenderer { return false; return false; } } void setup(int width, int height, DisplayMetrics metrics) { float lightX = width / 2.0f; float lightY = -400 * metrics.density; float lightZ = 800 * metrics.density; float lightRadius = 800 * metrics.density; setup(width, height, lightX, lightY, lightZ, lightRadius); } /** /** * Optional, sets the name of the renderer. Useful for debugging purposes. * Optional, sets the name of the renderer. Useful for debugging purposes. * * Loading core/java/android/view/ThreadedRenderer.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -145,11 +145,11 @@ public class ThreadedRenderer extends HardwareRenderer { } } @Override @Override void setup(int width, int height) { void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) { mWidth = width; mWidth = width; mHeight = height; mHeight = height; mRootNode.setLeftTopRightBottom(0, 0, mWidth, mHeight); mRootNode.setLeftTopRightBottom(0, 0, mWidth, mHeight); nSetup(mNativeProxy, width, height); nSetup(mNativeProxy, width, height, lightX, lightY, lightZ, lightRadius); } } @Override @Override Loading Loading @@ -348,10 +348,9 @@ public class ThreadedRenderer extends HardwareRenderer { private static native boolean nInitialize(long nativeProxy, Surface window); private static native boolean nInitialize(long nativeProxy, Surface window); private static native void nUpdateSurface(long nativeProxy, Surface window); private static native void nUpdateSurface(long nativeProxy, Surface window); private static native void nPauseSurface(long nativeProxy, Surface window); private static native void nPauseSurface(long nativeProxy, Surface window); private static native void nSetup(long nativeProxy, int width, int height); private static native void nSetup(long nativeProxy, int width, int height, float lightX, float lightY, float lightZ, float lightRadius); private static native void nSetOpaque(long nativeProxy, boolean opaque); private static native void nSetOpaque(long nativeProxy, boolean opaque); private static native void nSetDisplayListData(long nativeProxy, long displayList, long newData); private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos, private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos, int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); private static native void nRunWithGlContext(long nativeProxy, Runnable runnable); private static native void nRunWithGlContext(long nativeProxy, Runnable runnable); Loading core/java/android/view/ViewRootImpl.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.PowerManager; import android.os.Process; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; Loading Loading @@ -1714,7 +1713,8 @@ public final class ViewRootImpl implements ViewParent, if (hwInitialized || if (hwInitialized || mWidth != mAttachInfo.mHardwareRenderer.getWidth() || mWidth != mAttachInfo.mHardwareRenderer.getWidth() || mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight); mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight, mAttachInfo.mRootView.getResources().getDisplayMetrics()); if (!hwInitialized) { if (!hwInitialized) { mAttachInfo.mHardwareRenderer.invalidate(mSurface); mAttachInfo.mHardwareRenderer.invalidate(mSurface); mFullRedrawNeeded = true; mFullRedrawNeeded = true; Loading Loading @@ -2453,7 +2453,7 @@ public final class ViewRootImpl implements ViewParent, try { try { attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, mSurface); mSurface, attachInfo.mRootView.getResources().getDisplayMetrics()); } catch (OutOfResourcesException e) { } catch (OutOfResourcesException e) { handleOutOfResourcesException(e); handleOutOfResourcesException(e); return; return; Loading Loading @@ -3151,7 +3151,8 @@ public final class ViewRootImpl implements ViewParent, mFullRedrawNeeded = true; mFullRedrawNeeded = true; try { try { mAttachInfo.mHardwareRenderer.initializeIfNeeded( mAttachInfo.mHardwareRenderer.initializeIfNeeded( mWidth, mHeight, mSurface); mWidth, mHeight, mSurface, mAttachInfo.mRootView.getResources().getDisplayMetrics()); } catch (OutOfResourcesException e) { } catch (OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException locking surface", e); Log.e(TAG, "OutOfResourcesException locking surface", e); try { try { Loading core/jni/android_view_ThreadedRenderer.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <renderthread/RenderProxy.h> #include <renderthread/RenderProxy.h> #include <renderthread/RenderTask.h> #include <renderthread/RenderTask.h> #include <renderthread/RenderThread.h> #include <renderthread/RenderThread.h> #include <Vector.h> namespace android { namespace android { Loading Loading @@ -223,10 +224,11 @@ static void android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject claz proxy->pauseSurface(window); proxy->pauseSurface(window); } } static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr, jlong proxyPtr, jint width, jint height) { jint width, jint height, jfloat lightX, jfloat lightY, jfloat lightZ, jfloat lightRadius) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); proxy->setup(width, height); proxy->setup(width, height, Vector3(lightX, lightY, lightZ), lightRadius); } } static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz, static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz, Loading Loading @@ -316,7 +318,7 @@ static JNINativeMethod gMethods[] = { { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize }, { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize }, { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface }, { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface }, { "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface }, { "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface }, { "nSetup", "(JII)V", (void*) android_view_ThreadedRenderer_setup }, { "nSetup", "(JIIFFFF)V", (void*) android_view_ThreadedRenderer_setup }, { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque }, { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque }, { "nSyncAndDrawFrame", "(JJIIII)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame }, { "nSyncAndDrawFrame", "(JJIIII)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame }, { "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface }, { "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface }, Loading Loading
core/java/android/view/GLRenderer.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -1097,9 +1097,10 @@ public class GLRenderer extends HardwareRenderer { } } @Override @Override void setup(int width, int height) { void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) { if (validate()) { if (validate()) { mCanvas.setViewport(width, height); mCanvas.setViewport(width, height); mCanvas.initializeLight(lightX, lightY, lightZ, lightRadius); mWidth = width; mWidth = width; mHeight = height; mHeight = height; } } Loading
core/java/android/view/HardwareRenderer.java +18 −8 Original line number Original line Diff line number Diff line Loading @@ -273,12 +273,16 @@ public abstract class HardwareRenderer { * * * @param width Width of the drawing surface. * @param width Width of the drawing surface. * @param height Height of the drawing surface. * @param height Height of the drawing surface. * @param lightX X position of the shadow casting light * @param lightY Y position of the shadow casting light * @param lightZ Z position of the shadow casting light * @param lightRadius radius of the shadow casting light */ */ abstract void setup(int width, int height); abstract void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius); /** /** * Gets the current width of the surface. This is the width that the surface * Gets the current width of the surface. This is the width that the surface * was last set to in a call to {@link #setup(int, int)}. * was last set to in a call to {@link #setup(int, int, float, float, float, float)}. * * * @return the current width of the surface * @return the current width of the surface */ */ Loading @@ -286,7 +290,7 @@ public abstract class HardwareRenderer { /** /** * Gets the current height of the surface. This is the height that the surface * Gets the current height of the surface. This is the height that the surface * was last set to in a call to {@link #setup(int, int)}. * was last set to in a call to {@link #setup(int, int, float, float, float, float)}. * * * @return the current width of the surface * @return the current width of the surface */ */ Loading @@ -310,9 +314,6 @@ public abstract class HardwareRenderer { * whenever system properties are modified. Implementations can use this * whenever system properties are modified. Implementations can use this * to trigger live updates of the renderer based on properties. * to trigger live updates of the renderer based on properties. * * * @param surface The surface to update with the new properties. * Can be null. * * @return True if a property has changed. * @return True if a property has changed. */ */ abstract boolean loadSystemProperties(); abstract boolean loadSystemProperties(); Loading Loading @@ -443,17 +444,18 @@ public abstract class HardwareRenderer { * @param width The width of the drawing surface. * @param width The width of the drawing surface. * @param height The height of the drawing surface. * @param height The height of the drawing surface. * @param surface The surface to hardware accelerate * @param surface The surface to hardware accelerate * @param metrics The display metrics used to draw the output. * * * @return true if the surface was initialized, false otherwise. Returning * @return true if the surface was initialized, false otherwise. Returning * false might mean that the surface was already initialized. * false might mean that the surface was already initialized. */ */ boolean initializeIfNeeded(int width, int height, Surface surface) boolean initializeIfNeeded(int width, int height, Surface surface, DisplayMetrics metrics) throws OutOfResourcesException { throws OutOfResourcesException { if (isRequested()) { if (isRequested()) { // We lost the gl context, so recreate it. // We lost the gl context, so recreate it. if (!isEnabled()) { if (!isEnabled()) { if (initialize(surface)) { if (initialize(surface)) { setup(width, height); setup(width, height, metrics); return true; return true; } } } } Loading @@ -461,6 +463,14 @@ public abstract class HardwareRenderer { return false; return false; } } void setup(int width, int height, DisplayMetrics metrics) { float lightX = width / 2.0f; float lightY = -400 * metrics.density; float lightZ = 800 * metrics.density; float lightRadius = 800 * metrics.density; setup(width, height, lightX, lightY, lightZ, lightRadius); } /** /** * Optional, sets the name of the renderer. Useful for debugging purposes. * Optional, sets the name of the renderer. Useful for debugging purposes. * * Loading
core/java/android/view/ThreadedRenderer.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -145,11 +145,11 @@ public class ThreadedRenderer extends HardwareRenderer { } } @Override @Override void setup(int width, int height) { void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) { mWidth = width; mWidth = width; mHeight = height; mHeight = height; mRootNode.setLeftTopRightBottom(0, 0, mWidth, mHeight); mRootNode.setLeftTopRightBottom(0, 0, mWidth, mHeight); nSetup(mNativeProxy, width, height); nSetup(mNativeProxy, width, height, lightX, lightY, lightZ, lightRadius); } } @Override @Override Loading Loading @@ -348,10 +348,9 @@ public class ThreadedRenderer extends HardwareRenderer { private static native boolean nInitialize(long nativeProxy, Surface window); private static native boolean nInitialize(long nativeProxy, Surface window); private static native void nUpdateSurface(long nativeProxy, Surface window); private static native void nUpdateSurface(long nativeProxy, Surface window); private static native void nPauseSurface(long nativeProxy, Surface window); private static native void nPauseSurface(long nativeProxy, Surface window); private static native void nSetup(long nativeProxy, int width, int height); private static native void nSetup(long nativeProxy, int width, int height, float lightX, float lightY, float lightZ, float lightRadius); private static native void nSetOpaque(long nativeProxy, boolean opaque); private static native void nSetOpaque(long nativeProxy, boolean opaque); private static native void nSetDisplayListData(long nativeProxy, long displayList, long newData); private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos, private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos, int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); private static native void nRunWithGlContext(long nativeProxy, Runnable runnable); private static native void nRunWithGlContext(long nativeProxy, Runnable runnable); Loading
core/java/android/view/ViewRootImpl.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.PowerManager; import android.os.Process; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; Loading Loading @@ -1714,7 +1713,8 @@ public final class ViewRootImpl implements ViewParent, if (hwInitialized || if (hwInitialized || mWidth != mAttachInfo.mHardwareRenderer.getWidth() || mWidth != mAttachInfo.mHardwareRenderer.getWidth() || mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight); mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight, mAttachInfo.mRootView.getResources().getDisplayMetrics()); if (!hwInitialized) { if (!hwInitialized) { mAttachInfo.mHardwareRenderer.invalidate(mSurface); mAttachInfo.mHardwareRenderer.invalidate(mSurface); mFullRedrawNeeded = true; mFullRedrawNeeded = true; Loading Loading @@ -2453,7 +2453,7 @@ public final class ViewRootImpl implements ViewParent, try { try { attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, mSurface); mSurface, attachInfo.mRootView.getResources().getDisplayMetrics()); } catch (OutOfResourcesException e) { } catch (OutOfResourcesException e) { handleOutOfResourcesException(e); handleOutOfResourcesException(e); return; return; Loading Loading @@ -3151,7 +3151,8 @@ public final class ViewRootImpl implements ViewParent, mFullRedrawNeeded = true; mFullRedrawNeeded = true; try { try { mAttachInfo.mHardwareRenderer.initializeIfNeeded( mAttachInfo.mHardwareRenderer.initializeIfNeeded( mWidth, mHeight, mSurface); mWidth, mHeight, mSurface, mAttachInfo.mRootView.getResources().getDisplayMetrics()); } catch (OutOfResourcesException e) { } catch (OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException locking surface", e); Log.e(TAG, "OutOfResourcesException locking surface", e); try { try { Loading
core/jni/android_view_ThreadedRenderer.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <renderthread/RenderProxy.h> #include <renderthread/RenderProxy.h> #include <renderthread/RenderTask.h> #include <renderthread/RenderTask.h> #include <renderthread/RenderThread.h> #include <renderthread/RenderThread.h> #include <Vector.h> namespace android { namespace android { Loading Loading @@ -223,10 +224,11 @@ static void android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject claz proxy->pauseSurface(window); proxy->pauseSurface(window); } } static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr, jlong proxyPtr, jint width, jint height) { jint width, jint height, jfloat lightX, jfloat lightY, jfloat lightZ, jfloat lightRadius) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); proxy->setup(width, height); proxy->setup(width, height, Vector3(lightX, lightY, lightZ), lightRadius); } } static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz, static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz, Loading Loading @@ -316,7 +318,7 @@ static JNINativeMethod gMethods[] = { { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize }, { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize }, { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface }, { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface }, { "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface }, { "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface }, { "nSetup", "(JII)V", (void*) android_view_ThreadedRenderer_setup }, { "nSetup", "(JIIFFFF)V", (void*) android_view_ThreadedRenderer_setup }, { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque }, { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque }, { "nSyncAndDrawFrame", "(JJIIII)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame }, { "nSyncAndDrawFrame", "(JJIIII)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame }, { "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface }, { "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface }, Loading