From 13a082e160c2d1d8006b93a555a57035213d568b Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 24 Aug 2012 10:16:42 -0700 Subject: [PATCH] Added display initialization method The primary display device was being configured to "blank" by default, which prevented the boot animation from appearing (unless you got lucky with the hardware composer state). Bug 6975688 Change-Id: I0fa52e9e719c6e997c5725a7baf15d9718461b78 --- .../DisplayHardware/HWComposer.cpp | 2 +- services/surfaceflinger/SurfaceFlinger.cpp | 44 +++++++++++++++---- services/surfaceflinger/SurfaceFlinger.h | 9 +++- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index b1f83288c..1678fe131 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -261,7 +261,7 @@ status_t HWComposer::createWorkList(int32_t id, size_t numLayers) { if (mHwc) { DisplayData& disp(mDisplayData[id]); - if (disp.capacity < numLayers) { + if (disp.capacity < numLayers || disp.list == NULL) { const size_t size = sizeof(hwc_display_contents_1_t) + numLayers * sizeof(hwc_layer_1_t); free(disp.list); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 7b070bac9..1406deb45 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -137,15 +137,8 @@ void SurfaceFlinger::binderDied(const wp& who) { // the window manager died on us. prepare its eulogy. - // reset screen orientation - Vector state; - Vector displays; - DisplayState d; - d.what = DisplayState::eOrientationChanged; - d.token = mDefaultDisplays[DisplayDevice::DISPLAY_ID_MAIN]; - d.orientation = DisplayState::eOrientationDefault; - displays.add(d); - setTransactionState(state, displays, 0); + // restore initial conditions (default device unblank, etc) + initializeDisplays(); // restart the boot-animation startBootAnim(); @@ -451,6 +444,9 @@ status_t SurfaceFlinger::readyToRun() // We're now ready to accept clients... mReadyToRunBarrier.open(); + // set initial conditions (e.g. unblank default device) + initializeDisplays(); + // start boot animation startBootAnim(); @@ -1729,6 +1725,36 @@ status_t SurfaceFlinger::onLayerDestroyed(const wp& layer) // --------------------------------------------------------------------------- +void SurfaceFlinger::onInitializeDisplays() { + // reset screen orientation + Vector state; + Vector displays; + DisplayState d; + d.what = DisplayState::eOrientationChanged; + d.token = mDefaultDisplays[DisplayDevice::DISPLAY_ID_MAIN]; + d.orientation = DisplayState::eOrientationDefault; + displays.add(d); + setTransactionState(state, displays, 0); + + // XXX: this should init default device to "unblank" and all other devices to "blank" + onScreenAcquired(); +} + +void SurfaceFlinger::initializeDisplays() { + class MessageScreenInitialized : public MessageBase { + SurfaceFlinger* flinger; + public: + MessageScreenInitialized(SurfaceFlinger* flinger) : flinger(flinger) { } + virtual bool handler() { + flinger->onInitializeDisplays(); + return true; + } + }; + sp msg = new MessageScreenInitialized(this); + postMessageAsync(msg); // we may be called from main thread, use async message +} + + void SurfaceFlinger::onScreenAcquired() { ALOGD("Screen about to return, flinger = %p", this); sp hw(getDefaultDisplayDevice()); // XXX: this should be per DisplayDevice diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 754a2cc20..7ad5450fd 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -231,9 +231,11 @@ private: void signalLayerUpdate(); void signalRefresh(); - // called on the main thread in response to screenReleased() + // called on the main thread in response to initializeDisplays() + void onInitializeDisplays(); + // called on the main thread in response to blank() void onScreenReleased(); - // called on the main thread in response to screenAcquired() + // called on the main thread in response to unblank() void onScreenAcquired(); void handleMessageTransaction(); @@ -321,6 +323,9 @@ private: /* ------------------------------------------------------------------------ * Display and layer stack management */ + // called when starting, or restarting after system_server death + void initializeDisplays(); + sp getDisplayDevice(DisplayID dpy) const { return mDisplays.valueFor(dpy); }