Skip to content

Commit 2d77b53

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge changes I97807db6,I7d350bc0
* changes: workaround for an issue where the screen would flicker sometimes fix an issue in SF where we could miss some updates
2 parents edb948b + 6ea851f commit 2d77b53

File tree

3 files changed

+34
-31
lines changed

3 files changed

+34
-31
lines changed

services/surfaceflinger/Layer.cpp

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
#define DEBUG_RESIZE 0
4444

45-
4645
namespace android {
4746

4847
// ---------------------------------------------------------------------------
@@ -55,7 +54,7 @@ Layer::Layer(SurfaceFlinger* flinger,
5554
mCurrentTransform(0),
5655
mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
5756
mCurrentOpacity(true),
58-
mRefreshPending(0),
57+
mRefreshPending(false),
5958
mFrameLatencyNeeded(false),
6059
mFrameLatencyOffset(0),
6160
mFormat(PIXEL_FORMAT_NONE),
@@ -408,15 +407,9 @@ bool Layer::isCropped() const {
408407
// pageflip handling...
409408
// ----------------------------------------------------------------------------
410409

411-
bool Layer::onPreComposition()
412-
{
413-
// if there was more than one pending update, request a refresh
414-
if (mRefreshPending >= 2) {
415-
mRefreshPending = 0;
416-
return true;
417-
}
418-
mRefreshPending = 0;
419-
return false;
410+
bool Layer::onPreComposition() {
411+
mRefreshPending = false;
412+
return mQueuedFrames > 0;
420413
}
421414

422415
void Layer::lockPageFlip(bool& recomputeVisibleRegions)
@@ -428,9 +421,11 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
428421
// because we cannot call updateTeximage() without a corresponding
429422
// compositionComplete() call.
430423
// we'll trigger an update in onPreComposition().
431-
if (mRefreshPending++) {
424+
if (mRefreshPending) {
425+
mPostedDirtyRegion.clear();
432426
return;
433427
}
428+
mRefreshPending = true;
434429

435430
// Capture the old state of the layer for comparisons later
436431
const bool oldOpacity = isOpaque();
@@ -541,25 +536,23 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
541536
void Layer::unlockPageFlip(
542537
const Transform& planeTransform, Region& outDirtyRegion)
543538
{
544-
if (mRefreshPending >= 2) {
545-
return;
546-
}
547-
548-
Region dirtyRegion(mPostedDirtyRegion);
549-
if (!dirtyRegion.isEmpty()) {
539+
Region postedRegion(mPostedDirtyRegion);
540+
if (!postedRegion.isEmpty()) {
550541
mPostedDirtyRegion.clear();
551-
// The dirty region is given in the layer's coordinate space
552-
// transform the dirty region by the surface's transformation
553-
// and the global transformation.
554-
const Layer::State& s(drawingState());
555-
const Transform tr(planeTransform * s.transform);
556-
dirtyRegion = tr.transform(dirtyRegion);
557-
558-
// At this point, the dirty region is in screen space.
559-
// Make sure it's constrained by the visible region (which
560-
// is in screen space as well).
561-
dirtyRegion.andSelf(visibleRegionScreen);
562-
outDirtyRegion.orSelf(dirtyRegion);
542+
if (!visibleRegionScreen.isEmpty()) {
543+
// The dirty region is given in the layer's coordinate space
544+
// transform the dirty region by the surface's transformation
545+
// and the global transformation.
546+
const Layer::State& s(drawingState());
547+
const Transform tr(planeTransform * s.transform);
548+
postedRegion = tr.transform(postedRegion);
549+
550+
// At this point, the dirty region is in screen space.
551+
// Make sure it's constrained by the visible region (which
552+
// is in screen space as well).
553+
postedRegion.andSelf(visibleRegionScreen);
554+
outDirtyRegion.orSelf(postedRegion);
555+
}
563556
}
564557
}
565558

services/surfaceflinger/Layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Layer : public LayerBaseClient
116116
uint32_t mCurrentTransform;
117117
uint32_t mCurrentScalingMode;
118118
bool mCurrentOpacity;
119-
size_t mRefreshPending;
119+
bool mRefreshPending;
120120
bool mFrameLatencyNeeded;
121121
int mFrameLatencyOffset;
122122

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,12 @@ void SurfaceFlinger::composeSurfaces(const Region& dirty)
10001000
drawWormhole();
10011001
}
10021002

1003+
// FIXME: workaroud for b/6020860
1004+
glEnable(GL_SCISSOR_TEST);
1005+
glScissor(0,0,0,0);
1006+
glClear(GL_COLOR_BUFFER_BIT);
1007+
// end-workaround
1008+
10031009
/*
10041010
* and then, render the layers targeted at the framebuffer
10051011
*/
@@ -1776,6 +1782,10 @@ status_t SurfaceFlinger::onTransact(
17761782
setTransactionFlags(eTransactionNeeded|eTraversalNeeded);
17771783
return NO_ERROR;
17781784
}
1785+
case 1006:{ // send empty update
1786+
signalRefresh();
1787+
return NO_ERROR;
1788+
}
17791789
case 1008: // toggle use of hw composer
17801790
n = data.readInt32();
17811791
mDebugDisableHWC = n ? 1 : 0;

0 commit comments

Comments
 (0)