Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1dba36ce authored by Christopher Wiley's avatar Christopher Wiley Committed by android-build-merger
Browse files

Merge "Allocate buffers locally in systems without SurfaceFlinger" am: afcf267c

am: 225a2901

* commit '225a2901':
  Allocate buffers locally in systems without SurfaceFlinger
parents 90f0c71d 225a2901
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -93,6 +93,10 @@ ifeq ($(TARGET_BOARD_PLATFORM), tegra3)
	LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
endif

ifeq ($(TARGET_BOARD_HAS_NO_SURFACE_FLINGER), true)
	LOCAL_CFLAGS += -DHAVE_NO_SURFACE_FLINGER
endif

include $(BUILD_SHARED_LIBRARY)

ifeq (,$(ONE_SHOT_MAKEFILE))
+21 −2
Original line number Diff line number Diff line
@@ -28,8 +28,11 @@

#include <inttypes.h>

#include <cutils/properties.h>

#include <gui/BufferItem.h>
#include <gui/BufferQueueCore.h>
#include <gui/GraphicBufferAlloc.h>
#include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
@@ -84,8 +87,24 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
            HAL_DATASPACE_UNKNOWN)
{
    if (allocator == NULL) {

#ifdef HAVE_NO_SURFACE_FLINGER
        // Without a SurfaceFlinger, allocate in-process.  This only makes
        // sense in systems with static SELinux configurations and no
        // applications (since applications need dynamic SELinux policy).
        mAllocator = new GraphicBufferAlloc();
#else
        // Run time check for headless, where we also allocate in-process.
        char value[PROPERTY_VALUE_MAX];
        property_get("config.headless", value, "0");
        if (atoi(value) == 1) {
            mAllocator = new GraphicBufferAlloc();
        } else {
            sp<ISurfaceComposer> composer(ComposerService::getComposerService());
            mAllocator = composer->createGraphicBufferAlloc();
        }
#endif  // HAVE_NO_SURFACE_FLINGER

        if (mAllocator == NULL) {
            BQ_LOGE("createGraphicBufferAlloc failed");
        }