Skip to content

Commit

Permalink
Rework BOARD_EGL_NEEDS_LEGACY_FB implementation
Browse files Browse the repository at this point in the history
The problem with the window format boils down to a circular
dependency that makes service startup hang, so skip a round of
queues-to-window-composer to avoid it but keep using regular
Surface objects as windows, instead of replacing them with
native windows.

Change-Id: I6fed0fe04928df370c298c68ac1eb6d5b5cfb214
  • Loading branch information
rmcc authored and tdm committed Aug 15, 2013
1 parent bb37e5e commit bf3c0b5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
4 changes: 4 additions & 0 deletions include/gui/Surface.h
Expand Up @@ -252,6 +252,10 @@ class Surface

// must be accessed from lock/unlock thread only
Region mDirtyRegion;

#ifdef BOARD_EGL_NEEDS_LEGACY_FB
bool mDequeuedOnce;
#endif
};

}; // namespace android
Expand Down
4 changes: 4 additions & 0 deletions libs/gui/Android.mk
Expand Up @@ -43,6 +43,10 @@ ifeq ($(TARGET_USES_QCOM_BSP),true)
LOCAL_CFLAGS += -DQCOM_BSP
endif

ifeq ($(BOARD_EGL_NEEDS_LEGACY_FB),true)
LOCAL_CFLAGS += -DBOARD_EGL_NEEDS_LEGACY_FB
endif

LOCAL_MODULE:= libgui

ifeq ($(TARGET_BOARD_PLATFORM), tegra)
Expand Down
23 changes: 18 additions & 5 deletions libs/gui/Surface.cpp
Expand Up @@ -72,6 +72,9 @@ Surface::Surface(
mTransformHint = 0;
mConsumerRunningBehind = false;
mConnectedToCpu = false;
#ifdef BOARD_EGL_NEEDS_LEGACY_FB
mDequeuedOnce = false;
#endif
}

Surface::~Surface() {
Expand Down Expand Up @@ -218,6 +221,9 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer,
}

*buffer = gbuf.get();
#ifdef BOARD_EGL_NEEDS_LEGACY_FB
if (!mDequeuedOnce) mDequeuedOnce = true;
#endif
return OK;
}

Expand Down Expand Up @@ -306,12 +312,19 @@ int Surface::query(int what, int* value) const {
}
break;
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: {
sp<ISurfaceComposer> composer(
ComposerService::getComposerService());
if (composer->authenticateSurfaceTexture(mGraphicBufferProducer)) {
*value = 1;
} else {
#ifdef BOARD_EGL_NEEDS_LEGACY_FB
if (!mDequeuedOnce) {
*value = 0;
} else
#endif
{
sp<ISurfaceComposer> composer(
ComposerService::getComposerService());
if (composer->authenticateSurfaceTexture(mGraphicBufferProducer)) {
*value = 1;
} else {
*value = 0;
}
}
return NO_ERROR;
}
Expand Down
4 changes: 0 additions & 4 deletions services/surfaceflinger/Android.mk
Expand Up @@ -34,10 +34,6 @@ ifeq ($(TARGET_DISABLE_TRIPLE_BUFFERING),true)
LOCAL_CFLAGS += -DTARGET_DISABLE_TRIPLE_BUFFERING
endif

ifeq ($(BOARD_EGL_NEEDS_LEGACY_FB),true)
LOCAL_CFLAGS += -DBOARD_EGL_NEEDS_LEGACY_FB
endif

ifneq ($(NUM_FRAMEBUFFER_SURFACE_BUFFERS),)
LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
endif
Expand Down
8 changes: 0 additions & 8 deletions services/surfaceflinger/DisplayDevice.cpp
Expand Up @@ -29,10 +29,6 @@

#include <gui/Surface.h>

#ifdef BOARD_EGL_NEEDS_LEGACY_FB
#include <ui/FramebufferNativeWindow.h>
#endif

#include <GLES/gl.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
Expand Down Expand Up @@ -96,11 +92,7 @@ DisplayDevice::DisplayDevice(
mOrientation()
{
mNativeWindow = new Surface(mDisplaySurface->getIGraphicBufferProducer());
#ifndef BOARD_EGL_NEEDS_LEGACY_FB
ANativeWindow* const window = mNativeWindow.get();
#else
ANativeWindow* const window = new FramebufferNativeWindow();
#endif

int format;
window->query(window, NATIVE_WINDOW_FORMAT, &format);
Expand Down

0 comments on commit bf3c0b5

Please sign in to comment.