Merge "Create builtin display tokens on demand"
This commit is contained in:
commit
d24276d399
@ -191,12 +191,22 @@ sp<IBinder> SurfaceFlinger::createDisplay(const String8& displayName,
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SurfaceFlinger::createBuiltinDisplayLocked(DisplayDevice::DisplayType type) {
|
||||||
|
ALOGW_IF(mBuiltinDisplays[type],
|
||||||
|
"Overwriting display token for display type %d", type);
|
||||||
|
mBuiltinDisplays[type] = new BBinder();
|
||||||
|
DisplayDeviceState info(type);
|
||||||
|
// All non-virtual displays are currently considered secure.
|
||||||
|
info.isSecure = true;
|
||||||
|
mCurrentState.displays.add(mBuiltinDisplays[type], info);
|
||||||
|
}
|
||||||
|
|
||||||
sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) {
|
sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) {
|
||||||
if (uint32_t(id) >= DisplayDevice::NUM_DISPLAY_TYPES) {
|
if (uint32_t(id) >= DisplayDevice::NUM_DISPLAY_TYPES) {
|
||||||
ALOGE("getDefaultDisplay: id=%d is not a valid default display id", id);
|
ALOGE("getDefaultDisplay: id=%d is not a valid default display id", id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return mDefaultDisplays[id];
|
return mBuiltinDisplays[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc()
|
sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc()
|
||||||
@ -462,6 +472,8 @@ status_t SurfaceFlinger::readyToRun()
|
|||||||
ALOGI( "SurfaceFlinger's main thread ready to run. "
|
ALOGI( "SurfaceFlinger's main thread ready to run. "
|
||||||
"Initializing graphics H/W...");
|
"Initializing graphics H/W...");
|
||||||
|
|
||||||
|
Mutex::Autolock _l(mStateLock);
|
||||||
|
|
||||||
// initialize EGL for the default display
|
// initialize EGL for the default display
|
||||||
mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
eglInitialize(mEGLDisplay, NULL, NULL);
|
eglInitialize(mEGLDisplay, NULL, NULL);
|
||||||
@ -482,14 +494,13 @@ status_t SurfaceFlinger::readyToRun()
|
|||||||
// initialize our non-virtual displays
|
// initialize our non-virtual displays
|
||||||
for (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
|
for (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
|
||||||
DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i);
|
DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i);
|
||||||
mDefaultDisplays[i] = new BBinder();
|
|
||||||
wp<IBinder> token = mDefaultDisplays[i];
|
|
||||||
|
|
||||||
// set-up the displays that are already connected
|
// set-up the displays that are already connected
|
||||||
if (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) {
|
if (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) {
|
||||||
// All non-virtual displays are currently considered secure.
|
// All non-virtual displays are currently considered secure.
|
||||||
bool isSecure = true;
|
bool isSecure = true;
|
||||||
mCurrentState.displays.add(token, DisplayDeviceState(type));
|
createBuiltinDisplayLocked(type);
|
||||||
|
wp<IBinder> token = mBuiltinDisplays[i];
|
||||||
|
|
||||||
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i);
|
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i);
|
||||||
sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
|
sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
|
||||||
static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
|
static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
|
||||||
@ -601,9 +612,9 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
|
status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
|
||||||
int32_t type = BAD_VALUE;
|
int32_t type = NAME_NOT_FOUND;
|
||||||
for (int i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
|
for (int i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
|
||||||
if (display == mDefaultDisplays[i]) {
|
if (display == mBuiltinDisplays[i]) {
|
||||||
type = i;
|
type = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -614,10 +625,6 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo*
|
|||||||
}
|
}
|
||||||
|
|
||||||
const HWComposer& hwc(getHwComposer());
|
const HWComposer& hwc(getHwComposer());
|
||||||
if (!hwc.isConnected(type)) {
|
|
||||||
return NAME_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
float xdpi = hwc.getDpiX(type);
|
float xdpi = hwc.getDpiX(type);
|
||||||
float ydpi = hwc.getDpiY(type);
|
float ydpi = hwc.getDpiY(type);
|
||||||
|
|
||||||
@ -745,11 +752,11 @@ void SurfaceFlinger::onHotplugReceived(int type, bool connected) {
|
|||||||
|
|
||||||
if (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) {
|
if (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) {
|
||||||
Mutex::Autolock _l(mStateLock);
|
Mutex::Autolock _l(mStateLock);
|
||||||
if (connected == false) {
|
if (connected) {
|
||||||
mCurrentState.displays.removeItem(mDefaultDisplays[type]);
|
createBuiltinDisplayLocked((DisplayDevice::DisplayType)type);
|
||||||
} else {
|
} else {
|
||||||
DisplayDeviceState info((DisplayDevice::DisplayType)type);
|
mCurrentState.displays.removeItem(mBuiltinDisplays[type]);
|
||||||
mCurrentState.displays.add(mDefaultDisplays[type], info);
|
mBuiltinDisplays[type].clear();
|
||||||
}
|
}
|
||||||
setTransactionFlags(eDisplayTransactionNeeded);
|
setTransactionFlags(eDisplayTransactionNeeded);
|
||||||
|
|
||||||
@ -1163,7 +1170,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||||||
for (size_t i=0 ; i<cc ; i++) {
|
for (size_t i=0 ; i<cc ; i++) {
|
||||||
if (draw.indexOfKey(curr.keyAt(i)) < 0) {
|
if (draw.indexOfKey(curr.keyAt(i)) < 0) {
|
||||||
const DisplayDeviceState& state(curr[i]);
|
const DisplayDeviceState& state(curr[i]);
|
||||||
bool isSecure = false;
|
|
||||||
|
|
||||||
sp<FramebufferSurface> fbs;
|
sp<FramebufferSurface> fbs;
|
||||||
sp<SurfaceTextureClient> stc;
|
sp<SurfaceTextureClient> stc;
|
||||||
@ -1174,10 +1180,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||||||
"surface is provided (%p), ignoring it",
|
"surface is provided (%p), ignoring it",
|
||||||
state.surface.get());
|
state.surface.get());
|
||||||
|
|
||||||
// All non-virtual displays are currently considered
|
|
||||||
// secure.
|
|
||||||
isSecure = true;
|
|
||||||
|
|
||||||
// for supported (by hwc) displays we provide our
|
// for supported (by hwc) displays we provide our
|
||||||
// own rendering surface
|
// own rendering surface
|
||||||
fbs = new FramebufferSurface(*mHwc, state.type);
|
fbs = new FramebufferSurface(*mHwc, state.type);
|
||||||
@ -1188,13 +1190,12 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||||||
if (state.surface != NULL) {
|
if (state.surface != NULL) {
|
||||||
stc = new SurfaceTextureClient(state.surface);
|
stc = new SurfaceTextureClient(state.surface);
|
||||||
}
|
}
|
||||||
isSecure = state.isSecure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const wp<IBinder>& display(curr.keyAt(i));
|
const wp<IBinder>& display(curr.keyAt(i));
|
||||||
if (stc != NULL) {
|
if (stc != NULL) {
|
||||||
sp<DisplayDevice> hw = new DisplayDevice(this,
|
sp<DisplayDevice> hw = new DisplayDevice(this,
|
||||||
state.type, isSecure, display, stc, fbs,
|
state.type, state.isSecure, display, stc, fbs,
|
||||||
mEGLConfig);
|
mEGLConfig);
|
||||||
hw->setLayerStack(state.layerStack);
|
hw->setLayerStack(state.layerStack);
|
||||||
hw->setProjection(state.orientation,
|
hw->setProjection(state.orientation,
|
||||||
@ -2011,7 +2012,7 @@ void SurfaceFlinger::onInitializeDisplays() {
|
|||||||
Vector<DisplayState> displays;
|
Vector<DisplayState> displays;
|
||||||
DisplayState d;
|
DisplayState d;
|
||||||
d.what = DisplayState::eDisplayProjectionChanged;
|
d.what = DisplayState::eDisplayProjectionChanged;
|
||||||
d.token = mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY];
|
d.token = mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY];
|
||||||
d.orientation = DisplayState::eOrientationDefault;
|
d.orientation = DisplayState::eOrientationDefault;
|
||||||
d.frame.makeInvalid();
|
d.frame.makeInvalid();
|
||||||
d.viewport.makeInvalid();
|
d.viewport.makeInvalid();
|
||||||
|
@ -112,7 +112,7 @@ public:
|
|||||||
|
|
||||||
// returns the default Display
|
// returns the default Display
|
||||||
sp<const DisplayDevice> getDefaultDisplayDevice() const {
|
sp<const DisplayDevice> getDefaultDisplayDevice() const {
|
||||||
return getDisplayDevice(mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY]);
|
return getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility function to delete a texture on the main thread
|
// utility function to delete a texture on the main thread
|
||||||
@ -328,6 +328,9 @@ private:
|
|||||||
// called when starting, or restarting after system_server death
|
// called when starting, or restarting after system_server death
|
||||||
void initializeDisplays();
|
void initializeDisplays();
|
||||||
|
|
||||||
|
// Create an IBinder for a builtin display and add it to current state
|
||||||
|
void createBuiltinDisplayLocked(DisplayDevice::DisplayType type);
|
||||||
|
|
||||||
// NOTE: can only be called from the main thread or with mStateLock held
|
// NOTE: can only be called from the main thread or with mStateLock held
|
||||||
sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
|
sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
|
||||||
return mDisplays.valueFor(dpy);
|
return mDisplays.valueFor(dpy);
|
||||||
@ -422,7 +425,7 @@ private:
|
|||||||
EGLContext mEGLContext;
|
EGLContext mEGLContext;
|
||||||
EGLConfig mEGLConfig;
|
EGLConfig mEGLConfig;
|
||||||
EGLDisplay mEGLDisplay;
|
EGLDisplay mEGLDisplay;
|
||||||
sp<IBinder> mDefaultDisplays[DisplayDevice::NUM_DISPLAY_TYPES];
|
sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_DISPLAY_TYPES];
|
||||||
|
|
||||||
// Can only accessed from the main thread, these members
|
// Can only accessed from the main thread, these members
|
||||||
// don't need synchronization
|
// don't need synchronization
|
||||||
|
Loading…
Reference in New Issue
Block a user