diff options
author | Mathias Agopian <mathias@google.com> | 2012-08-21 23:34:09 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2012-08-23 16:03:37 -0700 |
commit | e60b0687c8d49871d0c8786cabe6851f7a7783b5 (patch) | |
tree | afef903dcaa648d2862278e289c254a99390f400 /services/surfaceflinger/SurfaceFlinger.cpp | |
parent | 7c9e82633c5c4f85b896a5879bdb25cdf659646e (diff) | |
download | frameworks_native-e60b0687c8d49871d0c8786cabe6851f7a7783b5.zip frameworks_native-e60b0687c8d49871d0c8786cabe6851f7a7783b5.tar.gz frameworks_native-e60b0687c8d49871d0c8786cabe6851f7a7783b5.tar.bz2 |
HWComposer now has its own concept of display IDs
HWComposer can now create IDs representing a display
it can deal with. IDs MAIN and HDMI are reserved.
SurfaceFlinger associate HWComposer IDs with a
DisplayDevice and uses that when it talks to HWComposer.
A DisplayDevice doesn't have to have a HWComposer ID,
in that case it just can't use h/w composer composition.
Change-Id: Iec3d7ac92e0c22bf975052ae2847402f58bade71
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index c63d0cf..e6e258f 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -409,7 +409,8 @@ status_t SurfaceFlinger::readyToRun() mCurrentState.displays.add(mDefaultDisplays[i], DisplayDeviceState(i)); } sp<DisplayDevice> hw = new DisplayDevice(this, - DisplayDevice::DISPLAY_ID_MAIN, anw, fbs, mEGLConfig); + DisplayDevice::DISPLAY_ID_MAIN, HWC_DISPLAY_PRIMARY, + anw, fbs, mEGLConfig); mDisplays.add(hw->getDisplayId(), hw); // initialize OpenGL ES @@ -779,29 +780,30 @@ void SurfaceFlinger::setUpHWComposer() { mHwWorkListDirty = false; for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { sp<const DisplayDevice> hw(mDisplays[dpy]); - const Vector< sp<LayerBase> >& currentLayers( + const int32_t id = hw->getHwcDisplayId(); + if (id >= 0) { + const Vector< sp<LayerBase> >& currentLayers( hw->getVisibleLayersSortedByZ()); - const size_t count = currentLayers.size(); - - const int32_t id = hw->getDisplayId(); - if (hwc.createWorkList(id, count) >= 0) { - HWComposer::LayerListIterator cur = hwc.begin(id); - const HWComposer::LayerListIterator end = hwc.end(id); - for (size_t i=0 ; cur!=end && i<count ; ++i, ++cur) { - const sp<LayerBase>& layer(currentLayers[i]); - - if (CC_UNLIKELY(workListsDirty)) { - layer->setGeometry(hw, *cur); - if (mDebugDisableHWC || mDebugRegion) { - cur->setSkip(true); + const size_t count = currentLayers.size(); + if (hwc.createWorkList(id, count) >= 0) { + HWComposer::LayerListIterator cur = hwc.begin(id); + const HWComposer::LayerListIterator end = hwc.end(id); + for (size_t i=0 ; cur!=end && i<count ; ++i, ++cur) { + const sp<LayerBase>& layer(currentLayers[i]); + + if (CC_UNLIKELY(workListsDirty)) { + layer->setGeometry(hw, *cur); + if (mDebugDisableHWC || mDebugRegion) { + cur->setSkip(true); + } } - } - /* - * update the per-frame h/w composer data for each layer - * and build the transparent region of the FB - */ - layer->setPerFrameData(hw, *cur); + /* + * update the per-frame h/w composer data for each layer + * and build the transparent region of the FB + */ + layer->setPerFrameData(hw, *cur); + } } } } @@ -841,21 +843,20 @@ void SurfaceFlinger::postFramebuffer() HWComposer& hwc(getHwComposer()); if (hwc.initCheck() == NO_ERROR) { - // FIXME: eventually commit() won't take arguments // FIXME: EGL spec says: // "surface must be bound to the calling thread's current context, // for the current rendering API." DisplayDevice::makeCurrent( getDisplayDevice(DisplayDevice::DISPLAY_ID_MAIN), mEGLContext); - hwc.commit(mEGLDisplay, getDefaultDisplayDevice()->getEGLSurface()); + hwc.commit(); } for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { sp<const DisplayDevice> hw(mDisplays[dpy]); const Vector< sp<LayerBase> >& currentLayers(hw->getVisibleLayersSortedByZ()); const size_t count = currentLayers.size(); - if (hwc.initCheck() == NO_ERROR) { - int32_t id = hw->getDisplayId(); + int32_t id = hw->getHwcDisplayId(); + if (id >=0 && hwc.initCheck() == NO_ERROR) { HWComposer::LayerListIterator cur = hwc.begin(id); const HWComposer::LayerListIterator end = hwc.end(id); for (size_t i = 0; cur != end && i < count; ++i, ++cur) { @@ -951,12 +952,15 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) if (state.surface->asBinder() != draw[i].surface->asBinder()) { // changing the surface is like destroying and // recreating the DisplayDevice + const int32_t hwcDisplayId = + (uint32_t(state.id) < DisplayDevice::DISPLAY_ID_COUNT) ? + state.id : getHwComposer().allocateDisplayId(); sp<SurfaceTextureClient> stc( new SurfaceTextureClient(state.surface)); sp<DisplayDevice> disp = new DisplayDevice(this, - state.id, stc, 0, mEGLConfig); + state.id, hwcDisplayId, stc, 0, mEGLConfig); disp->setLayerStack(state.layerStack); disp->setOrientation(state.orientation); @@ -982,10 +986,14 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) for (size_t i=0 ; i<cc ; i++) { if (draw.indexOfKey(curr.keyAt(i)) < 0) { const DisplayDeviceState& state(curr[i]); + const int32_t hwcDisplayId = + (uint32_t(state.id) < DisplayDevice::DISPLAY_ID_COUNT) ? + state.id : getHwComposer().allocateDisplayId(); + sp<SurfaceTextureClient> stc( new SurfaceTextureClient(state.surface)); - sp<DisplayDevice> disp = new DisplayDevice(this, state.id, - stc, 0, mEGLConfig); + sp<DisplayDevice> disp = new DisplayDevice(this, + state.id, hwcDisplayId, stc, 0, mEGLConfig); mDisplays.add(state.id, disp); } } @@ -1251,12 +1259,13 @@ void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw, void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty) { HWComposer& hwc(getHwComposer()); - int32_t id = hw->getDisplayId(); + int32_t id = hw->getHwcDisplayId(); HWComposer::LayerListIterator cur = hwc.begin(id); const HWComposer::LayerListIterator end = hwc.end(id); - const size_t fbLayerCount = hwc.getLayerCount(id, HWC_FRAMEBUFFER); - if (cur==end || fbLayerCount) { + const bool hasGlesComposition = hwc.hasGlesComposition(id); + const bool hasHwcComposition = hwc.hasHwcComposition(id); + if (cur==end || hasGlesComposition) { DisplayDevice::makeCurrent(hw, mEGLContext); @@ -1265,7 +1274,7 @@ void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const glLoadIdentity(); // Never touch the framebuffer if we don't have any framebuffer layers - if (hwc.getLayerCount(id, HWC_OVERLAY)) { + if (hasHwcComposition) { // when using overlays, we assume a fully transparent framebuffer // NOTE: we could reduce how much we need to clear, for instance // remove where there are opaque FB layers. however, on some |