diff options
author | Christopher Wiley <wiley@google.com> | 2016-02-17 17:32:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-02-17 17:32:15 +0000 |
commit | afcf267cbd86316cd98c96bc82400479c965d8d6 (patch) | |
tree | 6455d141b82fb0bdbbfa1f4f9ff9e01658128bfe | |
parent | 4f321d1629e2b848b4e9a5304ab4a9262bc81569 (diff) | |
parent | 45f33a57d6755c81db3c0dcbc6f49d1c4ca53e56 (diff) | |
download | native-brillo-m10-dev.tar.gz |
Merge "Allocate buffers locally in systems without SurfaceFlinger"brillo-m10-releasebrillo-m10-dev
-rw-r--r-- | libs/gui/Android.mk | 4 | ||||
-rw-r--r-- | libs/gui/BufferQueueCore.cpp | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk index 8a965dddfc..abc18db19a 100644 --- a/libs/gui/Android.mk +++ b/libs/gui/Android.mk @@ -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)) diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp index 851a396155..0f8ec7f6e5 100644 --- a/libs/gui/BufferQueueCore.cpp +++ b/libs/gui/BufferQueueCore.cpp @@ -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) { - sp<ISurfaceComposer> composer(ComposerService::getComposerService()); - mAllocator = composer->createGraphicBufferAlloc(); + +#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"); } |