Make full use of QT_ANDROID_RASTER_IMAGE_DEPTH env variable.

If raster only apps set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 (RGB16), we
should create also RGB16 native surface.

Change-Id: I82692ff34b0e604e627d1d86a437272e3700daf8
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
BogDan Vatra 2014-02-18 15:31:38 +02:00 committed by The Qt Project
parent 0febd75d52
commit 26a5727f75
7 changed files with 17 additions and 12 deletions

View File

@ -987,7 +987,7 @@ public class QtActivityDelegate
m_nativeViews.put(id, view); m_nativeViews.put(id, view);
} }
public void createSurface(int id, boolean onTop, int x, int y, int w, int h) { public void createSurface(int id, boolean onTop, int x, int y, int w, int h, int imageDepth) {
if (m_surfaces.size() == 0) { if (m_surfaces.size() == 0) {
TypedValue attr = new TypedValue(); TypedValue attr = new TypedValue();
m_activity.getTheme().resolveAttribute(android.R.attr.windowBackground, attr, true); m_activity.getTheme().resolveAttribute(android.R.attr.windowBackground, attr, true);
@ -1005,7 +1005,7 @@ public class QtActivityDelegate
if (m_surfaces.containsKey(id)) if (m_surfaces.containsKey(id))
m_layout.removeView(m_surfaces.remove(id)); m_layout.removeView(m_surfaces.remove(id));
QtSurface surface = new QtSurface(m_activity, id, onTop); QtSurface surface = new QtSurface(m_activity, id, onTop, imageDepth);
if (w < 0 || h < 0) { if (w < 0 || h < 0) {
surface.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, surface.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT)); ViewGroup.LayoutParams.MATCH_PARENT));

View File

@ -511,12 +511,12 @@ public class QtNative
return certificateArray; return certificateArray;
} }
private static void createSurface(final int id, final boolean onTop, final int x, final int y, final int w, final int h) private static void createSurface(final int id, final boolean onTop, final int x, final int y, final int w, final int h, final int imageDepth)
{ {
runAction(new Runnable() { runAction(new Runnable() {
@Override @Override
public void run() { public void run() {
m_activityDelegate.createSurface(id, onTop, x, y, w, h); m_activityDelegate.createSurface(id, onTop, x, y, w, h, imageDepth);
} }
}); });
} }

View File

@ -59,14 +59,18 @@ public class QtSurface extends SurfaceView implements SurfaceHolder.Callback
private GestureDetector m_gestureDetector; private GestureDetector m_gestureDetector;
private Object m_accessibilityDelegate = null; private Object m_accessibilityDelegate = null;
public QtSurface(Context context, int id, boolean onTop) public QtSurface(Context context, int id, boolean onTop, int imageDepth)
{ {
super(context); super(context);
setFocusable(false); setFocusable(false);
setFocusableInTouchMode(false); setFocusableInTouchMode(false);
setZOrderMediaOverlay(onTop); setZOrderMediaOverlay(onTop);
getHolder().addCallback(this); getHolder().addCallback(this);
getHolder().setFormat(PixelFormat.RGBA_8888); if (imageDepth == 16)
getHolder().setFormat(PixelFormat.RGB_565);
else
getHolder().setFormat(PixelFormat.RGBA_8888);
if (android.os.Build.VERSION.SDK_INT < 11) if (android.os.Build.VERSION.SDK_INT < 11)
getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);

View File

@ -334,7 +334,7 @@ namespace QtAndroid
return manufacturer + QStringLiteral(" ") + model; return manufacturer + QStringLiteral(" ") + model;
} }
int createSurface(AndroidSurfaceClient *client, const QRect &geometry, bool onTop) int createSurface(AndroidSurfaceClient *client, const QRect &geometry, bool onTop, int imageDepth)
{ {
QJNIEnvironmentPrivate env; QJNIEnvironmentPrivate env;
if (!env) if (!env)
@ -356,7 +356,8 @@ namespace QtAndroid
m_createSurfaceMethodID, m_createSurfaceMethodID,
surfaceId, surfaceId,
jboolean(onTop), jboolean(onTop),
x, y, w, h); x, y, w, h,
imageDepth);
return surfaceId; return surfaceId;
} }
@ -689,7 +690,7 @@ static int registerNatives(JNIEnv *env)
return JNI_FALSE; return JNI_FALSE;
} }
GET_AND_CHECK_STATIC_METHOD(m_createSurfaceMethodID, m_applicationClass, "createSurface", "(IZIIII)V"); GET_AND_CHECK_STATIC_METHOD(m_createSurfaceMethodID, m_applicationClass, "createSurface", "(IZIIIII)V");
GET_AND_CHECK_STATIC_METHOD(m_insertNativeViewMethodID, m_applicationClass, "insertNativeView", "(ILandroid/view/View;IIII)V"); GET_AND_CHECK_STATIC_METHOD(m_insertNativeViewMethodID, m_applicationClass, "insertNativeView", "(ILandroid/view/View;IIII)V");
GET_AND_CHECK_STATIC_METHOD(m_setSurfaceGeometryMethodID, m_applicationClass, "setSurfaceGeometry", "(IIIII)V"); GET_AND_CHECK_STATIC_METHOD(m_setSurfaceGeometryMethodID, m_applicationClass, "setSurfaceGeometry", "(IIIII)V");
GET_AND_CHECK_STATIC_METHOD(m_destroySurfaceMethodID, m_applicationClass, "destroySurface", "(I)V"); GET_AND_CHECK_STATIC_METHOD(m_destroySurfaceMethodID, m_applicationClass, "destroySurface", "(I)V");

View File

@ -66,7 +66,7 @@ namespace QtAndroid
void setQtThread(QThread *thread); void setQtThread(QThread *thread);
int createSurface(AndroidSurfaceClient * client, const QRect &geometry, bool onTop); int createSurface(AndroidSurfaceClient * client, const QRect &geometry, bool onTop, int imageDepth);
int insertNativeView(jobject view, const QRect &geometry); int insertNativeView(jobject view, const QRect &geometry);
void setSurfaceGeometry(int surfaceId, const QRect &geometry); void setSurfaceGeometry(int surfaceId, const QRect &geometry);
void destroySurface(int surfaceId); void destroySurface(int surfaceId);

View File

@ -57,7 +57,7 @@ QAndroidPlatformOpenGLWindow::QAndroidPlatformOpenGLWindow(QWindow *window, EGLD
:QAndroidPlatformWindow(window), m_eglDisplay(display) :QAndroidPlatformWindow(window), m_eglDisplay(display)
{ {
lockSurface(); lockSurface();
m_nativeSurfaceId = QtAndroid::createSurface(this, geometry(), bool(window->flags() & Qt::WindowStaysOnTopHint)); m_nativeSurfaceId = QtAndroid::createSurface(this, geometry(), bool(window->flags() & Qt::WindowStaysOnTopHint), 32);
m_surfaceWaitCondition.wait(&m_surfaceMutex); m_surfaceWaitCondition.wait(&m_surfaceMutex);
unlockSurface(); unlockSurface();
} }

View File

@ -247,7 +247,7 @@ void QAndroidPlatformScreen::doRedraw()
QMutexLocker lock(&m_surfaceMutex); QMutexLocker lock(&m_surfaceMutex);
if (m_id == -1) { if (m_id == -1) {
m_id = QtAndroid::createSurface(this, m_geometry, true); m_id = QtAndroid::createSurface(this, m_geometry, true, m_depth);
m_surfaceWaitCondition.wait(&m_surfaceMutex); m_surfaceWaitCondition.wait(&m_surfaceMutex);
} }