Permalink
Browse files

frameworks/native: Add support for external-only layers.

Add support for external-only layers, used for dual-display
or closed captions.
Do not draw external-only layers.

Change-Id: Ieeb945d8a01f16a61a40433aa388a7c7822dcc8a
  • Loading branch information...
Saurabh Shah authored and Whitehawkx committed Jul 22, 2012
1 parent 7175a57 commit d5e8d31250aebb18e5172cdd1afffb56fd231dd6
@@ -204,6 +204,15 @@ class SurfaceTextureClient
// must be accessed from lock/unlock thread only
Region mDirtyRegion;
+
+ // mReqExtUsage is a flag set by app to mark a layer for display on
+ // external panels only. Depending on the value of this flag mReqUsage
+ // will be ORed with existing values.
+ // Possible values GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY,
+ // GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK,
+ // GRALLOC_USAGE_PRIVATE_EXTERNAL_CC,
+ // It is initialized to 0
+ uint32_t mReqExtUsage;
};
}; // namespace android
View
@@ -51,6 +51,11 @@ ifeq ($(TARGET_BOARD_PLATFORM), tegra)
LOCAL_CFLAGS += -DALLOW_DEQUEUE_CURRENT_BUFFER
endif
+ifeq ($(BOARD_USES_QCOM_HARDWARE), true)
+ LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
+ LOCAL_CFLAGS += -DQCOMHW
+endif
+
include $(BUILD_SHARED_LIBRARY)
ifeq (,$(ONE_SHOT_MAKEFILE))
@@ -29,6 +29,9 @@
#include <gui/SurfaceTextureClient.h>
#include <private/gui/ComposerService.h>
+#ifdef QCOMHW
+#include <gralloc_priv.h>
+#endif
namespace android {
@@ -74,6 +77,7 @@ void SurfaceTextureClient::init() {
mReqHeight = 0;
mReqFormat = 0;
mReqUsage = 0;
+ mReqExtUsage = 0;
mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO;
mCrop.clear();
mScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
@@ -489,7 +493,27 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage)
{
ALOGV("SurfaceTextureClient::setUsage");
Mutex::Autolock lock(mMutex);
- mReqUsage = reqUsage;
+
+#ifdef QCOMHW
+ if (reqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) {
+ //Set explicitly, since reqUsage may have other values.
+ mReqExtUsage = GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY;
+ //This flag is never independent. Always an add-on to
+ //GRALLOC_USAGE_EXTERNAL_ONLY
+ if(reqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) {
+ mReqExtUsage |= GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK;
+ } else if(reqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) {
+ mReqExtUsage |= GRALLOC_USAGE_PRIVATE_EXTERNAL_CC;
+ }
+ }
+#endif
+
+ // For most cases mReqExtUsage will be 0.
+ // reqUsage could come from app or driver. When it comes from app
+ // and subsequently from driver, the latter ends up overwriting
+ // the existing values. We cache certain values in mReqExtUsage
+ // to avoid being overwritten.
+ mReqUsage = reqUsage | mReqExtUsage;
return OK;
}
@@ -16,7 +16,6 @@ LOCAL_SRC_FILES:= \
SurfaceFlinger.cpp \
SurfaceTextureLayer.cpp \
Transform.cpp \
-
LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\"
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
@@ -32,6 +31,11 @@ ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
LOCAL_CFLAGS += -DNEVER_DEFAULT_TO_ASYNC_MODE
endif
+ifeq ($(BOARD_USES_QCOM_HARDWARE), true)
+ LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
+ LOCAL_CFLAGS += -DQCOMHW
+endif
+
ifeq ($(TARGET_DISABLE_TRIPLE_BUFFERING), true)
LOCAL_CFLAGS += -DTARGET_DISABLE_TRIPLE_BUFFERING
endif
@@ -27,6 +27,9 @@
#include <GLES/glext.h>
#include <hardware/hardware.h>
+#ifdef QCOMHW
+#include <gralloc_priv.h>
+#endif
#include "clz.h"
#include "LayerBase.h"
@@ -35,6 +38,9 @@
namespace android {
+//Helper
+bool isLayerExternalOnly(const sp<Layer>& layer);
+
// ---------------------------------------------------------------------------
int32_t LayerBase::sSequence = 1;
@@ -66,13 +72,13 @@ String8 LayerBase::getName() const {
}
const GraphicPlane& LayerBase::graphicPlane(int dpy) const
-{
+{
return mFlinger->graphicPlane(dpy);
}
GraphicPlane& LayerBase::graphicPlane(int dpy)
{
- return mFlinger->graphicPlane(dpy);
+ return mFlinger->graphicPlane(dpy);
}
void LayerBase::initStates(uint32_t w, uint32_t h, uint32_t flags)
@@ -184,7 +190,7 @@ bool LayerBase::setCrop(const Rect& crop) {
Rect LayerBase::visibleBounds() const
{
return mTransformedBounds;
-}
+}
void LayerBase::setVisibleRegion(const Region& visibleRegion) {
// always called from main thread
@@ -337,11 +343,19 @@ bool LayerBase::getFiltering() const
void LayerBase::draw(const Region& clip) const
{
+ //Dont draw External-only layers
+ if (isLayerExternalOnly(getLayer())) {
+ return;
+ }
onDraw(clip);
}
void LayerBase::drawForSreenShot()
{
+ //Dont draw External-only layers
+ if (isLayerExternalOnly(getLayer())) {
+ return;
+ }
const DisplayHardware& hw(graphicPlane(0).displayHardware());
setFiltering(true);
onDraw( Region(hw.bounds()) );
@@ -566,4 +580,19 @@ LayerBaseClient::LayerCleaner::~LayerCleaner() {
// ---------------------------------------------------------------------------
+//Helper for external-only layers
+bool isLayerExternalOnly(const sp<Layer>& layer) {
+#ifdef QCOMHW
+ if(layer != NULL) {
+ const sp<GraphicBuffer>& buffer(layer->getActiveBuffer());
+ if (buffer != NULL) {
+ const int usage = buffer->getUsage();
+ if(usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY)
+ return true;
+ }
+ }
+#endif
+ return false;
+}
+
}; // namespace android

0 comments on commit d5e8d31

Please sign in to comment.