Loading include/gui/GLConsumer.h +0 −4 Original line number Original line Diff line number Diff line Loading @@ -267,10 +267,6 @@ protected: // values. // values. status_t checkAndUpdateEglStateLocked(); status_t checkAndUpdateEglStateLocked(); // If set, GLConsumer will use the EGL_ANDROID_native_fence_sync // extension to create Android native fences for GLES activity. static const bool sUseNativeFenceSync; private: private: // createImage creates a new EGLImage from a GraphicBuffer. // createImage creates a new EGLImage from a GraphicBuffer. EGLImageKHR createImage(EGLDisplay dpy, EGLImageKHR createImage(EGLDisplay dpy, Loading include/private/gui/SyncFeatures.h 0 → 100644 +45 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SYNC_FEATURES_H #define ANDROID_GUI_SYNC_FEATURES_H #include <utils/Singleton.h> #include <utils/String8.h> namespace android { // ---------------------------------------------------------------------------- class SyncFeatures : public Singleton<SyncFeatures> { friend class Singleton<SyncFeatures>; bool mHasNativeFenceSync; bool mHasFenceSync; bool mHasWaitSync; String8 mString; SyncFeatures(); public: bool useNativeFenceSync() const; bool useFenceSync() const; bool useWaitSync() const; String8 toString() const; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_SYNC_FEATURES_H libs/gui/Android.mk +5 −16 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ LOCAL_SRC_FILES:= \ Surface.cpp \ Surface.cpp \ SurfaceControl.cpp \ SurfaceControl.cpp \ SurfaceComposerClient.cpp \ SurfaceComposerClient.cpp \ SyncFeatures.cpp \ LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libbinder \ libbinder \ Loading @@ -39,23 +40,11 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE:= libgui LOCAL_MODULE:= libgui ifeq ($(TARGET_BOARD_PLATFORM), omap4) ifeq ($(TARGET_BOARD_PLATFORM), tegra) LOCAL_CFLAGS += -DUSE_FENCE_SYNC LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC endif endif ifeq ($(TARGET_BOARD_PLATFORM), s5pc110) ifeq ($(TARGET_BOARD_PLATFORM), tegra3) LOCAL_CFLAGS += -DUSE_FENCE_SYNC LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC endif ifeq ($(TARGET_BOARD_PLATFORM), exynos5) LOCAL_CFLAGS += -DUSE_NATIVE_FENCE_SYNC LOCAL_CFLAGS += -DUSE_WAIT_SYNC endif ifneq ($(filter generic%,$(TARGET_DEVICE)),) # Emulator build LOCAL_CFLAGS += -DUSE_FENCE_SYNC endif ifeq ($(TARGET_BOARD_PLATFORM), msm8960) LOCAL_CFLAGS += -DUSE_NATIVE_FENCE_SYNC endif endif include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY) Loading libs/gui/ConsumerBase.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #include <EGL/egl.h> #include <EGL/egl.h> Loading libs/gui/GLConsumer.cpp +5 −44 Original line number Original line Diff line number Diff line Loading @@ -28,12 +28,13 @@ #include <hardware/hardware.h> #include <hardware/hardware.h> #include <gui/GLConsumer.h> #include <gui/IGraphicBufferAlloc.h> #include <gui/IGraphicBufferAlloc.h> #include <gui/ISurfaceComposer.h> #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/GLConsumer.h> #include <private/gui/ComposerService.h> #include <private/gui/ComposerService.h> #include <private/gui/SyncFeatures.h> #include <utils/Log.h> #include <utils/Log.h> #include <utils/String8.h> #include <utils/String8.h> Loading @@ -41,30 +42,6 @@ namespace android { namespace android { // This compile option makes GLConsumer use the // EGL_ANDROID_native_fence_sync extension to create Android native fences to // signal when all GLES reads for a given buffer have completed. It is not // compatible with using the EGL_KHR_fence_sync extension for the same // purpose. #ifdef USE_NATIVE_FENCE_SYNC #ifdef USE_FENCE_SYNC #error "USE_NATIVE_FENCE_SYNC and USE_FENCE_SYNC are incompatible" #endif const bool GLConsumer::sUseNativeFenceSync = true; #else const bool GLConsumer::sUseNativeFenceSync = false; #endif // This compile option makes GLConsumer use the EGL_KHR_wait_sync // extension to insert server-side waits into the GLES command stream. This // feature requires the EGL_ANDROID_native_fence_sync and // EGL_KHR_wait_sync extensions. #ifdef USE_WAIT_SYNC static const bool useWaitSync = true; #else static const bool useWaitSync = false; #endif // Macros for including the GLConsumer name in log messages // Macros for including the GLConsumer name in log messages #define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) Loading Loading @@ -97,18 +74,6 @@ static float mtxRot90[16] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, }; }; static float mtxRot180[16] = { -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, }; static float mtxRot270[16] = { 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, }; static void mtxMul(float out[16], const float a[16], const float b[16]); static void mtxMul(float out[16], const float a[16], const float b[16]); Loading @@ -121,11 +86,7 @@ GLConsumer::GLConsumer(GLuint tex, bool allowSynchronousMode, mCurrentTimestamp(0), mCurrentTimestamp(0), mFilteringEnabled(true), mFilteringEnabled(true), mTexName(tex), mTexName(tex), #ifdef USE_FENCE_SYNC mUseFenceSync(useFenceSync), mUseFenceSync(useFenceSync), #else mUseFenceSync(false), #endif mTexTarget(texTarget), mTexTarget(texTarget), mEglDisplay(EGL_NO_DISPLAY), mEglDisplay(EGL_NO_DISPLAY), mEglContext(EGL_NO_CONTEXT), mEglContext(EGL_NO_CONTEXT), Loading Loading @@ -522,7 +483,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) { ST_LOGV("syncForReleaseLocked"); ST_LOGV("syncForReleaseLocked"); if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) { if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) { if (sUseNativeFenceSync) { if (SyncFeatures::getInstance().useNativeFenceSync()) { EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); if (sync == EGL_NO_SYNC_KHR) { if (sync == EGL_NO_SYNC_KHR) { Loading @@ -545,7 +506,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) { "%s (%d)", strerror(-err), err); "%s (%d)", strerror(-err), err); return err; return err; } } } else if (mUseFenceSync) { } else if (mUseFenceSync && SyncFeatures::getInstance().useFenceSync()) { EGLSyncKHR fence = mEglSlots[mCurrentTexture].mEglFence; EGLSyncKHR fence = mEglSlots[mCurrentTexture].mEglFence; if (fence != EGL_NO_SYNC_KHR) { if (fence != EGL_NO_SYNC_KHR) { // There is already a fence for the current slot. We need to // There is already a fence for the current slot. We need to Loading Loading @@ -825,7 +786,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const { } } if (mCurrentFence->isValid()) { if (mCurrentFence->isValid()) { if (useWaitSync) { if (SyncFeatures::getInstance().useWaitSync()) { // Create an EGLSyncKHR from the current fence. // Create an EGLSyncKHR from the current fence. int fenceFd = mCurrentFence->dup(); int fenceFd = mCurrentFence->dup(); if (fenceFd == -1) { if (fenceFd == -1) { Loading Loading
include/gui/GLConsumer.h +0 −4 Original line number Original line Diff line number Diff line Loading @@ -267,10 +267,6 @@ protected: // values. // values. status_t checkAndUpdateEglStateLocked(); status_t checkAndUpdateEglStateLocked(); // If set, GLConsumer will use the EGL_ANDROID_native_fence_sync // extension to create Android native fences for GLES activity. static const bool sUseNativeFenceSync; private: private: // createImage creates a new EGLImage from a GraphicBuffer. // createImage creates a new EGLImage from a GraphicBuffer. EGLImageKHR createImage(EGLDisplay dpy, EGLImageKHR createImage(EGLDisplay dpy, Loading
include/private/gui/SyncFeatures.h 0 → 100644 +45 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SYNC_FEATURES_H #define ANDROID_GUI_SYNC_FEATURES_H #include <utils/Singleton.h> #include <utils/String8.h> namespace android { // ---------------------------------------------------------------------------- class SyncFeatures : public Singleton<SyncFeatures> { friend class Singleton<SyncFeatures>; bool mHasNativeFenceSync; bool mHasFenceSync; bool mHasWaitSync; String8 mString; SyncFeatures(); public: bool useNativeFenceSync() const; bool useFenceSync() const; bool useWaitSync() const; String8 toString() const; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_SYNC_FEATURES_H
libs/gui/Android.mk +5 −16 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ LOCAL_SRC_FILES:= \ Surface.cpp \ Surface.cpp \ SurfaceControl.cpp \ SurfaceControl.cpp \ SurfaceComposerClient.cpp \ SurfaceComposerClient.cpp \ SyncFeatures.cpp \ LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libbinder \ libbinder \ Loading @@ -39,23 +40,11 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE:= libgui LOCAL_MODULE:= libgui ifeq ($(TARGET_BOARD_PLATFORM), omap4) ifeq ($(TARGET_BOARD_PLATFORM), tegra) LOCAL_CFLAGS += -DUSE_FENCE_SYNC LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC endif endif ifeq ($(TARGET_BOARD_PLATFORM), s5pc110) ifeq ($(TARGET_BOARD_PLATFORM), tegra3) LOCAL_CFLAGS += -DUSE_FENCE_SYNC LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC endif ifeq ($(TARGET_BOARD_PLATFORM), exynos5) LOCAL_CFLAGS += -DUSE_NATIVE_FENCE_SYNC LOCAL_CFLAGS += -DUSE_WAIT_SYNC endif ifneq ($(filter generic%,$(TARGET_DEVICE)),) # Emulator build LOCAL_CFLAGS += -DUSE_FENCE_SYNC endif ifeq ($(TARGET_BOARD_PLATFORM), msm8960) LOCAL_CFLAGS += -DUSE_NATIVE_FENCE_SYNC endif endif include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY) Loading
libs/gui/ConsumerBase.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #include <EGL/egl.h> #include <EGL/egl.h> Loading
libs/gui/GLConsumer.cpp +5 −44 Original line number Original line Diff line number Diff line Loading @@ -28,12 +28,13 @@ #include <hardware/hardware.h> #include <hardware/hardware.h> #include <gui/GLConsumer.h> #include <gui/IGraphicBufferAlloc.h> #include <gui/IGraphicBufferAlloc.h> #include <gui/ISurfaceComposer.h> #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/GLConsumer.h> #include <private/gui/ComposerService.h> #include <private/gui/ComposerService.h> #include <private/gui/SyncFeatures.h> #include <utils/Log.h> #include <utils/Log.h> #include <utils/String8.h> #include <utils/String8.h> Loading @@ -41,30 +42,6 @@ namespace android { namespace android { // This compile option makes GLConsumer use the // EGL_ANDROID_native_fence_sync extension to create Android native fences to // signal when all GLES reads for a given buffer have completed. It is not // compatible with using the EGL_KHR_fence_sync extension for the same // purpose. #ifdef USE_NATIVE_FENCE_SYNC #ifdef USE_FENCE_SYNC #error "USE_NATIVE_FENCE_SYNC and USE_FENCE_SYNC are incompatible" #endif const bool GLConsumer::sUseNativeFenceSync = true; #else const bool GLConsumer::sUseNativeFenceSync = false; #endif // This compile option makes GLConsumer use the EGL_KHR_wait_sync // extension to insert server-side waits into the GLES command stream. This // feature requires the EGL_ANDROID_native_fence_sync and // EGL_KHR_wait_sync extensions. #ifdef USE_WAIT_SYNC static const bool useWaitSync = true; #else static const bool useWaitSync = false; #endif // Macros for including the GLConsumer name in log messages // Macros for including the GLConsumer name in log messages #define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) Loading Loading @@ -97,18 +74,6 @@ static float mtxRot90[16] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, }; }; static float mtxRot180[16] = { -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, }; static float mtxRot270[16] = { 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, }; static void mtxMul(float out[16], const float a[16], const float b[16]); static void mtxMul(float out[16], const float a[16], const float b[16]); Loading @@ -121,11 +86,7 @@ GLConsumer::GLConsumer(GLuint tex, bool allowSynchronousMode, mCurrentTimestamp(0), mCurrentTimestamp(0), mFilteringEnabled(true), mFilteringEnabled(true), mTexName(tex), mTexName(tex), #ifdef USE_FENCE_SYNC mUseFenceSync(useFenceSync), mUseFenceSync(useFenceSync), #else mUseFenceSync(false), #endif mTexTarget(texTarget), mTexTarget(texTarget), mEglDisplay(EGL_NO_DISPLAY), mEglDisplay(EGL_NO_DISPLAY), mEglContext(EGL_NO_CONTEXT), mEglContext(EGL_NO_CONTEXT), Loading Loading @@ -522,7 +483,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) { ST_LOGV("syncForReleaseLocked"); ST_LOGV("syncForReleaseLocked"); if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) { if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) { if (sUseNativeFenceSync) { if (SyncFeatures::getInstance().useNativeFenceSync()) { EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); if (sync == EGL_NO_SYNC_KHR) { if (sync == EGL_NO_SYNC_KHR) { Loading @@ -545,7 +506,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) { "%s (%d)", strerror(-err), err); "%s (%d)", strerror(-err), err); return err; return err; } } } else if (mUseFenceSync) { } else if (mUseFenceSync && SyncFeatures::getInstance().useFenceSync()) { EGLSyncKHR fence = mEglSlots[mCurrentTexture].mEglFence; EGLSyncKHR fence = mEglSlots[mCurrentTexture].mEglFence; if (fence != EGL_NO_SYNC_KHR) { if (fence != EGL_NO_SYNC_KHR) { // There is already a fence for the current slot. We need to // There is already a fence for the current slot. We need to Loading Loading @@ -825,7 +786,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const { } } if (mCurrentFence->isValid()) { if (mCurrentFence->isValid()) { if (useWaitSync) { if (SyncFeatures::getInstance().useWaitSync()) { // Create an EGLSyncKHR from the current fence. // Create an EGLSyncKHR from the current fence. int fenceFd = mCurrentFence->dup(); int fenceFd = mCurrentFence->dup(); if (fenceFd == -1) { if (fenceFd == -1) { Loading