Skip to content

Commit

Permalink
sf: Validate display device id and disable dirtyrect composition
Browse files Browse the repository at this point in the history
1. Add validation check for display device id to prevent out of bound
   array access.
2. Disable Dirty rect composition feature for GPU by default

Change-Id: I4976468bb156fff197c8c38fe680e10512b4feb5
  • Loading branch information
Ramkumar Radhakrishnan authored and hyperb1iss committed Jun 30, 2014
1 parent 3305392 commit 5fb19b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion services/surfaceflinger/DisplayHardware/HWComposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,8 @@ HWComposer::DisplayData::~DisplayData() {
#ifdef QCOM_BSP
//======================== GPU TiledRect/DR changes =====================
bool HWComposer::areVisibleRegionsOverlapping(int32_t id ) {
if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
return false;
const Vector< sp<Layer> >& currentLayers =
mFlinger->getLayerSortedByZForHwcDisplay(id);
size_t count = currentLayers.size();
Expand All @@ -1550,6 +1552,8 @@ bool HWComposer::areVisibleRegionsOverlapping(int32_t id ) {
}

bool HWComposer::needsScaling(int32_t id) {
if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
return false;
DisplayData& disp(mDisplayData[id]);
for (size_t i=0; i<disp.list->numHwLayers-1; i++) {
int dst_w, dst_h, src_w, src_h;
Expand All @@ -1575,6 +1579,8 @@ bool HWComposer::needsScaling(int32_t id) {
}

void HWComposer::computeUnionDirtyRect(int32_t id, Rect& unionDirtyRect) {
if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
return;
const Vector< sp<Layer> >& currentLayers =
mFlinger->getLayerSortedByZForHwcDisplay(id);
size_t count = currentLayers.size();
Expand Down Expand Up @@ -1607,6 +1613,8 @@ void HWComposer::computeUnionDirtyRect(int32_t id, Rect& unionDirtyRect) {
}

bool HWComposer::isGeometryChanged(int32_t id) {
if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
return false;
DisplayData& disp(mDisplayData[id]);
return ( disp.list->flags & HWC_GEOMETRY_CHANGED );
}
Expand All @@ -1615,8 +1623,10 @@ bool HWComposer::isGeometryChanged(int32_t id) {
* 2. if overlapping visible regions present.
* 3. Compute a Union Dirty Rect to operate on. */
bool HWComposer::canUseTiledDR(int32_t id, Rect& unionDr ){
bool status = true;
if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
return false;

bool status = true;
if (isGeometryChanged(id)) {
ALOGD_IF(GPUTILERECT_DEBUG, "GPUTileRect : geometrychanged, disable");
status = false;
Expand Down
2 changes: 1 addition & 1 deletion services/surfaceflinger/SurfaceFlinger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ SurfaceFlinger::SurfaceFlinger()
}
}
#ifdef QCOM_BSP
property_get("debug.sf.gpu_comp_tiling", value, "1");
property_get("debug.sf.gpu_comp_tiling", value, "0");
mGpuTileRenderEnable = atoi(value) ? true : false;
if(mGpuTileRenderEnable)
ALOGV("DirtyRect optimization enabled for FULL GPU Composition");
Expand Down

0 comments on commit 5fb19b1

Please sign in to comment.