Add plumbing for new surface flinger display API.

Cleaned up the implementation of Surface and SurfaceSession
to use more consistent naming and structure.

Added JNI for all of the new surface flinger display API calls.

Enforced the requirement that all Surfaces created by
the window manager be named.

Updated the display manager service to use the new methods.

Change-Id: I2a658f1bfd0437e1c6f9d22df8d4ffcce7284ca2
This commit is contained in:
Jeff Brown
2012-08-26 02:47:39 -07:00
parent 0b722fe9ce
commit 64a55af0ac
34 changed files with 1567 additions and 1212 deletions

View File

@@ -6475,6 +6475,7 @@ package android.content.pm {
method public abstract int checkSignatures(int, int);
method public abstract void clearPackagePreferredActivities(java.lang.String);
method public abstract java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public abstract void extendVerificationTimeout(int, int, long);
method public abstract android.graphics.drawable.Drawable getActivityIcon(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.graphics.drawable.Drawable getActivityIcon(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.ActivityInfo getActivityInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -6533,7 +6534,6 @@ package android.content.pm {
method public abstract void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public abstract void setInstallerPackageName(java.lang.String, java.lang.String);
method public abstract void verifyPendingInstall(int, int);
method public abstract void extendVerificationTimeout(int, int, long);
field public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; // 0x0
field public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; // 0x2
field public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; // 0x3
@@ -6594,6 +6594,7 @@ package android.content.pm {
field public static final int GET_UNINSTALLED_PACKAGES = 8192; // 0x2000
field public static final int GET_URI_PERMISSION_PATTERNS = 2048; // 0x800
field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000
field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L
field public static final int PERMISSION_DENIED = -1; // 0xffffffff
field public static final int PERMISSION_GRANTED = 0; // 0x0
field public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; // 0xffffffff
@@ -6604,7 +6605,6 @@ package android.content.pm {
field public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; // 0xfffffffc
field public static final int VERIFICATION_ALLOW = 1; // 0x1
field public static final int VERIFICATION_REJECT = -1; // 0xffffffff
field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80
}
public static class PackageManager.NameNotFoundException extends android.util.AndroidException {
@@ -20069,8 +20069,8 @@ package android.service.dreams {
method public void setContentView(android.view.View);
method public void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
method public void setInteractive(boolean);
field public static final java.lang.String SERVICE_INTERFACE = "android.service.dreams.Dream";
field public static final java.lang.String METADATA_NAME_CONFIG_ACTIVITY = "android.service.dreams.config_activity";
field public static final java.lang.String SERVICE_INTERFACE = "android.service.dreams.Dream";
}
}
@@ -21328,6 +21328,7 @@ package android.test.mock {
method public int checkSignatures(int, int);
method public void clearPackagePreferredActivities(java.lang.String);
method public java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public void extendVerificationTimeout(int, int, long);
method public android.graphics.drawable.Drawable getActivityIcon(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.graphics.drawable.Drawable getActivityIcon(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.ActivityInfo getActivityInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -21385,7 +21386,6 @@ package android.test.mock {
method public void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public void setInstallerPackageName(java.lang.String, java.lang.String);
method public void verifyPendingInstall(int, int);
method public void extendVerificationTimeout(int, int, long);
}
public class MockResources extends android.content.res.Resources {
@@ -24422,7 +24422,7 @@ package android.view {
method public android.graphics.Canvas lockCanvas(android.graphics.Rect) throws java.lang.IllegalArgumentException, android.view.Surface.OutOfResourcesException;
method public void readFromParcel(android.os.Parcel);
method public void release();
method public void unlockCanvas(android.graphics.Canvas);
method public deprecated void unlockCanvas(android.graphics.Canvas);
method public void unlockCanvasAndPost(android.graphics.Canvas);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;

File diff suppressed because it is too large Load Diff

View File

@@ -16,30 +16,32 @@
package android.view;
/**
* An instance of this class represents a connection to the surface
* flinger, in which you can create one or more Surface instances that will
* flinger, from which you can create one or more Surface instances that will
* be composited to the screen.
* {@hide}
*/
public class SurfaceSession {
private int mClient;
public final class SurfaceSession {
// Note: This field is accessed by native code.
private int mNativeClient; // SurfaceComposerClient*
private native void nativeInit();
private native void nativeDestroy();
private native void nativeKill();
private static native int nativeCreate();
private static native void nativeDestroy(int ptr);
private static native void nativeKill(int ptr);
/** Create a new connection with the surface flinger. */
public SurfaceSession() {
nativeInit();
mNativeClient = nativeCreate();
}
/* no user serviceable parts here ... */
@Override
protected void finalize() throws Throwable {
try {
nativeDestroy();
if (mNativeClient != 0) {
nativeDestroy(mNativeClient);
}
} finally {
super.finalize();
}
@@ -48,10 +50,10 @@ public class SurfaceSession {
/**
* Forcibly detach native resources associated with this object.
* Unlike destroy(), after this call any surfaces that were created
* from the session will no longer work. The session itself is destroyed.
* from the session will no longer work.
*/
public void kill() {
nativeKill();
nativeKill(mNativeClient);
}
}

View File

@@ -46,6 +46,7 @@ LOCAL_SRC_FILES:= \
android_emoji_EmojiFactory.cpp \
android_view_DisplayEventReceiver.cpp \
android_view_Surface.cpp \
android_view_SurfaceSession.cpp \
android_view_TextureView.cpp \
android_view_InputChannel.cpp \
android_view_InputDevice.cpp \

View File

@@ -121,6 +121,7 @@ extern int register_android_view_GLES20DisplayList(JNIEnv* env);
extern int register_android_view_GLES20Canvas(JNIEnv* env);
extern int register_android_view_HardwareRenderer(JNIEnv* env);
extern int register_android_view_Surface(JNIEnv* env);
extern int register_android_view_SurfaceSession(JNIEnv* env);
extern int register_android_view_TextureView(JNIEnv* env);
extern int register_android_database_CursorWindow(JNIEnv* env);
extern int register_android_database_SQLiteConnection(JNIEnv* env);
@@ -1094,6 +1095,7 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_android_view_GLES20Canvas),
REG_JNI(register_android_view_HardwareRenderer),
REG_JNI(register_android_view_Surface),
REG_JNI(register_android_view_SurfaceSession),
REG_JNI(register_android_view_TextureView),
REG_JNI(register_com_google_android_gles_jni_EGLImpl),
REG_JNI(register_com_google_android_gles_jni_GLImpl),

View File

@@ -436,7 +436,7 @@ struct NativeCode : public ANativeActivity {
void setSurface(jobject _surface) {
if (_surface != NULL) {
nativeWindow = android_Surface_getNativeWindow(env, _surface);
nativeWindow = android_view_Surface_getNativeWindow(env, _surface);
} else {
nativeWindow = NULL;
}

View File

@@ -549,7 +549,7 @@ not_valid_surface:
goto exit;
}
window = android::android_Surface_getNativeWindow(_env, win);
window = android::android_view_Surface_getNativeWindow(_env, win);
if (window == NULL)
goto not_valid_surface;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "SurfaceSession"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_view_SurfaceSession.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
#include <gui/SurfaceComposerClient.h>
namespace android {
static struct {
jfieldID mNativeClient;
} gSurfaceSessionClassInfo;
sp<SurfaceComposerClient> android_view_SurfaceSession_getClient(
JNIEnv* env, jobject surfaceSessionObj) {
return reinterpret_cast<SurfaceComposerClient*>(
env->GetIntField(surfaceSessionObj, gSurfaceSessionClassInfo.mNativeClient));
}
static jint nativeCreate(JNIEnv* env, jclass clazz) {
SurfaceComposerClient* client = new SurfaceComposerClient();
client->incStrong(clazz);
return reinterpret_cast<jint>(client);
}
static void nativeDestroy(JNIEnv* env, jclass clazz, jint ptr) {
SurfaceComposerClient* client = reinterpret_cast<SurfaceComposerClient*>(ptr);
client->decStrong(clazz);
}
static void nativeKill(JNIEnv* env, jclass clazz, jint ptr) {
SurfaceComposerClient* client = reinterpret_cast<SurfaceComposerClient*>(ptr);
client->dispose();
}
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
{ "nativeCreate", "()I",
(void*)nativeCreate },
{ "nativeDestroy", "(I)V",
(void*)nativeDestroy },
{ "nativeKill", "(I)V",
(void*)nativeKill }
};
int register_android_view_SurfaceSession(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "android/view/SurfaceSession",
gMethods, NELEM(gMethods));
LOG_ALWAYS_FATAL_IF(res < 0, "Unable to register native methods.");
jclass clazz = env->FindClass("android/view/SurfaceSession");
gSurfaceSessionClassInfo.mNativeClient = env->GetFieldID(clazz, "mNativeClient", "I");
return 0;
}
} // namespace android

View File

@@ -326,7 +326,7 @@ not_valid_surface:
return 0;
}
window = android_Surface_getNativeWindow(_env, native_window);
window = android_view_Surface_getNativeWindow(_env, native_window);
if (window == NULL)
goto not_valid_surface;

View File

@@ -230,7 +230,7 @@ nContextSetSurface(JNIEnv *_env, jobject _this, RsContext con, jint width, jint
if (wnd == NULL) {
} else {
window = android_Surface_getNativeWindow(_env, wnd).get();
window = android_view_Surface_getNativeWindow(_env, wnd).get();
}
rsContextSetSurface(con, width, height, window);
@@ -494,7 +494,7 @@ nAllocationSetSurface(JNIEnv *_env, jobject _this, RsContext con, RsAllocation a
sp<Surface> s;
if (sur != 0) {
s = Surface_getSurface(_env, sur);
s = android_view_Surface_getSurface(_env, sur);
}
rsAllocationSetSurface(con, alloc, static_cast<ANativeWindow *>(s.get()));

View File

@@ -25,12 +25,15 @@ namespace android {
class Surface;
extern sp<ANativeWindow> android_Surface_getNativeWindow(
JNIEnv* env, jobject clazz);
extern bool android_Surface_isInstanceOf(JNIEnv* env, jobject obj);
/* Gets the underlying ANativeWindow for a Surface. */
extern sp<ANativeWindow> android_view_Surface_getNativeWindow(
JNIEnv* env, jobject surfaceObj);
/* Returns true if the object is an instance of Surface. */
extern bool android_view_Surface_isInstanceOf(JNIEnv* env, jobject obj);
/* Gets the underlying Surface from a Surface Java object. */
extern sp<Surface> Surface_getSurface(JNIEnv* env, jobject thiz);
extern sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceObj);
} // namespace android

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _ANDROID_VIEW_SURFACE_SESSION_H
#define _ANDROID_VIEW_SURFACE_SESSION_H
#include "jni.h"
namespace android {
class SurfaceComposerClient;
/* Gets the underlying SurfaceComposerClient for a SurfaceSession. */
extern sp<SurfaceComposerClient> android_view_SurfaceSession_getClient(
JNIEnv* env, jobject surfaceSessionObj);
} // namespace android
#endif // _ANDROID_VIEW_SURFACE_SESSION_H

View File

@@ -370,7 +370,7 @@ static void android_media_MediaCodec_native_configure(
sp<ISurfaceTexture> surfaceTexture;
if (jsurface != NULL) {
sp<Surface> surface(Surface_getSurface(env, jsurface));
sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
if (surface != NULL) {
surfaceTexture = surface->getSurfaceTexture();
} else {

View File

@@ -271,7 +271,7 @@ setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlaye
sp<ISurfaceTexture> new_st;
if (jsurface) {
sp<Surface> surface(Surface_getSurface(env, jsurface));
sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
if (surface != NULL) {
new_st = surface->getSurfaceTexture();
new_st->incStrong(thiz);

View File

@@ -25,7 +25,7 @@
using namespace android;
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface) {
sp<ANativeWindow> win = android_Surface_getNativeWindow(env, surface);
sp<ANativeWindow> win = android_view_Surface_getNativeWindow(env, surface);
if (win != NULL) {
win->incStrong((void*)ANativeWindow_acquire);
}

View File

@@ -369,7 +369,8 @@ sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height
ensureSurfaceComposerClient();
sp<SurfaceControl> surfaceControl = mSurfaceComposerClient->createSurface(
String8("Sprite"), width, height, PIXEL_FORMAT_RGBA_8888);
String8("Sprite"), width, height, PIXEL_FORMAT_RGBA_8888,
ISurfaceComposerClient::eHidden);
if (surfaceControl == NULL || !surfaceControl->isValid()
|| !surfaceControl->getSurface()->isValid()) {
ALOGE("Error creating sprite surface.");

View File

@@ -16,6 +16,8 @@
package com.android.server.display;
import android.os.IBinder;
/**
* Represents a physical display device such as the built-in display
* an external monitor, or a WiFi display.
@@ -28,6 +30,14 @@ public abstract class DisplayDevice {
*/
public abstract DisplayAdapter getAdapter();
/**
* Gets the Surface Flinger display token for this display.
*
* @return The display token, or null if the display is not being managed
* by Surface Flinger.
*/
public abstract IBinder getDisplayToken();
/**
* Gets information about the display device.
*

View File

@@ -22,6 +22,7 @@ import android.content.pm.PackageManager;
import android.hardware.display.DisplayManager;
import android.hardware.display.IDisplayManager;
import android.os.Binder;
import android.os.IBinder;
import android.os.SystemProperties;
import android.view.Display;
import android.view.DisplayInfo;
@@ -51,6 +52,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
private final ArrayList<DisplayAdapter> mDisplayAdapters = new ArrayList<DisplayAdapter>();
private final DisplayInfo mDefaultDisplayInfo = new DisplayInfo();
private DisplayDevice mDefaultDisplayDevice;
public DisplayManagerService(Context context) {
mContext = context;
@@ -63,7 +65,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
if (mHeadless) {
registerDisplayAdapter(new HeadlessDisplayAdapter(mContext));
} else {
registerDisplayAdapter(new SurfaceFlingerDisplayAdapter(mContext));
registerDisplayAdapter(new LocalDisplayAdapter(mContext));
}
}
@@ -84,9 +86,32 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
return mHeadless;
}
/**
* Set the new display orientation.
* @param displayId The logical display id.
* @param orientation One of the Surface.ROTATION_* constants.
*/
public void setDisplayOrientation(int displayId, int orientation) {
synchronized (mLock) {
if (displayId != Display.DEFAULT_DISPLAY) {
throw new UnsupportedOperationException();
}
IBinder displayToken = mDefaultDisplayDevice.getDisplayToken();
if (displayToken != null) {
Surface.openTransaction();
try {
Surface.setDisplayOrientation(displayToken, orientation);
} finally {
Surface.closeTransaction();
}
}
}
}
/**
* Save away new DisplayInfo data.
* @param displayId The local DisplayInfo to store the new data in.
* @param displayId The logical display id.
* @param info The new data to be stored.
*/
public void setDisplayInfo(int displayId, DisplayInfo info) {
@@ -119,6 +144,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
adapter.register(new DisplayAdapter.Listener() {
@Override
public void onDisplayDeviceAdded(DisplayDevice device) {
mDefaultDisplayDevice = device;
DisplayDeviceInfo deviceInfo = new DisplayDeviceInfo();
device.getInfo(deviceInfo);
copyDisplayInfoFromDeviceInfo(mDefaultDisplayInfo, deviceInfo);

View File

@@ -17,6 +17,7 @@
package com.android.server.display;
import android.content.Context;
import android.os.IBinder;
import android.util.DisplayMetrics;
/**
@@ -47,6 +48,11 @@ public final class HeadlessDisplayAdapter extends DisplayAdapter {
return HeadlessDisplayAdapter.this;
}
@Override
public IBinder getDisplayToken() {
return null;
}
@Override
public void getInfo(DisplayDeviceInfo outInfo) {
outInfo.name = mContext.getResources().getString(

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.display;
import android.content.Context;
import android.os.IBinder;
import android.view.Surface;
import android.view.Surface.PhysicalDisplayInfo;
/**
* A display adapter for the local displays managed by Surface Flinger.
*/
public final class LocalDisplayAdapter extends DisplayAdapter {
private final Context mContext;
private final LocalDisplayDevice mDefaultDisplayDevice;
public LocalDisplayAdapter(Context context) {
mContext = context;
IBinder token = Surface.getBuiltInDisplay(Surface.BUILT_IN_DISPLAY_ID_MAIN);
mDefaultDisplayDevice = new LocalDisplayDevice(token);
}
@Override
public String getName() {
return "LocalDisplayAdapter";
}
@Override
public void register(Listener listener) {
listener.onDisplayDeviceAdded(mDefaultDisplayDevice);
}
private final class LocalDisplayDevice extends DisplayDevice {
private final IBinder mDisplayToken;
public LocalDisplayDevice(IBinder token) {
mDisplayToken = token;
}
@Override
public DisplayAdapter getAdapter() {
return LocalDisplayAdapter.this;
}
@Override
public IBinder getDisplayToken() {
return mDisplayToken;
}
@Override
public void getInfo(DisplayDeviceInfo outInfo) {
PhysicalDisplayInfo phys = new PhysicalDisplayInfo();
Surface.getDisplayInfo(mDisplayToken, phys);
outInfo.name = mContext.getResources().getString(
com.android.internal.R.string.display_manager_built_in_display);
outInfo.width = phys.width;
outInfo.height = phys.height;
outInfo.refreshRate = phys.refreshRate;
outInfo.densityDpi = (int)(phys.density * 160 + 0.5f);
outInfo.xDpi = phys.xDpi;
outInfo.yDpi = phys.yDpi;
}
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.display;
import android.content.Context;
/**
* A display adapter for the displays managed by Surface Flinger.
*/
public final class SurfaceFlingerDisplayAdapter extends DisplayAdapter {
private final Context mContext;
private final SurfaceFlingerDisplayDevice mDefaultDisplayDevice;
private static native void nativeGetDefaultDisplayDeviceInfo(DisplayDeviceInfo outInfo);
public SurfaceFlingerDisplayAdapter(Context context) {
mContext = context;
mDefaultDisplayDevice = new SurfaceFlingerDisplayDevice();
}
@Override
public String getName() {
return "SurfaceFlingerDisplayAdapter";
}
@Override
public void register(Listener listener) {
listener.onDisplayDeviceAdded(mDefaultDisplayDevice);
}
private final class SurfaceFlingerDisplayDevice extends DisplayDevice {
@Override
public DisplayAdapter getAdapter() {
return SurfaceFlingerDisplayAdapter.this;
}
@Override
public void getInfo(DisplayDeviceInfo outInfo) {
outInfo.name = mContext.getResources().getString(
com.android.internal.R.string.display_manager_built_in_display);
nativeGetDefaultDisplayDeviceInfo(outInfo);
}
}
}

View File

@@ -481,8 +481,8 @@ final class ElectronBeam {
try {
if (mSurface == null) {
try {
mSurface = new Surface(mSurfaceSession, Process.myPid(),
"ElectronBeam", mDisplayLayerStack, mDisplayWidth, mDisplayHeight,
mSurface = new Surface(mSurfaceSession,
"ElectronBeam", mDisplayWidth, mDisplayHeight,
PixelFormat.OPAQUE, Surface.OPAQUE | Surface.HIDDEN);
} catch (Surface.OutOfResourcesException ex) {
Slog.e(TAG, "Unable to create surface.", ex);
@@ -490,6 +490,7 @@ final class ElectronBeam {
}
}
mSurface.setLayerStack(mDisplayLayerStack);
mSurface.setSize(mDisplayWidth, mDisplayHeight);
switch (mDisplayRotation) {

View File

@@ -43,14 +43,15 @@ public class BlackFrame {
int w = r-l;
int h = b-t;
if (WindowManagerService.DEBUG_SURFACE_TRACE) {
surface = new WindowStateAnimator.SurfaceTrace(session, 0, "BlackSurface("
+ l + ", " + t + ")", layerStack,
w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM);
surface = new WindowStateAnimator.SurfaceTrace(session, "BlackSurface("
+ l + ", " + t + ")",
w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM | Surface.HIDDEN);
} else {
surface = new Surface(session, 0, "BlackSurface", layerStack,
w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM);
surface = new Surface(session, "BlackSurface",
w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM | Surface.HIDDEN);
}
surface.setAlpha(1);
surface.setLayerStack(layerStack);
surface.setLayer(layer);
surface.show();
if (WindowManagerService.SHOW_TRANSACTIONS ||

View File

@@ -43,20 +43,21 @@ class DimAnimator {
if (mDimSurface == null) {
try {
if (WindowManagerService.DEBUG_SURFACE_TRACE) {
mDimSurface = new WindowStateAnimator.SurfaceTrace(session, 0,
mDimSurface = new WindowStateAnimator.SurfaceTrace(session,
"DimAnimator",
layerStack, 16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM);
16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM | Surface.HIDDEN);
} else {
mDimSurface = new Surface(session, 0,
"DimAnimator",
layerStack, 16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM);
mDimSurface = new Surface(session, "DimAnimator",
16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM | Surface.HIDDEN);
}
if (WindowManagerService.SHOW_TRANSACTIONS ||
WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG,
" DIM " + mDimSurface + ": CREATE");
mDimSurface.setLayerStack(layerStack);
mDimSurface.setAlpha(0.0f);
mDimSurface.show();
} catch (Exception e) {
Slog.e(WindowManagerService.TAG, "Exception creating Dim surface", e);
}
@@ -212,4 +213,4 @@ class DimAnimator {
mDimTarget = dimTarget;
}
}
}
}

View File

@@ -34,20 +34,21 @@ class DimSurface {
if (mDimSurface == null) {
try {
if (WindowManagerService.DEBUG_SURFACE_TRACE) {
mDimSurface = new WindowStateAnimator.SurfaceTrace(session, 0,
mDimSurface = new WindowStateAnimator.SurfaceTrace(session,
"DimSurface",
layerStack, 16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM);
16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM | Surface.HIDDEN);
} else {
mDimSurface = new Surface(session, 0,
"DimSurface",
layerStack, 16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM);
mDimSurface = new Surface(session, "DimSurface",
16, 16, PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM | Surface.HIDDEN);
}
if (WindowManagerService.SHOW_TRANSACTIONS ||
WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG,
" DIM " + mDimSurface + ": CREATE");
mDimSurface.setLayerStack(layerStack);
mDimSurface.setAlpha(0.0f);
mDimSurface.show();
} catch (Exception e) {
Slog.e(WindowManagerService.TAG, "Exception creating Dim surface", e);
}

View File

@@ -215,12 +215,12 @@ class ScreenRotationAnimation {
try {
try {
if (WindowManagerService.DEBUG_SURFACE_TRACE) {
mSurface = new SurfaceTrace(session, 0, "FreezeSurface",
mDisplay.getLayerStack(), mWidth, mHeight,
mSurface = new SurfaceTrace(session, "FreezeSurface",
mWidth, mHeight,
PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
} else {
mSurface = new Surface(session, 0, "FreezeSurface",
mDisplay.getLayerStack(), mWidth, mHeight,
mSurface = new Surface(session, "FreezeSurface",
mWidth, mHeight,
PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
}
if (!mSurface.isValid()) {
@@ -228,6 +228,7 @@ class ScreenRotationAnimation {
mSurface = null;
return;
}
mSurface.setLayerStack(mDisplay.getLayerStack());
mSurface.setLayer(FREEZE_LAYER + 1);
mSurface.setAlpha(0);
mSurface.show();

View File

@@ -37,14 +37,16 @@ class StrictModeFlash {
public StrictModeFlash(Display display, SurfaceSession session) {
try {
mSurface = new Surface(session, 0, "StrictModeFlash", display.getLayerStack(),
1, 1, PixelFormat.TRANSLUCENT, 0);
mSurface = new Surface(session, "StrictModeFlash",
1, 1, PixelFormat.TRANSLUCENT, Surface.HIDDEN);
} catch (Surface.OutOfResourcesException e) {
return;
}
mSurface.setLayerStack(display.getLayerStack());
mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 101); // one more than Watermark? arbitrary.
mSurface.setPosition(0, 0);
mSurface.show();
mDrawNeeded = true;
}

View File

@@ -113,9 +113,9 @@ class Watermark {
mTextPaint.setShadowLayer(shadowRadius, shadowDx, shadowDy, shadowColor);
try {
mSurface = new Surface(session, 0,
"WatermarkSurface", mDisplay.getLayerStack(),
1, 1, PixelFormat.TRANSLUCENT, 0);
mSurface = new Surface(session, "WatermarkSurface",
1, 1, PixelFormat.TRANSLUCENT, Surface.HIDDEN);
mSurface.setLayerStack(mDisplay.getLayerStack());
mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER*100);
mSurface.setPosition(0, 0);
mSurface.show();
@@ -174,4 +174,4 @@ class Watermark {
}
}
}
}
}

View File

@@ -5847,7 +5847,8 @@ public class WindowManagerService extends IWindowManager.Stub
updateLayoutToAnimationLocked();
}
}
Surface.setOrientation(0, rotation);
mDisplayManagerService.setDisplayOrientation(
displayContent.getDisplayId(), rotation);
} finally {
if (!inTransaction) {
Surface.closeTransaction();
@@ -6711,9 +6712,9 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized (mWindowMap) {
try {
if (mDragState == null) {
Surface surface = new Surface(session, callerPid, "drag surface",
mDefaultDisplay.getLayerStack(),
Surface surface = new Surface(session, "drag surface",
width, height, PixelFormat.TRANSLUCENT, Surface.HIDDEN);
surface.setLayerStack(mDefaultDisplay.getLayerStack());
if (SHOW_TRANSACTIONS) Slog.i(TAG, " DRAG "
+ surface + ": CREATE");
outSurface.copyFrom(surface);
@@ -8342,10 +8343,11 @@ public class WindowManagerService extends IWindowManager.Stub
Rect dirty = new Rect(0, 0, mNextAppTransitionThumbnail.getWidth(),
mNextAppTransitionThumbnail.getHeight());
try {
Surface surface = new Surface(mFxSession, Process.myPid(),
"thumbnail anim", mDefaultDisplay.getLayerStack(),
Surface surface = new Surface(mFxSession,
"thumbnail anim",
dirty.width(), dirty.height(),
PixelFormat.TRANSLUCENT, Surface.HIDDEN);
surface.setLayerStack(mDefaultDisplay.getLayerStack());
topOpeningApp.mAppAnimator.thumbnail = surface;
if (SHOW_TRANSACTIONS) Slog.i(TAG, " THUMBNAIL "
+ surface + ": CREATE");

View File

@@ -481,9 +481,9 @@ class WindowStateAnimator {
private String mName;
public SurfaceTrace(SurfaceSession s,
int pid, String name, int layerStack, int w, int h, int format, int flags)
String name, int w, int h, int format, int flags)
throws OutOfResourcesException {
super(s, pid, name, layerStack, w, h, format, flags);
super(s, name, w, h, format, flags);
mName = name != null ? name : "Not named";
mSize.set(w, h);
Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
@@ -608,7 +608,7 @@ class WindowStateAnimator {
mService.makeWindowFreezingScreenIfNeededLocked(mWin);
int flags = 0;
int flags = Surface.HIDDEN;
final WindowManager.LayoutParams attrs = mWin.mAttrs;
if ((attrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) {
@@ -652,14 +652,14 @@ class WindowStateAnimator {
}
if (DEBUG_SURFACE_TRACE) {
mSurface = new SurfaceTrace(
mSession.mSurfaceSession, mSession.mPid,
mSession.mSurfaceSession,
attrs.getTitle().toString(),
mLayerStack, w, h, format, flags);
w, h, format, flags);
} else {
mSurface = new Surface(
mSession.mSurfaceSession, mSession.mPid,
mSession.mSurfaceSession,
attrs.getTitle().toString(),
mLayerStack, w, h, format, flags);
w, h, format, flags);
}
mWin.mHasSurface = true;
if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG,
@@ -701,10 +701,10 @@ class WindowStateAnimator {
mSurfaceY = mWin.mFrame.top + mWin.mYOffset;
mSurface.setPosition(mSurfaceX, mSurfaceY);
mSurfaceLayer = mAnimLayer;
mSurface.setLayerStack(mLayerStack);
mSurface.setLayer(mAnimLayer);
mSurface.setAlpha(0);
mSurfaceShown = false;
mSurface.hide();
} catch (RuntimeException e) {
Slog.w(TAG, "Error creating surface in " + w, e);
mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true);

View File

@@ -4,7 +4,6 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
com_android_server_AlarmManagerService.cpp \
com_android_server_BatteryService.cpp \
com_android_server_display_SurfaceFlingerDisplayAdapter.cpp \
com_android_server_input_InputApplicationHandle.cpp \
com_android_server_input_InputManagerService.cpp \
com_android_server_input_InputWindowHandle.cpp \

View File

@@ -1,95 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "SurfaceFlingerDisplayAdapter"
#include "JNIHelp.h"
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <ui/DisplayInfo.h>
#include <utils/Log.h>
namespace android {
static struct {
jfieldID width;
jfieldID height;
jfieldID refreshRate;
jfieldID densityDpi;
jfieldID xDpi;
jfieldID yDpi;
} gDisplayDeviceInfoClassInfo;
static void nativeGetDefaultDisplayDeviceInfo(JNIEnv* env, jclass clazz, jobject infoObj) {
sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(
ISurfaceComposer::eDisplayIdMain));
DisplayInfo info;
status_t err = SurfaceComposerClient::getDisplayInfo(display, &info);
if (err < 0) {
jniThrowExceptionFmt(env, "java/lang/RuntimeException",
"Could not get display info. err=%d", err);
return;
}
env->SetIntField(infoObj, gDisplayDeviceInfoClassInfo.width, info.w);
env->SetIntField(infoObj, gDisplayDeviceInfoClassInfo.height, info.h);
env->SetFloatField(infoObj, gDisplayDeviceInfoClassInfo.refreshRate, info.fps);
env->SetIntField(infoObj, gDisplayDeviceInfoClassInfo.densityDpi,
(jint)((info.density*160) + .5f));
env->SetFloatField(infoObj, gDisplayDeviceInfoClassInfo.xDpi, info.xdpi);
env->SetFloatField(infoObj, gDisplayDeviceInfoClassInfo.yDpi, info.ydpi);
}
static JNINativeMethod gSurfaceFlingerDisplayAdapterMethods[] = {
/* name, signature, funcPtr */
{ "nativeGetDefaultDisplayDeviceInfo",
"(Lcom/android/server/display/DisplayDeviceInfo;)V",
(void*) nativeGetDefaultDisplayDeviceInfo },
};
#define FIND_CLASS(var, className) \
var = env->FindClass(className); \
LOG_FATAL_IF(! var, "Unable to find class " className);
#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
int register_android_server_display_SurfaceFlingerDisplayAdapter(JNIEnv* env) {
int res = jniRegisterNativeMethods(env,
"com/android/server/display/SurfaceFlingerDisplayAdapter",
gSurfaceFlingerDisplayAdapterMethods, NELEM(gSurfaceFlingerDisplayAdapterMethods));
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
jclass clazz;
FIND_CLASS(clazz, "com/android/server/display/DisplayDeviceInfo");
GET_FIELD_ID(gDisplayDeviceInfoClassInfo.width, clazz, "width", "I");
GET_FIELD_ID(gDisplayDeviceInfoClassInfo.height, clazz, "height", "I");
GET_FIELD_ID(gDisplayDeviceInfoClassInfo.refreshRate, clazz, "refreshRate", "F");
GET_FIELD_ID(gDisplayDeviceInfoClassInfo.densityDpi, clazz, "densityDpi", "I");
GET_FIELD_ID(gDisplayDeviceInfoClassInfo.xDpi, clazz, "xDpi", "F");
GET_FIELD_ID(gDisplayDeviceInfoClassInfo.yDpi, clazz, "yDpi", "F");
return 0;
}
} /* namespace android */

View File

@@ -22,7 +22,6 @@
namespace android {
int register_android_server_AlarmManagerService(JNIEnv* env);
int register_android_server_BatteryService(JNIEnv* env);
int register_android_server_display_SurfaceFlingerDisplayAdapter(JNIEnv* env);
int register_android_server_InputApplicationHandle(JNIEnv* env);
int register_android_server_InputWindowHandle(JNIEnv* env);
int register_android_server_InputManager(JNIEnv* env);
@@ -52,7 +51,6 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
register_android_server_PowerManagerService(env);
register_android_server_SerialService(env);
register_android_server_display_SurfaceFlingerDisplayAdapter(env);
register_android_server_InputApplicationHandle(env);
register_android_server_InputWindowHandle(env);
register_android_server_InputManager(env);