Move eglSwapBuffers out of HWComposer

Commit 8630320 moved the eglSwapBuffers fallback (for devices with no
HWC implementation) from DisplayHardware to HWComposer. But HWComposer
only knows about the framebuffer EGL display and surface handles if
there is a HWC, so it was always passing bogus handles.

This change moves the eglSwapBuffers fallback up to SurfaceFlinger,
which has access to the framebuffer EGL handles.

Bug: 6886613
Change-Id: Iad3f5ff7c90ee48d7053999e6a4548d6794b6ebd
This commit is contained in:
Jesse Hall 2012-07-29 22:35:34 -07:00
parent 747c480b0e
commit 34a09ba1ef
4 changed files with 11 additions and 29 deletions

View File

@ -39,8 +39,6 @@
#include <cutils/log.h>
#include <cutils/properties.h>
#include <EGL/egl.h>
#include "Layer.h" // needed only for debugging
#include "LayerBase.h"
#include "HWComposer.h"
@ -108,7 +106,6 @@ HWComposer::HWComposer(
: mFlinger(flinger),
mModule(0), mHwc(0), mList(0), mCapacity(0),
mNumOVLayers(0), mNumFBLayers(0),
mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE),
mCBContext(new cb_context),
mEventHandler(handler),
mRefreshPeriod(refreshPeriod),
@ -207,11 +204,6 @@ void HWComposer::eventControl(int event, int enabled) {
}
}
void HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) {
mDpy = (hwc_display_t)dpy;
mSur = (hwc_surface_t)sur;
}
status_t HWComposer::createWorkList(size_t numLayers) {
if (mHwc) {
if (!mList || mCapacity < numLayers) {
@ -270,15 +262,13 @@ size_t HWComposer::getLayerCount(int type) const {
return 0;
}
status_t HWComposer::commit() const {
status_t HWComposer::commit(void* fbDisplay, void* fbSurface) const {
int err = NO_ERROR;
if (mHwc) {
err = mHwc->set(mHwc, mDpy, mSur, mList);
err = mHwc->set(mHwc, fbDisplay, fbSurface, mList);
if (mList) {
mList->flags &= ~HWC_GEOMETRY_CHANGED;
}
} else {
eglSwapBuffers(mDpy, mSur);
}
return (status_t)err;
}

View File

@ -20,8 +20,6 @@
#include <stdint.h>
#include <sys/types.h>
#include <EGL/egl.h>
#include <hardware/hwcomposer_defs.h>
#include <utils/Condition.h>
@ -63,9 +61,6 @@ public:
status_t initCheck() const;
// tells the HAL what the framebuffer is
void setFrameBuffer(EGLDisplay dpy, EGLSurface sur);
// Asks the HAL what it can do
status_t prepare() const;
@ -73,7 +68,7 @@ public:
status_t disable();
// commits the list
status_t commit() const;
status_t commit(void* fbDisplay, void* fbSurface) const;
// release hardware resources and blank screen
status_t release() const;
@ -234,8 +229,6 @@ private:
size_t mCapacity;
mutable size_t mNumOVLayers;
mutable size_t mNumFBLayers;
EGLDisplay mDpy;
EGLSurface mSur;
cb_context* mCBContext;
EventHandler& mEventHandler;
nsecs_t mRefreshPeriod;

View File

@ -363,8 +363,8 @@ status_t SurfaceFlinger::readyToRun()
"Initializing graphics H/W...");
// initialize EGL
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, NULL, NULL);
mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(mEGLDisplay, NULL, NULL);
// Initialize the main display
// create native window to main display
@ -378,8 +378,8 @@ status_t SurfaceFlinger::readyToRun()
// initialize the config and context
int format;
window->query(window, NATIVE_WINDOW_FORMAT, &format);
mEGLConfig = selectEGLConfig(display, format);
mEGLContext = createGLContext(display, mEGLConfig);
mEGLConfig = selectEGLConfig(mEGLDisplay, format);
mEGLContext = createGLContext(mEGLDisplay, mEGLConfig);
// initialize our main display hardware
DisplayHardware* const hw = new DisplayHardware(this, 0, anw, mEGLConfig);
@ -387,7 +387,7 @@ status_t SurfaceFlinger::readyToRun()
// initialize OpenGL ES
EGLSurface surface = hw->getEGLSurface();
initializeGL(display, surface);
initializeGL(mEGLDisplay, surface);
// start the EventThread
mEventThread = new EventThread(this);
@ -397,9 +397,6 @@ status_t SurfaceFlinger::readyToRun()
mHwc = new HWComposer(this,
*static_cast<HWComposer::EventHandler *>(this),
hw->getRefreshPeriod());
if (mHwc->initCheck() == NO_ERROR) {
mHwc->setFrameBuffer(display, surface);
}
// We're now ready to accept clients...
mReadyToRunBarrier.open();
@ -733,15 +730,16 @@ void SurfaceFlinger::postFramebuffer()
}
hw.flip(mSwapRegion);
hwc.commit();
if (hwc.initCheck() == NO_ERROR) {
hwc.commit(mEGLDisplay, hw.getEGLSurface());
HWComposer::LayerListIterator cur = hwc.begin();
const HWComposer::LayerListIterator end = hwc.end();
for (size_t i = 0; cur != end && i < numLayers; ++i, ++cur) {
layers[i]->onLayerDisplayed(&*cur);
}
} else {
eglSwapBuffers(mEGLDisplay, hw.getEGLSurface());
for (size_t i = 0; i < numLayers; i++) {
layers[i]->onLayerDisplayed(NULL);
}

View File

@ -390,6 +390,7 @@ private:
GLint mMaxTextureSize;
EGLContext mEGLContext;
EGLConfig mEGLConfig;
EGLDisplay mEGLDisplay;
// Can only accessed from the main thread, these members
// don't need synchronization