Permalink
Browse files

SurfaceTexture: Add support for drawing non-GPU supported buffers.

Add support for drawing buffers which are not supported by the GPU.
These buffers are drawn using the overlay or C2D. During rotation,
when the draw operation is performed, the GPU clears the clip region
for this buffer.

Change-Id: I7e7abef68ef5aefddaf1596979819ddd66be3681
  • Loading branch information...
1 parent e7121f8 commit c322de3dc5cb685fa80590e940e366647fd3f2aa Naseer Ahmed committed with Gerrit Code Review Aug 1, 2012
Showing with 35 additions and 12 deletions.
  1. +2 −1 libs/gui/Android.mk
  2. +21 −9 libs/gui/SurfaceTexture.cpp
  3. +2 −1 services/surfaceflinger/Android.mk
  4. +10 −1 services/surfaceflinger/Layer.cpp
View
@@ -53,7 +53,8 @@ endif
ifeq ($(BOARD_USES_QCOM_HARDWARE), true)
LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
- LOCAL_CFLAGS += -DQCOMHW
+ LOCAL_C_INCLUDES += hardware/qcom/display/libqdutils
+ LOCAL_CFLAGS += -DQCOMHW
endif
include $(BUILD_SHARED_LIBRARY)
@@ -39,6 +39,10 @@
#include <utils/String8.h>
#include <utils/Trace.h>
+#ifdef QCOMHW
+#include <gpuformats.h>
+#endif
+
// This compile option makes SurfaceTexture use the EGL_KHR_fence_sync extension
// to synchronize access to the buffers. It will cause dequeueBuffer to stall,
// waiting for the GL reads for the buffer being dequeued to complete before
@@ -245,18 +249,25 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
// Update the GL texture object. We may have to do this even when
// item.mGraphicBuffer == NULL, if we destroyed the EGLImage when
// detaching from a context but the buffer has not been re-allocated.
+ bool gpuSupportedFormat = true;
EGLImageKHR image = mEGLSlots[buf].mEglImage;
if (image == EGL_NO_IMAGE_KHR) {
if (mEGLSlots[buf].mGraphicBuffer == NULL) {
ST_LOGE("updateTexImage: buffer at slot %d is null", buf);
err = BAD_VALUE;
} else {
- image = createImage(dpy, mEGLSlots[buf].mGraphicBuffer);
- mEGLSlots[buf].mEglImage = image;
- if (image == EGL_NO_IMAGE_KHR) {
- // NOTE: if dpy was invalid, createImage() is guaranteed to
- // fail. so we'd end up here.
- err = UNKNOWN_ERROR;
+#ifdef QCOMHW
+ gpuSupportedFormat = qdutils::isGPUSupportedFormat(
+ mEGLSlots[buf].mGraphicBuffer->format);
+#endif
+ if(gpuSupportedFormat) {
+ image = createImage(dpy, mEGLSlots[buf].mGraphicBuffer);
+ mEGLSlots[buf].mEglImage = image;
+ if (image == EGL_NO_IMAGE_KHR) {
+ // NOTE: if dpy was invalid, createImage() is guaranteed to
+ // fail. so we'd end up here.
+ err = UNKNOWN_ERROR;
+ }
}
}
}
@@ -267,9 +278,10 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
ST_LOGW("updateTexImage: clearing GL error: %#04x", error);
}
- glBindTexture(mTexTarget, mTexName);
- glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image);
-
+ if(gpuSupportedFormat) {
+ glBindTexture(mTexTarget, mTexName);
+ glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image);
+ }
while ((error = glGetError()) != GL_NO_ERROR) {
ST_LOGE("updateTexImage: error binding external texture image %p "
"(slot %d): %#04x", image, buf, error);
@@ -33,7 +33,8 @@ endif
ifeq ($(BOARD_USES_QCOM_HARDWARE), true)
LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
- LOCAL_CFLAGS += -DQCOMHW
+ LOCAL_C_INCLUDES += hardware/qcom/display/libqdutils
+ LOCAL_CFLAGS += -DQCOMHW
endif
ifeq ($(TARGET_DISABLE_TRIPLE_BUFFERING), true)
@@ -43,6 +43,10 @@
#include "SurfaceFlinger.h"
#include "SurfaceTextureLayer.h"
+#ifdef QCOMHW
+#include <gpuformats.h>
+#endif
+
#define DEBUG_RESIZE 0
namespace android {
@@ -354,7 +358,12 @@ void Layer::onDraw(const Region& clip) const
}
return;
}
-
+#ifdef QCOMHW
+ if (!qdutils::isGPUSupportedFormat(mActiveBuffer->format)) {
+ clearWithOpenGL(clip, 0, 0, 0, 1);
+ return;
+ }
+#endif
if (!isProtected()) {
// TODO: we could be more subtle with isFixedSize()
const bool useFiltering = getFiltering() || needsFiltering() || isFixedSize();

0 comments on commit c322de3

Please sign in to comment.