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

Commit afcf267c authored by Christopher Wiley's avatar Christopher Wiley Committed by Gerrit Code Review
Browse files

Merge "Allocate buffers locally in systems without SurfaceFlinger"

parents 4f321d16 45f33a57
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,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
@@ -22,8 +22,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>
@@ -75,8 +78,24 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
    mGenerationNumber(0)
{
    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");
        }