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

Commit 45f33a57 authored by Christopher Wiley's avatar Christopher Wiley
Browse files

Allocate buffers locally in systems without SurfaceFlinger

In Brillo systems, we have no applications and configure
SELinux policy statically.  In this model, we do not need
a special service to allocate buffers, since any process
that needs buffers can be appropriately marked at build time.

Bug: 26936651
Test: A test program on brilloemulator can allocate buffers for
      the camera with this patch.

Change-Id: Ifcdb7a4b878f9a26f4899c7b75a12447dcdb0ac9
parent d3a9228d
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");
        }