SurfaceFlinger: Move Extended SF classes to same repository

Move the ExSurfaceFlinger, ExLayer, etc., classes to this
repository, to avoid dependency accross projects with static
linking

The following commits are included in this:
commit 04f501b31f627e47ae540b5160b2f86b7adbd921
Author: Baldev Sahu <bsahu@codeaurora.org>
Date:   Wed Nov 25 18:05:51 2015 +0530

display-fw: Properly initialise mIsGPUAllowedForProtected flag

- This flag need to be initialize to false when layer is
  created.

Change-Id: Ie3df40ffc4240c33883f19ecbef6428f7c539b07
CRs-fixed: 942102

commit 09032188751356db295bc5467133ec484dc536cd
Author: Arun Kumar K.R <akumarkr@codeaurora.org>
Date:   Tue Oct 20 10:22:51 2015 -0700

display-fw: Enable checking for INTERNAL_ONLY private flag

Check for INTERNAL_ONLY private flag and return correct values
from the function isIntOnly

Change-Id: I61b44f636412e0ad93e1b3ff18e4accdf90eeafe
CRs-fixed: 927880

commit f687ac25b3482b92da3c252d29b65e850cca3ce1
Author: Arun Kumar K.R <akumarkr@codeaurora.org>
Date:   Thu Oct 15 16:37:11 2015 -0700

display-frameworks: Include libqdutils
only for target builds

Featurize including libqdutils for targets which uses QCOM_BSP,
helps in resolving compilation for emulator builds

Change-Id: I39639c3100eb20dd24d2a875bb0e9bc82d2b2d1f

commit 4ec765e01be506a8083980fc746a1737bbac4bf2
Author: Arun Kumar K.R <akumarkr@codeaurora.org>
Date:   Wed Oct 7 18:33:34 2015 -0700

display-fw: Disable rotation animation on secondary displays

- Set the animating flag on layer during animation which is used
  as hint to disable rotation animation on secondary displays.
- Set sys.disable_ext_animation to enable the feature
- Remove unused definitions in the extended hwc header

Change-Id: I7b72c7b605930ea189e047fec17ed18b17d46fdf
CRs-fixed: 922304

commit 6998bbdfd7af3126b64897b16b6961e84952601b
Author: Baldev Sahu <bsahu@codeaurora.org>
Date:   Thu Jul 30 16:01:15 2015 +0530

display-frameworks: Extend support for MDP3

- Add support for HWC_BLIT
- Allow GPU to compose widevine level 3

Change-Id:I11e03ccd0842d019e85d0c29bc5b7be559fccbaa

commit 2fa7aa1684c0162b8226c4327c86c6eaf6b76101
Author: Manoj Kumar <manoj@codeaurora.org>
Date:   Thu Aug 20 13:52:15 2015 -0700

display-frameworks: Override mOutputUsage with sink Usage flags

mOutputUsage flags contain default usage flags and doesnt reflect
sink usage flags. Override mOutputUsage with sink usage flags.

This change is needed to support WFD Secure usecase.

Change-Id: I14d8812049f635a8ebe6a944783e0ec7f8f80b1f

commit 09da768794c8c6acd786d73239ed5a739695b8cb
Author: Raj Kamal <rkamal@codeaurora.org>
Date:   Mon Jul 20 10:46:27 2015 +0530

display-frameworks: Extend the classes defined in SF

Add support for custom classes ExSurfaceFlinger,
ExLayer, ExHWComposer and ExVirtualDisplaySurface

Change-Id: Iab8c4835faaad9b436bbd34d38702741eb0cf12d

Change-Id: Ie400c94ccc77fc379ffa256af03a9e42ba5decaa
This commit is contained in:
Arun Kumar K.R 2015-12-02 18:19:20 -08:00 committed by Steve Kondik
parent cda438d95e
commit c86c815f74
11 changed files with 909 additions and 9 deletions

View File

@ -107,15 +107,16 @@ LOCAL_SHARED_LIBRARIES := \
libgui \
libpowermanager
ifeq ($(TARGET_USES_QCOM_BSP), true)
LOCAL_WHOLE_STATIC_LIBRARIES += libexsurfaceflinger
LOCAL_C_INCLUDES += vendor/qcom/opensource/display-frameworks/native/services/surfaceflinger
LOCAL_C_INCLUDES += vendor/qcom/opensource/display-frameworks/include
LOCAL_C_INCLUDES += $(call project-path-for,qcom-display)/libgralloc
LOCAL_C_INCLUDES += $(call project-path-for,qcom-display)/libqdutils
LOCAL_SHARED_LIBRARIES += libqdutils
LOCAL_CFLAGS += -DQTI_BSP
LOCAL_SRC_FILES += \
ExSurfaceFlinger/ExLayer.cpp \
ExSurfaceFlinger/ExSurfaceFlinger.cpp \
ExSurfaceFlinger/ExVirtualDisplaySurface.cpp \
ExSurfaceFlinger/ExHWComposer.cpp
endif
ifeq ($(TARGET_HAVE_UI_BLUR),true)

View File

@ -37,7 +37,7 @@
#include <hardware/hardware.h>
#include <hardware/hwcomposer.h>
#ifdef QTI_BSP
#include <exhwcomposer_defs.h>
#include <hardware/display_defs.h>
#endif
#include <android/configuration.h>

View File

@ -40,10 +40,10 @@
#include "DisplayHardware/FramebufferSurface.h"
#include "DisplayUtils.h"
#ifdef QTI_BSP
#include <ExSurfaceFlinger.h>
#include <ExLayer.h>
#include <DisplayHardware/ExHWComposer.h>
#include <DisplayHardware/ExVirtualDisplaySurface.h>
#include <ExSurfaceFlinger/ExSurfaceFlinger.h>
#include <ExSurfaceFlinger/ExLayer.h>
#include <ExSurfaceFlinger/ExHWComposer.h>
#include <ExSurfaceFlinger/ExVirtualDisplaySurface.h>
#include <gralloc_priv.h>
#endif
#include <dlfcn.h>

View File

@ -0,0 +1,77 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ExSurfaceFlinger.h"
#include "ExLayer.h"
#include "ExHWComposer.h"
#ifdef QTI_BSP
#include <hardware/display_defs.h>
#endif
namespace android {
ExHWComposer::ExHWComposer(const sp<SurfaceFlinger>& flinger,
EventHandler& handler)
: HWComposer(flinger, handler) {
mVDSEnabled = false;
char property[PROPERTY_VALUE_MAX] = {0};
/* Read system property for VDS solution.
* This property is expected to be setup once during bootup
*/
if( (property_get("persist.hwc.enable_vds", property, NULL) > 0) &&
((!strncmp(property, "1", strlen("1"))) ||
!strncasecmp(property, "true", strlen("true")))) {
/* HAL virtual display is using VDS based implementation */
mVDSEnabled = true;
}
mDebugLogs = false;
if((property_get("persist.debug.qdframework.logs", property, NULL) > 0) &&
(!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
(!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
mDebugLogs = true;
}
ALOGD_IF(isDebug(),"Creating custom HWC %s",__FUNCTION__);
}
ExHWComposer::~ExHWComposer() {
}
bool ExHWComposer::isCompositionTypeBlit(const int32_t compType) const {
#ifdef QTI_BSP
return (compType == HWC_BLIT);
#else
ALOGD_IF(mDebugLogs, "%s: compType = %d", __FUNCTION__, compType);
#endif
return false;
}
}; // namespace android

View File

@ -0,0 +1,57 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_EX_HWCOMPOSER_H
#define ANDROID_EX_HWCOMPOSER_H
#include <DisplayHardware/HWComposer.h>
namespace android {
class ExHWComposer : public HWComposer
{
public:
ExHWComposer(
const sp<SurfaceFlinger>& flinger,
EventHandler& handler);
virtual ~ExHWComposer();
protected:
bool mVDSEnabled;
inline bool isVDSEnabled() const { return mVDSEnabled; };
bool mDebugLogs;
bool isDebug() { return mDebugLogs; }
bool isCompositionTypeBlit(const int32_t compType) const;
};
}; //namespace android
#endif //ANDROID_EX_HWCOMPOSER_H

View File

@ -0,0 +1,207 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <ui/GraphicBuffer.h>
#ifdef QTI_BSP
#include <gralloc_priv.h>
#include <hardware/display_defs.h>
#endif
#include "ExLayer.h"
namespace android {
/* Calculates the aspect ratio for external display based on the video w/h */
static Rect getAspectRatio(const sp<const DisplayDevice>& hw,
const int& srcWidth, const int& srcHeight) {
Rect outRect;
int fbWidth = hw->getWidth();
int fbHeight = hw->getHeight();
int x , y = 0;
int w = fbWidth, h = fbHeight;
if (srcWidth * fbHeight > fbWidth * srcHeight) {
h = fbWidth * srcHeight / srcWidth;
w = fbWidth;
} else if (srcWidth * fbHeight < fbWidth * srcHeight) {
w = fbHeight * srcWidth / srcHeight;
h = fbHeight;
}
x = (fbWidth - w) / 2;
y = (fbHeight - h) / 2;
outRect.left = x;
outRect.top = y;
outRect.right = x + w;
outRect.bottom = y + h;
return outRect;
}
ExLayer::ExLayer(SurfaceFlinger* flinger, const sp<Client>& client,
const String8& name, uint32_t w, uint32_t h, uint32_t flags)
: Layer(flinger, client, name, w, h, flags) {
char property[PROPERTY_VALUE_MAX] = {0};
mDebugLogs = false;
mIsGPUAllowedForProtected = false;
if((property_get("persist.debug.qdframework.logs", property, NULL) > 0) &&
(!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
(!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
mDebugLogs = true;
}
ALOGD_IF(isDebug(),"Creating custom Layer %s",__FUNCTION__);
if ((property_get("persist.gralloc.cp.level3", property, NULL) > 0) &&
(atoi(property) == 1)) {
mIsGPUAllowedForProtected = true;
}
}
ExLayer::~ExLayer() {
}
bool ExLayer::isExtOnly() const {
const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
if (activeBuffer != 0) {
#ifdef QTI_BSP
ANativeWindowBuffer* buffer = activeBuffer->getNativeBuffer();
if(buffer) {
private_handle_t* hnd = static_cast<private_handle_t*>
(const_cast<native_handle_t*>(buffer->handle));
/* return true if layer is EXT_ONLY */
return (hnd && (hnd->flags & private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY));
}
#endif
}
return false;
}
bool ExLayer::isIntOnly() const {
const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
if (activeBuffer != 0) {
#ifdef QTI_BSP
ANativeWindowBuffer* buffer = activeBuffer->getNativeBuffer();
if(buffer) {
private_handle_t* hnd = static_cast<private_handle_t*>
(const_cast<native_handle_t*>(buffer->handle));
/* return true if layer is INT_ONLY */
return (hnd && (hnd->flags & private_handle_t::PRIV_FLAGS_INTERNAL_ONLY));
}
#endif
}
return false;
}
bool ExLayer::isSecureDisplay() const {
const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
if (activeBuffer != 0) {
#ifdef QTI_BSP
ANativeWindowBuffer* buffer = activeBuffer->getNativeBuffer();
if(buffer) {
private_handle_t* hnd = static_cast<private_handle_t*>
(const_cast<native_handle_t*>(buffer->handle));
/* return true if layer is SECURE_DISPLAY */
return (hnd && (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_DISPLAY));
}
#endif
}
return false;
}
bool ExLayer::isYuvLayer() const {
const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
if(activeBuffer != 0) {
#ifdef QTI_BSP
ANativeWindowBuffer* buffer = activeBuffer->getNativeBuffer();
if(buffer) {
private_handle_t* hnd = static_cast<private_handle_t*>
(const_cast<native_handle_t*>(buffer->handle));
/* return true if layer is YUV */
return (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO));
}
#endif
}
return false;
}
void ExLayer::setPosition(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface& layer, const State& state) {
/* Set dest_rect to display width and height, if external_only flag
* for the layer is enabled or if its yuvLayer in extended mode.
*/
uint32_t w = hw->getWidth();
uint32_t h = hw->getHeight();
bool extendedMode = ExSurfaceFlinger::isExtendedMode();
if(isExtOnly()) {
/* Position: fullscreen for ext_only */
Rect r(0, 0, w, h);
layer.setFrame(r);
} else if(hw->getDisplayType() > 0 && (extendedMode && isYuvLayer())) {
/* Need to position the video full screen on external with aspect ratio */
Rect r = getAspectRatio(hw, state.active.w, state.active.h);
layer.setFrame(r);
}
return;
}
void ExLayer::setAcquiredFenceIfBlit(int &fenceFd,
HWComposer::HWCLayerInterface& layer) {
#ifdef QTI_BSP
if (layer.getCompositionType() == HWC_BLIT) {
sp<Fence> fence = mSurfaceFlingerConsumer->getCurrentFence();
if (fence->isValid()) {
fenceFd = fence->dup();
if (fenceFd == -1) {
ALOGW("%s: failed to dup layer fence, skipping sync: %d",
__FUNCTION__,errno);
}
}
}
#else
ALOGD_IF(isDebug(),"Not a BLIT Layer, compType = %d fencefd = %d",
layer.getCompositionType(), fenceFd);
#endif
}
bool ExLayer::canAllowGPUForProtected() const {
if(isProtected()) {
return mIsGPUAllowedForProtected;
} else {
return false;
}
}
}; // namespace android

View File

@ -0,0 +1,68 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_EX_LAYER_H
#define ANDROID_EX_LAYER_H
#include <stdint.h>
#include <sys/types.h>
#include <cutils/properties.h>
#include <Layer.h>
#include "ExSurfaceFlinger.h"
namespace android {
class ExSurfaceFlinger;
class ExLayer : public Layer
{
public:
ExLayer(SurfaceFlinger* flinger, const sp<Client>& client,
const String8& name, uint32_t w, uint32_t h, uint32_t flags);
virtual ~ExLayer();
virtual bool isExtOnly() const;
virtual bool isIntOnly() const;
virtual bool isSecureDisplay() const;
virtual bool isYuvLayer() const;
virtual void setPosition(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface& layer, const State& state);
virtual void setAcquiredFenceIfBlit(int &fenceFd,
HWComposer::HWCLayerInterface& layer);
virtual bool canAllowGPUForProtected() const;
protected:
bool mDebugLogs;
bool isDebug() { return mDebugLogs; }
bool mIsGPUAllowedForProtected;
};
}; // namespace android
#endif // ANDROID_EX_LAYER_H

View File

@ -0,0 +1,256 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ExSurfaceFlinger.h"
#include "ExLayer.h"
#include <cutils/properties.h>
#ifdef QTI_BSP
#include <hardware/display_defs.h>
#endif
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
namespace android {
bool ExSurfaceFlinger::sExtendedMode = false;
ExSurfaceFlinger::ExSurfaceFlinger() {
char property[PROPERTY_VALUE_MAX] = {0};
mDebugLogs = false;
if((property_get("persist.debug.qdframework.logs", property, NULL) > 0) &&
(!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
(!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
mDebugLogs = true;
}
ALOGD_IF(isDebug(),"Creating custom SurfaceFlinger %s",__FUNCTION__);
mDisableExtAnimation = false;
if((property_get("sys.disable_ext_animation", property, "0") > 0) &&
(!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
(!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
mDisableExtAnimation = true;
}
ALOGD_IF(isDebug(),"Animation on external is %s in %s",
mDisableExtAnimation ? "disabled" : "not disabled", __FUNCTION__);
}
ExSurfaceFlinger::~ExSurfaceFlinger() { }
void ExSurfaceFlinger::updateExtendedMode() {
char prop[PROPERTY_VALUE_MAX];
property_get("sys.extended_mode", prop, "0");
sExtendedMode = atoi(prop) ? true : false;
}
void ExSurfaceFlinger::getIndexLOI(size_t dpy,
const LayerVector& currentLayers,
bool& bIgnoreLayers,
int& indexLOI ) {
size_t i = currentLayers.size();
while(i--) {
const sp<Layer>& layer = currentLayers[i];
/* iterate through the layer list to find ext_only layers and store
* the index
*/
if (layer->isSecureDisplay()) {
bIgnoreLayers = true;
indexLOI = -1;
if(!dpy)
indexLOI = i;
break;
}
/* iterate through the layer list to find ext_only layers or yuv
* layer(extended_mode) and store the index
*/
if ((dpy && (layer->isExtOnly() ||
(isExtendedMode() && layer->isYuvLayer())))) {
bIgnoreLayers= true;
indexLOI = i;
}
}
return;
}
bool ExSurfaceFlinger::updateLayerVisibleNonTransparentRegion(
const int& dpy, const sp<Layer>& layer,
bool& bIgnoreLayers, int& indexLOI,
uint32_t layerStack, const int& i) {
const Layer::State& s(layer->getDrawingState());
/* Only add the layer marked as "external_only" or yuvLayer
* (extended_mode) to external list and
* only remove the layer marked as "external_only" or yuvLayer in
* extended_mode from primary list
* and do not add the layer marked as "internal_only" to external list
* Add secure UI layers to primary and remove other layers from internal
* and external list
*/
if(((bIgnoreLayers && indexLOI != (int)i) ||
(!dpy && layer->isExtOnly()) ||
(!dpy && isExtendedMode() && layer->isYuvLayer()))||
(dpy && layer->isIntOnly())) {
/* Ignore all other layers except the layers marked as ext_only
* by setting visible non transparent region empty
*/
Region visibleNonTransRegion;
visibleNonTransRegion.set(Rect(0,0));
layer->setVisibleNonTransparentRegion(visibleNonTransRegion);
return true;
}
/* only consider the layers on the given later stack
* Override layers created using presentation class by the layers having
* ext_only flag enabled
*/
if(s.layerStack != layerStack && !bIgnoreLayers) {
/* set the visible region as empty since we have removed the
* layerstack check in rebuildLayerStack() function
*/
Region visibleNonTransRegion;
visibleNonTransRegion.set(Rect(0,0));
layer->setVisibleNonTransparentRegion(visibleNonTransRegion);
return true;
}
return false;
}
void ExSurfaceFlinger::delayDPTransactionIfNeeded(
const Vector<DisplayState>& displays) {
/* Delay the display projection transaction by 50ms only when the disable
* external rotation animation feature is enabled
*/
if(mDisableExtAnimation) {
size_t count = displays.size();
for (size_t i=0 ; i<count ; i++) {
const DisplayState& s(displays[i]);
if((mDisplays.indexOfKey(s.token) >= 0) && (s.token !=
mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY])) {
const uint32_t what = s.what;
/* Invalidate and Delay the binder thread by 50 ms on
* eDisplayProjectionChanged to trigger a draw cycle so that
* it can fix one incorrect frame on the External, when we
* disable external animation
*/
if (what & DisplayState::eDisplayProjectionChanged) {
invalidateHwcGeometry();
repaintEverything();
usleep(50000);
}
}
}
}
}
bool ExSurfaceFlinger::canDrawLayerinScreenShot(
const sp<const DisplayDevice>& hw,
const sp<Layer>& layer) {
int dispType = hw->getDisplayType();
/* a) Don't draw SecureDisplayLayer or ProtectedLayer.
* b) Don't let ext_only and extended_mode to be captured
* If not, we would see incorrect image during rotation
* on primary.
*/
if(!layer->isSecureDisplay()
&& !layer->isProtected()
&& !(!dispType && (layer->isExtOnly() ||
(isExtendedMode() && layer->isYuvLayer())))
&& layer->isVisible() ){
return true;
}
return false;
}
void ExSurfaceFlinger::isfreezeSurfacePresent(bool& freezeSurfacePresent,
const sp<const DisplayDevice>& hw,
const int32_t& id) {
freezeSurfacePresent = false;
/* Get the layers in the current drawing state */
const LayerVector& layers(mDrawingState.layersSortedByZ);
const size_t layerCount = layers.size();
/* Look for ScreenShotSurface in external layer list, only when
* disable external rotation animation feature is enabled
*/
if(mDisableExtAnimation && (id != HWC_DISPLAY_PRIMARY)) {
for (size_t i = 0 ; i < layerCount ; ++i) {
static int screenShotLen = strlen("ScreenshotSurface");
const sp<Layer>& layer(layers[i]);
const Layer::State& s(layer->getDrawingState());
/* check the layers associated with external display */
if(s.layerStack == hw->getLayerStack()) {
if(!strncmp(layer->getName(), "ScreenshotSurface",
screenShotLen)) {
/* Screenshot layer is present, and animation in
* progress
*/
freezeSurfacePresent = true;
break;
}
}
}
}
}
void ExSurfaceFlinger::setOrientationEventControl(bool& freezeSurfacePresent,
const int32_t& id) {
HWComposer& hwc(getHwComposer());
HWComposer::LayerListIterator cur = hwc.begin(id);
if(freezeSurfacePresent) {
/* If freezeSurfacePresent, set ANIMATING flag
* which is used to support disable animation on external
*/
cur->setAnimating(true);
}
}
void ExSurfaceFlinger::updateVisibleRegionsDirty() {
/* If extended_mode is set, and set mVisibleRegionsDirty
* as we need to rebuildLayerStack
*/
if(isExtendedMode()) {
mVisibleRegionsDirty = true;
}
}
void ExSurfaceFlinger::drawWormHoleIfRequired(HWComposer::LayerListIterator& cur,
const HWComposer::LayerListIterator& end,
const sp<const DisplayDevice>& hw,
const Region& region) {
if (cur != end) {
#ifdef QTI_BSP
if (cur->getCompositionType() != HWC_BLIT)
drawWormhole(hw, region);
#endif
} else {
drawWormhole(hw, region);
}
}
}; // namespace android

View File

@ -0,0 +1,86 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_EX_SURFACE_FLINGER_H
#define ANDROID_EX_SURFACE_FLINGER_H
#include "SurfaceFlinger.h"
namespace android {
class ExSurfaceFlinger : public SurfaceFlinger
{
public:
ExSurfaceFlinger();
protected:
friend class ExLayer;
virtual void updateExtendedMode();
virtual void getIndexLOI(size_t dpy,
const LayerVector& currentLayers,
bool& bIgnoreLayers,
int& indexLOI);
virtual bool updateLayerVisibleNonTransparentRegion(
const int& dpy, const sp<Layer>& layer,
bool& bIgnoreLayers, int& indexLOI,
uint32_t layerStack, const int& i);
virtual void delayDPTransactionIfNeeded(
const Vector<DisplayState>& displays);
virtual bool canDrawLayerinScreenShot(
const sp<const DisplayDevice>& hw,
const sp<Layer>& layer);
virtual void isfreezeSurfacePresent(
bool& freezeSurfacePresent,
const sp<const DisplayDevice>& hw,
const int32_t& id);
virtual void setOrientationEventControl(
bool& freezeSurfacePresent,
const int32_t& id);
virtual void updateVisibleRegionsDirty();
virtual void drawWormHoleIfRequired(HWComposer::LayerListIterator& /*cur*/,
const HWComposer::LayerListIterator& /*end*/,
const sp<const DisplayDevice>& hw,
const Region& region);
virtual ~ExSurfaceFlinger();
/* Extended Mode
* No video on primary but video will be shown full
* screen on External
*/
static bool sExtendedMode;
static bool isExtendedMode() { return sExtendedMode; }
bool mDebugLogs;
bool isDebug() { return mDebugLogs; }
bool mDisableExtAnimation;
};
}; //namespace android
#endif //ANDROID_EX_SURFACE_FLINGER_H

View File

@ -0,0 +1,93 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ExVirtualDisplaySurface.h"
#ifdef QTI_BSP
#include <gralloc_priv.h>
#endif
namespace android {
#define VDS_LOGE(msg, ...) ALOGE("[%s] " msg, \
mDisplayName.string(), ##__VA_ARGS__)
#define VDS_LOGW_IF(cond, msg, ...) ALOGW_IF(cond, "[%s] " msg, \
mDisplayName.string(), ##__VA_ARGS__)
#define VDS_LOGV(msg, ...) ALOGV("[%s] " msg, \
mDisplayName.string(), ##__VA_ARGS__)
ExVirtualDisplaySurface::ExVirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
const sp<IGraphicBufferProducer>& sink,
const sp<IGraphicBufferProducer>& bqProducer,
const sp<IGraphicBufferConsumer>& bqConsumer,
const String8& name,
bool secure)
: VirtualDisplaySurface(hwc, dispId, sink, bqProducer, bqConsumer, name),
mSecure(secure) {
sink->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS, &mSinkUsage);
mSinkUsage |= GRALLOC_USAGE_HW_COMPOSER;
setOutputUsage(mSinkUsage);
}
status_t ExVirtualDisplaySurface::beginFrame(bool mustRecompose) {
if (mDisplayId < 0)
return NO_ERROR;
mMustRecompose = mustRecompose;
/* For WFD use cases we must always set the recompose flag in order
* to support pause/resume functionality
*/
if (mOutputUsage & GRALLOC_USAGE_HW_VIDEO_ENCODER) {
mMustRecompose = true;
}
VDS_LOGW_IF(mDbgState != DBG_STATE_IDLE,
"Unexpected beginFrame() in %s state", dbgStateStr());
mDbgState = DBG_STATE_BEGUN;
return refreshOutputBuffer();
}
/* Helper to update the output usage when the display is secure */
void ExVirtualDisplaySurface::setOutputUsage(uint32_t /*flag*/) {
mOutputUsage = mSinkUsage;
if (mSecure && (mOutputUsage & GRALLOC_USAGE_HW_VIDEO_ENCODER)) {
/* TODO: Currently, the framework can only say whether the display
* and its subsequent session are secure or not. However, there is
* no mechanism to distinguish the different levels of security.
* The current solution assumes WV L3 protection.
*/
mOutputUsage |= GRALLOC_USAGE_PROTECTED;
#ifdef QTI_BSP
mOutputUsage |= GRALLOC_USAGE_PRIVATE_MM_HEAP |
GRALLOC_USAGE_PRIVATE_UNCACHED;
#endif
}
}
}; // namespace android

View File

@ -0,0 +1,55 @@
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_EX_VIRTUAL_DISPLAY_SURFACE_H
#define ANDROID_EX_VIRTUAL_DISPLAY_SURFACE_H
#include <DisplayHardware/VirtualDisplaySurface.h>
namespace android {
class ExVirtualDisplaySurface : public VirtualDisplaySurface {
public:
ExVirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
const sp<IGraphicBufferProducer>& sink,
const sp<IGraphicBufferProducer>& bqProducer,
const sp<IGraphicBufferConsumer>& bqConsumer,
const String8& name,
bool secure);
private:
virtual status_t beginFrame(bool mustRecompose);
virtual void setOutputUsage(uint32_t flag);
bool mSecure;
int mSinkUsage;
};
}; // namespace android
#endif // ANDROID_EX_VIRTUAL_DISPLAY_SURFACE_H