From dfab0ee25433bca9d9158a65cf2861c28a3fd75c Mon Sep 17 00:00:00 2001 From: Baldev Sahu Date: Fri, 17 Jul 2015 10:04:43 +0530 Subject: [PATCH] SurfaceFlinger: Add support for MDP3 This change is porting of following commits related to MDP3 1) SurfaceFlinger: Change to support framebuffer flip for 2D blitters - Surfaceflinger does not flip framebuffers when there are no layers marked for HWC_FRAMEBUFFER - This change checks for the HWC_BLIT flag and will request a flip to a new FB_TARGET buffer even if there are no FRAMEBUFFER layers "Change-Id: I1cb44389a05c9ec049d7f0d39c288feccb11a91c" 2) SF: Avoid wormhole clear for BLIT calls - Do not call GPU clear from SF when composition type is BLIT as it'll be taken care in HAL. "Change-Id: Ia613eb9b824c6484ecc8c8fa4ee883545d8541b8" 3) surfaceflinger: Allow gpu to render widevine level3 - Allow gpu to render widevine level3 but keep blocking screen shots. "Change-Id: I914232a062acbb7b17901dbf2b414973230e59d9" Change-Id: I35eef9eb1597af21c195e07d5fe4c0c73ab3a269 --- services/surfaceflinger/Android.mk | 1 + services/surfaceflinger/DisplayHardware/HWComposer.cpp | 7 +++++-- services/surfaceflinger/DisplayHardware/HWComposer.h | 3 +++ services/surfaceflinger/Layer.cpp | 3 ++- services/surfaceflinger/Layer.h | 4 ++++ services/surfaceflinger/SurfaceFlinger.cpp | 9 ++++++++- services/surfaceflinger/SurfaceFlinger.h | 5 +++++ 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 3c966e2f7..e097540ab 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -113,6 +113,7 @@ LOCAL_C_INCLUDES += $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/display-framewor ifeq ($(TARGET_USES_QCOM_BSP), true) LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc LOCAL_C_INCLUDES += hardware/qcom/display/libqdutils + LOCAL_C_INCLUDES += vendor/qcom/opensource/display-frameworks/include LOCAL_SHARED_LIBRARIES += libqdutils LOCAL_CFLAGS += -DQTI_BSP endif diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 83318281e..5bdcd7f79 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -707,6 +707,9 @@ status_t HWComposer::prepare() { if (l.compositionType == HWC_OVERLAY) { disp.hasOvComp = true; } + if (isCompositionTypeBlit(l.compositionType)) { + disp.hasFbComp = true; + } if (l.compositionType == HWC_CURSOR_OVERLAY) { disp.hasOvComp = true; } @@ -1242,7 +1245,7 @@ void HWComposer::dump(String8& result) const { if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) { result.appendFormat( " %9s | %08" PRIxPTR " | %04x | %04x | %02x | %04x | %-11s |%7.1f,%7.1f,%7.1f,%7.1f |%5d,%5d,%5d,%5d | %s\n", - compositionTypeName[type], + (isCompositionTypeBlit(l.compositionType)) ? "HWC_BLIT" : compositionTypeName[type], intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, formatStr.string(), l.sourceCropf.left, l.sourceCropf.top, l.sourceCropf.right, l.sourceCropf.bottom, l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom, @@ -1250,7 +1253,7 @@ void HWComposer::dump(String8& result) const { } else { result.appendFormat( " %9s | %08" PRIxPTR " | %04x | %04x | %02x | %04x | %-11s |%7d,%7d,%7d,%7d |%5d,%5d,%5d,%5d | %s\n", - compositionTypeName[type], + (isCompositionTypeBlit(l.compositionType)) ? "HWC_BLIT" : compositionTypeName[type], intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, formatStr.string(), l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom, l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom, diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index 952635fcd..ea9a208b5 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -312,6 +312,9 @@ public: * Extensions */ virtual inline bool isVDSEnabled() const { return true; }; + virtual inline bool isCompositionTypeBlit(const int32_t /*compType*/) const { + return false; + }; private: void loadHwcModule(); diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index bfd83e470..bcd591523 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -579,6 +579,7 @@ void Layer::setAcquireFence(const sp& /* hw */, } } } + setAcquiredFenceIfBlit(fenceFd, layer); layer.setAcquireFenceFd(fenceFd); } @@ -665,7 +666,7 @@ void Layer::onDraw(const sp& hw, const Region& clip, RenderEngine& engine(mFlinger->getRenderEngine()); - if (!blackOutLayer) { + if (!blackOutLayer || canAllowGPUForProtected()) { // TODO: we could be more subtle with isFixedSize() const bool useFiltering = getFiltering() || needsFiltering(hw) || isFixedSize(); diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 910ac97db..558f026ed 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -296,6 +296,10 @@ public: virtual void setPosition(const sp& /*hw*/, HWComposer::HWCLayerInterface& /*layer*/, const State& /*state*/) { } + virtual void setAcquiredFenceIfBlit(int& /*fenceFd */, + HWComposer::HWCLayerInterface& /*layer */) { } + virtual bool canAllowGPUForProtected() const { return false; } + /* * returns the rectangle that crops the content of the layer and scales it diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index c5e50e88c..21c8aa5bd 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1957,7 +1957,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp& hw, const // screen is already cleared here if (!region.isEmpty()) { // can happen with SurfaceView - drawWormhole(hw, region); + drawWormHoleIfRequired(cur, end, hw, region); } } @@ -3534,6 +3534,13 @@ bool SurfaceFlinger::canDrawLayerinScreenShot( return layer->isVisible(); } +void SurfaceFlinger::drawWormHoleIfRequired(HWComposer::LayerListIterator& /*cur*/, + const HWComposer::LayerListIterator& /*end*/, + const sp& hw, + const Region& region) { + drawWormhole(hw, region); +} + // --------------------------------------------------------------------------- SurfaceFlinger::LayerVector::LayerVector() { diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 2c5043222..678f2e1dc 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -269,6 +269,11 @@ private: const int32_t& /*id*/) { } virtual void updateVisibleRegionsDirty() { } + + virtual void drawWormHoleIfRequired(HWComposer::LayerListIterator &cur, + const HWComposer::LayerListIterator &end, + const sp& hw, + const Region& region); /* ------------------------------------------------------------------------ * Message handling */