From d6ddcb7f00a7af95b452233d965b922632f78f21 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 24 May 2010 19:00:08 -0700 Subject: fix [2677468] some 3rd party GL ES apps get a 32-bits surface by default and fail force all SurfaceView to 565 Change-Id: I8ebfa1239d8e4fa097c2e544677fb92fa20b39bd --- core/java/android/view/SurfaceView.java | 13 ++++++++++--- opengl/java/android/opengl/GLSurfaceView.java | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 2a3f03269cd9..cc30d71de313 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -140,7 +140,10 @@ public class SurfaceView extends View { boolean mViewVisibility = false; int mRequestedWidth = -1; int mRequestedHeight = -1; - int mRequestedFormat = PixelFormat.OPAQUE; + /* Set SurfaceView's format to 565 by default to maintain backward + * compatibility with applications assuming this format. + */ + int mRequestedFormat = PixelFormat.RGB_565; int mRequestedType = -1; boolean mHaveFrame = false; @@ -163,16 +166,20 @@ public class SurfaceView extends View { public SurfaceView(Context context) { super(context); - setWillNotDraw(true); + init(); } public SurfaceView(Context context, AttributeSet attrs) { super(context, attrs); - setWillNotDraw(true); + init(); } public SurfaceView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + init(); + } + + private void init() { setWillNotDraw(true); } diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index f904cdf6babb..2ff231da52ec 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -222,7 +222,6 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback // underlying surface is created and destroyed SurfaceHolder holder = getHolder(); holder.addCallback(this); - holder.setFormat(PixelFormat.RGB_565); // setType is not needed for SDK 2.0 or newer. Uncomment this // statement if back-porting this code to older SDKs. // holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); -- cgit v1.2.3-59-g8ed1b