History log of /frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
b583b3bb0195e964e46e3879ddce09bde8ec7db5 06-Jun-2018 Chia-I Wu <olv@google.com> Merge "surfaceflinger: force client composition for Y410" into pi-dev
07376a98a6c66c4e48bdebe82616f0ae47e5f805 06-Jun-2018 Chia-I Wu <olv@google.com> surfaceflinger: force client composition for Y410

When the pixel format is Y410 masquerading as RGBA_1010102, always
force client composition.

Bug: 80509363
Test: no effect on Pixel devices
Change-Id: I31996eeda1559b0557a5acb53d593fd4f395ccaf
Merged-In: I31996eeda1559b0557a5acb53d593fd4f395ccaf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3c6b7efc5204eab5701d5ab2f0ff87763cc322fa 05-Jun-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Respect HDR data space.

Respect HDR data space when there is no legacy HDR support. Previously we only
cared about HDR data space when it is supported, however, on Pixel 2 there is
no HDR mode support. This patch makes sure that when HDR mode is not supported,
we fall back to Display P3 color mode correctly.

BUG: 80404330
Test: Build, flash and watch Youtube HDR
Change-Id: I7d27711fe4d33268e5ebbd14fce0975f9e642e84
Merged-In: I7d27711fe4d33268e5ebbd14fce0975f9e642e84
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
70522fe55cdba436e3f8db2b8b049c9a8b02fe3c 01-Jun-2018 Jorim Jaggi <jjaggi@google.com> Merge "Push existing pending state when deferring transaction" into pi-dev
664ff4f0169970479fda925a032e1d9538409a12 31-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Keep early vsync-offsets for at least two frames after transaction" into pi-dev
dba3273a27fb90f19a73abe7142790ad21387484 28-May-2018 Jorim Jaggi <jjaggi@google.com> Push existing pending state when deferring transaction

Otherwise the information from another transaction that happened
before deferring the transaction could have been deferred as well.
To fix that, we push the currently pending state if the
transaction is deferred.

Furthermore, we need to modify the behavior how flags are applied.
Imagine the following sequence of events
- Surface is hidden flags=hidden
- t1 doesn't modify the flags (0/0) but sets some other properties.
flags=hidden mask=0. mCurrentState gets pushed onto mPendingState
before t2 sets (0/hidden) (flags/mask) flags=0 mask=hidden, to
show the surface. Furthemore, we defer this transaction.
mCurrentState gets pushed onto mPendingState.
- At this point, mCurrentState.flags = 0 (shown), but
mDrawingState.flags = hidden
- doTransaction happens. c (the state to promote to drawing state)
= mCurrentState => c.flags = 0 (shown)
Since t1 isn't deferred, the 0th element of mPendingState gets
popped and applied to c. Since mask=0, c.flags = 0 still.
- c gets promoted to mDrawingState and BOOM the
surface was shown even though the barrier of the transaction
showing hasn't opened yet.

Looking closer at the logic it makes sense to just apply the mask
when modifying the current state, and then just pushing it like
all other attributes.

Test: go/wm-smoke
Bug: 78611607
Change-Id: Ia100532189ef7f59f8939c59db9b6292b41e8e77
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c4b08bde2aaa455a7f789eb2858863d19563b949 29-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: RenderIntent::COLORIMETRIC is no longer mandatory

RenderIntent::COLORIMETRIC is mandatory only for SDR color modes.
For HDR color modes, RenderIntent::TONE_MAP_COLORIMETRIC is
mandatory.

Bug: 80030364
Test: HDR videos
Change-Id: I70d96ac66d069218d789dded330169284a61bde1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9053521815dc4cbe3d2ab21096e05d33386dd5da 23-May-2018 Jorim Jaggi <jjaggi@google.com> Keep early vsync-offsets for at least two frames after transaction

Imagine the following sequence, in which vsync-sf is usually 4ms
behind vsync-app.
- Vsync-app fires. The app sends a transaction with early wakeup.
- Vsync-sf fires immediately after early wakeup is received,
before the regular 4ms delay.
- Vsync-sf resets itself to vsync-app+4ms as the transaction was
handled.
- Repeat 1, but now the app was a bit delayed and sends the early
wakeup late, such that the time used to do GL comp isn't enough to
avoid jank.

To fix this, we apply a low pass filter for transaction-caused
early wake and keep it early for at least 2 frames.

Test: Open/close apps, inspect systraces and verify wake-up times
Bug: 78611607
Change-Id: I74b0d88a4d95ca5b6d24950e14e3d6a9379f2714
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2c5f734f9778c9e80f1909f448b72807a006b3a5 24-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Need GSI to support landscape LCM" into pi-dev
7501ed66a05f530062925011d1342e8651216051 30-Apr-2018 Iris Chang <iris.chang@mediatek.com> Need GSI to support landscape LCM

When device uses landscape LCM, the nature of the screen shows that
the device is a portrait device. After we flash with GSI, there is
vendor solution for landscape LCM used at portrait device. As the
result, the screen displays landscape layout and orientation while
device is at portrait orientation. In addition, the sensor coordinate
system mismatches with android coordinate system.

We suggest Google can add config to handle the case "portrait device
uses landscape LCM or landscape device uses portrait LCM".

Bug: 69691076

Test: We verified following test cases for this patch on Android O-MR1.
1. Make sure homescreen is normal
2. Rotate device and make sure screen is normal
3. Grab screen shot and check if screen shot is normal
4. Connect to Wi-Fi display and make sure WFD screen is normal
Test: Tested 1, 2 and 3 on Pixel 2.

Test: artifially setup 90 degree rotation on Pixel and make sure that
screenshots are aligned to the screen.

Change-Id: Ib42c9a216e8a6fe465139d6eece152fb1765b422
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0d711268fe57b73a38ec3590b6e67f03ff789fa1 22-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: allow unknown render intents

Allow render intents that are unknown to SurfaceFlinger.

Bug: 79843697
Bug: 75981986
Test: manual
Change-Id: Ia81436747b1d2fe9f44e749b93a9c1a5a7f1f6cb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bbb44464990d0becd1c5eef77f85da82b8008534 22-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: display color setting is a hint

Display color setting is merely a hint. Check the active render
intent before applying the legacy sRGB color matrix.

Bug: 79843697
Test: manual
Change-Id: I73b45cbf2274a56037ce0439470f1baafffa8914
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0607fbe8956a64151b165ac88ef9f3cf9b4ece5d 18-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: compute color mode mappings on hotplug

Populuate DisplayDevice::mColorModes when a DisplayDevice is
created.

DisplayDevice::mColorModes is a map from any possible
Dataspace/RenderIntent to supported
Dataspace/ColorMode/RenderIntent. This makes sure we never ask the
composer to use an unsupported Dataspace/ColorMode/RenderIntent
combination.

The map is populated on hotplug because we don't want to compute the
mapping on the fly at each frame.

Bug: 79843697
Bug: 75981986
Test: manual under sRGB, P3, HDR
Change-Id: I967d09b1e8d31ea631b202db1799a7a2a0c5ee3f
Merged-In: I967d09b1e8d31ea631b202db1799a7a2a0c5ee3f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1b6bafca6e5c4a71bc97f14be30e64541633bda7 22-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: layer dataspace is not a state

Like current crop or transform, layer dataspace is latched with the
buffer. It is not a layer state, and should take effect
immediately.

Bug: 80139629
Test: manual
Change-Id: I52342ca345f174e647550b45defa977484db95a1
Merged-In: I52342ca345f174e647550b45defa977484db95a1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3c085a07a84bc03aefb2c0caf24a1ae1a9f5f90c 10-May-2018 Lloyd Pique <lpique@google.com> SF: Initialize DisplayDevice with the active config index

This is a port of aosp/580542, with added unit test changes now that the
correct config is being set in the DisplayDevice.

Bug: 69807179
Test: atest libsurfaceflinger_unittest

Change-Id: I51c13678bc28c715fa116ad127478d4afa3d0349
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
858e30b7d79b0c22cffe307a9377699b1bdfc375 21-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes I6618561d,If9479cd9,I3e13894e into pi-dev

* changes:
SF: Test coverage for EventControlThread
SF: Test coverage for EventThread
SF: Test coverage for setPowerModeInternal
e1043320e8634fb100b5bc2cca4c5ac1f3e9f483 17-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: use layer drawing dataspace

Layer::getDataSpace returns the current (as opposed to drawing)
dataspace, which we almost never want and is racy. Remove the
helper and access the dataspace directly.

Bug: 79210409
Test: boots, Photos
Change-Id: Ifec7055cf0a1f2d84da7ad58e27be2c01082e6e9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
891f1c0c807f6ffe6e5f02f059c88f6869386ce4 17-May-2018 Yiwei Zhang <zzyiwei@google.com> Merge "SF: Fix IGBP list leak" into pi-dev
36574d99f78bb533db4eaeb35998bb96f2e69193 16-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: fix screenshot dataspace under WCG

Commit a252d8958 (Use GraphicBuffer instead of GBP for screenshots)
removed the ability to query the dataspace of the screenshots. WM
assumes they are sRGB anyway. Let's force screenshots to be in
sRGB.

Bug: 79547689
Test: no color shift during Photos rotation
Change-Id: If57cba1b5a50c4e1f9b305af39d9588b3dd1775d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
243b378f47552ab6916fc9b92557c0df0557fd98 16-May-2018 Yiwei Zhang <zzyiwei@google.com> SF: Fix IGBP list leak

This change fixed the IGBP list leak.

Bug: b/77602128
Test: open and close an app repeatedly and check the GraphicBufferProducers size in dumpsys SurfaceFlinger
Change-Id: I2dbf4ee2c20c4404bfb15bbc2ab89df5783d90a4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
24b0a485fb58afd16a42de6378c0b743d7aca58a 10-Mar-2018 Lloyd Pique <lpique@google.com> SF: Test coverage for EventThread

Add a unit test to cover EventThread.cpp

Test: atest libsurfaceflinger_unittest
Bug: 74827900
Change-Id: If9479cd9deedff836068cb53e7da2cb64041aea1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
76dd77a6f5298bf0e7cb89ec570ab1578e3947fb 10-May-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Add methods for setting legacy starution matrix.

This patch adds methods for setting legacy saturation matrix for legacy sRGB
content. Previously it was combined into the color transform matrix which was
applied right before applying OETF, however, we want to apply the legacy
staturation matrix right after applying EOTF.

BUG: 78891890
Test: build
Change-Id: I7709eab0857822e48c49237d6681f6e337b4d29e
Merged-In: I7709eab0857822e48c49237d6681f6e337b4d29e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d6fa4a70ba70393816176eda0b64e2b576ce6d6b 18-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Add BT2100_PQ and BT2100_HLG color mode.

When hardware composer has native HDR10/HLG support, SurfaceFlinger will always
pass the layer to hardware composer. When hardware composer doesn't have native
HDR10/HLG support, but has BT2100_PQ or BT2100_HLG color mode with render
intent, SurfaceFlinger will always set the color mode to BT2100_PQ and
BT2100_HLG respectively, and set the render intent to TONE_MAP_ENHANCE if
supported, or TONE_MAP_COLORIMETRIC. Otherwise, SurfaceFlinger will set the
color mode to Display P3 and simulate PQ/HLG in RenderEngine.

Since SurfaceFlinger now can simulate HLG support in Display P3 mode, when apps
query HDR capability from platform, we also return HLG support.

BUG: 73825729
Test: build, flash
Change-Id: I53696360f2b3d986aa9191ff42866e275ba4fd0b
Merged-In: I53696360f2b3d986aa9191ff42866e275ba4fd0b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
96b513cea0b0165852722bb7456579cfbb6c68b5 07-May-2018 Chia-I Wu <olv@google.com> Merge changes from topic "color-auto-legacy-srgb" into pi-dev

* changes:
surfaceflinger: no re-saturation when in SRGB mode
surfaceflinger: switch RE color matrices lazily
surfaceflinger: remove hwcId < 0 path in doComposeSurfaces
surfaceflinger: re-saturate all legacy dataspaces
621f9d47638c7a147c6513801eaeb0ed0fdcad30 07-May-2018 Yiwei Zhang <zzyiwei@google.com> SF TimeStats: fix missed frame logic

The current missed frames count is correct, but the decrement on the
total frames when mPropagateBackpressure is enabled is not right since
the missed frame won't count twice on SurfaceFlinger side. This change
fixed this logic error.

Test: dumpsys SurfaceFlinger --timestats <see go/sf-timestats for args>
Bug: b/70388650
Change-Id: I3bab221ad4b9f44da965084fd52da6c82523d1f4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7a28ecb9bdbc1697bdf08804e47a512291e0b878 04-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: no re-saturation when in SRGB mode

Under ColorMode::SRGB and RenderIntent::ENHANCE, HWC always applies
the legacy sRGB saturation matrix. SurfaceFlinger should not apply
the matrix.

Bug: 78891890
Test: no color shift when forcing GPU fallback
Change-Id: I7ebbefa38c5a6b72d326e0b2d4eee52d8409b5c7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8e50e696caf054c2f014162834916a8926a194c7 04-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: switch RE color matrices lazily

Client composition in doComposeSurfaces normally needs to handle

N sRGB layers, when in ColorMode::SRGB
N P3 layer and then M sRGB layers, when in ColorMode::DISPLAY_P3

Constantly switching and restoring RE color matrices when handling
sRGB layers is less efficient. Do the switches lazily.

We don't really care about the current RE color matrix when
doComposeSurfaces is called, and we already assume it to be
identity. Update RenderEngine::setupColorTransform not to return
the current color matrix.

Bug: 78891890
Test: night light under Boosted/Enhanced and sRGB/P3
Change-Id: I3b785c2a05f2e1679e486ab2497fc0e13993a791
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5e9a43e006a185fa43409c7fdb6c32d5bb786e70 03-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: remove hwcId < 0 path in doComposeSurfaces

Remove the check for hwcId and re-indent the code. hwcId is never
less than zero. Even if it did,
getCompositionType(DISPLAY_ID_INVALID) would return
HWC2::Composition::Client and it would still work.

The motivation is that the hwcId < 0 path has gone outdated since
the introduction of legacy sRGB saturation matrix.

Bug: 78891890
Test: virtual displays
Change-Id: I6f3e779bc0f8ef21d33ce7de49ddbfa95757e473
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1148147c4c06d9d5390c7b7c8b0ca5e0c245fc4a 04-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: re-saturate all legacy dataspaces

We changed HIDL interface to re-saturate any legacy dataspace.
Update SurfaceFlinger to match the behavior.

Bug: 78303195
Test: videos are re-saturated as well in GPU fallback
Change-Id: Idfa74783061a62d79ca5d9f38e50f4095ce38322
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
72128ee8d96161829babcec659128231f7067265 04-May-2018 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix color tranform matrix races" into pi-dev
28f320b443106f1656f9720224f579136dcf0c61 03-May-2018 Chia-I Wu <olv@google.com> surfaceflinger: fix color tranform matrix races

The color transform matrices may be updated by the binder threads
while being used by the main thread. Protect the matrices with
mStateLock, compute the effective matrix when the individual
matrices are updated, and copy the effective matrix to mDrawingState
during commitTransaction.

This commit fixes the race and moves the matrix computation out of
the hot path.

Bug: 79210409
Test: night light, color correction, boosted
Change-Id: Ibdb756b7b66345ffcef3c665652e20b050865f6d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0102ad2d522de255efabd50adf6c6a27811344f4 03-May-2018 Yiwei Zhang <zzyiwei@google.com> SurfaceFlinger TimeStats Metrics

Add timestats metrics for SurfaceFlinger. Keep track of global metrics
like total frames, missed frames, frames fellback to client
compositions, etc, as well as layer timing metrics like the delta
combination of postTime, desiredPresentTime, acqureTime, latchTime,
presentTime, etc. This metric is aimed at GMScore.

Test: dumpsys SurfaceFlinger --timestats [go/sf-timestats for more args]
Bug: b/70388650
Change-Id: I6e4545aef62f7893020533a4e7521541ea453ecd
Merged-In: I6e4545aef62f7893020533a4e7521541ea453ecd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fb069305e90947aeb76b72527f23aa24564f3c87 25-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Adapt min/max luminance from hardware composer.

The luminance capability of the display is very important to HDR content.
Previously, the minimum and maximum luminance were assumed as 0.0 and 500.0
respectively. This patch adapts the value returned from hardware composer and
plumbs the value to RenderEngine. If hardware composer doesn't return valid
values, 0.0 and 500.0 are still used as minimum and maximum luminance
respectively.

BUG: 73825729
BUG: 78574325
Test: Build, flash, watch video.
Change-Id: Ie1dc93f5cca7068580d6ae19da43346491196d7c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f59a719fe91b201ea0ef9447ae436457aa29a6d6 25-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Add HLG simulation support.

This patch adds GPU fallback configuration in SurfaceFlinger for HLG support,
as well as propagate HLG simulation up to frameworks.

BUG: 73825729
Test: build, flash
Change-Id: I58e52648817b326dee868949c3845f613fd218d6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2c327ac2840b34848543cc961d16d3dbad102f16 20-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Plumb getPerFrameMetadataKeys and setLayerPerFrameMetadata.

This patch compresses supported metdata types into a bitmask and stores it in
DisplayDevice and refactors the code in Hwc2::Layer regarding HdrMetadata. When
DisplayDevice is created, the ability of accepting metadata will be queried
from hardware composer and stored in DisplayDevice. Hwc2::Layer will construct
HdrMetadata to PerFrameMetadata when setPerFrameHdrMetadata is called if the
incoming meta data is changed.

Previously, setLayerPerFrameMetadata was named as setLayerHdrMetadata, but
since we move the responsibility of constructing PerFrameMetadata from
ComposerHal to Hwc2::Layer, we change the name to setLayerPerFrameMetadata,
which is more generic and matches the HIDL interface.

BUG: 77831156
Test: Build and flash
Change-Id: I447956f4dcf42c90ceb3d29091cd5034ad91061a
Merged-In: I447956f4dcf42c90ceb3d29091cd5034ad91061a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6266589793ddd9769a649a6b5f61ef115179572b 16-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Extend HDR support.

Previously we stored HDR10 support in DisplayDevice. This patch extends and
generalizes the support to HLG and Dolby Vision.

Minor: Adapt Hdr type from HAL.

BUG: 73825729
BUG: 77156734
Test: Build, flash, watch Youtube HDR
Change-Id: Id642bc9482523b4646814dca9ecfb1f043987dc5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
68f97b10524e1a3dc6e40e63454e0dbde4392795 13-Apr-2018 Jorim Jaggi <jjaggi@google.com> Merge "Fix transaction phase offsets" into pi-dev
052a61ebbe52b9ef398b5f74f6dc8c2f65671403 12-Apr-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SF: Fix repaint everything logic" into pi-dev
7ffee99c32c33cea23b265e81ba1beaa3f062d38 12-Apr-2018 Chavi Weingarten <chaviw@google.com> Merge "Set window to transparent when screenshotting layer." into pi-dev
50da5043ad224fd6b6024ed73785a9502bf7978d 09-Apr-2018 chaviw <chaviw@google.com> Set window to transparent when screenshotting layer.

Set the screenshot to transparent instead of black. This allows the
system to draw a color behind without having to crop out the area that
may not be drawn into.

Bug: 76442549
Test: When going to recents, area not drawn from layers is now
transparent instead of black.
Test: Transaction_test#CaptureTransparent

Change-Id: Id535eb753d3d1cae82658cd33423ce588aaa62f8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c7a25adf66b138de66814383540905b83cf12a01 12-Apr-2018 Dan Stoza <stoza@google.com> SF: Fix repaint everything logic

This solves the same problem with dirty regions not being updated
as Ia7a3dc15c96626a213c4459dac4f695d91540fb5, but it is better in a
couple of ways:

1) It no longer updates dirty regions from a binder thread, which was
likely causing the memory corruption in b/77919748.
2) It removes the distinction between repaintEverything and
repaintEverythingLocked, which is not necessary since both
operations in repaintEverything (updating an atomic and signaling a
transaction) are threadsafe.

Bug: 77335744
Bug: 77546473
Bug: 77919748
Test: Manual - on an ASAN build, played TouchLatency bouncy ball while
toggling between GL and HWC composition; doesn't crash whereas it
would crash in a matter of a couple minutes before

Change-Id: Iecadfecb40e87e400a301de2dcad1664e154982d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f15c3be1e8eab73da2dd3b2a7e6215302dae4314 12-Apr-2018 Jorim Jaggi <jjaggi@google.com> Fix transaction phase offsets

There are cases where we have multiple source of transactions
in one frame. In these cases, if a NORMAL gets submitted after an
EARLY, it will override the early one which will cause to use
the wrong phase offset for this frame.

In some cases an EARLY was then still scheduled before the frame
happened, so any kind of phase offset was observeable, which
looked like drifting.

Fix this by making sure an EARLY frame stays an EARLY frame.

Test: Open app. Ensure by looking really closely that vsync-sf is
happening at the supposed offset.
Bug: 75985430

Change-Id: I5dbf097d314767493b0f06b9eb6dd7c6b2f93919
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
38e9a56173c64a9640c6c390735a398d32752650 11-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Fix color mode switch.

Previously we didn't take render intent into account when switch color mode,
switching from staturated to automatic and then to natural/boosted doesn't
work.

BUG: 73824924
BUG: 73825729
Test: Built, flashed to taimen, and verified with Color settings.
Change-Id: I4556e82e2bab10113d05c446fc4bb3351a3e65a6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
dd9b2ae8500d85a6aba82de15e8b40d14a921ca6 02-Mar-2018 Peiyong Lin <lpy@google.com> [SurfaceFinger] Adds auto color mode support in SurfaceFlinger.

This patch adds auto color mode support in SurfaceFlinger. For Auto Awesome
Color milestone 1, we expect the hardware composer is capable of handling P3
layers, meaning if the hardware composer is given P3 layers, it will strech the
color from Display P3 to the pannel native color space. Hardware composer may
punt sRGB layers back to SurfaceFlinger, in this case, we fall back to
RenderEngine. We will set the destination data space to Display P3 when the
layers are mixed color spaces, and set the destination data space as SRGB if
they are all SRGB layers.

BUG: 73824924
BUG: 73825729
Test: Build
Change-Id: I577841b14de0cfe8c29f8aa30bee8621c5d72976
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2713c30843816d3511b39b85a2c268a2b7682047 29-Mar-2018 Dan Stoza <stoza@google.com> Early wake-up for transitions (1/2)

On some devices it's very likely that we fall into GL comp during
app transitions. However, SF offsets are chosen in a way such that
the time to finish a frame is just too tight to be completely jank
free when hitting GL composition in SurfaceFlinger. Thus, we
introduce the concept of a separate early offset, and wakeup
SurfaceFlinger at that time if we think that hitting GL comp is
likely, or we already hit GL comp in the last frame.

Test: Open app, check vsync offsets in systrace
Test: Open many dialogs/apps to fall into GPU comp.
Bug: 75985430
Change-Id: Ie17e30c4575359fa11bb8912f68dcafe3e569ddb
Merged-In: Ie17e30c4575359fa11bb8912f68dcafe3e569ddb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0e7a791d51e92aafefd416044a2d38b6eec22a00 05-Apr-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Plumb HAL to hardware composer.

Previously we introduced HIDL interfaces for Auto Color support. This patch
implements HAL interfaces in DisplayHardware/.

BUG: 73824924
BUG: 73825729
Test: Build
Change-Id: I4f2011bfa9306552d50a88fe0f065932be3efd0c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6b50255645fe338671011f6e3ced02afb26f5b24 04-Apr-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Update dirty regions when requested to repaint everything" into pi-dev
a9dcf11831380f2b9f310ceb9a72f2bf953d25e1 03-Apr-2018 Jeffrey Kardatzke <jkardatzke@google.com> Update dirty regions when requested to repaint everything

This is a merge from: ag/3827114

The issue was when an HWC implementation was requesting a composer
refresh, it wouldn't actually mark the areas as dirty so the
mustRecompose flag wasn't getting sent when a virtual display was doing
the redraw. That then prevented the changes from its output buffer from
propagating through to the consumer of that surface.

Bug: 77335744
Bug: 77546473
Test: Manually verified refreshes propagate through
Change-Id: Ia7a3dc15c96626a213c4459dac4f695d91540fb5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
36a1fe93c530055a9b25519c9182c20e2eb6e532 03-Apr-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SF: Clean up updateTransformHint() processing." into pi-dev
34beb7a0ff0494b0c5ad81104171f8a49e599163 28-Mar-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Replace android_dataspace with Dataspace.

This patch replaces all android_dataspace in SurfaceFlinger with Dataspace
V1.1. 3 commands in sequence are used to do the conversion:

find ./ -type f -exec sed -i -e 's/android_dataspace_t/Dataspace/g' {} \;
find ./ -type f -exec sed -i -e 's/android_dataspace/Dataspace/g' {} \;
find ./ -type f -exec sed -i -e 's/HAL_DATASPACE_/Dataspace::/g' {} \;

With some minor tweak because most of the APIs in frameworks/native are still
accepting android_dataspace/android_dataspace_t.

Next step is to convert the rest of android_dataspace usage to Dataspace in
frameworks/native as well as frameworks/base.

BUG: 77156734
Test: Build and flash
Change-Id: I2304c7014cb49a1c9f67c4563603fb55e8dbd679
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7c64f17bd0d70aec63b475c3de850dcf3abaff33 07-Mar-2018 Yiwei Zhang <zzyiwei@google.com> Implement Display Layer Stats V0.1

Try to collect data for analyzing how many display controller layers we
need and what we use them for. This change will collect additional data
from per frame point of view.

Test: adb shell dumpsys SurfaceFlinger --enable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --disable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --clear-layer-stats
Test: adb shell dumpsys SurfaceFlinger --dump-layer-stats
Bug: b/75953772
Change-Id: Ib48777df7e1fed637be7eb1aefbdf1808d1daccd
Merged-In: Ib48777df7e1fed637be7eb1aefbdf1808d1daccd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
068e31b929b40a1bc9be742c04cbdf5b04f3ce97 21-Feb-2018 Yiwei Zhang <zzyiwei@google.com> Implement Display Layer Stats

Try to collect data for analyzing how many display controller layers we
need and what we use them for. Also part of a bug fixing for potential
memory leak of existing layer tracing work of winscope.

Test: adb shell dumpsys SurfaceFlinger --enable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --disable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --clear-layer-stats
Test: adb shell dumpsys SurfaceFlinger --dump-layer-stats
Bug: b/73668062
Change-Id: Ie08aa85d34db2c2c767b8e27eb5aad6f7c3fb975
Merged-In: Ie08aa85d34db2c2c767b8e27eb5aad6f7c3fb975
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
36d8ba87141022784b4f1dede894bfd039d14f8e 30-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "surfaceflinger: minor dumpsys improvements" into pi-dev
fd997e0969100418b4df8b8d97d21d497afa76c3 29-Mar-2018 Peiyong Lin <lpy@google.com> Add proper namespace to GraphicTypes.

Renamed GraphicsTypes.h to GraphicTypes.h and added proper namespace to avoid
naming conflict.

BUG: 77156734
Test: Build and flash
Change-Id: Ibd9f454b5b72d5f8c6d94a3869a60a1bf821f106
Merged-In: Ibd9f454b5b72d5f8c6d94a3869a60a1bf821f106
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d432a7c40dfa6c5498038ec652db54478df966c1 24-Mar-2018 Lloyd Pique <lpique@google.com> SF: Clean up updateTransformHint() processing.

While working on ag/3368935, an unintentional duplicate call was added
to Layer::updateTransform() from
SurfaceFlinger::handleTransactionLocked(). This patch removes the
duplicate call.

In examining the code, the update conditions also did not appear to be
set correctly. They have been adjusted so that a display change or a
significant layer change (such as a layer being added) will result in an
update.

Bug: 76223411
Test: No immediate issues observed on a Pixel XL.

Change-Id: I59220837b22ae1f76d7d9d376c1ebd24d8d14105
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1e04361db1b65d3998edbf820078ccfaed477cb6 01-Mar-2018 Chia-I Wu <olv@google.com> surfaceflinger: minor dumpsys improvements

In the order of importance,

- fix eglGetConfigAttrib calls
- mark Zs as relative in minidump
- dump DisplayDevice wide color states
- rename pixelformat to defaultPixelFormat in layer state
- better grouping and indentation for DisplayDevice dump

Bug: 76415976
Test: dumpsys
Change-Id: If9254ffe43cb1de82d562fcc27e828d54eba9387
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2252bdbb9bd77ba4203836cc955932a4f1649147 28-Mar-2018 Alice Sheng <alicesheng@google.com> Merge "Add log for when a display mode change finishes." into pi-dev
05ee4c93fb050fc17b61396ab9ec17bfd7e122b4 28-Mar-2018 Alice Sheng <alicesheng@google.com> Add log for when a display mode change finishes.

Adds logging when surfaceflinger finishes changing display mode at the end of
setPowerMode, which is useful to measure wakeup latency.

Bug: 77151769
Change-Id: I0930c4ea1f5e7872a2e3d47031da7933fe1ab5de
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2afd5172c3e6bd99a287d24a1dd5fe5c7b70754e 28-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes Icf7cf2fd,I325521b7,Ia80c865d,I73599f62,I8526e671, ... into pi-dev

* changes:
SF: Use display device factory in unit test
SF: Introduce mock::NativeWindowSurface
SF: Refactor display device creation
SF: Introduce mock::NativeWindow
SF: Introduce mock::DisplaySurface
SF: Introduce mock::EventControlThread
SF: Separate EventControlThread into interface and impl
SF: Define mock::SurfaceInterceptor
SF: Separate SurfaceInterceptor into interface and impl
SF: Define mock::MessageQueue
SF: Separate MessageQueue into interface and impl
SF: libsurfaceflinger_unittest should skip SF ctor
SF: Switch to internal display setup
0c2de3681db029180ed13b02f090bfa1636bae1c 27-Mar-2018 Rob Carr <racarr@google.com> Merge "SurfaceFlinger: Fix reparenting following ReparentForDrawing" into pi-dev
0959483fe3a2e4f70c91d4a0579ddbe03c9d3262 23-Jan-2018 Lloyd Pique <lpique@google.com> SF: Refactor display device creation

Move display device creation to its own function which handles all
initialization before creating a DisplayDevice instance, which now just
simply constructs an instance from the passed values.

Also introduces a factory to abstract creating libgui Surface instances,
so that can be replaced by the test.

Test: Builds
Bug: 74827900
Change-Id: Ia80c865dc96b300033c506cc3093e563bcab787b
(cherry picked from commit 99d3da56143c24c99ba73b830c9e16a6f9814770)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0c3a88319136a8ce0e7050ef5695610a986ce900 23-Jan-2018 Lloyd Pique <lpique@google.com> SF: Separate EventControlThread into interface and impl

Test: Builds
Bug: 74827900
Change-Id: Ib79503860bf9409cc71d98e2e845ffaff114fbb1
(cherry picked from commit 379adc10ebe94eec8c7754d262c6184fbfb3f0a3)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4d2348551e73b4990aedc83db17a336b533316e6 23-Jan-2018 Lloyd Pique <lpique@google.com> SF: Separate SurfaceInterceptor into interface and impl

SurfaceInterceptor is now an abstract interface.
impl::SurfaceInterceptor is the normal implementation.

This allows unit tests to replace it with a GMock.

Test: Builds
Bug: 74827900
Change-Id: I4d5bb2649b0c7a8ec1e6c0abf01ab53174d06a19
(cherry picked from commit 4dccc413ddf822ca6f1856fd2d8ab80185203eed)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9123ae5f9da83f1d0efd2260c5ecd84f66a11fb7 23-Jan-2018 Lloyd Pique <lpique@google.com> SF: Separate MessageQueue into interface and impl

Test: Builds
Bug: 74827900
Change-Id: I906892c00b6cb9adca3fbdd72a03001c2d72cbfc
(cherry picked from commit 3fcdef18f41330b4f1e3f1e2b9a33c544e8803b0)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2d3ee6dda3547b08b0de3373da5b6b2edb223fa9 17-Jan-2018 Lloyd Pique <lpique@google.com> SF: libsurfaceflinger_unittest should skip SF ctor

This reduces the cost of constructing a SurfaceFlinger instance for each
test, but it means the tests must take care to set up all internal state
that is needed for each test.

[Test execution time reduced from 6.1 to 3.1ms]

Test: libsurfaceflinger_unittest passes on Pixel XL
Bug: 74827900
Change-Id: I7eed4fd274cae521fe0f22b655cf3343cee66342
(cherry picked from commit ac648ee7ead13b4c23fb0d12e00b7f15f844f04f)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ccd348460ca25890a8fb709e82e6f780e3ce878e 14-Mar-2018 rongliu <rongliu@google.com> Pass correct window type and app id to hw composer.

1. Set -1 as default value for window type and app id.
2. When send layer information to hal, layers inherit type and app id from parent node when
parent node has valid type/appId.
3. Add window type and app id to SurfaceFlinger dumpsys.

Bug: 74622357
Test: Manual test. Several things verified:
1. Android settings layer, status bar layer, nav bar layer have valid window type and appId
when start android settings.
2. Layers without buffer have window type -1 and app id -1.
3. When send layers to hal, Chrome SurfaceView layer inherit type and app id from
its parent (MainActivity layer).

Change-Id: I8d6ad274ca18b61d1bbf6b28f7def5160b55b1e7
Merged-In: I8d6ad274ca18b61d1bbf6b28f7def5160b55b1e7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2e971a918ce1f6ea51fe0c504766c77fd18a8676 24-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Use unique_ptr for proto parser to handle destruction." into pi-dev
7794ec15e59fd6dd389ba05379ff81287c6ab52f 14-Mar-2018 chaviw <chaviw@google.com> Use unique_ptr for proto parser to handle destruction.

There's a memory leak where Layers created for the proto tree are not
removed when no longer used. This ensures that there's a unique_ptr for
each parser layer created so it will be automatically destroyed when
out of scope.

Merged-In: I56731d28a39e7d9d157c59065102d97f316f3b7d

Change-Id: I56731d28a39e7d9d157c59065102d97f316f3b7d
Fixes: 74071380
Test: adb shell dumpsys SurfaceFlinger
Test: LayerProtoStress.mem_info no longer shows increased memory
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
15eae09ebb293135dedce203bcb542a2e6e8d43a 23-Mar-2018 Robert Carr <racarr@google.com> SurfaceFlinger: Fix reparenting following ReparentForDrawing

Counterintuitively, the new-parent doesn't have the children in
it's child list so even when cleaning up we need to call
reparentChildrenForDrawing on the old parent instead of the new parent.
Also clarify name to make this more obvious and add test.

Test: Transaction_test.cpp
Bug: 76099859
Change-Id: I935eec303dba320b5a2731606ec862311c5ca43e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3bed0524e31f5f1844909006d952ff72196b98a2 20-Mar-2018 Steven Thomas <steventhomas@google.com> Fix frozen screen after exiting vr

When a hotplug connected event occurs, don't recreate any
already-existing entries in mBuiltinDisplays. This fixes a problem where
the screen would freeze after exiting vr.

In the future, we may want to use hotplug connected events to notify
surface flinger to reinitialize display state. This CL includes a change
to the code in HWC2.cpp to always reinitialize the display state when we
get a hotplug connected event, even if the display is already connected.

Bug: 74985350

Test: - Confirmed exiting vr no longer freezes the screen.

- Added code to simulate a hotplug connected event while the device is
running, to test the changes in HWC2.cpp. Confirmed the device
continued to function normally.

Change-Id: I6afda67cae84842b2568c773e6b5aa4f38df6a96
Merged-In: I6afda67cae84842b2568c773e6b5aa4f38df6a96
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3c6f5390a20fa0f32f0d46cb027a1b2412df2c26 19-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add a null check in case device disappears." into pi-dev
3b1b8affbda97b8414c3015648d7804609f727e6 17-Mar-2018 Garfield Tan <xutan@google.com> Add a null check in case device disappears.

This is a race condition possible when the caller get display IBinder
the display is still here, but when it tries to take screenshot with
that display, the display disappeared before it.

Bug: 75324434
Test: smoke tests on walleye. This is a race so hard to verify.
Change-Id: I5a107862e0b442840038b0956736e9661f556a23
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0a0158c25c74de41770a9fa2f8d7da234a0dacee 16-Mar-2018 Dan Stoza <stoza@google.com> SF: Add IGBP list leak debugging info

Adds a few things intended to make debugging IGBP list leaks easier:
1) A dumpsys line listing the current and max occupancies of the list
2) A debug property to set the max: debug.sf.max_igbp_list_size
3) Printing the current number of Layers when aborting

Since we still have an unknown leak, this also sets the default limit
four times higher to avoid hitting it in dogfood/automation.

Bug: 74616334
Test: Manual, set max to 100 and verify above behaviors
Change-Id: I7a6227a1d6fc05c197ec632db7dd9f875c64c6c9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a52f0295622a42849f5ef81c44589b816b2ccacb 15-Mar-2018 Peiyong Lin <lpy@google.com> [Native] Replace android_color_mode usage with ColorMode.

To ease the pain when we add color mode v1.1, we replace all current
android_color_mode usage in framework native with ColorMode directly from HAL.

BUG: 73824924
Test: Build & flash
Change-Id: I4436fc225c7807506825c7148bc794cb99f278dc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
578038fc49f83c4c8c4accdce49df404ecd6ad02 09-Mar-2018 Robert Carr <racarr@google.com> SurfaceFlinger: Add childLayersOnly variant of capture layers.

Currently captureLayers is being used to capture children of abstract
buffer-less layers, for example we capture the node representing
a Task. Because of animations, etc, the node may have been scaled
when we want to take the screenshot, so we solved this problem with
an inverse transform in LayerRenderArea. However we have parallel problems
for crop, visibility, etc...It seems what we really want from captureLayers
is the ability to capture all child layers while ignoring the parent imposed
state as if in a parallel hierarchy. I initially considered implementing a parallel
hierarchy with layer clones but it seemed much less risky for P to instead
reparent the existing hierarchy to a parallel abstract parent on the server side.

Bug: 72760590
Test: Existing tests pass. Quickstep works with new implementation. New transaction tests.
Change-Id: Ifd2b2f9ed45351d8ed0d7f09be1cd9806ec4abe8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
df1c25fc23f43807c01ee6b709eb83f10d1e055b 01-Mar-2018 Chia-I Wu <olv@google.com> Merge changes from topic "re-simplify-wcg"

* changes:
surfaceflinger: simplify getActiveColorMode check
surfaceflinger: simplify P3 support in RE
surfaceflinger: fix WCG flag in DisplayDevice creation
a52a5b6e0ce4b41cbc264cd5c7ec1e5b1aa5434c 28-Feb-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SF: Fix mGraphicBufferProducerList"
101d8dc00001bd282f09a25f10058c77f982c11c 28-Feb-2018 Dan Stoza <stoza@google.com> SF: Fix mGraphicBufferProducerList

This change is primarily to fix a memory leak discovered while
investigating bug 73792507. It turned out that while we were adding
every new IGBP to SF's list (which it uses for authentication), we were
never removing anything from that list, causing us to leak wp<> items.

The root cause was some subtlety around MonitoredProducer, which wraps
a generic IGBP in order to allow SF to perform some work when one is
destroyed. When we were adding elements to mGBPL, we were adding the
address of the MonitoredProducer, but upon destruction, the
MonitoredProducer was trying to remove the address of its wrapped IGBP,
which, naturally, wasn't present in the list.

In order to address this, the key functional change here is to pass the
IBinder address of the MonitoredProducer from its destructor rather
than that of the wrapped IGBP.

On top of the bug fix, however, this also switches from a custom
MessageBase-derived class to LambdaMessage and converts mGBPL from a
SortedVector to a std::set.

Bug: 73792507
Test: Manual - log lines to verify mGBPL no longer increases over time
Change-Id: Idabae211354561a0f13c8d9e594c7acc4822aab0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9a48a8c84bf84dff2aaf51a011b5810d89dddc32 20-Feb-2018 Chia-I Wu <olv@google.com> surfaceflinger: simplify getActiveColorMode check

When mForceNativeColorMode is true, getActiveColorMode returns
HAL_COLOR_MODE_NATIVE. There is no need to check both.

Test: manual with UiBench
Change-Id: I3bbf66d85ccb262441b9d216096ec869c529b7e8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
69bf10f5ea9b8abce49d49235630388dd57d3e62 20-Feb-2018 Chia-I Wu <olv@google.com> surfaceflinger: simplify P3 support in RE

RE always knows how to convert sRGB/P3/BT2020 to P3. The conversion
is enabled by SurfaceFlinger whenever the color mode is P3 (and when
hasWideColorDisplay is true). This change simplifies or removes
some wide color state functions from RE, and moves the burden to
SurfaceFlinger. It also changes GLES20RenderEngine::drawMesh to
inspect mDataSpace and mOutputDataSpace directly.

This allows us to enable the conversion in more cases more easily.
For example, we can choose to set the RE output dataspace to P3 even
when the display color mode is NATIVE.

Test: manual with UiBench
Change-Id: I5e701dd6b01764efbbab967dc4a26a4d008dfc09
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4b0e4ddf448f14198c578a71fae888025ab5964f 20-Feb-2018 Chia-I Wu <olv@google.com> surfaceflinger: fix WCG flag in DisplayDevice creation

When a display does not support any wide color mode, yet it is
plugged when mForceNativeColorMode is true, we would incorrectly
mark the display as supporting wide color.

We should ignore mForceNativeColorMode entirely in DisplayDevice
creation because mForceNativeColorMode may change at runtime.

Test: builds
Change-Id: Icb245a2e78954b90d6c5461de8f4ef571858d959
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8ee5227050439e49dc543b305ba4fc56f8d4a889 28-Feb-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes Ic400e8d1,If108059c

* changes:
SF: Add and use MockGraphicBufferProducer/Consumer
SF: Abstract out buffer queue creation
ccfd682b5280fe638d4e0b4c7841c98aab298788 22-Feb-2018 Jiwen 'Steve' Cai <jwcai@google.com> Fix VrFlinger handoff

In ag/3368932, hotplug processing was moved to main thread and deferred
the actual display devices creation to the next cycle of
SurfaceFlinger's main thread. This breaks UpdateVrFlinger logic, which
runs on the main thread and assumes all new display devices get created
synchronously during the handoff.

This CL fixes the issue by allowing synchronous calling
processDisplayHotplugEventsLocked() from onHotplugReceived() if and only
if the callback is called on main thread.

Bug: 72103899
Test: VrApp now renders fine
Change-Id: I2abd5d5861e0bb74419f12142f7f7c33190a022c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
12eb423785adba54be4c7112e5198a80d563896e 17-Jan-2018 Lloyd Pique <lpique@google.com> SF: Abstract out buffer queue creation

Modifies SurfaceFlinger so that the type of the buffer queue
producer/consumer pair produced for framebuffers can be changed at
runtime.

Test: Builds
Bug: None
Change-Id: If108059c43e5c0d03de9645966d9b8eca2b9ed16
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ca27f2500cff74ae1e08b3ae06f18e9b3414ffb7 07-Feb-2018 chaviw <chaviw@google.com> Allow destroySurface to get called in transaction.

Previously, destroy was always initiated immediatley and could not be
synchronized with a client transaction. This change allows
destroySurface to be called in the same transaction as other client
state updates.

Test: Unit tests pass
Test: Call from Java fixes bugs.
Change-Id: I841359530538961a0187216cc455cc388c0ede77
Fixes: 72953020
Fixes: 71499373
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0fcde1b23edcb8105b944df70bf1113cac8f0c15 21-Dec-2017 Lloyd Pique <lpique@google.com> SF: Separate EventThread into interface and impl

This allows the normal EventThread to be substituted by a GMock for unit
tests.

The EventThread is now the abstract interface. impl::EventThread is the
normal implementation.

Test: Builds
Bug: None
Change-Id: I2c6234a10849f7d34a215d53e5f601895738a5ae
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
144e116f45f196396f0d59d5fc09766ab618f885 21-Dec-2017 Lloyd Pique <lpique@google.com> SF: Separate RenderEngine into interface and impl

This allows the RenderEngine to be substituted by a GMock for tests.

RE::RenderEngine is now a pure virtual interface class.
RE::impl::RenderEngine is the normal/base implementation.

Similarly, RE::Image and RE::Surface are pure virtual interfaces.
RE::impl::Image and RE::impl::Surface are the normal implementations.

Test: Builds
Bug: None
Change-Id: Ib5e658df4bb4efc1a9c0ae95feaf0c1e052cdc94
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a822d52f1a7f651bf1056f4b99e7b8dd214c2ebb 21-Dec-2017 Lloyd Pique <lpique@google.com> SF: Separate Hwc2::Composer into interface and impl

This makes the android::Hwc2::Composer substitutable. In this case the
intent is to allow a mock::Composer GMock class to be defined.

Hwc2::Composer now is a pure interface class. Hwc2::impl::Composer is
the normal implementation.

Also included is another minor change to allow HWC2::Device to be
constructed with a Hwc2::Composer (interface) pointer instead of a
service name. This means that now SurfaceFlinger itself constructs the
Hwc2::impl::Composer using the service name, rather than passing it down
a call chain.

Test: Code builds
Bug: None
Change-Id: Ic79f645cee40c534651b9c7b70f05497d98e51dc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e83f93151800f4f7999f7e0c3b727de9267a5f5f 01-Feb-2018 Lloyd Pique <lpique@google.com> SF: Cleanup EventThread Part 2

De-refbase EventThread and a bunch of related classes. Convert from
usign StrongPointer to std::unique_ptr to hold owned references, or bare
pointers for unowned references.

I did not see any need for using std::shared_ptr, or anything else, as
SurfaceFlinger appeared to own all the objects, and they were created
once and not really destroyed afterwards.

Test: Things seem to still work on a Pixel XL
Bug: None

Change-Id: Ifff32118d31bc1bb51e38df695ebe5cf86d2bb6d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
46a46b317153f26e3361c9c74158fc6414bff7da 01-Feb-2018 Lloyd Pique <lpique@google.com> SF: Cleanup EventThread Part 1

The cleanups in this CL are primarily about switching from
android::Thread to std::thread.

1) Convert from android::Thread to std::thread, along with using
std::mutex and std::condition_variable to keep consistency.
2) Switch the header to #pragma once.
3) Added Clang thread annotations and enabled the corresponding warning.
4) Added proper thread shutdown handling (invoked by dtor).

Test: No issues observed on Pixel XL
Bug: None

Change-Id: I2ef0ad18ef75e139f70d856031991f87d187efe6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
755e319d6a656dc92bd4f2b486d8f5a44b0e7350 01-Feb-2018 Lloyd Pique <lpique@google.com> SF: Cleanup EventControlThread

Primarily the goal was to eliminate the use of RefBase in various forms
from EventControlThread.

1) SurfaceFlinger only needs a std::unique_ptr<> and not an
android::sp<> to own the created instance.
2) Convert from android::Thread to std::thread, along with using
std::mutex and std::condition_variable to keep consistency.
3) The code only needs a reference to a function to call, rather than a
reference to all of SurfaceFlinger. This removes an unnecessary full
dependency.
4) Switch the header to #pragma once.
5) Added Clang thread annotations and enabled the corresponding warning.
6) Simplified the thread function to eliminate unnecessary locals and
indentation.
7) Added proper thread shutdown handling (invoked by dtor).

Bug: None
Test: Verified event control thread still works on Pixel XL

Change-Id: I2d5621b0cbbfb9e0f8c5831ccfc94704c95a4a55
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8d2651e484d5090e8d067672cb82ca285b93f4a9 24-Jan-2018 Chia-I Wu <olv@google.com> surfaceflinger: support BT2020_ITU_PQ

Games use BT2020_PQ while videos use BT2020_ITU_PQ usually. We can
support both and treat them as the same, since the YUV->RGB
conversion happens before the pixel data are uploaded to texture, or
happens inside the GLES driver.

The only caveat is that we treat RGBA1010102/BT2020_ITU_PQ from
media specially. The hack is also updated in this change.

Test: manual
Change-Id: I1e4b8e0d907af5e5a95cf7fde1a7ea67a4e7da0b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5c6e46353676b4fd647317fde28c413d8ffe3565 11-Jan-2018 Chia-I Wu <olv@google.com> surfaceflinger: always advertise HDR10 when wide color is available

For HWC that already adversises HDR10 support, this has no effect.
Otherwise, SurfaceFlinger will insert HDR10 into HdrCapabilities
when wide color is supported.

SurfaceFlinger simulates HDR10 support by switching the color mode
to DISPLAY_P3 and forcing client composition for HDR10 layers. It
also has a special path to treat RGBA_1010102/BT2020_PQ as
Y410/BT2020_PQ in RenderEngine when the buffer is from media.

Test: manual
Change-Id: Ib5f18e0100f5610ee65218108bdb9843baccbe98
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f1831a120a44ef9260eb16191195a7db5d6c03d7 18-Jan-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SurfaceFlinger: Do not capture rounded corners on screenshots"
8acf5a0acc2d45d090bbc25fa8bbb07ce1076e40 17-Jan-2018 Adrian Roos <roosa@google.com> SurfaceFlinger: Do not capture rounded corners on screenshots

Fixes a regression that arose because we no longer properly
checked for the layerStack when traversing the layers for
screenshotting.

Bug: 72111097
Test: Take screenshot, verify rounded corner overlays do not appear.
Change-Id: Ifc178247fe5b72376c56a0a1d347d7bd04784cae
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5b15ef66927507f01c6ec19ed39b04dfc549a111 17-Jan-2018 Jorim Jaggi <jjaggi@google.com> Enable IMG_context_priority depending on availability

The config value from the config store can still be used to
override it.

Test: Enable gpu completion tracing, observe how SF preempts other
GPU drawing
Bug: 64674361

Change-Id: Id2f6f11019c2e6cae078fb9e64e3d9d72e42533c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a67cda6bf2e131a4ff7edcf7b383166126a91510 17-Jan-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SurfaceFlinger: Optimize region calculation for invisible layers."
e5f4f694f11ad1e8a9bb3b1b9579a175435c7c19 12-Jan-2018 Robert Carr <racarr@google.com> SurfaceFlinger: Optimize region calculation for invisible layers.

This CL causes the computeVisibleRegions codepath to escape earlier
for a given layer when it is found that it's visible region is empty.
All the juggling in the later part of the function can end up being
quite expensive even when it's no-op. It seems this is largely due
to allocation of storage space for temporary Region variables. In particular
I found that without this CL Walleye was uncapable of staying in 60fps mode
when there were 100 fully occluded layers and 1 visible layer. With this CL
we're able to stay in 60FPS. We are running in to this issue in some practical
cases where we can have a few dozen parent layers with no buffer adding a lot
of time to computeVisibleRegion. Since they have no mActiveBuffer they will
bail early from isVisible and benefit from this change.

Test: Manual. Existing tests pass.
Change-Id: I7dd39f8641649a3cc38b4ed017ffe9b6eefcf224
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c520831fb7ea03e9d515add9b2d96d423b3b6093 09-Jan-2018 Lloyd Pique <lpique@google.com> Use wide color modes with external displays

A prior code cleanup made it obvious that wide color modes were only
being used for the primary display. This patch allows external displays
to use wide color modes, and adds a requested TODO to update a variable
name.

Bug: None
Test: Builds
Change-Id: Iec262e51674a2a2f7fcfc9177c7bfbf0b1a860e3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2ae2b3bd5bfbacc3b52f222441bfbbeb9bd54dc7 15-Dec-2017 Lloyd Pique <lpique@google.com> Allow a primary display disconnect

This patch forwards the primary display disconnect event to the
Framework, and otherwise ensures that SurfaceFlinger does not crash
while there is no primary display.

Note that the Framework does not yet accept this change. In particular
the ActivityManager ActivityStackSupervisor code promptly asserts that
one cannot remove the primary display. With this assertion disabled, the
framework does not crash (surprisingly). And if the Framework
subsequently receives a primary display connect event, it does not seem
to do anything useful -- the display remains in a default off state, and
no layer stack/viewport/etc is set on it.

Bug: 38464421
Test: Works (with workarounds as noted) on a Chromebook
Test: Added Unit test passes on Pixel 1 XL

Change-Id: Ia11439030efdc53bc17474b71a0ffb3d3085bb49
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
715a2c13e6a010143761c1822ce7c4975921aa0b 15-Dec-2017 Lloyd Pique <lpique@google.com> Determine displayType in SurfaceFlinger

This change eliminates an assumption that the first hotplug connect
event is for the primary display, and all other events are for the
external display.

Bug: 38464421
Test: Boots, settings app navigable
Change-Id: I753deb9a4e99a7b225ab89562c7acf4ce284dbf5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fcd86617fb5cbbad3463c828211868859de23329 15-Dec-2017 Lloyd Pique <lpique@google.com> Eliminate duplicate device creation code

On startup, SurfaceFlinger used a special code path to set up the
primary display.

This removes the code, as all display event processing is done on
initialization, so the normal DisplayDevice creation path is used.

This also resolves some differences between the two code paths so the
primary display is set up the same way.

Bug: 38464421
Test: Settings app is navigable.
Change-Id: Icef8ee6c2ddd26604a33f06fb45ec0a743d82a29
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ba04e6237fb6ae1aede76b543028da101412b11d 15-Dec-2017 Lloyd Pique <lpique@google.com> Move hotplug processing to the main thread

Queue up all hotplug events for processing in the main thread, as part
of a display transaction (eDisplayTransactionNeeded).

This is needed so that everything done for each individual hotplug disconnect or
connect is done at the same time, such as creating and destroying the
corresponding DisplayDevice.

This fixes an issue with a hotplug disconnect event followed by an
immediate connect event for the same display not being handled properly.

Bug: 38464421
Test: Immediate disconnect/connect handled correctly.
Change-Id: I96266db8b02ffd6ad9eb4897d6c8510657775991
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
347200f079e004495aa46d6e1d5c1dec2632bbc6 15-Dec-2017 Lloyd Pique <lpique@google.com> Create processDisplayChangesLocked

This simply extracts the code in handleTransactionLocked for the
eDisplayTransactionNeeded case into its own function.

There were no changes other than a quick clang-format of the extracted function.

Bug: 38464421
Test: Builds
Change-Id: Id84f5b990fb6818db1f8b0c37ac02bf3caa26002
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
79894211143e8bb01a0332cc0ec870b1b1b165e3 11-Jan-2018 Peiyong Lin <lpy@google.com> Merge "[SurfaceFlinger] Replace NULL with nullptr."
566a3b4a1d1a2a6d38257113700eea92aa44ea2b 10-Jan-2018 Peiyong Lin <lpy@google.com> [SurfaceFlinger] Replace NULL with nullptr.

Test: make
Change-Id: Ia0ecb3160cd5fddf22fb7100c1759d62e723d0b7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
87704c94fac81f625ba5b25548fd4ad497500f58 09-Jan-2018 Vishnu Nair <vishnun@google.com> Get layer trace status from SurfaceFlinger service

Bug: 64831661
Test: Toggle layer trace from new QS Tile
Change-Id: I7259dbb295feefd2302b0e93c8e1ed1a857616bf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
03480e23a6abd6c25aa3b689f736eb9c051eb8c3 05-Jan-2018 Robert Carr <racarr@google.com> Restore ability of system to screenshot secure layers.

In previous iterations of the code the "secureLayerIsVisible" block
had a guard for "localProducer" which was set to true if the IGBP we
were screenshotting to was originally allocated by SurfaceFlinger. What
this means is that it came from a SurfaceControl, rather than just being
allocated on the client side. Note that the caller could still read the
Screenshot back out from the surface, so the old logic just ensured
you can't screenshot secure layers unless you have a SurfaceControl. Having
a SurfaceControl meant you had either the permission ACCESS_SURFACE_FLINGER,
were from AID_SYSTEM/AID_GRAPHICS, or had been granted a SurfaceControl. This
allowed the system server to screenshot secure layers for the screen rotation
animation. When switching to the GraphicBuffer based interface we eliminated
this permisivity. This CL reintroduces it in what is hopefully
a clearer way, by explicitly only granting the ability to system
components.

Bug: 70403018
Test: Manual
Change-Id: Icbc51e897f5d46838a68c1387e993b8e6a68cd1d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
154f5bba911cd3fd1ac9b556f133e21888522039 03-Jan-2018 Rob Carr <racarr@google.com> Merge "Avoid unnecessary calls to updateTransformHint"
767fcf7ef21a2db44ead9e685ebe48f638f3e651 01-Dec-2017 Chia-I Wu <olv@google.com> surfaceflinger: add more sync operations to RenderEngine

Add RenderEngine::finish and RenderEngine::waitFence. Rework flush
not to fall back to finish.

Test: SurfaceFlinger_test
Change-Id: I2e5738f72b4aa1186d45d23cab9055f96d90ff23
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
95f40fb256d54f1b5d8e65bfad1735f61377a458 07-Dec-2017 Ivan Lozano <ivanlozano@google.com> Merge "Fix sanitizer in handleTransitionLocked."
51a0b41a6bb7378fd60e96bfb87b820948960187 07-Dec-2017 Ivan Lozano <ivanlozano@google.com> Fix sanitizer in handleTransitionLocked.

The loop as constructed in handleTransitionLocked potentially leads to
two unsigned integer overflows on the i = 0 loop on integer sanitized
builds.

runtime error: unsigned integer overflow: 0 - 1 cannot be represented in
type 'size_t' (aka 'unsigned long')

runtime error: unsigned integer overflow: 18446744073709551615 + 1
cannot be represented in type 'size_t' (aka 'unsigned long')

This refactors the loop to prevent the overflow.

Bug: 30969751
Test: Compiles, device boots.

Change-Id: Ia660dffbee3da9667d5e266cc85798eb458660ac
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
56a0b9ac6a951053e283cf42e245a48d28d2624c 05-Dec-2017 Robert Carr <racarr@google.com> Avoid unnecessary calls to updateTransformHint

It was observed that this could start to take
noticeable time with high layer counts, I guess
due to the acquisition of one mutex per layer per call. Anyway
it looks like there's no need to call it if a display transaction
didn't occur.

Test: Existing tests pass.
Change-Id: I1918d326a6d0ed32a0a5fea4008a746d328b335d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
73bededbdc82a5b6199f0860c8900e75c6f0e467 15-Nov-2017 David Sodman <dsodman@google.com> SF: Move glComp/DispTimeline to SFBE

Move glCompositionDoneTimeline and mDisplayTimeline to the
SurfaceFlingerBE object.

Test: Build/run manually
Change-Id: I77f2cc39ecf20d5b1c93b5396e37df5b1273d613
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4a36e9384d10fe3a1e57599558d68e95ff51279a 07-Nov-2017 David Sodman <dsodman@google.com> SF: FrameBuckets state to SFBE

Move FrameBuckets state to SurfaceFlingerBE

Test: build
Change-Id: Ib44ab2dc189e0ba31ab8ec5a157c9c3b7cd9808a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cbaf083d0a916ad4b6264d770594d44e411f4674 07-Nov-2017 David Sodman <dsodman@google.com> SF: BufferingStats state to SFBE

Move BufferingStats state to SurfaceFlingerBE

Test: build
Change-Id: I4404607e44b078bb70dca9562c8d3b180702fe15
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
99974d2935a520141d77983ac0329350460f2379 28-Nov-2017 David Sodman <dsodman@google.com> SF: CompositorTiming/CompositorPresentTime state to SFBE

Add CompositorTiming/CompositorPresentTime state to
SurfaceFlingerBE

Test: build
Change-Id: I49f11953e75f080ecefb295af95539d20315bb7a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bc8152863f81c9af1038d92c9eb8caca1cfd4027 06-Nov-2017 David Sodman <dsodman@google.com> SF: RenderEngine/EGL state to SFBE

Move RenderEngine and EGL handles to SurfaceFlingerBE

Test: build
Change-Id: Ifc6736882200db02df7a7a87eda6e909fa0f6ef2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
105b7dcf6b2e3e4af368cabeec275008b7e73806 05-Nov-2017 David Sodman <dsodman@google.com> surfaceflinger: Create SurfaceFlingerBE class

Split SurfaceFlinger object into a backend and
frontend version. This change creates the backend
struct and only puts a single data item in that
struct. Follow-on changes to move more things
to the backend will follow

Test: build
Change-Id: I0fd6b4eb506791346da2b9f94cc12d9cf854ad08
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1801d27b35c6f4be1ca606b443576291df6bfede 04-Dec-2017 Chavi Weingarten <chaviw@google.com> Merge "Revert "Revert "Use GraphicBuffer instead of GBP for screenshots."""
59182e5430d04402c03fcca41ad328d8b468d80d 30-Nov-2017 Chia-I Wu <olv@google.com> Merge changes from topic "sf-re"

* changes:
surfaceflinger: run clang-format on RenderEngine
surfaceflinger: remove all direct use of EGL
surfaceflinger: use RE::Surface in DisplayDevice
surfaceflinger: add surface abstraction to RE
surfaceflinger: remove DisplayDevice::swapRegion
surfaceflinger: remove DisplayDevice::mFlags
surfaceflinger: remove unused EGL data members
surfaceflinger: remove EGLConfig from DisplayDevice ctor
surfaceflinger: add RenderEngine::BindNativeBufferAsFramebuffer
surfaceflinger: return fence fd from RenderEngine::flush
surfaceflinger: add RenderEngine::setCurrentSurface
surfaceflinger: move EGL version/extensions dump into RE
surfaceflinger: move EGL termination into RE
surfaceflinger: move EGL initialization into RE
surfaceflinger: add RenderEngine::mEGLDisplay
surfaceflinger: manage RenderEngine with unique_ptr
40482ff650751819d4104c10a30974838168438c 30-Nov-2017 Chavi Weingarten <chaviw@google.com> Revert "Revert "Use GraphicBuffer instead of GBP for screenshots.""

This reverts commit 707b8f3507fa4a3915844c7a4730e67f94eee2f7.

Reason for revert: Ready to test out changes with SystemUI update

Change-Id: I9fd0cb7ad9cc68d2366fc5ec4ab087fbe4c21f3b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c5aad50b5ee8e9a0f5e86e1eaf040ecf369a819a 29-Nov-2017 Chavi Weingarten <chaviw@google.com> Merge "Revert "Use GraphicBuffer instead of GBP for screenshots.""
b02087dbd6a25e9d077fde16039050da8012b413 09-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: remove DisplayDevice::swapRegion

With SWAP_RECTANGLE and PARTIAL_UPDATES removed, it becomes clear
that swapRegion is not needed. It also becomes clear that
DisplayDevice::flip and SurfaceFlinger::doComposeSurfaces do not
need the dirty region.

Test: SurfaceFlinger_test
Change-Id: Id9cd2b43812d3c7dcfa36f605d0f8a647264f228
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
94e6a688edbf01b44fb4403bc20439326e8f3c3f 09-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: remove DisplayDevice::mFlags

It is always 0.

Test: SurfaceFlinger_test
Change-Id: I0a7a53412dbddc9b9a1f0a0c4b521737c59f7d59
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b523df0c48cefe4b29b5ecbdf1e80c633d3ad36e 09-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: remove unused EGL data members

Remove SurfaceFlinger::mEGLDisplay and SurfaceFlinger::mEGLContext.
With this change, SurfaceFlinger does not use EGL directly anymore.
This also allows us to get rid of RenderEngine::getEGLContext.

Test: SurfaceFlinger_test
Change-Id: I7799d935367650508b741e62a53ce325fdc94234
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c670d50b2e1a33ee4e0a8b6967f3e99e03149447 10-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: remove EGLConfig from DisplayDevice ctor

It is queryable from RenderEngine.

Test: SurfaceFlinger_test
Change-Id: Id976f831f846b9ff7a5f6d8578cfe1787d55da86
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
eadbaa68dbf0f674b2a5260fc813b408cb42fee3 09-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: add RenderEngine::BindNativeBufferAsFramebuffer

It replaces BindImageAsFramebuffer and makes EGLImage an
implementation detail of RenderEngine.

Test: SurfaceFlinger_test
Change-Id: I01be2d95fb9af9cbefa1a72131afb0975f1e0296
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b0c041b61ef38eb1912b8bb4ff372cf836aa8a30 09-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: return fence fd from RenderEngine::flush

The caller does not need to work with EGLSync after this chnage.

Test: SurfaceFlinger_test
Change-Id: I1cf7d11d3023d09be8a73001493c39b4309e7542
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7f40290b223afe1fea1d173da43e8e3d6ae49590 09-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: add RenderEngine::setCurrentSurface

setCurrentSurface is a wrapper to eglMakeCurrent and it uses the EGL
context implied by the RenderEngine. This also allows us to
simplify DisplayDevice::makeCurrent.

Test: SurfaceFlinger_test
Change-Id: Idab581f0ef79af7263159a558d8fad493a198ce7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8601f886d506886d72767979c12f393cbcd2a2cd 10-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: move EGL version/extensions dump into RE

Test: SurfaceFlinger_test
Change-Id: I0c6e258e5ab2e55c7092d1642627c573038b99ac
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b01450b71d7d335f72904ca5ee8d3e1e1fc08bcc 10-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: move EGL termination into RE

This defers EGL termination a bit but that should be fine. More
importantly, SurfaceFlinger is never destructed.

Test: SurfaceFlinger_test
Change-Id: I200e2169eb1cc419a587a7626b438d3d5ddedc70
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d4d9c6fc5616ace39b2c3f23e4590ea8373d3fcf 10-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: move EGL initialization into RE

This defers EGL initialization a bit, from before EventThread
initialization to after.

Test: SurfaceFlinger_test
Change-Id: Icbe9b78d1db189ce5e6aeedf902fe7b62ea2004e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
707b8f3507fa4a3915844c7a4730e67f94eee2f7 29-Nov-2017 Chavi Weingarten <chaviw@google.com> Revert "Use GraphicBuffer instead of GBP for screenshots."

This reverts commit a252d895816b3aa6c3bc2b2083113694ead6963d.

Reason for revert: SystemUI and some other places need to be updated as well. Will resubmit with the other necessary changes

Change-Id: I2dfb7b439c866f31ffa584e450d3208c75afecaa
Bug: 69898957
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
761f8b4a54871ba1de4b6fca0bd35d453f67ad11 29-Nov-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Remove from top layer list if re-parenting top layer."
8ea97bbe9b5097feaa76926c6ac49120e0fc3649 29-Nov-2017 chaviw <chaviw@google.com> Remove from top layer list if re-parenting top layer.

If a layer is given a parent when it originally didn't have one,
remove the layer from the top layer list. This is to ensure the
layer isn't in duplicate places and that it can get properly
cleaned up.

Test: Transaction_test#ReparentFromNoParent successfully removes
layer when test completes.

Change-Id: I1f1c4ee386626c1ef2e3a2e50324ec336d234d5b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a252d895816b3aa6c3bc2b2083113694ead6963d 21-Nov-2017 chaviw <chaviw@google.com> Use GraphicBuffer instead of GBP for screenshots.

Migrate screenshot code to render the layers into a
GraphicBuffer instead of creating a GraphicBufferProducer. This cleans
up the code and makes rendering a screen capture simpler and clearer.

Test: Screencaptures for Recents, manual screenshots, and "adb shell
screencap"
Test: Transaction_test

Change-Id: Ifb463c0e98cfaa3f96ad27837b1a2e2921e253d1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
503b79e3db0d6dce40ea0a8e17bbffd6f6176123 28-Nov-2017 Chavi Weingarten <chaviw@google.com> Merge "Add additional parameters for the captureLayer functions."
c5de5b391c7be208681d7ba9882fa02ea60c4bbc 28-Nov-2017 Steven Thomas <steventhomas@google.com> Merge "Fix usage of HWC_DISPLAY_PRIMARY in vr flinger"
ebd62af1a1efcd200c7f7ecf5f165a31568907b0 28-Nov-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Fix removal check when adding child layers.

Traversing the current state has the same problem we had in other
CL's with relative Z. In this case if there was a parent that
was relative-Zed then it's Z relative is removed, we will be unable
to add children to it until we assign it a new layer. However there's
no reason to traverse, we can just use the new "isPendingRemoval"
flag to detect this state.

Bug: 69633137
Test: Existing tests pass.
Change-Id: I4584f051346fe77c3e6158a04dd1279a86164476
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7206d49b2963ce2e926a5f25fe94aca9c06471e6 11-Nov-2017 chaviw <chaviw@google.com> Add additional parameters for the captureLayer functions.

1. Added new captureLayers function that will return a GraphicBuffer
instead of storing into a Surface.
2. Added crop to captureLayers function.
3. Added frameScale to allow captures to scale.
4. Removed rotation parameter from captureLayers since it will always be
in the correct orientation.

Test: Transaction_test ScreenCaptureTest.CaptureCrop, .CaptureSize

Change-Id: Ib16d8575cf0c103126b9427ad32e2d28d568ea61
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6e8f706c21a01d6a1225e86972ff432bba5f0106 22-Nov-2017 Steven Thomas <steventhomas@google.com> Fix usage of HWC_DISPLAY_PRIMARY in vr flinger

The hardware composer functions require display ids obtained from the
onHotplug() composer callback. Our vr flinger code was supplying
HWC_DISPLAY_PRIMARY as the primary display id, which is incorrect. The
HWC_DISPLAY_* values are used for representing the display type, not the
display id. The code worked anyway because most hardware composers
always use 0 as the primary display id, which happens to be the same
value as HWC_DISPLAY_PRIMARY. The emulator uses 1 as the primary display
id though, which exposed the bug.

This CL changes the vr flinger code to get the display id from the
onHotplug() composer callback, and uses that value when talking to
hardware composer, instead of HWC_DISPLAY_PRIMARY. This matches the
behavior of surface flinger.

Bug: 69631196

Test: Verified the vr flinger code path works as expected on phones and
standalones.

Change-Id: Ia691941d0eafaa1f89e0ee81a4ae27fdef5a57cf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ec2d9855acb6b2dd4507bca28eaf3c5b41573c44 21-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix traverseLayersInDisplay

Ignore top-level relative layers in the loop since they are and
should be traversed by Layer::traverseInZOrder.

Test: SurfaceFlinger_test
Change-Id: Ibd82298257b057b564e4985686d40c10f618e1d9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8d7cb208f52d5034d1b580e819488e7a0b012d27 20-Nov-2017 Rob Carr <racarr@google.com> Merge "Allow relative layering of children"
68e316ebdf4d1b43f72d9782cbc6a2f3badd7292 20-Nov-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix fencing when layers become invisible"
91601ac498b70af52ad262002aef8bd903acc24a 17-Nov-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix fencing when composition mode switches" am: 42ddbb44ac am: 4256a72959
am: 3d91a35182

Change-Id: I3ffbf8ba6f224cdb8c4d6d5a36ad40a1860dfad4
3d91a35182cb15675e4fda87ffcab529ae4c3fd3 17-Nov-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix fencing when composition mode switches" am: 42ddbb44ac
am: 4256a72959

Change-Id: I1414b9899336f34aac86116cf4d39fd68f2b0fdd
4256a72959b63d3648760ae3956ac3b6922fe807 17-Nov-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix fencing when composition mode switches"
am: 42ddbb44ac

Change-Id: Ie5255dcdadbd872670e07abfc6ece40cd543bb71
83806897c6366d841971a38f4a007bb83a7afb64 16-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix fencing when layers become invisible

A layer always holds on to a buffer (after the first one is
acquired). When a new buffer comes in, and the layer is visible, it
will

- acquire the new buffer
- present the new buffer to HWC
- get the release fence from HWC
- associate the old buffer with the release fence and release it

But if the layer happens to be becoming invisible, it will go
through

- acquire the new buffer
- destroy the HWC layer and present
- release the old buffer without any fence

The problem here is that the old buffer is still on screen until the
present takes effect (e.g., on next HW vsync). Rendering artifacts
may be seen on screen.

This commit changes the acquire/release process for layer becoming
invisible to

- acquire the new buffer
- destroy the HWC layer and present
- get a fence from HWC
- associate the old buffer with the fence and release it

We do not require HWC getReleaseFences to return fences for
destroyed layers. We can only use the next best fence, the present
fence.

Bug: 68490054
Test: manual
Change-Id: I68bbf392a6681c6512fc0be68a7d17df122f7308
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
69600966976587bc8ec7d29f93bd9d4362de4503 16-Nov-2017 Jorim Jaggi <jjaggi@google.com> Merge "Trace drawing state"
503c7046237f2797a5cf8584064223359d0e6d10 28-Sep-2017 Robert Carr <racarr@google.com> Allow relative layering of children

Initially we had hoped not to go down this route in order to produce the most
understandable model, but in the end it seems to be the most sane way to
satisfy some existing use cases from the WM. In particular we have the use
case of the IME. The IME may of course be larger than the application it is
targetting, in particular we see this in side by side split-screen portrait
and freeform. However, various UI features such as the text drag handles,
spell checking popups, etc, are controlled by the application process
and modelled as child windows of the application. This is a good fit for them
as they need to inherit most properties of the application window: Cropping,
Transform, Alpha. However they need to appear over the IME! As the IME can't
be a child of the application (it is bigger), we now see our use case for relative
layering. Perhaps the drag handles could be reimplemented as controlled by the IME
process but if nothing else as a legacy API we have exposed the idea of child windows
of the app going over the IME and are likely to need to continue to support it in some
mode.

Test: Transaction_test.cpp
Change-Id: If2d831bcbe88fc753b02c044a57882cca6ccffbb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8e0af3679ec73e07775142825d592448b255f61c 14-Nov-2017 Jorim Jaggi <jjaggi@google.com> Trace drawing state

Some state that was dumped was still the current state, creating
misalignment between what was visible on screen and what was being
dumped. Make sure to dump all state consistently.

Test: adb shell service call SurfaceFlinger 1025 i32 1 &&
adb shell service call SurfaceFlinger 1025 i32 0 &&
adb pull /data/misc/trace/layerstrace.pb
Inspect with WindowScope

Change-Id: I16ea06764328fd8c506ed90dfc59929f7d26d156
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7b5495932f6cb57c0b5771641655b70218a690fa 15-Nov-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix fencing when composition mode switches

When a layer switches from HWC composition to GLES composition, we
use the GLES rendering fence to indicate that the previous layer
buffer is released by HWC. This is incorrect.

Bug: 68490054
Test: manual
Change-Id: I4070940c26d39251161f45682398e6987f4fba15
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c9232edd34618360d099272fb0537cae2f715860 15-Nov-2017 chaviw <chaviw@google.com> Added check for forceClientComposition for every layer.

Instead of having the Layers check for forceClientComposition, have
SurfaceFlinger check since it will be skipping hwc. This also ensures
that new Layer types also get the same check.

Fixes: 69254085
Test: Current tests pass. Rotation works correctly now.

Change-Id: I7a2a378d9690206008b1dab9ce521f959542903a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
83ce7c162855742a2d9eeebc0cd70fe48d2cd125 20-Oct-2017 Chia-I Wu <olv@google.com> surfaceflinger: remove USE_HWC2

Remove USE_HWC2 and assume it to be true. Remove all !USE_HWC2
code.

This also fixes a compile error in tests/fakehwc, which never
defines USE_HWC2.

Test: boots taimen and hikey960
Change-Id: Ie6d2fcf884aa6fc715ab0ce19a1e0f7c8acf734c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
de1eb9c03becf0207aea85983692d7e7e43ff3bc 10-Nov-2017 Matthew Bouyack <mbouyack@google.com> Merge "Eliminate redundant changes to hardware vsync state."
8b3871addb9bbd5776f4ed59e67af2baa9c583fd 02-Nov-2017 chaviw <chaviw@google.com> Don't invoke transactions on layers that will be removed.

A layer can be marked as removed, but still be present in memory.
This check ensures that transactions aren't invoked on layers that
will be removed on the next commitTransaction.

Normally, this would be harmless since the layer will get removed
as soon as a commitTransaction is called. However, for cases like
re-parenting, a removed child layer can be re-parented to a non-removed
layer, which prevents the child from getting removed.

Test: Added code that would destroy a layer before the re-parent was
called. Ensure that the re-parent was ignored. There doesn't
seem to be an easy way to write a test case right now.

Change-Id: I17614447fc4253bdbbb0c06469bb09117b55c1ab
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0c69cad13dda09f1df1dbf23810b1c5b7f28ba08 21-Aug-2017 David Sodman <dsodman@google.com> Refactor Layer/ColorLayer into siblings

New class hierarchy should look like:

Layer (abstract)
/ \
/ \
Buffer Color
Layer Layer

Note: LayerBuffer is what previously was referred to by class Layer

Test: Transaction_test.cpp/manual test

Change-Id: I372a27d533e08371da37be811e4372404f7787bd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2b18d431747aa469afc5088245c707411bf5d2e2 06-Nov-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add SurfaceFlinger tracing"
1e1a1282846318caa0bfe271500eb3ba24e9a513 01-Nov-2017 Adrian Roos <roosa@google.com> Add SurfaceFlinger tracing

Bug: 64831661
Test: adb shell service call SurfaceFlinger 1025 i32 1 && adb shell service call SurfaceFlinger 1025 i32 0
Change-Id: Idf272715b52aee5d2d366fbd4a96b0afaaf2d0c7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a3d7bd39d130ec2e711692d045a435657c4bc0aa 03-Nov-2017 chaviw <chaviw@google.com> Allow SurfaceFlinger to dump to proto

SurfaceFlinger dump to proto was broken due to another CL.

Test: "adb shell dumpsys SurfaceFlinger --proto" works correctly now
Change-Id: I574e2a0b22764928e5ebdf1bd3f76bf20612f879
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2f5bd001333b331894690bf6dbc2068000703a44 31-Oct-2017 Chia-I Wu <olv@google.com> surfaceflinger: make vsync injection more robust am: 6200eacdc9 am: ffbf2d94a1
am: 3c192d059e

Change-Id: I229ea69baff9295ace1495111640eca1222486c8
3c192d059e2c1e5fc47812091dcf276f25f24f2c 31-Oct-2017 Chia-I Wu <olv@google.com> surfaceflinger: make vsync injection more robust am: 6200eacdc9
am: ffbf2d94a1

Change-Id: I2f007234616adaff87866089bec9be000412e7cb
ffbf2d94a1838126f05fcebb6a90a7d6cdf9601f 31-Oct-2017 Chia-I Wu <olv@google.com> surfaceflinger: make vsync injection more robust
am: 6200eacdc9

Change-Id: Ie04e3e56b035ea9e52038de49a2e5c2e67c8abe2
6200eacdc927776483d775562db11cce284cc7e0 05-Oct-2017 Chia-I Wu <olv@google.com> surfaceflinger: make vsync injection more robust

There are more issues than I expected :)

- no lock to synchronize enable/disable and injection
- Every time injection is diabled and enabled, a new EventThread is
created
- mCallback might be nullptr
- ENABLE_VSYNC_INJECTIONS/INJECT_VSYNC should require special
permission
- MessageQueue::setEventThread must be called from the main thread
- MessageQueue::setEventThread does not handle EventThread switch
well

Bug: 65483324
Test: manual
Merged-In: I7d7b98d1f57afc64af0f2065a9bc7c8ad004ca9f
Change-Id: I7d7b98d1f57afc64af0f2065a9bc7c8ad004ca9f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7e8d74b6c5ecb013b69e2080554e9518bfbfea1b 27-Oct-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add captureLayers function to capture a layer and its children."
a76b271f0e14325fa0ebb98e1cac0a15adfea1cb 20-Sep-2017 chaviw <chaviw@google.com> Add captureLayers function to capture a layer and its children.

The captureLayers function gets a root layer as its argument.
It will capture the content for that layer and its descendants. The
capture will set the root layer's transform back to (0, 0).

Test: Transaction_test ScreenCaptureTest
Change-Id: I84fb66a65cd91434cddc99506b1924cf9f950935
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e7f2e3a8db8b3dd0d34b4b894d6a5c475e777d10 27-Oct-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add proto dump flag to services (1/2)"
90f669f238cdc750483d0961efc61bbf551ae782 05-Oct-2017 Chia-I Wu <olv@google.com> surfaceflinger: make vsync injection more robust

There are more issues than I expected :)

- no lock to synchronize enable/disable and injection
- Every time injection is diabled and enabled, a new EventThread is
created
- mCallback might be nullptr
- ENABLE_VSYNC_INJECTIONS/INJECT_VSYNC should require special
permission
- MessageQueue::setEventThread must be called from the main thread
- MessageQueue::setEventThread does not handle EventThread switch
well

Bug: 65483324
Test: manual
Change-Id: I7d7b98d1f57afc64af0f2065a9bc7c8ad004ca9f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a14443fac49543abda174f8c3457ab0b60021b01 24-Oct-2017 Romain Guy <romainguy@google.com> Add new color setting

On devices that support wide color rendering and color management,
add a new setting to disable color management ("saturated" color
mode). To disable color management, the framework can set a persistent
property. Color management can be also toggled by using a Binder
transaction. Finally this change adds a new Binder query so Settings
can easily check whether the device supports wide color rendering.

Bug: 68159303
Test: manual (adb shell + apps)
Change-Id: If74d9b0273bc04f4a3d11e63fe2ec96451fbcc2e
(cherry picked from commit 54f154a28284eabb52ade2689d4a9f8fa190163b)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6bde3c8488fe8a1b63cc9966b8aba7f9aae01f93 25-Oct-2017 Chavi Weingarten <chaviw@google.com> Merge "Added protobuf to gather layer info."
275166a049f3b5d0cb7853087c23a94b0cdda3b4 25-Oct-2017 Romain Guy <romainguy@google.com> Add new color setting am: 54f154a282
am: c5e26a942e

Change-Id: I9e778acebcffd7cb93c69d9429a20b36ca800f57
c5e26a942ebe2a3c189024100d4d9b617aa5133c 25-Oct-2017 Romain Guy <romainguy@google.com> Add new color setting
am: 54f154a282

Change-Id: Ibffa745ee66d102b92657f054f53188ccfeeb6c3
54f154a28284eabb52ade2689d4a9f8fa190163b 24-Oct-2017 Romain Guy <romainguy@google.com> Add new color setting

On devices that support wide color rendering and color management,
add a new setting to disable color management ("saturated" color
mode). To disable color management, the framework can set a persistent
property. Color management can be also toggled by using a Binder
transaction. Finally this change adds a new Binder query so Settings
can easily check whether the device supports wide color rendering.

Bug: 68159303
Test: manual (adb shell + apps)
Change-Id: If74d9b0273bc04f4a3d11e63fe2ec96451fbcc2e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6a40853e06f5274d84b0fc66e349a36510d1497f 24-Oct-2017 Vishnu Nair <vishnun@google.com> Add proto dump flag to services (1/2)

Adds new PROTO flag which requests services to dump sections
in proto format. Modifies dumpsys to take in proto argument
and pass on proto flags to services which support proto
dumps. Modify PriorityDumper helper class to parse proto
arguments and set asProto flags.

Bug: 67716082

Test: mmm -j56 frameworks/native/cmds/dumpsys && \
mmm -j56 frameworks/native/services/utils && \
adb sync data && \
adb shell /data/nativetest/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest64/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest/prioritydumper_test/prioritydumper_test && \
adb shell /data/nativetest64/prioritydumper_test/prioritydumper_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"

Change-Id: I42c2a6a8876efbf9a7d792d68572499b16985147
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1d04428c3cff3503212ec3e76775ca5ba20abc18 27-Sep-2017 chaviw <chaviw@google.com> Added protobuf to gather layer info.

Use protobuf to gather information about the layers. This change also
uses protobuf for the layer dumpsys.

Test: Ran dumpsys for layers to confirm the data was correct.

Change-Id: Iec474e57a4fb9de1e548440d6a08685505947278
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
357988777218502ed68a56a0c8b247ba64b74721 07-Oct-2017 Vishnu Nair <vishnun@google.com> Support priority based dumpsys in surface flinger

Call dump with no args when called with CRITICAL priority. Register
service with support for critical priority dumps.

BUG: 31774394

Test: lunch mini_emulator_x86-userdebug && make -j56
Test: adb bugreport ~/tmp.zip
Test: adb shell dumpsys --priority CRITICAL
Test: mmm -j32 frameworks/native/services/utils && \
adb sync data && adb shell /data/nativetest/prioritydumper_test/prioritydumper_test && \
adb shell /data/nativetest64/prioritydumper_test/prioritydumper_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"

Change-Id: Iec35ef8026d4d9346c83bab203bed8524c28bf89
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
91a86774805069c853edbb2adb5033ca43621497 06-Oct-2017 Vishnu Nair <vishnun@google.com> Revert "Support priority based dumpsys in surface flinger"

This reverts commit deb36f24f43fdbd83c5c61d40b9a32d091ac2a37.

Reason for revert: fixing git_master/mini_emulator_x86-userdebug break

Change-Id: I4729bcb0f4c6ee1f388b916666a0ddbf8a5da5bd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
deb36f24f43fdbd83c5c61d40b9a32d091ac2a37 06-Oct-2017 Vishnu Nair <vishnun@google.com> Support priority based dumpsys in surface flinger

Call dump with no args when called with CRITICAL priority. Register
service with support for critical priority dumps.

BUG: 31774394

Test: adb bugreport ~/tmp.zip
Test: adb shell dumpsys --priority CRITICAL
Test: mmm -j32 frameworks/native/services/utils && \
adb sync data && adb shell /data/nativetest/prioritydumper_test/prioritydumper_test && \
adb shell /data/nativetest64/prioritydumper_test/prioritydumper_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"

Change-Id: I29140808493eb7c8805bfa338ab9a335154862b4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4a485ae8528a43a6385c4b05daec070335475eec 30-Sep-2017 Steven Thomas <steventhomas@google.com> Merge "Fix deadlock when transitioning to vr flinger" into oc-mr1-dev am: c026c52ee6
am: 87d42635af

Change-Id: I43369e455c35a9e8dc3af9e163a958ef24c9dd46
87d42635af7427ffdae2dcab0d6e827fbb677463 30-Sep-2017 Steven Thomas <steventhomas@google.com> Merge "Fix deadlock when transitioning to vr flinger" into oc-mr1-dev
am: c026c52ee6

Change-Id: I1703d835bba529afdc4c7b9d6b8a3c195b1686df
be6cbae3b61a55ab87c131e79dba03d159961aa3 29-Sep-2017 Steven Thomas <steventhomas@google.com> Fix deadlock when transitioning to vr flinger

If we were unlucky with the timing when switching to vr flinger we would
sometimes deadlock. The vr dispatch thread would request the display
from surface flinger, locking mStateLock in the process. mStateLock was
being held by the surface flinger main thread, which was processing a
previous request to switch to vr flinger. The main thread was trying to
connect to the vr hardware composer service, which sent a request to the
vr dispatch thread as part of its initialization, leading to the
deadlock.

The deadlock is easily fixed by posting a message to request the vr
flinger switch to the surface flinger main thread, instead of doing it
on the vr dispatch thread.

Bug: 66916578

Test: Confirmed I can still get into/out of vr flinger on
Marlin. There's no longer code to acquire mStateLock in the vr dispatch
thread, so the deadlock is no longer possible.

Change-Id: I3de5476f698ed798f6b9afe927cc733f0f38c56e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7a88a1458db95285bb147823c53b322018f2afc6 22-Sep-2017 Chavi Weingarten <chaviw@google.com> Merge "Added native functionality to create a color layer."
13fdc49516d17f41e64e62e73c313b0928bf13cc 27-Jun-2017 chaviw <chaviw@google.com> Added native functionality to create a color layer.

Added a new layer that can draw a specified color and specified
alpha. This will replace creating a dim layer and allow any colors,
not just black, to be set for this layer.

Test: Added tests to Transaction_test.cpp to test with a color
and a color layer with alpha.

Change-Id: I00a38d1bbc01093026f088c3347454281bdc2b8c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8754785d7239d9919a1fe76e33ceb9151540e9f3 22-Sep-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Single ATRACE_CALL per function"
fc2589e27981836d36b97ff19e85c84d8f50f915 22-Sep-2017 Siarhei Vishniakou <svv@google.com> Single ATRACE_CALL per function

Tracing was fixed in ag/1940080, which
was later reverted. This change re-applies
portion of the patch.

Test: m -j
Change-Id: I31cc126e6c222f6d8ae02803c037da773c9b8c4d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ec9c7010ca1a184b0b3ca560189449b2ced86ba6 21-Sep-2017 Jorim Jaggi <jjaggi@google.com> Merge "Use Layer.getAlpha instead of State.alpha to calculate occlusion"
f1961f713de2b3f54c8ce7653964b969e1a02bc8 19-Sep-2017 chaviw <chaviw@google.com> Re-parent invoked on child instead of on parent.

The function to re-parent an individual child is now invoked on
the child instead of the parent. This ensures the child ends up with
the last parent set if multiple reparent requests are made in the same
transaction.
This also allows adding a parent to a layer that didn't have one
previously.

Test: Transaction_test -> Reparent, ReparentToNoParent,
ReparentFromNoParent

Change-Id: Idab429eb2dca5a4ae1b020a5a7629d719dd4d995
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
039bbb8aca1280afdf0ecf20810c32804a82199d 06-Sep-2017 Jorim Jaggi <jjaggi@google.com> Use Layer.getAlpha instead of State.alpha to calculate occlusion

Test: CP lock-free anim CL and make sure no black flickers
when starting window fading out.

Change-Id: I422f69e26ba86414476bae9cc3253caf062d4e36
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5c34e4895c4f66a19901bd2d9d1eb6b9bcd623bd 20-Sep-2017 Jae Shin <jaeshin@google.com> resolve merge conflicts of 8007bdd7d to stage-aosp-master

Test: I solemnly swear I tested this conflict resolution.
Change-Id: I728cde095a0b722ff64c0f7b0ef1df4b54cf1fbd
8d455e9f7cae3c73947a2054ce5c945ed1062783 10-Aug-2017 Jiyong Park <jiyong@google.com> Mark libEGL, GLESv1_CM, GLESv2, and GLESv3 as LLNDK

They are used by libRSDriver and libRS_internal which are VNDK-SP
libraries. Therefore, the EGL/GLES libs must be LLNDK or VNDK-SP. We
choose to make them as LLNDK since they already have stable ABIs (as
they are NDK).

In addition, two more functions of libEGL are exposed to vendors

eglQueryStringImplementationANDROID and eglDupNativeFenceFDANDROID are
non-NDK symbols but are being used by libgui, which is a library marked
with vendor_available:true. In order to provide the symbols to the
library, they are added to the map.txt file and tagged as "# vndk" so
that they are exposed only when built for vendor libs (and hidden when
built for NDK).

Furthermore, eglQueryStringImplementationANDROID is changed to C-symbol
in order to be mentioned in the map.txt file, where C++ mangled symbol
name can't be used.

Bug: 64425518
Test: BOARD_VNDK_VERSION=current m -j libRSDriver.vendor
Test: BOARD_VNDK_VERSION=current m -j libRS_internal.vendor
Merged-In: I4d5bcd5f72fb05a7908887f5192de70fd1d8c8f1
Change-Id: I4d5bcd5f72fb05a7908887f5192de70fd1d8c8f1
(cherry picked from commit 00b15b8f223976d016e16536e4720771ef634695)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
005aecd8b28fc244e9934383a7e73f58b3c0bca6 07-Sep-2017 Steven Thomas <steventhomas@google.com> Fix race conditions when using mHwc off the main thread am: 6d8110b170
am: 1f3e4bbbc4

Change-Id: I38a5fac1457245c1fba024179dc34c43814c596b
1f3e4bbbc4a459a848f2912ee1e2ef09e13963ab 07-Sep-2017 Steven Thomas <steventhomas@google.com> Fix race conditions when using mHwc off the main thread
am: 6d8110b170

Change-Id: I1da28635e48581339f67c01306602605935184b2
6d8110b1708171da278782d18886fa1a21971cd9 01-Sep-2017 Steven Thomas <steventhomas@google.com> Fix race conditions when using mHwc off the main thread

In a few cases we were accessing mHwc off the main thread without
acquiring mStateLock, resulting in crashes and other incorrect
behavior. This CL adds the missing locks. Since the locking semantics
are somewhat hard to understand, also add a clarifying comment to the
mHwc member declaration in SurfaceFlinger.h.

Bug: 64586546

Test: I manually tested normal surface flinger operation and vr behavior
on different devices, and confirmed everything looks fine. The crashes
we saw that were caused by these mHwc race conditions are hard to
reproduce, so I couldn't empirically verify this fixes the crash. I'm
relying on manual code inspection to confirm the issue is in fact fixed.

Regarding performance, I added profiling code (not part of this CL) to
check for lock contention and hold times with the newly added locks. I
confirmed that contention is low, so these calls shouldn't be
significantly slower as a result of adding the locks. The time spent
holding these new locks is also low, except for getDisplayColorModes(),
which makes a call to hardware composer service and can in some cases
take over a millisecond. That function is called so rarely though, only
once at boot, or twice at boot after a fresh flash, that it's not worth
optimizing.

Change-Id: I3854779c12a61983aaaecddb9f6316f218e519e3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4a71a386e92608362d9bbaba18040936cd9f7155 31-Aug-2017 George Burgess IV <gbiv@google.com> Merge "surfaceflinger: fix static analyzer complaints" am: 6d31f4eb4a am: 72e782036d am: 1719e70b04
am: 94ffdb2918

Change-Id: Ib58556f53240baf86621f3fda651cf62c17c85aa
94ffdb29188bdefffa0d070eb9335f750ed1df72 30-Aug-2017 George Burgess IV <gbiv@google.com> Merge "surfaceflinger: fix static analyzer complaints" am: 6d31f4eb4a am: 72e782036d
am: 1719e70b04

Change-Id: I8a1e49bc6036dab29d439cf79d7dcb4c5d2036ff
72e782036d2d6cff93ff6c7945fb785534cc181f 30-Aug-2017 George Burgess IV <gbiv@google.com> Merge "surfaceflinger: fix static analyzer complaints"
am: 6d31f4eb4a

Change-Id: I3ed3ca3f69e8a44232553afaaaed4c6cab6b3bfd
406a285ab039e4bd83fc98fc7c3fb4a9107d8dd2 30-Aug-2017 George Burgess IV <gbiv@google.com> surfaceflinger: fix static analyzer complaints

Due to https://bugs.llvm.org/show_bug.cgi?id=34365, the static analyzer
complains about use of copied `sp`s. In this case, the copy is entirely
unnecessary, since we're just going to destroy the copied-from sp
anyway.

Speed things up a bit + appease the analyzer by moving instead.

Bug: 27101951
Test: mma. Static analyzer no longer complains.
Change-Id: Idf45abcc5c9b3694ef710e330e88a7c2fd766929
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c9674336c053c071022279211eeffc6c9e7c1e99 28-Aug-2017 chaviw <chaviw@google.com> Traverse all layers to check if parent exists to add child layer.

With the current implementation, when adding a child layer, the code
only looks in the layersSortedByZ vector to see if the parent exists.
The layersSortedByZ vector only contains the top most layers and not the
child layers. The current behavior prevents creating child layers that
have a parent that is also a child layer. This won't allow for nested child
layers. Instead, traverse the list of layers, which will include looking
at the child layers, to see if the parent layer exists.

Test: NestedChildren test in Transaction_test

Change-Id: I6c1a773b65e450010733f74f459fc327c7af3aea
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0617894190ea0c3ee50889bee1d4df0f369b0761 27-Jul-2017 chaviw <chaviw@google.com> Add a re-parent function to re-parent a specific child.

This is similar to reparentChildren, but the reparentChild will
only re-parent a specific child to the new parent and not all
children.

Test: Added test in Transaction_test for reparentChild.

Change-Id: I4275e0d5f1d5601b489956753c78a56d1a5d4c1c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c8a1e48ea0a0eddacdbccc58a2b087e4d925cedd 16-Aug-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix z-relative layer destruction" into oc-mr1-dev
am: 11e66edfad

Change-Id: I8210bbb66165da88aa3331a31f134f0088d9f01e
11e66edfad9fe7aa370e99ceeadbafdd7d563f81 16-Aug-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix z-relative layer destruction" into oc-mr1-dev
1c901cdd7a9273e160fd1c27ad9e279b5eabfba0 16-Aug-2017 Thierry Strudel <tstrudel@google.com> Revert "Postpone color mode change until after boot animation" am: 2924d01304
am: 53bb4e138c

Change-Id: If76cb24f722ab33c9c36e799f025fa02c2baf5ce
53bb4e138c95045ab8fc5f5dedd47dd1012d6ef2 16-Aug-2017 Thierry Strudel <tstrudel@google.com> Revert "Postpone color mode change until after boot animation"
am: 2924d01304

Change-Id: If182308e0602e3e5af0998698f0e428f7c3ff18d
c665702cea06c5c42360b7f66fed1693127e6680 15-Aug-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix z-relative layer destruction

Layer::commitTransaction is called before Layer::onRemoved. The
removal of a layer from another layer's zOrderRelatives is not
reflected in Layer::mDrawingState until Layer::commitTransaction is
called again. As a result, we may draw a removed layer, which is
not supposed to own any HWC or GL resource.

Add Layer::onRemovedFromCurrentState that is called when a layer is
removed from mCurrentState to mLayersPendingRemoval. Move
zOrderRelative* updates from onRemoved to the new
onRemovedFromCurrentState, and set eTraversalNeeded as needed.

Also fix Layer::~Layer to restore the old behavior and destroy all
stale HWC layers just in case.

Bug: 64572777
Test: manual and AUPT
Change-Id: I546c5b4b7ecac0937fead655733402fae664331c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2924d01304dba0b714c556b14e45e34f70472e96 15-Aug-2017 Thierry Strudel <tstrudel@google.com> Revert "Postpone color mode change until after boot animation"

This reverts commit c53d3558d55dfd1d1c424b0d632fea693113e83e.

To have better control on when the color shift is happening, the
bootloader asset will be aligned with the Android OS applied
saturation. So apply the color setting as soon as SF is up.

Bug: 63520186
Bug: 63823274
Test: Verify that sRGB is applied at the start of boot animation
Change-Id: I611eb61266c909fde50e7ea2b4c1314541228736
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7c47163851a9f20dea67b50f2e8abe57f6ea3f56 15-Aug-2017 Jiyong Park <jiyong@google.com> Merge "Mark libEGL, GLESv1_CM, GLESv2, and GLESv3 as LLNDK" into oc-mr1-dev
am: d2bc3ac8c4

Change-Id: I2ac5a8e4bf53de7f8a7e47ea77c8818c6f036c66
00b15b8f223976d016e16536e4720771ef634695 10-Aug-2017 Jiyong Park <jiyong@google.com> Mark libEGL, GLESv1_CM, GLESv2, and GLESv3 as LLNDK

They are used by libRSDriver and libRS_internal which are VNDK-SP
libraries. Therefore, the EGL/GLES libs must be LLNDK or VNDK-SP. We
choose to make them as LLNDK since they already have stable ABIs (as
they are NDK).

In addition, two more functions of libEGL are exposed to vendors

eglQueryStringImplementationANDROID and eglDupNativeFenceFDANDROID are
non-NDK symbols but are being used by libgui, which is a library marked
with vendor_available:true. In order to provide the symbols to the
library, they are added to the map.txt file and tagged as "# vndk" so
that they are exposed only when built for vendor libs (and hidden when
built for NDK).

Furthermore, eglQueryStringImplementationANDROID is changed to C-symbol
in order to be mentioned in the map.txt file, where C++ mangled symbol
name can't be used.

Bug: 64425518
Test: BOARD_VNDK_VERSION=current m -j libRSDriver.vendor
Test: BOARD_VNDK_VERSION=current m -j libRS_internal.vendor
Change-Id: I4d5bcd5f72fb05a7908887f5192de70fd1d8c8f1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3bc82e4c44f7d76c4d45d47ce3cefeece24de15c 10-Aug-2017 Steven Thomas <steventhomas@google.com> Merge "Use a separate hwcomposer hidl instance for vr flinger" into oc-mr1-dev-plus-aosp
359d3ab4abc8d0ec59c33068f8a69398af2181c0 10-Aug-2017 Jorim Jaggi <jjaggi@google.com> Merge "Fix out-of-order transactions (2/2)" into oc-dr1-dev am: 0436b01d1b
am: 65186a22be

Change-Id: I4323d366104435fa5e04262d546fd00be06722e2
b02664ddc146893e6bbe7939ee2b948d54e7166a 27-Jul-2017 Steven Thomas <steventhomas@google.com> Use a separate hwcomposer hidl instance for vr flinger

Improve robustness of vr flinger <--> surface flinger switching by
having vr flinger use a separate hardware composer hidl instance instead
of sharing the instance with surface flinger. Sharing the hardware
composer instance has proven to be error prone, with situations where
both the vr flinger thread and surface flinger main thread would write
to the composer at the same time, causing hard to diagnose
crashes (b/62925812).

Instead of sharing the hardware composer instance, when switching to vr
flinger we now delete the existing instance, create a new instance
directed to the vr hardware composer shim, and vr flinger creates its
own composer instance connected to the real hardware composer. By
creating a separate composer instance for vr flinger, crashes like the
ones found in b/62925812 are no longer impossible.

Most of the changes in this commit are related to enabling surface
flinger to delete HWComposer instances cleanly. In particular:

- Previously the hardware composer callbacks (which come in on a
hwbinder thread) would land in HWC2::Device and bubble up to the
SurfaceFlinger object. But with the new behavior the HWC2::Device
might be dead or in the process of being destroyed, so instead we have
SurfaceFlinger receive the composer callbacks directly, and forward
them to HWComposer and HWC2::Device. We include a composer id field in
the callbacks so surface flinger can ignore stale callbacks from dead
composer instances.

- Object ownership for HWC2::Display and HWC2::Layer was shared by
passing around shared_ptrs to these objects. This was problematic
because they referenced and used the HWC2::Device, which can now be
destroyed when switching to vr flinger. Simplify the ownership model
by having HWC2::Device own (via unique_ptr<>) instances of
HWC2::Display, which owns (again via unique_ptr<>) instances of
HWC2::Layer. In cases where we previously passed std::shared_ptr<> to
HWC2::Display or HWC2::Layer, instead pass non-owning HWC2::Display*
and HWC2::Layer* pointers. This ensures clean composer instance
teardown with no stale references to the deleted HWC2::Device.

- When the hardware composer instance is destroyed and the HWC2::Layers
are removed, notify the android::Layer via a callback, so it can
remove the HWC2::Layer from its internal table of hardware composer
layers. This removes the burden to explicitly clear out all hardware
composer layers when switching to vr flinger, which has been a source
of bugs.

- We were missing an mStateLock lock in
SurfaceFlinger::setVsyncEnabled(), which was necessary to ensure we
were setting vsync on the correct hardware composer instance. Once
that lock was added, surface flinger would sometimes deadlock when
transitioning to vr flinger, because the surface flinger main thread
would acquire mStateLock and then EventControlThread::mMutex, whereas
the event control thread would acquire the locks in the opposite
order. The changes in EventControlThread.cpp are to ensure it doesn't
hold a lock on EventControlThread::mMutex while calling
setVsyncEnabled(), to avoid the deadlock.

I found that without a composer callback registered in vr flinger the
vsync_event file wasn't getting vsync timestamps written, so vr flinger
would get stuck in an infinite loop trying to parse a vsync
timestamp. Since we need to have a callback anyway I changed the code in
hardware_composer.cpp to get the vsync timestamp from the callback, as
surface flinger does. I confirmed the timestamps are the same with
either method, and this lets us remove some extra code for extracting
the vsync timestamp that (probably) wasn't compatible with all devices
we want to run on anyway. I also added a timeout to the vysnc wait so
we'll see an error message in the log if we fail to wait for vsync,
instead of looping forever.

Bug: 62925812

Test: - Confirmed surface flinger <--> vr flinger switching is robust by
switching devices on and off hundreds of times and observing no
hardware composer related issues, surface flinger crashes, or
hardware composer service crashes.

- Confirmed 2d in vr works as before by going through the OOBE flow on a
standalone. This also exercises virtual display creation and usage
through surface flinger.

- Added logs to confirm perfect layer/display cleanup when destroying
hardware composer instances.

- Tested normal 2d phone usage to confirm basic layer create/destroy
functionality works as before.

- Monitored surface flinger file descriptor usage across dozens of
surface flinger <--> vr flinger transitions and observed no file
descriptor leaks.

- Confirmed the HWC1 code path still compiles.

- Ran the surface flinger tests and confirmed there are no new test
failures.

- Ran the hardware composer hidl in passthrough mode on a Marlin and
confirmed it works.

- Ran CTS tests for virtual displays and confirmed they all pass.

- Tested Android Auto and confirmed basic graphics functionality still
works.

Change-Id: Ibf1dbdf3ec15ca66467697d711f8109dc9e46a47
Merged-In: I17dc0e060bfb5cb447ffbaa573b279fc6d2d8bd1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
50bd661d4bac9c903946f95ead7770252032bd1a 10-Aug-2017 Chia-I Wu <olv@google.com> libsurfaceflinger: fix screenshot permission check am: fc0b911090
am: 88f99396fd

Change-Id: I41c256f2b96bf0adbe7e7aa05828c3e4e1725ff5
e89483f1bda1468a8f58fc8bcd8477a7d4cb0c92 09-Aug-2017 Jorim Jaggi <jjaggi@google.com> Merge "Fix out-of-order transactions (2/2)" into oc-dr1-dev
am: 0436b01d1b

Change-Id: I021a2635b40e74f29e1d94ad4a738f3b043ed5db
0436b01d1b48c55e59d8ad21187c0e80b7828a9f 09-Aug-2017 Jorim Jaggi <jjaggi@google.com> Merge "Fix out-of-order transactions (2/2)" into oc-dr1-dev
27a7c02f0ca4afa27cd1516b342ab485df03c15b 08-Aug-2017 Steven Thomas <steventhomas@google.com> Merge "Use a separate hwcomposer hidl instance for vr flinger" into oc-mr1-dev
88f99396fd53ce3a5b3306ed05057f477604ac69 08-Aug-2017 Chia-I Wu <olv@google.com> libsurfaceflinger: fix screenshot permission check
am: fc0b911090

Change-Id: I9a2c42ea76572e5200f99d65f56ee4b10da4ca15
bdcf09c4984d47e30e34ff0d3cb1b797ba7fd778 08-Aug-2017 Jorim Jaggi <jjaggi@google.com> Fix out-of-order transactions (2/2)

The following sequence of order may happen which cause wrong
surface positions:
- WA.animate updates surfaces properties to S
- WA.animate closes the surface transaction
- Since the previous animation transaction wasn't commited yet,
closeSurfaceTransaction blocks and updating the surface properties
on SF side is deferred.
- In the meantime, since we are not holding WM lock, we have
another thread updating surfaces properties to S'
- Closing the transaction in this thread completes immediately
because it's not a synchronous transaction or animation
transaction.
- After a frame has been processed S gets applied on SF side as
the other transaction is done waiting for the frame to complete.

The issue here is that properties are now set to S instead of S'.
Sad!

We originally started calling closeTransaction without the WM
lock being held because it lead to thread starvation (b/38192114).
However, that fix has this big flaw as described above.

To fix this, we create an empty animation transaction before
updating the animation properties to simulate the back-pressuring
behavior of animation transactions without the WM lock being held.
If that transaction arrives out of order, it doesn't matter at all
because it is empty.

After that, we perform the animation udpate in a transaction that
is not marked as an animation transaction, and thus will not
block, which avoids the starvation issue.

Part of this change is also a change in SF to allow executing
empty animation transactions.

Test: go/wm-smoke
Test: Open VideoPlayer from VRCore, close it, observe no wrong
positiioning of surfaces.
Test: Inspect traces while animating. Ensure back pressuring still
works.

Change-Id: Ie545463e71e0d1bc73439d14381077a290d2f959
Fixes: 63905190
Bug: 38192114
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d7f49c5e93a554c2f0e85e279a765f92fb1e66f1 27-Jul-2017 Steven Thomas <steventhomas@google.com> Use a separate hwcomposer hidl instance for vr flinger

Improve robustness of vr flinger <--> surface flinger switching by
having vr flinger use a separate hardware composer hidl instance instead
of sharing the instance with surface flinger. Sharing the hardware
composer instance has proven to be error prone, with situations where
both the vr flinger thread and surface flinger main thread would write
to the composer at the same time, causing hard to diagnose
crashes (b/62925812).

Instead of sharing the hardware composer instance, when switching to vr
flinger we now delete the existing instance, create a new instance
directed to the vr hardware composer shim, and vr flinger creates its
own composer instance connected to the real hardware composer. By
creating a separate composer instance for vr flinger, crashes like the
ones found in b/62925812 are no longer impossible.

Most of the changes in this commit are related to enabling surface
flinger to delete HWComposer instances cleanly. In particular:

- Previously the hardware composer callbacks (which come in on a
hwbinder thread) would land in HWC2::Device and bubble up to the
SurfaceFlinger object. But with the new behavior the HWC2::Device
might be dead or in the process of being destroyed, so instead we have
SurfaceFlinger receive the composer callbacks directly, and forward
them to HWComposer and HWC2::Device. We include a composer id field in
the callbacks so surface flinger can ignore stale callbacks from dead
composer instances.

- Object ownership for HWC2::Display and HWC2::Layer was shared by
passing around shared_ptrs to these objects. This was problematic
because they referenced and used the HWC2::Device, which can now be
destroyed when switching to vr flinger. Simplify the ownership model
by having HWC2::Device own (via unique_ptr<>) instances of
HWC2::Display, which owns (again via unique_ptr<>) instances of
HWC2::Layer. In cases where we previously passed std::shared_ptr<> to
HWC2::Display or HWC2::Layer, instead pass non-owning HWC2::Display*
and HWC2::Layer* pointers. This ensures clean composer instance
teardown with no stale references to the deleted HWC2::Device.

- When the hardware composer instance is destroyed and the HWC2::Layers
are removed, notify the android::Layer via a callback, so it can
remove the HWC2::Layer from its internal table of hardware composer
layers. This removes the burden to explicitly clear out all hardware
composer layers when switching to vr flinger, which has been a source
of bugs.

- We were missing an mStateLock lock in
SurfaceFlinger::setVsyncEnabled(), which was necessary to ensure we
were setting vsync on the correct hardware composer instance. Once
that lock was added, surface flinger would sometimes deadlock when
transitioning to vr flinger, because the surface flinger main thread
would acquire mStateLock and then EventControlThread::mMutex, whereas
the event control thread would acquire the locks in the opposite
order. The changes in EventControlThread.cpp are to ensure it doesn't
hold a lock on EventControlThread::mMutex while calling
setVsyncEnabled(), to avoid the deadlock.

I found that without a composer callback registered in vr flinger the
vsync_event file wasn't getting vsync timestamps written, so vr flinger
would get stuck in an infinite loop trying to parse a vsync
timestamp. Since we need to have a callback anyway I changed the code in
hardware_composer.cpp to get the vsync timestamp from the callback, as
surface flinger does. I confirmed the timestamps are the same with
either method, and this lets us remove some extra code for extracting
the vsync timestamp that (probably) wasn't compatible with all devices
we want to run on anyway. I also added a timeout to the vysnc wait so
we'll see an error message in the log if we fail to wait for vsync,
instead of looping forever.

Bug: 62925812

Test: - Confirmed surface flinger <--> vr flinger switching is robust by
switching devices on and off hundreds of times and observing no
hardware composer related issues, surface flinger crashes, or
hardware composer service crashes.

- Confirmed 2d in vr works as before by going through the OOBE flow on a
standalone. This also exercises virtual display creation and usage
through surface flinger.

- Added logs to confirm perfect layer/display cleanup when destroying
hardware composer instances.

- Tested normal 2d phone usage to confirm basic layer create/destroy
functionality works as before.

- Monitored surface flinger file descriptor usage across dozens of
surface flinger <--> vr flinger transitions and observed no file
descriptor leaks.

- Confirmed the HWC1 code path still compiles.

- Ran the surface flinger tests and confirmed there are no new test
failures.

- Ran the hardware composer hidl in passthrough mode on a Marlin and
confirmed it works.

- Ran CTS tests for virtual displays and confirmed they all pass.

- Tested Android Auto and confirmed basic graphics functionality still
works.

Change-Id: I17dc0e060bfb5cb447ffbaa573b279fc6d2d8bd1
Merged-In: I17dc0e060bfb5cb447ffbaa573b279fc6d2d8bd1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fc0b9110901cd9814a83c574fdaf5c4428838424 08-Aug-2017 Chia-I Wu <olv@google.com> libsurfaceflinger: fix screenshot permission check

Fix the logic for layers we check isSecure or isVisible for. It was
regressed by my previous change to support
WINDOW_TYPE_DONT_SCREENSHOT.

Bug: 63311708
Bug: 62656774
Test: CTS
Change-Id: I7768cb590014cc610ec564847958bbd98742c277
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a099a24c93bfa599fc5c36a647e946c26f68514f 11-Jan-2017 Kalle Raita <kraita@google.com> Faked HWC for SurfaceFlinger testing

Infrastructure and initial port of transaction tests. Faking the HWC
allows exercising the real path through the SurfaceFlinger, not relying
on screen captures. Faked HWC also opens up the possibility of faking
interactions like display hotplugs.

The tests are verifying the composition rectangles instead of a set of
select pixels. GLES rendering differences won't affect the
results. Also, the test expectations become clearer.

The ported transaction tests ran roughly twice as fast when compared
with the original transaction test. This is mostly due to the thighter
control over the vsyncs.

Test: Running the test on Marlin
Change-Id: I1c876cda78db94c1965498af957e64fdd23459ce
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
449fec5d089ffec2debdbcd09f766c16517a0631 03-Aug-2017 Chia-I Wu <olv@google.com> Merge "libsurfaceflinger: handle WINDOW_TYPE_DONT_SCREENSHOT" into oc-dr1-dev am: 1e9bf7c91b am: ebc55de1a8
am: 0fd740c511

Change-Id: I427ba9348e63a390407453d12a9dd7b226c9daee
0fd740c5115b122a9b41f57fc325ab2b3cdc882c 03-Aug-2017 Chia-I Wu <olv@google.com> Merge "libsurfaceflinger: handle WINDOW_TYPE_DONT_SCREENSHOT" into oc-dr1-dev am: 1e9bf7c91b
am: ebc55de1a8

Change-Id: I7f00ef3c36326aef9cb3789a07946d7f29dac612
7cc9d29816baaa85185b4e13ebb05bfb1cc2dfce 03-Aug-2017 Chia-I Wu <olv@google.com> Merge "libsurfaceflinger: handle WINDOW_TYPE_DONT_SCREENSHOT" into oc-dr1-dev
am: 1e9bf7c91b

Change-Id: Ie0d80934d0bf1d92ecfb2ab491cdf2b374132c17
1e9bf7c91b359747cc3d043caec66922618ca79d 03-Aug-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "libsurfaceflinger: handle WINDOW_TYPE_DONT_SCREENSHOT" into oc-dr1-dev
ab0c319824632c463ea624cee6f0bc3c8cd8a779 01-Aug-2017 Chia-I Wu <olv@google.com> libsurfaceflinger: handle WINDOW_TYPE_DONT_SCREENSHOT

When a layer has type WINDOW_TYPE_DONT_SCREENSHOT, hide it from
everywhere but the primary display. This should be reverted when we
switch to use layer hierarchy properly.

Bug: 63311708
Test: screencap, screenrecord, android.view.cts.SurfaceViewSyncTest
Change-Id: I6a8d6b93399b0dc42832588f9a6c5e8879a8b754
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ac8661beae733fde679c3ec190ea4f04974ed0cb 02-Aug-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Merge changes If4271719,I9c9b5de9,I46a26a67 into oc-dr1-dev
am: ddd9c71272

Change-Id: Ie3868b140dfc675f450ac5f436f3533c1d2bdc93
346203f942789898b8be209049fa2c73a29a9330 02-Aug-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Merge changes If4271719,I9c9b5de9,I46a26a67 into oc-dr1-dev am: ddd9c71272
am: e124f74dff

Change-Id: I17280865ba7570933c3bfd04f2104704ac854607
ddd9c712727881acbedec8a66535ab31fa2a5b4f 02-Aug-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes If4271719,I9c9b5de9,I46a26a67 into oc-dr1-dev

* changes:
Communicate composition buffer dataspace to HWC
Add VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT.
Check wide-color support before adding extensions
281e8113d0ce20c702e847caf971663021eb65e3 14-Jul-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Communicate composition buffer dataspace to HWC

Test: adb shell dumpsys SurfaceFlinger
look for dataspace info in DisplayDevice section
Bug: 63146977
Change-Id: If427171994fbc91faacf5bad9cc736ddfbd35ec3
(cherry picked from commit 79d272442ce13418c3ea81c95d7fea0159b4b481)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ce398e4b0347757558dad84ccab052513b92df5e 13-Jul-2017 Saurabh Shah <saurshah@codeaurora.org> sf: Defer DispSync initialization

Some DispSync members are initialized based on uninitialized static
members of sf, that are in turn initialized in sf constructor. Fix
the sequence by deferring DispSync initialization.

Current sequence:
sf constructor|-> DispSync constructor -> Access static sf members
|-> Initialize sf static members

New sequence:
sf constructor|-> DispSync constructor
|-> Initialize sf static members
|-> DispSync init -> Access static sf members

Bug: 63671437
Test: "present fences are ignored" not present in SF dumpsys
Change-Id: I618d2bbbbd4e39fc382e67f85dd8d637dd82cf38
(cherry picked from commit f41745301d5ecfa680dcef3a1948a8a321f80509)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
30b390cb021315e5fe6d0788c037a8f77624d99e 26-Jul-2017 Chavi Weingarten <chaviw@google.com> Merge "Update LayerVector's order after modifying relative layer."
79d272442ce13418c3ea81c95d7fea0159b4b481 14-Jul-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Communicate composition buffer dataspace to HWC

Test: adb shell dumpsys SurfaceFlinger
look for dataspace info in DisplayDevice section
Bug: 63146977
Change-Id: If427171994fbc91faacf5bad9cc736ddfbd35ec3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
88a852805dbe643cd4bbf77b87de1beddeb98f88 22-Jul-2017 Romain Guy <romainguy@google.com> Postpone color mode change until after boot animation am: c53d3558d5
am: fa215072e7

Change-Id: I82823ca821815045cbd93f8f1c90d0c8b2cc696f
18b6b78eccbaeb33765eab54929c2264b9a78912 22-Jul-2017 Romain Guy <romainguy@google.com> Postpone color mode change until after boot animation
am: c53d3558d5

Change-Id: I96c0f0fb297be1ff9c1b5df2b33ffeacc39888b9
c53d3558d55dfd1d1c424b0d632fea693113e83e 21-Jul-2017 Romain Guy <romainguy@google.com> Postpone color mode change until after boot animation

sRGB is only set by SurfaceFlinger when the default display is
wide color capable. Since we compute the best color mode on
every frame anyway for wide color capable displays, we can
simply move the sRGB set to the end of the boot animation.

Bug: 63823274
Test: Manual
Change-Id: I11bb6095acb63e66bcf7dff9e3f7b36588e371c1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
732ee9e17f7bbe843b652a45471f6b7eae353c55 21-Jul-2017 Romain Guy <romainguy@google.com> Merge "Properly applies the selected saturation boost (vivid mode)" into oc-dr1-dev
am: 3eba4064ef

Change-Id: I9ee74bf11f728524501b7003dbcd5fcf6707be2d
61d27675018fe501e38baaa47844d6ae85019a76 21-Jul-2017 Romain Guy <romainguy@google.com> Merge "Properly applies the selected saturation boost (vivid mode)" into oc-dr1-dev am: 3eba4064ef
am: 3770426bc4

Change-Id: I41cc35ca14bb6362b1d5029677cbf3dcba1a778f
3eba4064efec313dd619e51c4f32cd40d8758d63 21-Jul-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Properly applies the selected saturation boost (vivid mode)" into oc-dr1-dev
5ba35156fec2b46516e45ca542ac1865fe60eee1 21-Jul-2017 Wei Wang <wvw@google.com> SurfaceFlinger: Set property in StartPropertySetThread during init
am: f9b05eeb5f

Change-Id: I3433d57d6e929f57202c4d9a68a6a09845474166
11d63f4b7d99cc09ff1f8c320bb7a8648ca07fa1 20-Jul-2017 Romain Guy <romainguy@google.com> Properly applies the selected saturation boost (vivid mode)

The saturation boost setting is read by SurfaceFlinger as a
persistent system property. Unfortunately, persistent props
are only available after Vold is up and /data is decrypted,
which may happen before or after SF attempts to read the
property.

This CL moves the propery lookup to the end of the boot
animation. This solves two issues:
- The saturation boost will not be applied to the boot animation
- The vivid colors user setting is now reliably applied

Bug: 63823274
Test: Manual

Change-Id: Icb8e30c799c30cf674f0fc0bab0369f4c99367ed
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f9b05eeb5f3b3ea92ea196f37a53df06b535690c 20-Jul-2017 Wei Wang <wvw@google.com> SurfaceFlinger: Set property in StartPropertySetThread during init

This is similar to ag/1849505/ (see b/34499826), which by setting
property in a separate thread, that CL aims to avoid slow initialization
in SurfaceFlinger::init where SurfaceFlinger is waiting on
property_service.

There is new property_set() call added, and this CL is to move it to the
StartPropertySetThread.

Bug: 63844978
Test: on taimen with simulated delay ag/2562492/
Change-Id: I31547cb5e75f44eac635386b3cf345a44931c78f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f41745301d5ecfa680dcef3a1948a8a321f80509 13-Jul-2017 Saurabh Shah <saurshah@codeaurora.org> sf: Defer DispSync initialization

Some DispSync members are initialized based on uninitialized static
members of sf, that are in turn initialized in sf constructor. Fix
the sequence by deferring DispSync initialization.

Current sequence:
sf constructor|-> DispSync constructor -> Access static sf members
|-> Initialize sf static members

New sequence:
sf constructor|-> DispSync constructor
|-> Initialize sf static members
|-> DispSync init -> Access static sf members

Bug: 63671437
Test: "present fences are ignored" not present in SF dumpsys
Change-Id: I618d2bbbbd4e39fc382e67f85dd8d637dd82cf38
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cb35066649b1aabacd02809e1c03b0fb6e3f34b2 18-Jul-2017 Steven Thomas <steventhomas@google.com> Merge "Fix concurrent writes to the hardware composer" into oc-dr1-dev am: 87cd11513f
am: ad59d3ad0b

Change-Id: Ib0e1c3a2804d2b77c7f41adcca65b4de926ae24b
87cd11513fa0d3d0800c0f93fd1bc57ba71b0039 18-Jul-2017 Steven Thomas <steventhomas@google.com> Merge "Fix concurrent writes to the hardware composer" into oc-dr1-dev
f5a5f6e810fb5064b81d0b5360fe65829eb90980 17-Jul-2017 Steven Thomas <steventhomas@google.com> Fix concurrent writes to the hardware composer

Stale hardware composer layers were causing concurrent writes to the
Composer object from the surface flinger and vr flinger threads, a big
no-no. The concurrent writes would sometimes stomp on each other,
causing the hardware composer service to fail to read the command buffer
containing surface flinger's composer commands, leading to all sorts of
issues.

Bug: 62925812

Test: Locally added logs to surface flinger to catch the concurrent
writes, and confirmed the logs are no longer present with this patch
applied. Went through a bunch of sleep/wake cycles and confirmed the
device continues to function normally.

Change-Id: I70929c4a3c71142f5e9083cac294c122d127aa27
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3da6f353c93121132475f46f070cecdce99843c7 14-Jul-2017 Dan Stoza <stoza@google.com> Merge changes I23e6f088,I800208e8,I55123a7a into oc-dr1-dev am: 607b5d1b40
am: 1042a22877

Change-Id: I4c5e092f7119fb9a90e791dd31fbdb4f56b811cd
2b6d38e8eca1fe7137757b8269c6c19c6d1a04e4 02-Jun-2017 Dan Stoza <stoza@google.com> SF: Move screenshot Surface ops off main thread

This change rearranges the various operations that correspond to
capturing a screenshot such that all of the Surface-related ones
(connect, dequeue, queue, disconnect) are performed on the incoming
Binder thread rather than on SurfaceFlinger's main thread. This has two
major benefits:

1) It reduces the amount of time that the SurfaceFlinger main thread
is blocked while performing a screenshot, often by a considerable
amount. This should reduce the risk of jank when screenshots are
taken, such as for task snapshots during window transitions.
2) It means that the SurfaceFlinger main thread is not susceptible to
being blocked by a badly-performing BufferQueue consumer. This
also enables us to remove the GraphicProducerWrapper class, which
was previously performing a similar role.

Finally, this change also adds a mechanism that detects if the
screenshot would have been performed between the two phases of normal
SurfaceFlinger operation (invalidate and refresh), and defers it if
this condition is detected. This should further reduce the risk of jank
as a screenshot will only occur between frames rather than in the
middle of a frame.

Bug: 62257775
Test: SurfaceFlinger_test and manual verification that screenshots
still work
Change-Id: I23e6f088b4d6e477472dfc2a6c36ef3dd930c047
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
64f7b420c4a48cf75bcd8536716d9a515369dc7a 12-Jul-2017 chaviw <chaviw@google.com> Update LayerVector's order after modifying relative layer.

If the z value for a layer is updated due to a relative layer change,
the order of layers in the SortedVector was not updated and could cause
lookup failures in the binary search. This updates the vector by
removing and then re-adding the layer to ensure it's resorted.

Also added the eRelativeLayerChanged condition for SurfaceFlinger_hwc1.

Test: Added multiple layers that updated relative layer. The LayerVector's
order was updated correctly and the layers remain in the correct
order.

Change-Id: If5403a0b626f34db41bf7a98fe42830ed272d16e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
abcda352f126016ce4dd227d34088e8c7957c32e 01-Jun-2017 Dan Stoza <stoza@google.com> SF: Add ImageHolder for screenshot code

Adds a simple ImageHolder class, which holds an EGLImage and destroys
it either when an explicit destroy() method is called or when the class
is destructed (whichever occurs first). This allows us to reduce the
nesting of, and otherwise simplify, the captureScreenImplLocked method
of SurfaceFlinger.

Bug: 62257775
Test: SurfaceFlinger_test and manually verified that screenshots still
work
Change-Id: I800208e8f6bedd2ce66827268ecc64968dbe616d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a9b1aa0b0dded03256a4deae50b4e94393506547 01-Jun-2017 Dan Stoza <stoza@google.com> SF: Add WindowDisconnector for screenshot code

Adds a simple WindowDisconnector class that holds an ANativeWindow* and
disconnects from it when it goes out of scope. This allows us to
drastically reduce the nesting of the captureScreenImplLocked method
of SurfaceFlinger.

Bug: 62257775
Test: SurfaceFlinger_test and manually verified that screenshots still
work
Change-Id: I55123a7a6b2036158d0959328b0e6f8b206cce5d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1a1552472e7eaae15025a88486ebcb647f99fcc8 01-Jul-2017 Chia-I Wu <olv@google.com> surfaceflinger: refresh after latching any buffer am: a36bf92663
am: 81876de166

Change-Id: I6a62ab9052f47f9d97bc30029aa20546094ab9a7
a36bf92663256f1c8d2956902daf0f1045961953 30-Jun-2017 Chia-I Wu <olv@google.com> surfaceflinger: refresh after latching any buffer

We should not skip refresh when a latched buffer happens to have an
empty dirty region. Also, we should signal a layer update when we
skip refresh.

Bug: 62752640
Test: manual
Change-Id: Ia603e7eeb37491c6ece7ea08d5d1e3b7ba93e6fa
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b1e29aff043f9b34322b64cde47510f82ea911a1 29-Jun-2017 Karthik Ravi Shankar <karthikrs@google.com> Merge "Add VrFlinger dumpsys to SurfaceFlinger" into oc-dr1-dev am: ae11e71bb7
am: 9579e3cd94

Change-Id: I3f56806205f651d714255c66a1b1bd8e0cc73f6d
171155a55d7a3b7571ea1292f1aad926b6f82509 29-Jun-2017 Karthik Ravi Shankar <karthikrs@google.com> Add VrFlinger dumpsys to SurfaceFlinger

When we do dumpsys SurfaceFlinger, we get no information about the
layers/what is composed when the device is in VR mode.

Bug: 63113212
Test:
VrFlinger state:
Application Surfaces:
Surface 0: surface_id=11 process_id=5550 user_id=10104 visible=1
z_order=0 queue_ids=29,37
Surface 1: surface_id=13 process_id=5035 user_id=10130 visible=1
z_order=0 queue_ids=53,65

Direct Surfaces:
Surface 0: surface_id=8 process_id=5563 user_id=10104 visible=1
z_order=0 queue_ids=17

Display metrics: 1440x2880 537.882x537.882 dpi @ 60 Hz
Post thread resumed: 1
Active layers: 1

Layer 0: type=Device surface_id=8 buffer_id=19

Hardware Composer Debug Info:
-------------------------------
HWC2 display_id: 0
layer: 30 z: 0 compositon: Device/Device alpha: 255 format:
RGBA_8888_UBWC dataspace:0x00000000 transform: 0/0/0 buffer_id:
0x70b4877500
color modes supported: 0 7 9 current mode: 7
current transform:
1.08 -0.02 -0.02 0.00
-0.07 1.03 -0.07 0.00
-0.01 -0.01 1.09 0.00
0.00 0.00 0.00 1.00
-------------------------------

This section doesn't appear when the device is not in VR mode.

Change-Id: I2961a05fc3ea303e070be08de355fb6e56c3d0db
Signed-off-by: Karthik Ravi Shankar <karthikrs@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
56e2939d80f355952fac0c4123079cccc56ef66b 21-Jun-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Remove backpressure ALOG"
ee9806ad2f0e0e3249dc63af333cae8ca3891b66 21-Jun-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Reduce number of Fence syscalls made."
fda2c6fd94052e19ef327e5a2656ae74d9da0554 21-Jun-2017 Fabien Sanglard <sanglardf@google.com> Remove backpressure ALOG

The backpressure ALOG was needed to troubleshoot fence not signaling
while we worked on libhwc2on1adapter. Since these issues have been
resolved we don't need the log anymore.

Test: Manual
Change-Id: I29b2aa36f27f93d93ef14f1746d8c2f03101fc33
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4a96718e3e3d9264c9925efa1f62d99b19536194 20-Jun-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix a potential child layer leak" into oc-dev am: 1b02b6329e
am: 4d5cc90559

Change-Id: Ib956b914044fee1941ef966bbf96c151bbbcf6a4
989ed5c4c1be7e82070cc42043c3cb3d64d9de14 20-Jun-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix a potential child layer leak" into oc-dev
am: 1b02b6329e

Change-Id: Ie2bd5a6d1d37bb5b7c7b679b8c472389ff619188
fbc80aef0ba1b11982cf4ca88d218b65b6eca0f3 27-May-2017 Brian Anderson <brianderson@google.com> Reduce number of Fence syscalls made.

This patch saves 6 or more Fence syscalls per frame.

* Timelines are updated just before adding a new fence
since the newly added fence is unlikely to have signaled.
* Layer::latch uses a FenceTime now, so the signal time is
automatically shared with other owners of the FenceTime.
* DispSync uses FenceTime now, only using cached values of
the signal time that have been populated by a Timeline.

Test: SurfaceFlinger boots and dumps still work.
Change-Id: Ie0cfc1af2aca143dd8d5f08f08dbe1e597376f2f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
40d6bc3e6187520cc4a0e3b72c985c54d6ac69db 17-Jun-2017 Chia-I Wu <olv@google.com> Merge changes from topic 'layer-wp-race' into oc-dev am: a17b14eb92
am: f39c08c906

Change-Id: I579504e93cc6c21dd13e5b8468d8b87037133a0c
c35a5e29f3c4c05041ac0f4a0bcbfe669d3d67bc 17-Jun-2017 Chia-I Wu <olv@google.com> Merge changes from topic 'layer-wp-race' into oc-dev
am: a17b14eb92

Change-Id: I1af51f57255024d36e9cae5c221361f36cb28da4
fae51c438827ae0a55c1b83c0e9be348254bfbd4 15-Jun-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix a potential child layer leak

We should not remove a child layer from its already removed parent.
Call p->removeChild only after we've checked that the ancestor is
alive.

Apply e6b63e1ae12692327f7e46d5f10d6ade5a7bf192 and this fix to
SurfaceFlinger_hwc1.cpp as well.

Bug: 37121786
Test: manual stress test
Change-Id: I7b811450a998acc4ad9690bd4eda058ce6588e14
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
515dc9c538b8206b746eeb4906ac0b8aed1fb497 15-Jun-2017 Chia-I Wu <olv@google.com> surfaceflinger: Layer::getParent requires state lock held

We rely on mStateLock to synchronize accesses to
Layer::mCurrentParent.

Bug: 38505866
Test: manual stress test
Change-Id: I5f8ec358ed7e35df28f8c6aec31ae6ee51cb5b93
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
096cb99ad877594121d0112ba52dc343d1d34d9b 05-Jun-2017 Alex Sakhartchouk <alexst@google.com> Re-enable default display when switching to VR mode.

Previously, in an attempt to minimize the number of changes that got
reset during VR mode transitions, the primary display was not turned back
on.

Bug: 62215749
Test: Switch device into VR mode, observe primary display invalidations.

Change-Id: Idd883e1522f519a0db06fdd88b071007487b6e70
(cherry picked from commit 933ed5ceb9d70829333ae438985a1bfeec8e79a8)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
84a794e0423a341a2665998e86309ed9b6053b04 09-Jun-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes Idd883e15,I9e13e04f

* changes:
Re-enable default display when switching to VR mode.
Add LambdaMessage to SurfaceFlinger
a151804acb3f52f99915904aff256edda52ac43d 09-Jun-2017 Jorim Jaggi <jjaggi@google.com> Properly run window animations at vsync-sf (2/2) am: b1e2f8deb3
am: d5ebce91c8

Change-Id: I30768aba500834a157290871b0970f20a8eebd06
5d37ae59e040fdca43a92084c96d89db4be33fec 09-Jun-2017 Jorim Jaggi <jjaggi@google.com> Properly run window animations at vsync-sf (2/2)
am: b1e2f8deb3

Change-Id: I7fbd22c681688edce1eda7f2786c68e6cbe32a22
b1e2f8deb38353e4bcc9d3ef06bc15bd5e417425 09-Jun-2017 Jorim Jaggi <jjaggi@google.com> Properly run window animations at vsync-sf (2/2)

- Add new Choreographer instance that runs on vsync-sf
- Use this new Choreographer for WindowAnimator, and remove all
the hacks around it

Test: Open apps and close apps, notice no stutter
Test: Screen zoom animations
Test: go/wm-smoke
Bug: 36631902
Change-Id: I72a8b39709303a38fc077100229b8a81a153ba3e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
933ed5ceb9d70829333ae438985a1bfeec8e79a8 05-Jun-2017 Alex Sakhartchouk <alexst@google.com> Re-enable default display when switching to VR mode.

Previously, in an attempt to minimize the number of changes that got
reset during VR mode transitions, the primary display was not turned back
on.

Bug: 62215749
Test: Switch device into VR mode, observe primary display invalidations.

Change-Id: Idd883e1522f519a0db06fdd88b071007487b6e70
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cd9b55c70f081dbd004d347b51a793ce6fe3cacf 01-Jun-2017 Matthew Bouyack <mbouyack@google.com> Eliminate redundant changes to hardware vsync state.

When transitioning between NORMAL and DOZE power modes
we were redundantly calling resyncHardwareVsync.

Similarly, when transitioning from DOZE_SUSPEND to OFF
we were redundantly calling disableHardwareVsync.

This change eliminates those redundant calls.

Fixes bug 62235417

Change-Id: I513bbf94a7ab973ab258efe16436441ac2379b70
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3054f004567bffc4b77e31fcf8d6c126b2262295 06-Jun-2017 Romain Guy <romainguy@google.com> Read saturation boost from a persistent property

We use a persisten property because Android's various settings
stores are not available early enough to avoid a color change
during the boot animation.

Bug: 62238038
Test: Manual
Change-Id: I905435efe89b5e1c85fc8a396b7888de5c318a18
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
378053760f1d45e5a1767a7cbbb2b1183e3c0662 06-Jun-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Let the system process set the saturation boost"
8c6bbd63d8bb06197c671690268c49d20949d8cc 05-Jun-2017 Romain Guy <romainguy@google.com> Let the system process set the saturation boost

The display manager service will need to call this code early
in the boot process, but before the hardware test calling permission
check can pass (it depends on the order of initalization of other
services like sensors).

Bug: 62238038
Test: Manual (modified display manager service)
Change-Id: I46a673ba971e566a0b9e023005c41fa54603cd1f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e6b63e1ae12692327f7e46d5f10d6ade5a7bf192 30-May-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix layer count

When a layer is removed, mLayerCount is always decremented by 1 even
though the layer has children. This commit fixes that by making
sure mLayerCount is properly decremented, and makes sure that a
parent layer must be a valid layer in mCurrentState.

Bug: 37121786
Test: manually open and close Camera app
Change-Id: I5a3e18be41646b167b4d361dfe08db4d06e1c2d0
(cherry picked from commit 98f1c108b016dda77c808f3d099e7a45bdd70768)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1fdfea5a7bd07bde5814618dce7d385a939bc74d 02-Jun-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add saturation boost feature to SurfaceFlinger"
0147a17adb08a155e1d6f72e6ca5e794fc7f5cc4 01-Jun-2017 Romain Guy <romainguy@google.com> Add saturation boost feature to SurfaceFlinger

Bug: 62238038
Test: adb shell service call SurfaceFlinger 1022 f 1.5

The saturation boost will be set by framework to increase
the visual appeal of the sRGB mode. It simply modifies the
color transform matrix based on the supplied value (from
0.0 for black and white to 2.0 for 100% extra saturation).

Change-Id: I9832fbe0361acacc8b17300c37c006792c6c1618
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
38513f257a058d29775826b503e14bd770487df2 01-Jun-2017 Romain Guy <romainguy@google.com> Merge "Fix the build"
a96387361ca25f0e8a7cebc59827c5be4c95a457 01-Jun-2017 Romain Guy <romainguy@google.com> Fix the build

Bug: n/a
Test: compile
Change-Id: I39179d83ae748434dcfd2043143e7154053071d7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
efd096d780b4ee3e44e4c91ea4e935b2a7a0c1ac 01-Jun-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix layer count"
98f1c108b016dda77c808f3d099e7a45bdd70768 30-May-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix layer count

When a layer is removed, mLayerCount is always decremented by 1 even
though the layer has children. This commit fixes that by making
sure mLayerCount is properly decremented, and makes sure that a
parent layer must be a valid layer in mCurrentState.

Bug: 37121786
Test: manually open and close Camera app
Change-Id: I5a3e18be41646b167b4d361dfe08db4d06e1c2d0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8ec6ff22dc56e7447991557075d19f9edb2d5aa8 01-Jun-2017 Romain Guy <romainguy@google.com> Use wide gamut only when necessary

Set the dataspace of the screenshot based on the result of
the composition. When no wide gamut app is visible, the screenshot
will be in sRGB, otherwise in Display P3. On device that do not
support wide gamut, the color space will be unknown (native).

Bug: 29940137
Test: screencap and Android Studio
Change-Id: I93f3f8e5afebb9f3f17b835fdf5bc215b0856d55
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
88d37ddac876c75dd5d2e39d33787dbcbf833641 27-May-2017 Romain Guy <romainguy@google.com> Various fixes for wide color gamut rendering

This CL addresses multiple issues:
- A logic issue where the wide gamut color mode was not set at the right time
- The presence of scRGB surfaces was not detected
- The sRGB to Display P3 matrix was transposed
- The color matrix was applied in gamma space instead of linear space*
- The GPU code path was doing a division by w for each pixel when a
color transform is set, which shouldn't be necessary (the code now
checks that the matrix has the expected form)
- Incorrect comment
- Dead code in Description.cpp (mDirtyUniforms was never used)
- Screenshots were taken using the last render engine configuration,
the configuration is now properly set every time

* This can in theory cause a discrepancy when we switch to/from hardware
composer mode. I was not able to create a visible discrepancy in practice
using Night Light, color blindness compensation modes and color inversion.
More importantly, how/where the hardware composer applies the color
transform is not specified: it could be gamma or linear space, before or
after the hardware color LUT. We'll address this in a future CL if needed.
In addition, this code assumes that fp16 surfaces are encoded in non-linear
space (scRGB-nl instead of scRGB) but we do not have EGL/Vulkan extensions
to specify this behavior. We need to address this as well

This CL also fixes potential divides by 0 in the GPU code path.

Bug: 29940137
Test: CtsUiRenderingTestsCases, CtsGraphicsTestCases

Change-Id: I9ae15850f8b9d48c39ebc2724ca3da202be9b008
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bbdcf1f4fa87e942bae7ee9bbef0ecc9a786900d 23-May-2017 Kalle Raita <kraita@google.com> Remove GLES2Renderer dependency on config stores

Test: Builds, code search for RenderEngine::create
Change-Id: I7b5032f072d0fc468a8e0eba54035867c5bf74c4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
38d4961eb2c64288a6be252fdce9c40a133e45bd 12-May-2017 Matthew Bouyack <mbouyack@google.com> Fixes vsync behavior in power mode transitions.

Calling EventThread::onScreenAcquired enables hardware vsync and
calling EventThread::onScreenReleased disables hardware vsync.

The power modes 'NORMAL' and 'DOZE' should have hardware vsync
enabled while power modes 'OFF' and 'DOZE_SUSPEND' should have
hardware vsync disabled.

This change correctly handles the transitions from 'OFF' to
'DOZE_SUSPEND' and from either 'OFF' or 'DOZE_SUSPEND' to
'NORMAL'. Previously these cases were handled incorrectly.

Note that redundant calls to onScreenAcquired or onScreenReleased
are safe.

Fixes bug: 38232221

Change-Id: I7b00f97a67b157366364b3d26fe94533da07c263
(cherry picked from commit 4de4ee3cb3ccb3bcf4ea507f7bd6e02ab29aeb75)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
429fd15f0080379bebdf822d682bc96c8c6e1f16 11-May-2017 Dan Stoza <stoza@google.com> Merge "SF: Use last call time to rate limit resyncs" into oc-dev am: 2e252c93ac
am: 60954518c3

Change-Id: Ic03549017c29b05cae9363483b3e980723a3817d
2e252c93ac02ec7a6bfeab69ac2c200c53f35486 10-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SF: Use last call time to rate limit resyncs" into oc-dev
3defa56f66e5583189cbd56bfde8afc66fce83df 09-May-2017 Stephen Kiazyk <skiazyk@google.com> Merge "Prevent buggy display orientation when exiting vr" into oc-dev am: 95d4e52244
am: 71c79d34f7

Change-Id: I823d21b127cd9e90a536da7df3517f16812701c3
95d4e522448618edb42701f755e0ed768c13fa76 09-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Prevent buggy display orientation when exiting vr" into oc-dev
57164302da664fc58c3fd3c1ed9980bc1c9bdf1f 08-May-2017 Dan Stoza <stoza@google.com> SF: Use last call time to rate limit resyncs

SurfaceFlinger has a method which tells it to resync to hardware vsync
as long as it hasn't resynced too recently. This is used when we
receive a request for a Choreographer wakeup since if it has been a
while since we animated, we have likely drifted.

To determine whether we should actually resync or whether we should
instead rate-limit the call, we compare the current time to the last
time we drew, but this is problematic. When we first start animating
after a period of inactivity, this triggers a resync every time the
method is called until we receive the first frame and draw it, even if
we are already mid-resync, which delays the time until we can lock onto
the hardware vsync phase and has the side-effect of causing weird wakeup
times in both Choreographer and SurfaceFlinger.

This change instead keeps a local timestamp which is updated every time
the method is called and therefore effectively rate limits even before
the first frame is received.

Bug: 38117777
Test: ApiDemos/ListView + manual inspection of systraces
Change-Id: I7210594f9ed6ed5397bb0f3f14a8966503454643
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b6cc403149d8eaa2c892f8b999276d9463d73e8f 05-May-2017 Corey Tabaka <eieio@google.com> Merge changes from topic 'o-compositor-unification' into oc-dev am: 0e04fe4713
am: 21d661f3cc

Change-Id: I69641ef3f9792b0624dcba595cfd58ea97371fef
0e04fe47130add878c12ee4db3c8cf1931efdda8 05-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes from topic 'o-compositor-unification' into oc-dev

* changes:
Remove the VR compositor from the framework.
Remove unnecessary clients and rename files.
Support multiple consumer queues.
Return pdx::Status<T> from BufferHubQueue::Dequeue.
Add support for consumer queue initial import and hangup.
2251d822dac2a96aad4184a6fdc2690f0a58af7c 21-Apr-2017 Corey Tabaka <eieio@google.com> Remove the VR compositor from the framework.

Remove the VR compositor framework and enable out-of-process VR composition
in VrCore.

This CL seems large due to the ripple effect of changing the VrFlinger
API and protocol types. There are three major modules that require
concurrent changes:
1. Protocol definitions and low-level VrFlinger API in libdisplay.
* Additional changes needed to keep old interfaces working for
a short time while replacing the dependent code (dvrGraphics*).
2. VrFlinger service implementation changes to support VrCore compositor
and the removal of the internal compositor.
3. Changes to libdvr platform library API due to changes in #1 and #2.

Because of the nature of the interdependence of types and other defs it is
difficult to break this CL into smaller chunks. However, review of the three
major modules (libdisplay, libdvr, and libvrflinger) may be done separately
to ease the mental burden on reviewers.

Change Summary:
- Remove obsolete screenshot service. VR screenshots will be implemented
by VrCore.
- Update display protocol definitions for changes in VrFlinger service
requirements. The majority of the changes in libdisplay are a
consequence of these protocol and service changes.
- Update VrFlinger to support two kinds of surfaces:
1. Application - use by VR apps.
2. Direct - used by VrCore (protected by permission check).
- Remove VrFlinger internal compositor and GL context.
- Remove obsolete debug console.
- Update VrFlinger hardware composer interface to handle direct
surfaces only, removing the concept of GPU (compositor) layers.
- Update display manager to expose access to application surface info
to VrCore (protected by permission check).
- Update libdvr platform library interfaces for changes to VrFlinger
API / protocol.
- Clean up libdvr API struct setup using a common include.
- Add C++ header-only helpers for DVR platform library opaque types.

Bug: 36401174
Test: Build; run VrFlinger display test tool.
Change-Id: I15abfde5f72dbb3725a3f58621486afba6b64902
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8ca53743ce22a405ae24bece2781e4d657fb1152 05-May-2017 Tim Murray <timmurray@google.com> Merge "surfaceflinger: make EventThread FIFO" into oc-dev am: 0ad5feff27
am: f628d8f286

Change-Id: If5ed6ac496d39ccd8c8b5900ceb4b8e9cb63ff8b
22752851180b26f8d797b3fe5f7e99ad0eeaf7ee 04-May-2017 Tim Murray <timmurray@google.com> surfaceflinger: make EventThread FIFO

Jitter in EventThread scheduling was contributing to SystemUI jank.

Test: thread is FIFO
bug 36631902

Change-Id: I930c729b27403ef8941e9a1e0ef8ec57a3d323a0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3ee80d605bf83203ff546eeea71b37e42068d152 03-May-2017 Dan Stoza <stoza@google.com> Merge "SurfaceFlinger: Select which layer state to visit" into oc-dev am: 3e0a85b997
am: 4f98f7a3b7

Change-Id: Ib6a403c330c0b7f436abf8f1355b99bfe7e42e60
412903fce3a93f411c85c54375a1851bfb370400 27-Apr-2017 Dan Stoza <stoza@google.com> SurfaceFlinger: Select which layer state to visit

Modifies the traverseIn[Reverse]ZOrder methods to also take an enum
value specifying whether to traverse the current state or the drawing
state.

This has the effect of fixing a bug where we weren't performing
transactions on a child layer because its parent was only visiting its
drawing layers (rather than its current layers) and was thus skipping
the child, which had not yet been moved from current to drawing.

Bug: 36858924
Test: ChildLayerTest.Bug36858924 doesn't hang
Change-Id: I1959f40bc07e77864ba024511d429592a398a67a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ab702f5110628108de5f3611820d86b97852826f 19-Apr-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Log error when exceeding MAX_LAYERS count

This is not a fix, but logging to make it clearer
what's happening.
Test: for i in {1..1000}; do cts-tradefed run commandAndExit cts-dev \
--abi armeabi-v7a --no-primary-abi-only --module \
CtsOpenGLTestCases -t android.opengl.cts.EglConfigTest#testEglConfigs ; \
done
May take a while to run.
The log message below indicates an issue, most likely leaking layers.
Once b/3712178 is resolved, should not see this error.
AddClientLayer failed, mNumLayers (4096) >= MAX_LAYERS (4096)

Bug: 37121786
Also related to Bug: 30948621

Change-Id: I7ed931ae5433657bdc986edc66a9782ff08ed194
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5afdba8a2c694b512eb42eebb70713d63d4039e1 21-Apr-2017 Mike Stroyan <stroyan@google.com> Merge "Defer surfaceflinger composition until data latch" into oc-dev am: 09e897b415
am: d9d704766f

Change-Id: I520d9107f8874612e7c32e115cbdf126f0508126
0cd7619bce422d46a5f2c45ca97734ae467a1b01 20-Apr-2017 Mike Stroyan <stroyan@google.com> Defer surfaceflinger composition until data latch

If layer data is not yet ready, latchBuffer will return an empty region.
SurfaceFlinger::handlePageFlip will now check if any layer has a queued
frame which succeeded in latching data.
If no new frame is latched, handlePageFlip will return false.
That will defer refresh until the next vsync.
That reduces HWC and GPU load, improving framerates.
It prevents dEQP tests from timing out on some devices.

Test: dEQP-VK.wsi.android.incremental_present.scale_down.fifo.reference
Bug: 37439915
Change-Id: Id46c82f79953f3a147af77bb0e8e81a395c606b3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8a43fe6af02580b52d7f0b3947b40a9942f7fb86 17-Mar-2017 Zheng Zhang <zhzh@google.com> SF: disable HW vsync while dozing

It cancels any in-progress resync when display goes to sleep, then
it avoids any unexpected wake up due to delayed frames once device
has just switched to ambient mode.

In DOZE_SUSPEND, screen displays a still image in a self-refresh mode,
so there is no need to keep aligned with HW vsync. At the opposite, DOZE
mode is used to refresh the screen in Ambient (i.e. watchface refresh,
nofications, app updates in ambi-active), hence resync SF to HW vsync.

Bug: 35998607
Bug: 36215242
Change-Id: I22cd8f84e9aca04b4f657fe07785751cf31a7c68
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b87e75de6192643ee6abbf87619ff04ce3f4cafd 15-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Avoid a potential race condition on mDisplays" into oc-dev
82386cd4eb194a9bf4b8688cb02317909ba346e0 14-Apr-2017 Stephen Kiazyk <skiazyk@google.com> Prevent buggy display orientation when exiting vr

The underlying issue is that the viewport settings were being re-set to
(0,0,-1,-1) on every transition to VR. I've instead extracted the vsync
period updates, and only apply those, as that was really all we wanted
out of it.

Bug: 37093920
Test: Compile and run Vr application. The 2d scene is now no longer in
the weird landscape viewport with portrait orientation if the phone is
in landscape when exiting VR mode.

Change-Id: I2bab6e4d834e15f477d1b56991375d1a18a77b8c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5d6d98a1dff7a6de2ea89f5098af0b77e1d5c36a 14-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Release virtual display hwcId during vr mode transition." into oc-dev
7d3dcb9235ec149af2f5139a8a9c6eac859d92e2 06-Apr-2017 Stephen Kiazyk <skiazyk@google.com> Avoid a potential race condition on mDisplays

I've now run this on a HWC1 and HWC2 build. Both appear to be running
correctly.

Original Message:

The race could occur when transitioning in/out of VR flinger mode.
It is now avoided by ensuring that the primary |DisplayDevice| is always
created once |mStateLock| is released, and ensuring that all accesses
to the primary |DisplayDevice| are guarded by |mStateLock|.

Bug: 36194616
Bug: 37249613
Bug: 37288476

Test: Compiled, installed, and ran with both HWC1 and HWC2 variants.
HWC1 was tested on Nexus 6P. Was able to boot, install apps, run apps,
turn screen on/off, and reboot phone.
HWC2 was tested on sailfish. Was able to boot, install apps, run apps,
run VR apps using both N path, and O1 path, turn screen on/off, and
reboot phone.

Change-Id: I0e80c2553f40cce2116b718bbb0d2566679f794a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0556d79eacbf0c9978080d87aa4075120533c7ef 22-Mar-2017 Mathias Agopian <mathias@google.com> get rid of IGraphicBufferAlloc

Buffers can now be allocated directly through
the graphic allocator HAL.

Test: marlin: run full camera cts
Test: angler: take screenshot, take photo w/ and w/o HDR, video, panorama, refocus, slo-mo
Bug: 36462585
Bug: 36333314
Change-Id: Ie5222c53c3b9462e0ac7a41568718aad131eb328
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c90e469393493ff2dbb96a60abf1c828d9da2012 13-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Revert "Avoid a potential race condition on mDisplays"" into oc-dev
8722a310c00557195a0703e95564f31d908ab2d5 13-Apr-2017 Tomasz Wasilczyk <twasilczyk@google.com> Revert "Avoid a potential race condition on mDisplays"

This reverts commit 8d6c16dc3dc8b88a0046f53668a4e3be074507ff.

Bug: b/37282502
Change-Id: Ibf64607f9e14ede201510e2c1b502c49a31e9f2a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
430f8eae67ff20c53dd834695fc3259b7eca9093 13-Apr-2017 Ian Elliott <ianelliott@google.com> Merge "Only enumerate display_timing when present timestamp supported" into oc-dev
7dcda8011de1753b0d9f4bf640733f83db601cec 13-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SurfaceFlinger: Add parent-less relative layering." into oc-dev
5c34de2c12ab2638fd6b16f1b77dedd0ffa3ab27 10-Apr-2017 Ian Elliott <ianelliott@google.com> Only enumerate display_timing when present timestamp supported

Test: CTS and cube demo.
Bug: 36887025

Vulkan should only enumerate the VK_GOOGLE_display_timing extension if
the device supports reliably returning the present timestamp. Vulkan
will determine this by reading a property that SurfaceFlinger will set
(based on the HWC2::Capability::PresentFenceIsNotReliable capability).

Change-Id: I6025be5f9120a8f02f228b8437b64be4ff8cfb17
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
21d072ac4a4f67b89c465121ace7a9764872aef0 12-Apr-2017 Brian C. Anderson <brianderson@google.com> Merge changes from topic 'presentFenceNotReliable' into oc-dev

* changes:
egl: Use reserved values for eglGetFrameTimestamps
egl: Differentiate pending vs invalid timestamps.
egl: Avoid use of retire as present
da8490da6221ba2a8762fa04f863bddb4088d587 12-Apr-2017 Alex Sakhartchouk <alexst@google.com> Release virtual display hwcId during vr mode transition.

When we recreate the display state during VR mode transition, we were not
previously releasing hwcId with vr hardware composer. That resulted in VR
using the only VirtualDisplay provided by vr_hwc during the first run.
Every subsequent run failed to allocate a new hwcId id.

This manifested itself when DON (device on) flow quickly kicked the device
into and out of VR mode. Normally the binding is cleaned up when java
frameworks destroy the VD upon exiting VR mode, but it does so with a
short delay to account for rapid in/out transition, during which the
hwcId was getting left behind.

Bug: 34281731
Test: Run VR app, launch 2D app in VirtualDisplay, see it on the screen.
Close VR app, exit to 2D mode, repeat and observe 2D app in VR again.

Change-Id: I8faabdcd3516190ad88d1361c468f7f472ead588
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
db66e627ad8904491e384c64f82fc77a939b9705 11-Apr-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Add parent-less relative layering.

This is a temporary functionality for the intermediate state where not
all child-surface like things in WM land are ported to use Child
Surfaces. In particular, we have ported SurfaceView to use child
surfaces and relative Z ordering. However the TV frameworks provide a
View framework component which overlays views over the SurfaceView but
below the main application window. Since we have not ported View
framework surfaces to use child layers, there is nothing the WM or
View Framework can do about this situation. Luckily the WM API's to
have requested this are @hide but we have the one media framework
component using it. In order to solve this issue we provide a method
to set Z ordering relative to another window without inheriting
its coordinate space as a child window would. This way the WM can
recognize these TYPE_APPLICATION_MEDIA_OVERLAY windows and Z-order
them at -1 with respect to the parents (and the SurfaceView can be at
-2).

Test: Included in transaction tests. Also manual test of bug repro steps with accomp frameworks/base CL
Bug: 36693738
Change-Id: I921852d3d34f67f79ec745b9703f9e679867e7a1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6b376713907086c9642e7b7e66e51ddfa531b003 04-Apr-2017 Brian Anderson <brianderson@google.com> egl: Avoid use of retire as present

Retire fences from HWC1 are implemented inconsitently,
so present emulation doesn't always work well.

This patch disables present for all HWC1 based devices.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Bug: 36730849, 36887025

Change-Id: I1eba2f8490c2f6feced2a36d1efc4cd66be7da40
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8d6c16dc3dc8b88a0046f53668a4e3be074507ff 06-Apr-2017 Stephen Kiazyk <skiazyk@google.com> Avoid a potential race condition on mDisplays

Update: The HWC1 path needed to be updated in light of a change to
SurfaceFlinger.h. The build now works for both paths.

Original Message:

The race could occur when transitioning in/out of VR flinger mode.
It is now avoided by ensuring that the primary |DisplayDevice| is always
created once |mStateLock| is released, and ensuring that all accesses
to the primary |DisplayDevice| are guarded by |mStateLock|.

Bug: 36194616
Bug: 37249613
Test: Compiled for both HWC1 and HWC2 surface flinger builds.
Normal behavior is unchanged. Explicitly testing the race
condition required instrumenting code with sleep statements.

Change-Id: I0b00e857a3b2fd01948a888db2f0715d2a8204c1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
80c02320c49f5f6e1cb2651620fa31de551502a7 10-Apr-2017 Polina Bondarenko <pbond@google.com> Revert "Avoid a potential race condition on mDisplays"

This reverts commit 5576a555a14edd8c76addce2cee37b9b9ced2c3f.

Change-Id: I5d5889fccd94acacfbfef29847e4b65ef2543c75
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5576a555a14edd8c76addce2cee37b9b9ced2c3f 06-Apr-2017 Stephen Kiazyk <skiazyk@google.com> Avoid a potential race condition on mDisplays

The race could occur when transitioning in/out of VR flinger mode.
It is now avoided by ensuring that the primary |DisplayDevice| is always
created once |mStateLock| is released, and ensuring that all accesses
to the primary |DisplayDevice| are guarded by |mStateLock|.

Bug: 36194616
Test: Normal behavior is unchanged. Explicitly testing the race
condition required instrumenting code with sleep statements.

Change-Id: I1f8fcf23982c311d47267beca8127b6c29562ce5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f3b2de10caa2a96e65f3e8ebecb2730ff28aeeb1 27-Mar-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Dump info about wide-color

Test: adb shell dumpsys SurfaceFlinger
Look for section titled "Wide-Color information:"
Bug: 29940137

Change-Id: I2bd642aa026b49bbb9effd5cb1687c7a36dae684
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5d94389241cc651e6bd327ab80eba3ad476f3724 22-Mar-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Add wide-color support to SurfaceFlinger

Test: manual testing
Bug: 29940137

Change-Id: I9358b3c982e0205e598fd20cbf8d2e956591b3ac
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c3bae03442d8e7e9f46b3cf754d51a738a40f4a9 02-Apr-2017 Cody Northrop <cnorthrop@google.com> Merge "surfaceflinger: Generate unique layer names" into oc-dev
bc7552874052ee33f1b35b4474e20c003d216391 31-Mar-2017 Cody Northrop <cnorthrop@google.com> surfaceflinger: Generate unique layer names

Add a counter to layer names to make it clear when there are duplicates.

layer foo#0
layer foo#1
layer bar#0
layer bar#1
layer bar#2

Bug: b/32543755
Test: Build, install, run game with duplicate layers, see unique names.

Change-Id: I915531d7adbdc506c429b86a685665fb6c56d25e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5cee136dd4f9ee18ea600f0dc6e6f45f786cd097 26-Mar-2017 Alex Sakhartchouk <alexst@google.com> Allow VirtualDisplay's to use hardware composer when in VR mode even if
physical composer does not support them.

Bug: 36071574
Test: Applied remaining wip patches, launched 2D activity while in
persistent VR mode. Observed 2D activity rendered in VR in VirtualDisplay.
Further, instrumented SurfaceFlinger code to ensure DisplayDevice's are
created and destroyed with proper composers during VR mode transition.

Change-Id: I12b09f1209fcf33f97abfd77e14c6ce61f45a5e9
(cherry picked from commit d38ec4e294eadd4f655476fc90b675c78c1c8740)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8d5227b8416b099c884429312daf2d60496fa484 16-Mar-2017 Robert Carr <racarr@google.com> Include finalCrop in setGeometryAppliesWithResize.

A refresher on this archaic function. Normally window crop and
position apply immediately. This is so the window manager can always
crop surfaces (e.g. while docked resizing) even if the app is lagging
behind. In some cases though the apps position or cropping may depend
on whether the resize has occured or not. For example when an app
gains shadows, we need to move expand the Surface and move it by a
negative offset for the content to remain in the same place. This
movement needs to be synchronized with the buffer latching for the
expansion.

We implemented setGeometryAppliesWithResize to take care of this. At
the time it wasn't clear if it was needed for finalCrop so we let it
be. Now that we are exclusively using final crop in the pinned stack
however it is required. The same way we have an issue with position
and shadows, we have an issue with expanding the crop rect (we may
have actually been cropping out part of a larger surface that is now
supposed to be shadows).

Also includes a test suite for setGeometryAppliesWithResize behavior
which was previously untested.

Bug: 35396882
Test: SurfaceFlinger_test
Change-Id: Ie4d32162eb21154496bb231161692d18341a1e1e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1971b63aa4d82db37794f19e0eb01feb1826e422 10-Mar-2017 Fabien Sanglard <sanglardf@google.com> Use max acquired buffer setting to configStore

Change-Id: I48454243bcac12f5a83d080cd9115686f9f728ca
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4d8f53906fa71ab3850e0fbdb62573b7b1f90deb 21-Mar-2017 Steven Thomas <steventhomas@google.com> Merge "Revert "Revert "Tie vr flinger to persistent vr mode"""
d8ab4396a858a9c929a1bb3cadf7705fb8061574 21-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "egl: Remove retire event."
050b2c83304bd16ec3a838da08b6ba6acf6a3af4 06-Mar-2017 Steven Thomas <steventhomas@google.com> Revert "Revert "Tie vr flinger to persistent vr mode""

This reverts commit 7480c060cb3466d97ec3125d61bbace153f534c8.

Transfer display control to vr flinger when persistent vr mode is
entered, rather than when vr mode is entered. This allows cardboard
apps, which will invoke vr mode but not persistent vr mode, to work as
in N.

This activates vr flinger at device boot for Daydream ready devices,
which fixes an issue where an app would attempt to create a surface
before vr flinger was running, which would hang indefinitely.

The VrManager listener for persistent vr mode is put in vr flinger
instead of surface flinger. This is cleaner since the vr interaction
with the rest of the device is now consolidated in vr flinger.

While testing I encountered a problem where vr flinger was given control
of the display but vsync was turned off, causing vr flinger's post
thread to hang. I changed the vr flinger logic to give control over
vsync and other display settings to the post thread, and took the
opportunity to further simplify and improve vr flinger's thread
interactions.

Bug: 35885165

Test: Manually confirmed that when persistent vr mode is not invoked we
get the N-based render implementation, and when persistent vr mode is
invoked we get vr flinger.

Change-Id: I3b5ad599cc0748e38b861c714c4cc3118f854acf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7480c060cb3466d97ec3125d61bbace153f534c8 21-Mar-2017 Jin Qian <jinqian@google.com> Revert "Tie vr flinger to persistent vr mode"

This reverts commit f43d13e4e35ae7d3cdafc4b97c819669d42cef78.

Change-Id: Ib67db8e51b7ea2dbbe6faccce36962bf5b44a6e2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f43d13e4e35ae7d3cdafc4b97c819669d42cef78 06-Mar-2017 Steven Thomas <steventhomas@google.com> Tie vr flinger to persistent vr mode

Transfer display control to vr flinger when persistent vr mode is
entered, rather than when vr mode is entered. This allows cardboard
apps, which will invoke vr mode but not persistent vr mode, to work as
in N.

This activates vr flinger at device boot for Daydream ready devices,
which fixes an issue where an app would attempt to create a surface
before vr flinger was running, which would hang indefinitely.

The VrManager listener for persistent vr mode is put in vr flinger
instead of surface flinger. This is cleaner since the vr interaction
with the rest of the device is now consolidated in vr flinger.

While testing I encountered a problem where vr flinger was given control
of the display but vsync was turned off, causing vr flinger's post
thread to hang. I changed the vr flinger logic to give control over
vsync and other display settings to the post thread, and took the
opportunity to further simplify and improve vr flinger's thread
interactions.

Bug: 35885165

Test: Manually confirmed that when persistent vr mode is not invoked we
get the N-based render implementation, and when persistent vr mode is
invoked we get vr flinger.

Change-Id: Ieeb8dabc19e799e3179e52971f3b63f5a8f54b3b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
757b4ec4b453cd8e58b4d67d8ac79a73a1046bbd 18-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix getFrameTimestamp test flakes."
cbf153bedf2eafc1443bbc97c4e74f97e7973edd 11-Mar-2017 Fabien Sanglard <sanglardf@google.com> Use hasSyncFramework value from configStore

Change-Id: I41c6b1a26001eb6ba08cbc419dc8a683f5722aa3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4e606e3901b500bdd0f3ea21b8cb63734087bf0a 16-Mar-2017 Brian Anderson <brianderson@google.com> egl: Remove retire event.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: Ibf63d22e42ae52307662107eec50f80de0e703f5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c8e387edfcead55b6e6fb1d05db279c264b644fa 10-Mar-2017 Fabien Sanglard <sanglardf@google.com> Use configStore for maxVirtualDisplay Size

Test: Manual and AUPT
Change-Id: I17ec13f782a7c7c693d84d11c9b5e87624ee71d0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8c02341c732956b282f11744501cc6a97ac165dc 17-Mar-2017 Fabien Sanglard <sanglardf@google.com> Revert "Use configStore for maxVirtualDisplay Size"

This reverts commit 56a5dbd3b050cbfd324308d224c7d12f4aec3320.

Change-Id: I66224bb48d3146846200ff7f2d5a66d1d8ff5cf7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
56a5dbd3b050cbfd324308d224c7d12f4aec3320 10-Mar-2017 Fabien Sanglard <sanglardf@google.com> Use configStore for maxVirtualDisplay Size

Test: Manual and AUPT
Change-Id: Iefc09b06ab473c4029756279920135761547dd65
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a34ed639c3057b99da0fb703beb12827e30aa508 14-Mar-2017 Fabien Sanglard <sanglardf@google.com> Use forceHwcCopyForVirtualDisplay in configStore

Test: Manual
Change-Id: Ie6f816cf8f48b1cca41d51f40e9f0ae49aef2908
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d001058145c2186f454a3fb043388d6d9b84c9d8 07-Mar-2017 Brian Anderson <brianderson@google.com> Fix getFrameTimestamp test flakes.

This fixes both the dEQP CTS flakes relating to
compositor timing and the lib_gui test flakes that
don't initialize properly.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Bug: 35995043

Change-Id: If8e59f0dc9a916bab28bd1a36190cef9a56cb64f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f9e6033ea896e43d962a81c13d2b65d952955450 16-Mar-2017 Romain Guy <romainguy@google.com> Merge "Revert "Get rid of IGraphicBufferAlloc""
f8b4ca51111cd2e566d1774ac464da859db78976 16-Mar-2017 Romain Guy <romainguy@google.com> Revert "Get rid of IGraphicBufferAlloc"

This reverts commit 78491c9f694cb0767996503c629776a8eda950d7.

Change-Id: I78d5c0a30ab80265f697f681387872b6763b2d1e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d4639b1eae0d934ad47b260315416fb7b8026a50 16-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Get rid of IGraphicBufferAlloc"
78491c9f694cb0767996503c629776a8eda950d7 15-Mar-2017 Mathias Agopian <mathias@google.com> Get rid of IGraphicBufferAlloc

This reverts commit 527747dce1ab4714bd424e5c1a25ebad3506c2cb.

selinux policy allowing this change fixed.

Test: took a screenshot
Test: ran ImageReaderTest CTS
Bug: 36194109
Change-Id: I72ac17b6c252750aa2a66cd1d94bd8b4e21b5e9d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c45a7d9dfdefa07512c5acc07bcbee5362b34e3d 14-Mar-2017 Fabien Sanglard <sanglardf@google.com> [SF] Use presentTimeOffset from configStore

Change-Id: If9c872c565e68e8abe552ee11d2c7d48f44aec4b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
db910d4906667019de79eec44b1873bd8c2f2437 15-Mar-2017 Fabien Sanglard <sanglardf@google.com> [SF] Delete unused NEVER_DEFAULT_TO_ASYNC_MODE

Test: AUPT
Change-Id: I0abbbdcbd2a7ccb2b60514b54e600eb9489dc6a4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bd7ba140b3898f2a3a671311744600fb60b40053 15-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "[SurfaceFlinger]Use configStore useContextPriority"
c93afd54a05497c4ae42db99ea0310ee69cca492 13-Mar-2017 Fabien Sanglard <sanglardf@google.com> [SurfaceFlinger]Use configStore useContextPriority

Change-Id: I329b5da0e92822eb0878c8866c8ab87ea13f7e07
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
975e49a2ae848ef7d2b9d9ad8ea1afad656f037b 13-Mar-2017 Chia-I Wu <olv@google.com> Merge "Revert "get rid of IGraphicBufferAlloc""
527747dce1ab4714bd424e5c1a25ebad3506c2cb 13-Mar-2017 Chia-I Wu <olv@google.com> Revert "get rid of IGraphicBufferAlloc"

This reverts commit 1da94dfed674e94edc37cdc8ef68530520edf169.

Bug: 36176799
Bug: 36175706
Change-Id: I6dd5fe8df564f0efa4392a800fb316e27a05076e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3e3474eaadc5a1ed345bb866f1469e5a4658327e 10-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Re-add mistakenly removed lock in SurfaceFlinger::removeLayer."
4e67f0f8c13c4777bccbcd527ff18584c3ccc93a 10-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "[SurfaceFlinger] Use sf phase offset from CS"
7f9b899c33c5d69597bc676c0bee828819c97a0f 10-Mar-2017 Robert Carr <racarr@google.com> Re-add mistakenly removed lock in SurfaceFlinger::removeLayer.

Lock was mistakenly removed with "Add detachChildren transaction"
when refactoring the weak-pointer to a strong-pointer.

Test: I will try and follow up with a stress-test in Transaction_test.
Bug: 36117490
Change-Id: I94171c86334bb52b974392186e1c3ebbf9f33a05
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1da94dfed674e94edc37cdc8ef68530520edf169 28-Feb-2017 Mathias Agopian <mathias@google.com> get rid of IGraphicBufferAlloc

buffers can now be allocated in-process.

Test: compile & run
Bug: cleanup
Change-Id: I3d4317a9bed20a6d8be2b7ac8fbb85738efb3657
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0cc1938871edd6659d6783404a3523abc6b98d92 06-Mar-2017 Fabien Sanglard <sanglardf@google.com> [SurfaceFlinger] Use sf phase offset from CS

If present, use sf phase offset from the config Store.

Test: Manual
Change-Id: I2dd7ecf984b7484f6b447699680f54c7c8e221a0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
10012f0ce0c06ad56459a41aabef682d0b1b06d0 07-Mar-2017 Fabien Sanglard <sanglardf@google.com> Merge "[SurfaceFlinger] Comment SurfaceFlinger HWC2"
801ea093b0e923a61b832f2adba698a273479880 07-Mar-2017 Mathias Agopian <mathias@google.com> split libsensor our of libgui

Test: compile & run
Bug: treble cleanup
Change-Id: I5b2c2a14f7d3b364d25695cf0901c5b08cfb0fc9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8226051f627aa976700885cda28c26c5a5b8bc7b 03-Mar-2017 Fabien Sanglard <sanglardf@google.com> [SurfaceFlinger] Comment SurfaceFlinger HWC2

Document decision to clear SurfaceFlinger HWC2 state upon sleep and
awake.

Test: This is just a comment.
Change-Id: I0034d8d79e6e0d5b6287579d23f941e291c89bc0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e9c0475b74553a9d478a3ff14bc849f8312fe457 03-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix black screen upon awake (reused after free)"
8f35e15dd65b92bc35116a025bd5f31299fe87c2 03-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Delete unused variable in setUpHWComposer"
06a76c022fcb87602e160ffa97b26a27cc1a5481 03-Mar-2017 Fabien Sanglard <sanglardf@google.com> Fix black screen upon awake (reused after free)

Under a specific timing, the state of the HWC can be left populated
with "old" layers. If a Refresh Message comes before the WM sends
a Transaction resetting the layer, the old layers are sent to the
HWC. These old layers features buffer_handle which had been freed,
resulting in a frame never signaling and a locked screen due to
backpressure triggering constantly.

Detailed explanation:

When the device power off is pressed, the WM plays the fadeout
animation, set the layer "fadeOut" to displayId -1 and calls
setPowerMode(Off). This sequence of events leads to a state where
no layers are deemed visible in surface flinger but the HWC2 still
has one.

Upon awakening the device, if a Refresh message is received before
the WM has the time to reset fadeOut layer displayId to its original
value, the HWC2 will use its last known state.

Sequence of events (with and without crash):

Put device to sleep.
Awake device.
PowerOn
Refresh <- crash

Put device to sleep.
Awake device.
PowerOn
Transac
Refresh <- Ok

Bug: 35712353
Test: AUPT (100 cycles sleep/awake without black screen lock)
Change-Id: If9177ccc0627f3b733030ed5e462dc465e63e963
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
67a98056133b6930261ffd8b8826b1d1d8154403 03-Mar-2017 Fabien Sanglard <sanglardf@google.com> Delete unused variable in setUpHWComposer

Test: AUPT and Manual
Change-Id: I53fbd7f9fa83b8729554a021be526a5fb71e2b13
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3a8f794471815e6419caefe254adf2bbb19a8a53 03-Mar-2017 Mark Urbanus <urbanus@google.com> Tie VR mode support to a property

Bug: 35854545
Test:
- Validate VR mode is not supported when ro.boot.vr is unset
- Validate VR mode is supported when ro.boot.vr is set

Change-Id: I26f7e851766eab0d8a5a2f9fb4d72bfcee0c42f3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
77c073bdbe1b24a332056e1194a6162b7717a848 01-Mar-2017 Rob Carr <racarr@google.com> Merge changes from topic 'surfaceview-without-wm'

* changes:
Add detachChildren transaction.
Add deferTransaction variant taking GraphicBufferProducer.
6961b6bc1f6f172745deee98e7dcb34a3668e4e6 01-Mar-2017 Mathias Agopian <mathias@google.com> Remove unneeded references to IMemory

Test: compiled & run
Bug: cleanup
Change-Id: Ifef6695275f244a420df574b3bc49adb99c93fbf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
764881145a75987d3e832aa0b850d8ed381e7cca 27-Feb-2017 Jeff Sharkey <jsharkey@android.com> Revert "Refactor SurfaceFlinger::rebuildLayerStacks"

This reverts commit 3beb7117d247c64c5d9d3a7e6df7eecdd9523711.

Bug: 35801498
Change-Id: Ife431b19f3aef21cbe07863ca2964b2a40677dbd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b665cd388c787d750e5b9282c64208d77fbceaf2 27-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Adjust traces to diagnostic of HWC2on1Adapter"
5c3c77623b9841998ad418ab54043d34e10b9748 27-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Refactor SurfaceFlinger::rebuildLayerStacks"
9524cb3b37a91b5741790c77ff24fd825b02bca7 13-Feb-2017 Robert Carr <racarr@google.com> Add detachChildren transaction.

Add SurfaceControl#detachChildren for use by the WindowManager.
This method is used in cases where the WM would previously preserve
windows the client tried to destroy. For example, when becoming invisible
(in the activity lifecycle sense, not in the SurfaceFlinger sense)
an app will destroy its child surfaces. Previously the WM would keep child
windows alive until the animation finishes to prevent glitches. The new
scheme for this is the WM will detach the children at this point,
at which point the parent layer becomes the owner of the children and the WM
can control the lifecycle as it wishes. I also included a test for reparentChildren
as I realized I had forgotten that.

Test: New test in Transaction_test.cpp
Change-Id: I79c22b2ccccceb9bdcc37b70c491bdf33dcf83d2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0d48072f6047140119ff194c1194ce402fca2c0b 11-Jan-2017 Robert Carr <racarr@google.com> Add deferTransaction variant taking GraphicBufferProducer.

For SurfaceView using child layers, the client framework
will not have access to the Handle* for the parent surface,
but still needs a way to defer transactions to it's frames.

Test: Tested with corresponding SurfaceView modifications and existing tests.
Change-Id: I6f01c360e85a95ff0ab08db406741221152e5d5c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3beb7117d247c64c5d9d3a7e6df7eecdd9523711 25-Feb-2017 Fabien Sanglard <sanglardf@google.com> Refactor SurfaceFlinger::rebuildLayerStacks

Reduce indentation with early return

Change-Id: Ic3a16bf45a0c1792b0fcbd5d9d1cd9f1e239ae32
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
af5b6b814119151985d27d6edde7917cfb1e8d45 23-Feb-2017 Fabien Sanglard <sanglardf@google.com> Adjust traces to diagnostic of HWC2on1Adapter

Change-Id: I0110fac372791bec657521522de3e08907f465f7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
209beca0f051ff56654c2027f2e281c8a73d1686 23-Feb-2017 Mark Urbanus <urbanus@google.com> Create VR HWComposer without locks held

Problem:
Surfaceflinger is occassionally deadlocking when switching to VR Mode.

Root-cause:
During the creation of the VR HWComposer through hwbinder,
hwservicemanager notifies surfaceflinger the service is available through a
binder callback. Because Surfaceflinger holds the state-lock during the
HWComposer creation, its possible all of SurfaceFlinger's binder threads are
handling other transactions waiting for the state-lock to be released.
This prevents the hwservicemanager callback ever to be handled resulting in
a deadlock.

Solution:
Don't hold the state-lock when instantiating the VR HWComposer.

Test: Validated deadlocks no longer occur when switching to VR mode.
Bug: 35680107
Change-Id: I932c81fce293a8b57983f4242432b87522ce964c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
136e2f6570d68e86dca1b2bfa23fc61abcee149e 09-Feb-2017 Robert Carr <racarr@google.com> Remove erroneous log message

It seems we always get a duplicate remove from the layer-cleaner
so this was showing up any time any layer was removed. We didn't have
this message before the child layers CL so lets get rid of it quickly.

Test: Deleting a line of logging code. It builds!
Change-Id: I16cc0c0b325e43d36cae684b06a93c099baa1aa6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f810b29ebc8564f94ff7fb14f2d13a0f4d111703 17-Feb-2017 Brian C. Anderson <brianderson@google.com> Merge changes from topic 'GPU_replace_GL'

* changes:
Fix unexpected FrameEvents on BufferQueue reconnect
Add FrameEvents::isValidTimestamp
Change GL references to GPU for getFrameTimestamps.
Clean up FrameTimestamp log messages.
5297807559ce3e5f217d3aba988a240aa4f25f57 16-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "surfaceflinger: disable VR mode while SELinux issues are resolved."
125c3ae33e284b09dede27a7e01b0b51d0653227 16-Feb-2017 Jaesoo Lee <jaesoo@google.com> Merge changes from topic 'cfg_nsfbuf'

* changes:
configstore: removing BoardConfig variables (NUM_FRAMEBUFFER_SURFACE_BUFFERS)
configstore: use utility functions defined in ConfigStoreUtils.h
ce2c1983bb6b272b4b1377dedddc429b78249226 16-Feb-2017 Corey Tabaka <eieio@google.com> surfaceflinger: disable VR mode while SELinux issues are resolved.

Temporarily disable VR mode support while SELinux policy issues are
rectified.

Bug: 35319396
Test: build; flash; run
Change-Id: I218afb6f9bff21980de184596471f8ec673af2e6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b04c6f03a2334b03ae0105ec005aeecfa61f4a90 21-Oct-2016 Brian Anderson <brianderson@google.com> Change GL references to GPU for getFrameTimestamps.

Test: Rename only.

Change-Id: Idaf7ab38f78f58aa8387823f47dac084e21eb1f0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4351857c9de86df9f418b3df28aebb1239ca35dd 23-Jan-2017 Jaesoo Lee <jaesoo@google.com> configstore: use utility functions defined in ConfigStoreUtils.h

This change modifies existing implementation to get config values via
configstore by using utility functions defined in ConfigStoreUtils.h.

Specifically, as an example, the utility function getInt64() is used
for vsyncEventPhaseoffsetNs defined in ISurfaceFlingerConfigs.

Design doc: go/design-confighal
Bug: 34724435
Test: build, run

Change-Id: I82a9371a84902c1e185d619d77e4c2e3272f84db
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9f02435fd44c0651c85e9bd4dc7307bc6b1a85fa 15-Feb-2017 Brian C. Anderson <brianderson@google.com> Merge "EGL: Add eglGetCompositorTimingANDROID."
0a61b0c813f5991bf462e36a2314dda062727a10 07-Dec-2016 Brian Anderson <brianderson@google.com> EGL: Add eglGetCompositorTimingANDROID.

Exposes the composite deadline, composite interval, and
the composite to present latency.

A history of composite and present fences are stored.
When the present fence's timestamp becomes known,
the composite to present latency is updated with
sampling jitter removed.

The values are updated in the producer when timestamps
are enabled and on queue and dequeue.

The deadline is snapped to the next expected deadline
based on the current systemTime().

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I406814258613b984b56488236632494f2f61ff2e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3cfac28462910d3f976aebac54ac7301aca7e434 06-Feb-2017 Steven Thomas <steventhomas@google.com> Ignore callbacks from the non-active hardware composer

Ignore callbacks from the non-active hardware composer so we don't get
e.g. duplicate vsync callbacks, one from each composer.

Bug: None

Test: Manually confirmed with logs we're now ignoring callbacks on the
non-active composer.

Change-Id: I8b475d6283d86c64ff96b41e78528bce8c6ff1d3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fe37b77efae4dc10c1a5bdaec4127cdf8d182bfb 10-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix boolean logic in SurfaceFlinger property read"
bb5afada05e597b8a74e3888863319c319c3c944 10-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Disable Virtual Display by default in SF"
87670ffe26079eb50b62f698eb0f7bfa8ee51deb 01-Feb-2017 Hendrik Wagenaar <hendrikw@google.com> Allow surfaceflinger to run vrflinger

* Allows surface flinger to switch in and out of vr mode

Bug: None
Test: Manually ran various vr test programs.
Change-Id: I15fbba0eb67cbcffeef41be31429550448a1db9c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
642b23d70f7b513e88680c1d8400c1c1cfe6edd3 09-Feb-2017 Fabien Sanglard <sanglardf@google.com> Disable Virtual Display by default in SF

These should be enabled by default once b/30022738 is resolved.

Change-Id: I70a48a0bcf98ca984a28aa130170270d16e708bf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c65dafa95467f52e7f65350b38e94ab217c008da 07-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix boolean logic in SurfaceFlinger property read

Test: AUPT
Change-Id: Ib1db9198f470d62db1efa77193bf9e5f47b8a4b8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e8b5536c591ee74709f87e46cc98dee21cc0b03e 07-Feb-2017 Fabien Sanglard <sanglardf@google.com> Merge "Revert "Enable TripleBuffering on SF by default""
4e06b00ae85155117f4456c0beaa17175670f501 07-Feb-2017 Fabien Sanglard <sanglardf@google.com> Revert "Enable TripleBuffering on SF by default"

This reverts commit f222b2e6f4a3c26d6d2d9e3dd9056e5c95d7bc9c.

Change-Id: I300e46c9e93840fde85471eed4e5f7d10dde9b43
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
97a83762413be0d255841d6abaf6c1f474ce5364 07-Feb-2017 wyau <wyau@google.com> Merge "SurfaceFlinger supports ClearClientTarget for Sideband" am: 6560727f37 am: adde06b9e8 am: 1f94c41f83
am: d7a4a56b37

Change-Id: I6be4ced0d5779f319976f8f24fc446c3473d0428
1f94c41f8332c1ff51e6531bae01dc5880529d09 07-Feb-2017 wyau <wyau@google.com> Merge "SurfaceFlinger supports ClearClientTarget for Sideband" am: 6560727f37
am: adde06b9e8

Change-Id: I68e33ab1173bbae30e8d22ae86397ec081051f7f
39fe1d879cc2e55d4d3c3f7445977c674b97c472 06-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Enable TripleBuffering on SF by default"
267ab79b22f9d0b995ff787e36aca9c39497c489 11-Jan-2017 Gray Huang <gray.huang@mediatek.com> SurfaceFlinger supports ClearClientTarget for Sideband

When clearing the layer's intersection with the dirty region,
HWC2::Composition::Sideband layer needs to be cleared as well.

Bug: 33443134
Test: manual - enter PIP mode with Live Channel
Change-Id: I4fecc7b5db8a2bf220b681bd087264290d1a2443
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f222b2e6f4a3c26d6d2d9e3dd9056e5c95d7bc9c 06-Feb-2017 Fabien Sanglard <sanglardf@google.com> Enable TripleBuffering on SF by default

Change-Id: I5958534133799419fa77c00536c68cacd1ccb6a9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b254fa3a9eccd5ad7d853d687cf50a68dd8ee41c 01-Feb-2017 Wei Wang <wvw@google.com> SurfaceFlinger: Set property in separate thread in init

By setting property in a separate thread, the CL aims to
avoid slow initilization in SurfaceFlinger::init where
SurfaceFlinger is waiting on property_service.

Bug: 34499826
Test: on marlin
Change-Id: I91afad3cbc9a2b31aa89ae9cc752ad491cc9d8e4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cb11135f1df815b822eb3fe1571a1536618289dd 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24 am: c7892d9d0b am: cca3b79c32 am: ebbf8a6b5a am: 5ba227f96e am: 40cd915a54 am: ded5521871 am: 0e0a258771 am: 6a5a220b48 am: 30ab1434c3 am: f6868443ef
am: 53ed9c6c7e

Change-Id: I8f312459a57431221201c1fae8bfd6c178bf07c4
f6868443ef7ff3465b87c615b3519f945d9224ef 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24 am: c7892d9d0b am: cca3b79c32 am: ebbf8a6b5a am: 5ba227f96e am: 40cd915a54 am: ded5521871 am: 0e0a258771 am: 6a5a220b48
am: 30ab1434c3

Change-Id: Iaa4ffc3bca279f294a36df31823ec9a30a728fe7
6a5a220b481d2014f2c0c523a41a57ee1b4374fa 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24 am: c7892d9d0b am: cca3b79c32 am: ebbf8a6b5a am: 5ba227f96e am: 40cd915a54 am: ded5521871
am: 0e0a258771

Change-Id: I4479a276592fc9d5d25378a5abee12473a2104ae
0e0a25877137154a5da927c6c0924d96b57fdee8 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24 am: c7892d9d0b am: cca3b79c32 am: ebbf8a6b5a am: 5ba227f96e am: 40cd915a54
am: ded5521871

Change-Id: Ibf93b2a73caab87ee6c0b27234a8cdc05c0aa61e
ded55218716612e979b3194ce33d5aa05ac4c5ed 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24 am: c7892d9d0b am: cca3b79c32 am: ebbf8a6b5a am: 5ba227f96e
am: 40cd915a54

Change-Id: Ib34c9d0e90e77565ab6d0d7fb805bb425964b5aa
ebbf8a6b5ab37ba7e51ce159db33d7b1fa170f72 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24 am: c7892d9d0b
am: cca3b79c32

Change-Id: I2e5da5ee33eb2757f360881e6ecc7dfd9fb67938
cca3b79c3259eee98f27e7b5f1634de6b49cc902 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f am: 132d0f2aef am: 3995674f24
am: c7892d9d0b

Change-Id: Ic59ba49542b907591f3e514ae0417ed82a5be7aa
3995674f2457c457839cea8aeabc14432512e8e6 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834 am: ac2b87ac0f
am: 132d0f2aef

Change-Id: If2aa999ec1f261ea34a6aa725241ea50226083ad
132d0f2aefb36a0a83fc77460ed24383d0e3202a 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62 am: 11ab583834
am: ac2b87ac0f

Change-Id: I3b249a9ec1820917dc015c72bd093535927c9ed6
ac2b87ac0f613f9995b938a9157544cdd2dbe646 02-Feb-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability am: 2ae83f4f62
am: 11ab583834

Change-Id: I09ec85b9f83e1f4458940415cd07f6fca725c552
cdb6b9e8b3489e29150537f021986657b7daf3fc 01-Feb-2017 Jiyong Park <jiyong@google.com> Merge "configstore: remove build flags from surfaceflinger"
479c60c85c40fd3536b0c88036e838dc1a4c56a0 27-Jan-2017 Albert Chaulk <achaulk@google.com> Refactor how layer metadata for use by VR is propagated
from WindowManager based on feedback in frameworks/base.

Since windowType and ownerUid are immutable, they are sent
on creation instead of separate IPC.

Bug: 30984984
Test: built locally

Change-Id: I380b3cdcf6aec471fc23f1e27846ab80492e8add
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1db73f66624e7d151710483dd58e03eed672f064 21-Dec-2016 Robert Carr <racarr@google.com> SurfaceFlinger: Add support for non-privileged clients.

Allow clients without privilege to create child layers through scoped
connections. We enable this in preparation for allowing SurfaceView
to bypass the WindowManager. We include support for reparenting of
all of a layer's children for the WindowManager to use in cases where
one surface is replacing another (while keeping its children around).

Test: Tested with corresponding SurfaceView modifications.
Change-Id: I9920e6730d719113522a68788e63fb59f70d3406
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2f5f8a51f5994cf14837030d4b3b252a9d1b950b 20-Dec-2016 Daniel Nicoara <dnicoara@google.com> VR: Add ability to pass layer info through SurfaceFlinger

Updates SurfaceFlinger to connect to the VR HWC service and pass
additional layer information.

For now VR mode is enabled at build time.

Bug: 33297385
Test: Ran on device and verified the IVrComposerClient::setLayerInfo()
call is done successfully.

Change-Id: I9dea2451a3a2aa1919395d3785ae00446ba51f26
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1f0a16a5d7cd00ba7fda82e7d315afa1fd1303b9 25-Oct-2016 Robert Carr <racarr@google.com> SurfaceFlinger and libgui: Support for child layers.

Add support for parenting Layers in a tree. Layers
follow scene-graph style rules, that is to say:
1. A child is cropped to the final bounds of the parent.
2. A child inherits the parent's transform (including position)
3. A child's Z ordering is relative to the parent and bounded between
the parents siblings.
4. A childs lifetime is bounded by it's parents lifetime.

Test: New tests in Transaction_test plus manual testing with later branches.
Change-Id: I96f8ad863665b9a70b6f845561344c297b7e6eff
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2047fae0cfed99c425dc7333f31d309e5b8ee1ba 28-Nov-2016 Robert Carr <racarr@google.com> SurfaceFlinger: Use traversal functions to iterate LayerList.

In preparation for the Layer hierarchy. There we will need
to use such a style to traverse the tree of layers.

Test: Just a refactoring. SurfaceFlinger still works.
Change-Id: I84dcd82e713f1bdbe911658793ce11460267a956
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ae0608381b2b4699218febd6d45ad9d307544d55 28-Nov-2016 Robert Carr <racarr@google.com> SurfaceFlinger and libgui: Switch Z-order to signed type.

In preparation for SurfaceFlinger child layers. In that model
children's Z order will be relative to their parent. We need
negative Z values to represent children stacking below their
parent (e.g. SurfaceView). Java side already uses signed types
strangely enough.

Test: Basically a refactoring. SurfaceFlinger still works.
Change-Id: Ifcece69f6f9d917cbf5238a59f8e5de1e8ba6a25
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4b20c2ee8e51006db51bbe1391f9173230bb73d2 14-Jan-2017 Jiyong Park <jiyong@google.com> configstore: remove build flags from surfaceflinger

This change removes build flags used in building surfaceflinger.
Instead, surfaceflinger uses android.hardware.configstore HAL to get
values for the build flags at runtime.

As a first attempt, a build flag VSYNC_VENT_PHASE_OFFSET_NS is converted
to a hwbinder call to vsyncEventPhaseoffsetNs() function in
android.hardware.configstore@1.0 package.

Note that VSYNC_EVENT_PHASE_OFFSET_NS still remains in Android.mk
for non-treble targets.

Design doc: go/design-confighal
Bug: 34314793
Test: build, run, log message "Phase offset NS: ..." should be seen.

Change-Id: I43862d4df5abd3e9275ec9c0e2e0b568d8b48347
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2ae83f4f628d4da96f363d0668380ba1f753b867 19-Jan-2017 Fabien Sanglard <sanglardf@google.com> Fix security vulnerability

Test: hammerhead
Bug: 32628763
Change-Id: I19a81b63fffee8f323a5925c7e8633fbd640b91c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c939411a88e5a248f6e6668b8b4041e868b97059 17-Jan-2017 Brian C. Anderson <brianderson@google.com> Merge changes from topic 'latchAndLastRefresh'

* changes:
EGL: Expose latch, last composite, and dequeue ready.
Add a DequeueReady FrameEvent
f7fd56a649f07133ad78d31eb5d3ae7a4e95d522 02-Sep-2016 Brian Anderson <brianderson@google.com> EGL: Expose latch, last composite, and dequeue ready.

Also fix discontinuous reserved token values.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I9d513b8784a7205dfe534c1c74b56c18cd49e74a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f6386862dffb0fb9cb39343d959104a32e5e95b7 01-Nov-2016 Brian Anderson <brianderson@google.com> Add a DequeueReady FrameEvent

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I98ffd4123fc50b5f560e432f4078408c913c8edf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e0ea99cc4ba89452b9b6b1baa33bddcb11f3351a 12-Jan-2017 Mark Salyzyn <salyzyn@google.com> resolve merge conflicts of a2c2d11f9 to master

Test: compile
Bug: 26552300
Bug: 31289077
Change-Id: I84d0ffa430df3beca0dcc6ed205ce220d7be1f87
7823e124e00576e20e47ec717cbe8bc89f0f2bf2 29-Sep-2016 Mark Salyzyn <salyzyn@google.com> Replace cutils/log.h and rationalize log/log.h and android/log.h

- cutils/log.h treat as deprecated and lead by example
- android/log.h to be used instead of log/log.h if possible
- add system includes that are assumed as side effects
- define LOG_TAG first

Test: compile
Bug: 31289077
Bug: 30465923
Change-Id: I8d99b24c333578c9b5aa9f2a01324bd0bba268dd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
83756055ff9d897621bf61883c212e3b96b342de 09-Jan-2017 Fabien Sanglard <sanglardf@google.com> Fix syntax error in appendSfConfigString (#endif)

Change-Id: I1ff05e34e4d8d9f73bb5cb090c96011497132947
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
63a5fcd2aa55c8eb0ccba621517a4215d8504df6 30-Dec-2016 Fabien Sanglard <sanglardf@google.com> Move TARGET_DISABLE_TRIPLE_BUFFERING to property

As part of the migration to Soong, Android.mk environment variables
must be moved to property which are checked at runtime.

Tests: Angler and Sailfish
Change-Id: I7c620656c6778b36fea78c3087fbd5d33cea96f8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c03d283e8b3f830d76dd94822b2a13872c05c730 28-Dec-2016 Mark Salyzyn <salyzyn@google.com> resolve merge conflicts of 525a5f2 to master

Test: build
Change-Id: Id1c6d3d9dd158fb086b0d8ab74f7838ef0a51af1
a5e161b1207ef447a51e99856097d69d4a6111e1 29-Sep-2016 Mark Salyzyn <salyzyn@google.com> Replace cutils/log.h and rationalize log/log.h and android/log.h

- cutils/log.h treat as deprecated and lead by example
- android/log.h to be used instead of log/log.h if required
- add system includes that are assumed as side effects of log.h
- modules that use SLOG should use SLOG for all logging (installd)
- define LOG_TAG first
- remove logging infrastructure if not used

Test: build
Bug: 31289077
Change-Id: Iea147a0104c7ab7f12451304131d6500f42141e7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3d4039d7a291cd9b6f2dd4b46fcdb576f2db3356 24-Sep-2016 Brian Anderson <brianderson@google.com> Use FenceTime to share fence times and reduce open fds.

FenceTimes are created and shared for each Fence that
FrameTimestampHistory and FrameTracker care about.

On the consumer side, the FenceTimes are also added to
shared timelines that are owned by SurfaceFlinger or
unshared timelines owned by Layer. The timelines are
checked at the end of every frame to minimize the number
of file descriptors open.

On the producer side, the FenceTimes are added to
the ConsumerFrameEventHistory instead, since the timelines
that would be tracked by SurfaceFlinger are not shared
with anyone else in the consumer's process. The timelines
are checked just after a frame is queued to minimize
the number of file descriptors open.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: Ifd4301affe1b24705b2bee7608c5a2c09dfb4041
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8c9ba46eb3a2e382f2911eaf9d19af49f60a65a1 09-Dec-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Delete unused dirtyRegion local variable"
e685bb48f7b0650286f6f1c87f466d2a67a132d2 08-Dec-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Delete unused mask eTransactionMask parameter"
c4b2ae377a90b8189c92c23e07a3cc9dbca14f9d 07-Dec-2016 Fabien Sanglard <sanglardf@google.com> Delete unused dirtyRegion local variable

Change-Id: Ibcaf7c52ee9a80e86e51985a3af0e63bebf338fe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c8251eb7a6ecfdd16b3e4cfbfb442aa4c789c039 07-Dec-2016 Fabien Sanglard <sanglardf@google.com> Delete unused mask eTransactionMask parameter

Change-Id: I1f9dafb014bb3090186443ef1049b7dd53a9a697
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1748719ea1b69cc7ad111d8c6149d692b9f056f8 07-Dec-2016 Fabien Sanglard <sanglardf@google.com> Delete unused clip parameter in clearWithOpenGL

Change-Id: Idc31d6cfe0c804fd6c5528432e1179f920e231b3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b52cfec8ded83ebb36a41851c01f0e5666a25a39 05-Dec-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Rename hw to displayDevice for consistency"
830b84704b0f33030d0e391a0ea2e7faa5646e2e 01-Dec-2016 Fabien Sanglard <sanglardf@google.com> Rename hw to displayDevice for consistency

Change-Id: I8bdb9be9c0e024d74a5aacc1f78c553cc1bc5ab4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
11d0fc38ad8d2e5bb5bc0a282336cabe28dbf9d6 02-Dec-2016 Fabien Sanglard <sanglardf@google.com> Rename "retire" to "present" for consistency

The HWC2 model has no concept of retire fence beyond HWC2to1Adapter
All references to "retire" fence should be called "present"

Change-Id: I26540aad9e65f138a4df60a34eaee030f1c17567
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
49670c84019d58f6c95aadf168db677f85b46a88 03-Dec-2016 Brian C. Anderson <brianderson@google.com> Merge "Cache frame event history producer-side."
3e5af2d242a5b73a76be9742d23da20ed28e06e0 02-Dec-2016 Brian C. Anderson <brianderson@google.com> Merge "Track frame events incrementally and per layer."
f7dfa47683c4810c2955affe26db0e9454614cf7 02-Dec-2016 Brian C. Anderson <brianderson@google.com> Merge "Fix FenceTracker releaseFence"
4a1f8a53aa0d51486f47ca3d2699e600e540a12a 01-Dec-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Rename "commit" to use "present" nomenclature"
a87aa7bb5e44fd4b352e34d3cd745aa7e038d19f 01-Dec-2016 Fabien Sanglard <sanglardf@google.com> Rename "commit" to use "present" nomenclature

We use "present" down the HWC2, commit is a confusing name.

Change-Id: I7b23edaf4aeab807bc523e31dfcb8e716166d849
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
834bccb1f58780d51367ae39598ae68407986252 01-Dec-2016 Brian C. Anderson <brianderson@google.com> Merge "Add displayPresentTime to getFrameTimestamps"
8650c6fe8282a08f10672c917f3facf1398b0928 30-Nov-2016 Jinguang Dong <dongjinguang@huawei.com> Merge "surfaceflinger:Fix potential crash issue when do AIDL FUZZ test" am: 2792ff4527 am: 83f8bba2a5 am: 60f8850e70
am: f3fe700dc2

Change-Id: I13ae45fde822c625cd70b60db6fdbd1e1236a462
83f8bba2a5b64e453404d5609c49ba31d5ec5b38 30-Nov-2016 Jinguang Dong <dongjinguang@huawei.com> Merge "surfaceflinger:Fix potential crash issue when do AIDL FUZZ test"
am: 2792ff4527

Change-Id: Ia8c1ac3f9eff3680ed64235cb01043d0b7c434b9
9f8b9ae2a95eec78e676a11a719deafea4952190 29-Nov-2016 Jinguang Dong <dongjinguang@huawei.com> surfaceflinger:Fix potential crash issue when do AIDL FUZZ
test

There will be trigger exception when we provide invalid
inputs parameter for surfaceflinger JNI interface

Test: 1.Run adb shell and open AIDLer tools;
2.change to Dir /sdcard/elong.AIDLer
3.run commond service list > service_list.txt
4.Rerun AIDL FUZZ test

Change-Id: I0a63adc1e8ae5d9c9e43cb6df6aa13503c40a0c5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3890c3995c4a52439844faeb80b5503d42b977d8 25-Jul-2016 Brian Anderson <brianderson@google.com> Cache frame event history producer-side.

* Producer maintains a recent history of frames.
* Producer only does a binder call if requested
informatiVon doesn't exist in the cache.
* Consumer sends fences to the producer, which
can be queried for timestamps without a
binder call.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I8a64579407cc2935f5c659462cb227b07ba27e43
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d6927fb1143398370c0885844bfb58923ef740b7 24-Jul-2016 Brian Anderson <brianderson@google.com> Track frame events incrementally and per layer.

* Replaces FenceTracker, which was owned by SurfaceFlinger,
with FrameEventHistory, which is owned by Layer.
* Updates FrameEventHistory as events occur.
* Changes SurfaceFlinger flag "--fences" to
"--frame-events".

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I868c2ef93964656d7e41848243433499e7f45fe7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3546a3f08ad84099db4006d651c656d58d2ed566 14-Jul-2016 Brian Anderson <brianderson@google.com> Fix FenceTracker releaseFence

This patch:
* Fixes the release fence when GPU compositing.
* Stores the final release fence in ConsumerBase just
before releasing the Buffer, which helps ensure
sync points aren't added unknowningly.
* Makes HWC2 release pending buffers as the first step
of postCompostion, rather than the last, which should
allow dequeue to unblock a little earlier and helps
make sure the previous buffer's release fence has
been finalized before FenceTracker::addFrame is
called.
* Fence tracker only sets the release fence once it
has been finalized so it does not report a release
fence for a buffer that is still latched.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I27d484bfd48f730bdcea2628f96795c6f4b4df7b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
069b365163470d2736eb6f591c354d208b5da23b 22-Jul-2016 Brian Anderson <brianderson@google.com> Add displayPresentTime to getFrameTimestamps

Makes HWC1 use displayRetireTime and HWC2 use
displayPresentTime.

Properly takes into account if HWC2On1Adapter is used.

Returns whether present or retire is supported via
eglQueryTimestampSupportedANDROID, which uses a
cached answer in Surface.

Surface::getFrameTimestamps returns with an error
if the caller requests an unsupported timestamp.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: Ib91c2d05d7fb5cbf307e2dec1e20e79bcc19d90b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
dda9bb00cd466b859f35c767944607bd851494b3 14-Nov-2016 Evgenii Stepanov <eugenis@google.com> Merge "Revert "Workaround alloc-dealloc-mismatch error on ASan device boot."" am: 5c58020c00 am: 22d12a89e6 am: df48bcff26
am: 1852c5564d

Change-Id: Ibb34264848e1e4c7b800b35a7a4dd61e551b42ee
1852c5564dd9181e83b289c6bfe0515c8c048018 14-Nov-2016 Evgenii Stepanov <eugenis@google.com> Merge "Revert "Workaround alloc-dealloc-mismatch error on ASan device boot."" am: 5c58020c00 am: 22d12a89e6
am: df48bcff26

Change-Id: If0ede202f577d8e1452c7905a4a06e7d36bce761
df48bcff26971a805c04f04e3b80ba8f1713bc3b 14-Nov-2016 Evgenii Stepanov <eugenis@google.com> Merge "Revert "Workaround alloc-dealloc-mismatch error on ASan device boot."" am: 5c58020c00
am: 22d12a89e6

Change-Id: Ie392d157a320fba28e91214af4486d09d671a23a
22d12a89e62890315104112636b71f7be9c95fb1 14-Nov-2016 Evgenii Stepanov <eugenis@google.com> Merge "Revert "Workaround alloc-dealloc-mismatch error on ASan device boot.""
am: 5c58020c00

Change-Id: I107ce2043fd261b08413418825daf6c35f808228
3ed78e47009f4918c4a904c52bd774c93e24c8c1 14-Sep-2016 Evgenii Stepanov <eugenis@google.com> Revert "Workaround alloc-dealloc-mismatch error on ASan device boot."

This reverts commit 22819276b147e34a80e8ca696be5b3fda68764b9.

The underlying kernel bug has been fixed.

Test: SANITIZE_TARGET=address build should continue working

Change-Id: I6f3938047d9f60357e7bd9bccd3ef36d7686c73b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6e8e98a23592c2522396b673145814a4bbee69db 28-Oct-2016 Fabien Sanglard <sanglardf@google.com> Refactor SurfaceFlinger::onTransact

Reduce length of SurfaceFlinger::onTransact by moving credential
code to dedicated function.

Change-Id: I0fa30439443295b4a807e0eeae4f113d7b0534c4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
94ef1fda8ddd761b2ced012a7a43ce1481f76dc9 26-Oct-2016 Steve Pfetsch <spfetsch@google.com> Revert "services: surfaceflinger: ASAN fix" am: 598f6d5429 am: d5156b70ff am: 12924419de
am: 6d2eb659a5

Change-Id: I609bac956dff460334942bd348c0eedc53a42123
6d2eb659a5c70648ef9f67bbd6272c90b42bab85 26-Oct-2016 Steve Pfetsch <spfetsch@google.com> Revert "services: surfaceflinger: ASAN fix" am: 598f6d5429 am: d5156b70ff
am: 12924419de

Change-Id: I520fff2e1cc9b3a49478cbc9e783df081defc75d
598f6d5429b290f33107ef678328914b99c8312e 25-Oct-2016 Steve Pfetsch <spfetsch@google.com> Revert "services: surfaceflinger: ASAN fix"

This reverts commit 1d3df546d5ee4dcc9e7cae6f8b8b790f741539af.

Original patch may have caused a stability issue caught in monkey testing.

Bug: 32312240
Change-Id: Ie8d291679590e624b8b90c4786b1c25c76cb2c9f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f4ddfacffd96267ee43cf2cf3b7cacf9374b4135 19-Oct-2016 Steve Pfetsch <spfetsch@google.com> services: surfaceflinger: ASAN fix am: 1d3df546d5 am: ff06017cfe
am: 409c087ffe

Change-Id: Ia0a821a314c9bc5582cef8f434a77115599263e2
409c087ffe6aa79d943e0ed18593df19967f81d5 19-Oct-2016 Steve Pfetsch <spfetsch@google.com> services: surfaceflinger: ASAN fix am: 1d3df546d5
am: ff06017cfe

Change-Id: Ie1f5418312cffc6b1a1ec9a7fd0194babaf9d6d9
1d3df546d5ee4dcc9e7cae6f8b8b790f741539af 30-Sep-2016 Steve Pfetsch <spfetsch@google.com> services: surfaceflinger: ASAN fix

Move layer removal to the main thread, while the display is on.

Bug: 30281222
Change-Id: Id9f956c1e626819734868340e7fa12abf257b702
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
de84eb6b823ff143f3465ce8f291f1100ce42168 09-Aug-2016 Dan Stoza <stoza@google.com> SF: Fix a couple of Layer ref count issues

This is an attempt at fixing two reference counting issues for Layers.

The first issue is that since we were holding an sp<IBinder> (really a
reference to a LayerCleaner) inside the layer state for deferred
transactions, there was a possibility that it could end up being the
last strong reference to the LayerCleaner such that when it was
destroyed while applying a non-deferred transaction, it would attempt
to grab the SurfaceFlinger main lock to destroy its Layer. Since this
occurred in the main SurfaceFlinger loop, which was already holding
the lock to process transactions, this would cause a deadlock.

To fix this, the sp<IBinder> inside the layer state was changed to a
wp<IBinder>, only being promoted when it actually needs to be accessed
(i.e., when the deferred transaction is created).

The second issue is that we were promoting and holding a strong
reference to a Layer before calling into SurfaceFlinger to destroy it
on the onLayerDestroyed path (triggered when a LayerCleaner is
destroyed). After returning from the attempt to grab the SurfaceFlinger
main lock, it was possible that this strong reference was the last one
keeping the Layer alive, and destroying it at this point could cause
the HWC2 version of the layer to be destroyed at effectively any point,
even between validate/present.

To fix this, the promotion of the weak Layer reference was moved inside
the critical section where the SurfaceFlinger main lock is held.

Test: Cherry-pick from internal branch
Bug: 30503916
Bug: 30281222
Change-Id: I1c6a271f9a7b5d6eea9a9db61d971f262d0cfe84
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
00ac359a3b69670824ceab8d1dd5a1d5ad0ac5bd 17-Jun-2016 Dan Stoza <stoza@google.com> HWC2: Skip validate/present if display is off

Adds checks to ensure that the display is still on before attempting
to call into prepareFrame/commit (which in turn call into
validate/present).

Test: Cherry-pick from internal branch
Bug: 28596387
Change-Id: Iad87f02c3e44e86db43a15c258ee66b0cde14faa
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b2c838b7add20c4515966a80de809b0a1d315001 04-Aug-2016 Season Li <seasonl@nvidia.com> SF: Call makeCurrent after presenting each display

HWC can change EGLContext in each present. Restore to
default EGLContext after commiting each display.

Change-Id: I4abc84fb3d4b74964fabcad5a2568ff01a6c5dbb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
75b1868620b63f772a93cbc9a67dec5a62cc6182 08-Sep-2016 Tim Murray <timmurray@google.com> Boost priority of short-running SF FIFO threads slightly. am: 35520634e2 am: 584fb9544f
am: 7a7de48b25

Change-Id: I23f953ba137f7958e77733fc516cfa5c351290f8
7a7de48b2559d024a463e15cd4627b3ca0978800 08-Sep-2016 Tim Murray <timmurray@google.com> Boost priority of short-running SF FIFO threads slightly. am: 35520634e2
am: 584fb9544f

Change-Id: Ib10bc21d1166df03704fcc2b67b99ed3c1a92464
584fb9544f2ce5fab38691b88bac42359de6c51b 08-Sep-2016 Tim Murray <timmurray@google.com> Boost priority of short-running SF FIFO threads slightly.
am: 35520634e2

Change-Id: Ic4a53cc1399dff489414ac1c891a041c2500b8e2
4df766b00ac6801f2e4462b20b6dd6f195051afb 08-Sep-2016 Tim Murray <timmurray@google.com> Merge "Boost priority of short-running SF FIFO threads slightly." into nyc-mr1-dev
58a64714126bf3d34566d56cb535e2ae78d1c5ef 08-Sep-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add a layer minidump am: e22aec741f am: a9f976b50f
am: 11e9bd2b48

Change-Id: I14a22fe1dde3e93107834516ad826ddadcd6781a
11e9bd2b4861cc8e878fd7da3e65e66167b3d001 08-Sep-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add a layer minidump am: e22aec741f
am: a9f976b50f

Change-Id: Ia04d91da4cc6fc6e2962c7dc6421882c2e4874b6
a9f976b50f03890e7b1cb6c182f7608360b2bdbc 08-Sep-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add a layer minidump
am: e22aec741f

Change-Id: Ib97254ebbf2e914c965b529e7d1e59a01db48214
a020f00bc156ebdf6ea1f3c2de8af049dac9d5e6 08-Sep-2016 Dan Stoza <stoza@google.com> Merge "SF/HWC2: Add a layer minidump" into nyc-mr1-dev
35520634e298f53bd8433825640d6999760f25b3 07-Sep-2016 Tim Murray <timmurray@google.com> Boost priority of short-running SF FIFO threads slightly.

The short-running FIFO threads should preempt the SurfaceFlinger main
thread in order to prevent deadlock.

bug 31223682

Change-Id: I29e7b4b8439bb876998a8aeeb2b8d6ee5b6b7d36
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
22851c3ba2cf5ccb0c3a0aa6c5b94ae123a5616a 09-Aug-2016 Dan Stoza <stoza@google.com> SF: Fix a couple of Layer ref count issues

This is an attempt at fixing two reference counting issues for Layers.

The first issue is that since we were holding an sp<IBinder> (really a
reference to a LayerCleaner) inside the layer state for deferred
transactions, there was a possibility that it could end up being the
last strong reference to the LayerCleaner such that when it was
destroyed while applying a non-deferred transaction, it would attempt
to grab the SurfaceFlinger main lock to destroy its Layer. Since this
occurred in the main SurfaceFlinger loop, which was already holding
the lock to process transactions, this would cause a deadlock.

To fix this, the sp<IBinder> inside the layer state was changed to a
wp<IBinder>, only being promoted when it actually needs to be accessed
(i.e., when the deferred transaction is created).

The second issue is that we were promoting and holding a strong
reference to a Layer before calling into SurfaceFlinger to destroy it
on the onLayerDestroyed path (triggered when a LayerCleaner is
destroyed). After returning from the attempt to grab the SurfaceFlinger
main lock, it was possible that this strong reference was the last one
keeping the Layer alive, and destroying it at this point could cause
the HWC2 version of the layer to be destroyed at effectively any point,
even between validate/present.

To fix this, the promotion of the weak Layer reference was moved inside
the critical section where the SurfaceFlinger main lock is held.

Bug: 30503916
Bug: 30281222
Change-Id: I1c6a271f9a7b5d6eea9a9db61d971f262d0cfe84
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ab04685578b254c2eaf43bf5da85e5e922787825 28-Jul-2016 Irvel <irvel@google.com> Fix duplicated VSync tracing in SurfaceInterceptor

Change-Id: Id02bb2916d0c53dc11d7106c4aec6954a1acc035
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ffc9efc4b55df38ac524f20cdd1a2fca8e259fae 28-Jul-2016 Irvel <irvel@google.com> Add display tracing to SurfaceInterceptor

Change-Id: Iaae5a840ca7dca7a9a70dde1ccab0fa3944cd863
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a807cd502e3e8e78095efd8ac5bd2a087a934d20 12-Aug-2016 Dan Stoza <stoza@google.com> DO NOT MERGE SF: Add property to disable HWC virtual displays am: 3cf4bfe236
am: cce24b398c

Change-Id: I0eb9092b3f09b607bb4d2da5d5533867d6ef1ebd
cce24b398ce24f7deeac4f92560766c330717c63 12-Aug-2016 Dan Stoza <stoza@google.com> DO NOT MERGE SF: Add property to disable HWC virtual displays
am: 3cf4bfe236

Change-Id: I615cdf9466cbb37d32890f126dc0be1fecf9a50a
e26ce9f612d3afe54b9806beee3fd0a3dc1638be 12-Aug-2016 Dan Stoza <stoza@google.com> Merge "DO NOT MERGE SF: Add property to disable HWC virtual displays" into nyc-mr1-dev
3cf4bfe2368020b50a3e22360910b6af6590c5be 02-Aug-2016 Dan Stoza <stoza@google.com> DO NOT MERGE SF: Add property to disable HWC virtual displays

Adds the property debug.sf.disable_hwc_vds, which will disable the use
of Hardware Composer virtual displays inside SurfaceFlinger (falling
back to SurfaceFlinger management and client composition of such
displays).

Also adds a Binder debug interface for controlling this behavior.

Bug: 30510632
Change-Id: I2c1a199213a24195b144bfa0c0f1679f2dfd0668
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8cf150a0341768133b37cd9c6f2369bf6f79a943 02-Aug-2016 Dan Stoza <stoza@google.com> SF: Add property to disable HWC virtual displays

Adds the property debug.sf.disable_hwc_vds, which will disable the use
of Hardware Composer virtual displays inside SurfaceFlinger (falling
back to SurfaceFlinger management and client composition of such
displays).

Also adds a Binder debug interface for controlling this behavior.

Bug: 30510632
Change-Id: I2c1a199213a24195b144bfa0c0f1679f2dfd0668
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ae56a32be71278b77e82fe56bcfbdc9589f7e1dc 10-Aug-2016 Dan Stoza <stoza@google.com> Revert "SF: Fix a couple of Layer ref count issues"

This reverts commit 92cd24e5f648175944deef5899258981807a9ca4.

Change-Id: I551c292d8151d39bd34f2667eda384273f7cfd87
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
dd03e70fd620a7a305c1a271583e0da07d6c1ac4 10-Aug-2016 Dan Stoza <stoza@google.com> SF: Fix a couple of Layer ref count issues am: 92cd24e5f6 am: 56e16bb1ca
am: 263910d00a

Change-Id: I76564ea2195d2de9aaf00ebd4c50db1d36dafeff
263910d00ac40a5787a414a79df94d3459139e87 10-Aug-2016 Dan Stoza <stoza@google.com> SF: Fix a couple of Layer ref count issues am: 92cd24e5f6
am: 56e16bb1ca

Change-Id: I64cac41e0f6e6412a3334cf17c15c9b754f8dd07
92cd24e5f648175944deef5899258981807a9ca4 09-Aug-2016 Dan Stoza <stoza@google.com> SF: Fix a couple of Layer ref count issues

This is an attempt at fixing two reference counting issues for Layers.

The first issue is that since we were holding an sp<IBinder> (really a
reference to a LayerCleaner) inside the layer state for deferred
transactions, there was a possibility that it could end up being the
last strong reference to the LayerCleaner such that when it was
destroyed while applying a non-deferred transaction, it would attempt
to grab the SurfaceFlinger main lock to destroy its Layer. Since this
occurred in the main SurfaceFlinger loop, which was already holding
the lock to process transactions, this would cause a deadlock.

To fix this, the sp<IBinder> inside the layer state was changed to a
wp<IBinder>, only being promoted when it actually needs to be accessed
(i.e., when the deferred transaction is created).

The second issue is that we were promoting and holding a strong
reference to a Layer before calling into SurfaceFlinger to destroy it
on the onLayerDestroyed path (triggered when a LayerCleaner is
destroyed). After returning from the attempt to grab the SurfaceFlinger
main lock, it was possible that this strong reference was the last one
keeping the Layer alive, and destroying it at this point could cause
the HWC2 version of the layer to be destroyed at effectively any point,
even between validate/present.

To fix this, the promotion of the weak Layer reference was moved inside
the critical section where the SurfaceFlinger main lock is held.

Bug: 30503916
Bug: 30281222
Change-Id: I1c6a271f9a7b5d6eea9a9db61d971f262d0cfe84
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
43d4e6a7b9eae63e66c0fdfd8c514ba678f0cfb5 03-Aug-2016 Tim Murray <timmurray@google.com> Disable SCHED_FIFO when turning off the display. am: f9d4e44fff am: d406094fe9
am: 53b2a9f89f

Change-Id: I46a698104605c50d595023118346a656b31fb29a
53b2a9f89f6e2b4c0eda9a2f1516ee3d14287430 03-Aug-2016 Tim Murray <timmurray@google.com> Disable SCHED_FIFO when turning off the display. am: f9d4e44fff
am: d406094fe9

Change-Id: Ia5020b7e8c2e09524e8801068c2863af933c7714
f9d4e44fff4f9c0a09e5820a5596c6dec34ee4da 03-Aug-2016 Tim Murray <timmurray@google.com> Disable SCHED_FIFO when turning off the display.

There can be long SF runtimes when turning the display on or off. Only
use SCHED_FIFO when we are actively going to be rendering frames, not
when turning the display on or off.

bug 30375418

Change-Id: Ibef8e5f3bba0bafc36f92f9f1b299f015fc335f9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c1ba5c4649554e744844b07cfe402b42fbe12ff3 08-Jun-2016 Sahil Dhanju <sahildhanju@google.com> Multithreaded Surface Replayer that replays traces

Change-Id: Id8d17f74e00d4796e1ea266bdaf9e8dd0af6475b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e22aec741f1530cde86c38989bcc2f87626b93b0 01-Aug-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add a layer minidump

Adds a brief dump of visible HWC layers to replace functionality that
was lost when moving from HWC1 to HWC2.

Bug: 30242002
Change-Id: I7331517c7d1eb515b33d5db85cdaf23d8b9ae9d9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
de4883bab707e2699350d561c5e6382d0bad34ba 02-Aug-2016 Tim Murray <timmurray@google.com> Update SurfaceFlinger FIFO configuration. am: acff43dca6 am: 4d818bf221
am: 618f8aba21

Change-Id: Ie003b648afb3b63abf8335d4332c22fcdd98c1d5
618f8aba211c60ee5f4a48e1ff38e13b4c20a542 31-Jul-2016 Tim Murray <timmurray@google.com> Update SurfaceFlinger FIFO configuration. am: acff43dca6
am: 4d818bf221

Change-Id: Ic21edd708e48ef535afc927e821451b3fbb20c66
acff43dca6a3c8a29f449706967d4de21c373d26 29-Jul-2016 Tim Murray <timmurray@google.com> Update SurfaceFlinger FIFO configuration.

- move SurfaceFlinger main thread to prio 2
- drop EventThread from FIFO but not SFEventThread, which is still FIFO
prio 1
- make DispSyncThread FIFO, prio 1

bug 30481949

Change-Id: Ifedccfbf3cf144ffad030109849a924dddae8d09
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5043c3b32c7a7cec264ac89c767b26e101d7f034 29-Jul-2016 Dan Stoza <stoza@google.com> SF: Prime shader cache before boot animation am: 4e63777f75 am: fa37ad521a
am: 85c57eb151

Change-Id: I2ef501e59efd2a510db07df998f11f05b563df14
85c57eb151ac673eb869f57add64819afdea9bcc 29-Jul-2016 Dan Stoza <stoza@google.com> SF: Prime shader cache before boot animation am: 4e63777f75
am: fa37ad521a

Change-Id: I5a0b3152dab5f7d6813220a5f53581a5563d7bad
4e63777f75e9756c74352e62e79dfa8a994de2b3 28-Jul-2016 Dan Stoza <stoza@google.com> SF: Prime shader cache before boot animation

Primes the shader cache before launching boot animation to avoid
janking when we eventually fall into GLES composition.

Bug: 30040263
Change-Id: I76ba66e92c5e6bb05930c325f384f3b774e91101
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cf268f197c75832aa29fbfbdbadde34e4587ca2c 22-Jul-2016 Pablo Ceballos <pceballos@google.com> SF: Make screenshot surface async am: 605d15afbb
am: 6d4164bc9a

Change-Id: I88547ffedb80ee500ff508e1e788852c8806f52d
08da1d85771ba237033e90b201a3350f3381188a 22-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Check all displays for client composition am: bfbffeb4d1
am: 638708adee

Change-Id: I0ededbfa206b58a5eeaae3de36bdb91745f899c7
6d4164bc9a78cf7766fb9cb87ef5ed6401609b52 22-Jul-2016 Pablo Ceballos <pceballos@google.com> SF: Make screenshot surface async
am: 605d15afbb

Change-Id: Id24c7ccb275dcad914bda83b825c71af90aac637
638708adeee347a3c7ed104cb59b01d449a9d297 22-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Check all displays for client composition
am: bfbffeb4d1

Change-Id: I96d86695d1553cfd57dfca6e007d3137a4b73843
3dd1045c27a7c49ad9d2295566fb0ca13713c977 22-Jul-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Make screenshot surface async" into nyc-mr1-dev
468051e20be19130572231266db306396a56402b 14-Jun-2016 Irvel <irvel@google.com> Integrate SurfaceInterceptor into SurfaceFlinger

Change-Id: If18d967f2b69ed219f17a9afedb61884ad5f1dc8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bfbffeb4d15b8a783e2f8aa21daee5fff755913f 21-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Check all displays for client composition

SurfaceFlinger currently only checks whether the primary display
performed client composition when considering whether to propagate
backpressure back to apps. This change expands that check to all
displays so that if an external or virtual display is using client
composition it disables backpressure propagation as well.

Bug: 30022738
Change-Id: I7f7d4e0a1ea7d27ef1f280e2b4ebd5e5bd3bd911
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
605d15afbb801ddeee173a3f430006bd25c07d2e 21-Jul-2016 Pablo Ceballos <pceballos@google.com> SF: Make screenshot surface async

It will only ever have one frame pushed to it and this guarantees that
the late-latching logic will always latch it immediately.

Bug 30209608

Change-Id: I875cb5ea258ebb0afae5d1af4ad946475c2240bc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c353f015c3e52339811cb83c991daa59663971aa 21-Jul-2016 Dan Stoza <stoza@google.com> Merge \\"HWC2: Add properties to revert latching changes\\" into nyc-mr1-dev am: d16f6ae2bd
am: 3569f1fe4e

Change-Id: I430c5609590d2c5f04bf6a07ff509430a2bcdf9f
3569f1fe4e7faf64720c6e023bfdf76347f5b2b6 21-Jul-2016 Dan Stoza <stoza@google.com> Merge \"HWC2: Add properties to revert latching changes\" into nyc-mr1-dev
am: d16f6ae2bd

Change-Id: I27f8bd2c5e3756ffa809dfeed4887ea849e4eb3c
d16f6ae2bd1083ee29717829a39e93908bba2bf5 21-Jul-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "HWC2: Add properties to revert latching changes" into nyc-mr1-dev
c5da271eec001da9e11a2786f2618a45257439c3 21-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Add properties to revert latching changes

Adds two properties:

debug.sf.latch_unsignaled - This causes SurfaceFlinger to latch
buffers even if their fences haven't signaled
debug.sf.disable_backpressure - This causes SurfaceFlinger to skip
propagating backpressure back to apps by not running when it
detects that a prior composition missed hardware vsync

Bug: 30216498
Change-Id: Idd70f472ec567a4bc03352f30f201f434cf5d660
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c4cba997508820c5ffbbcdca8d4769944a7caacf 20-Jul-2016 Michael Wright <michaelwr@google.com> Merge commit '19cd2f88b6914e2f4c43a9595532e81a697304fe' into fresh-again

Change-Id: I6032eea1ad12960fc1c88582ae295f83c84bb37e
19cd2f88b6914e2f4c43a9595532e81a697304fe 20-Jul-2016 Michael Wright <michaelwr@google.com> Merge \"Color transforms are now color modes.\" into nyc-mr1-dev
am: f42ca4da5b

Change-Id: I2b5f704695dbbf84baf56b21369c3c80cc2142e1
28f24d0ab481bd9c6fd5618414fee694e837c5c6 12-Jul-2016 Michael Wright <michaelwr@google.com> Color transforms are now color modes.

Rename color transforms to color modes for all interfaces exposed to
surfaceflinger clients. Also split it out to be a separate
configuration value from display modes.

Bug: 29044347

Change-Id: I87e937f7c954a50c946e8e2c606797caa416c5d8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
615e573cae9eca90ffc7f6527393a97914107cdf 15-Jul-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add support for color transforms am: 9f26a9c8be
am: 840dae503c

Change-Id: I64e2d133031c010aa12c5e8c764f4845357b6c42
840dae503c00ad207ab4f1396347817dbb68ed3c 15-Jul-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add support for color transforms
am: 9f26a9c8be

Change-Id: I0622633dd37d3695458deb94f8ca7c7c337a73e7
9f26a9c8be6f00f55cbc30b93adf4895c6a093aa 22-Jun-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add support for color transforms

Adds support for color transforms using the setColorTransform method
of HWC2.

This means that instead of always falling back to client composition
when applying a transform, SurfaceFlinger will allow the device to
make that decision. If all layers fall back to client composition, the
SKIP_CLIENT_COLOR_TRANSFORM capability allows the device greater
control over whether SF should apply the transform or whether it
should allow the device to apply it to the client target buffer.

Bug: 19539930
Change-Id: I47a3d5453a3c47a8dd105ab77cce7f9c9687e925
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9a33f76219690a8991428361acf9751bb655be92 14-Jul-2016 Evgenii Stepanov <eugenis@google.com> Merge \\\\"Workaround alloc-dealloc-mismatch error on ASan device boot.\\\\" am: 7d8f246415 am: 23d1d10872 am: 316c5165bc
am: e96d025385

Change-Id: Id15ed9fe2e651647a6ab8990f82fc38f4ef05bf8
e96d025385e742f8d9a571f5713227b141d79eba 14-Jul-2016 Evgenii Stepanov <eugenis@google.com> Merge \\\"Workaround alloc-dealloc-mismatch error on ASan device boot.\\\" am: 7d8f246415 am: 23d1d10872
am: 316c5165bc

Change-Id: I585c6737d3811110bd519b5cc375f0219fee7927
23d1d108720beff1f37e6e8aecaea9045f1968f7 14-Jul-2016 Evgenii Stepanov <eugenis@google.com> Merge \"Workaround alloc-dealloc-mismatch error on ASan device boot.\"
am: 7d8f246415

Change-Id: Ic34e6263619b98739f935e0aa05bf50aa7399829
22819276b147e34a80e8ca696be5b3fda68764b9 14-Jul-2016 Evgenii Stepanov <eugenis@google.com> Workaround alloc-dealloc-mismatch error on ASan device boot.

/proc/self/environ inaccessible in SurfaceFlinger
=> ASan fails to read ASAN_OPTIONS => alloc-dealloc-mismatch bug is not
suppressed and prevents the device from booting.

This is not perfect because, by enabling it in asan build only, the first several attempts to start
surfaceflinger fail while the /data partition is being encrypted. On the other hand, this does not affect
user builds, and device eventually gets up anyway.

BUG=b/30067360

Change-Id: Ieaa37ff7768a11450ea33fee1f7d70a41b246c6a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8305f25b66773e914a3fe1df19d8aa7783df03af 13-Jul-2016 Courtney Goeltzenleuchter <courtneygo@google.com> Merge changes Iea048eaa,I5c246571 into nyc-mr1-dev am: 72d1772eca
am: 340680891a

Change-Id: If71c96930270a5290e066c29477305686e3b1d2d
fad9d8cd070e94749d8eb5be8f92011c9567a44c 23-Jun-2016 Courtney Goeltzenleuchter <courtneygo@google.com> Add support for multiple color modes

Bug: 29044347
Change-Id: Iea048eaa62f072a9bbefc4f3a6c29a9e593eab69
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1485624fa9ed071368e8b89452a25971e68dd456 08-Jul-2016 Dan Stoza <stoza@google.com> Merge \\"HWC2: Backpressure on transactions as well\\" into nyc-mr1-dev am: e365c9945e
am: 895b177c4d

Change-Id: Id4c5ec2af8cf5dffee50f91ce302e8a559e8c39c
5018288a44ca53b64fce17b3bfb9656a79cc3465 08-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Backpressure on transactions as well

Modifies the backpressure detection to skip transactions as well as
buffer updates.

Bug: 29413700
Change-Id: I97cda920e7fc1cd7151f0a4df1b00f96b84f4145
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f31493efd6e105238497647f2749ba60644e24f9 07-Jul-2016 Tim Murray <timmurray@google.com> surfaceflinger: make critical threads SCHED_FIFO am: 41a3853cea
am: ce680f8b2c

Change-Id: I9122dc6982467943af4801e52b191809b4192625
41a3853cea0cffede422fc2692b9c8e1674fc5eb 22-Jun-2016 Tim Murray <timmurray@google.com> surfaceflinger: make critical threads SCHED_FIFO

Sets the main thread, EventThread, and SFEventThread to SCHED_FIFO to
minimize jitter.

bug 24503801

Change-Id: I3751c00c79482842f5c0bdaec92b6cbfe62328a0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e11eead86164a3bfc96f6226fc23a1f5c1f92067 07-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Backpressure missed vsyncs into apps am: 05dacfb68a
am: d5193eb9a4

Change-Id: I059c90695cdaef5cb57531d53215baf9856bce56
05dacfb68af895fce3cc8ebb0b4aa06c6c336e26 01-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Backpressure missed vsyncs into apps

Adds a mechanism to detect whether the prior frame SurfaceFlinger
presented to hardware composer was actually picked up or not. We then
use this mechanism to avoid pushing two frames in the same vsync.
This backpressure is passed back to applications by not latching any
buffers, which will manifest as dequeueBuffer stalling until
SurfaceFlinger releases a buffer on the following vsync.

Also makes the former INVALIDATE_ON_VSYNC behavior the only behavior
so that this functionality works correctly.

Bug: 29413700
Change-Id: Ibde358e45423ee6fea7b5e09ff65e49c4ad67baa
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
689fa1e78a3d1a2bfcef08defe34533eba0284c9 22-Jun-2016 Robert Carr <racarr@google.com> Merge changes from topic \\'seamless-rotation\\' into nyc-mr1-dev am: 4bfbe1f7ef
am: d99daf4fe6

Change-Id: Iaabf524a3b835b794b2b1269cd573b66676be9a1
99e27f0bc236e38d88ff4f9912ede514a729b8eb 17-Jun-2016 Robert Carr <racarr@google.com> Change setPositionAppliesWithResize to apply to all geometry.

To support seamless rotation, change setPositionAppliesWithResize
to also include the crop. As the transformation matrix is already
frozen during resize, this enables the window manager to set the
total geometry state before and after resize in a race free fashion.

Bug: 28823590
Change-Id: I3f8f0e162b7ef4e9403c1220c7e4191b3ef30526
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
25207934b4936b796db8604df42d90bbb4cfd00b 20-Jun-2016 Dan Stoza <stoza@google.com> Merge \\"HWC2: Skip validate/present if display is off\\" into nyc-mr1-dev am: 9409a53b45
am: 495a15491f

Change-Id: If771408108db1ded2b2fae404e98c439aa4ce911
7bdf55aacf84715fae7dcd495756d9606e900a86 17-Jun-2016 Dan Stoza <stoza@google.com> HWC2: Skip validate/present if display is off

Adds checks to ensure that the display is still on before attempting
to call into prepareFrame/commit (which in turn call into
validate/present).

Bug: 28596387
Change-Id: Iad87f02c3e44e86db43a15c258ee66b0cde14faa
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2eca129e15a3ad95e9df2f7032ecc9c46a4c0e10 09-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge \\"Plumbing for getting FenceTracker timestamps\\" into nyc-mr1-dev am: 9e8143ec78
am: a26e661886

Change-Id: I91220ec2367d97104e0e2f37852fe7679912180a
9e8143ec78a0bf3779f12000b67f21b8fba6e2a7 09-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "Plumbing for getting FenceTracker timestamps" into nyc-mr1-dev
ce796e78a57018f186b062199c75d94545318aca 05-Feb-2016 Pablo Ceballos <pceballos@google.com> Plumbing for getting FenceTracker timestamps

Change-Id: I1ebee9e42e28658bd3a2b161fdaabb7da756d8f3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8a95daddd965fff9d7bb7c86e227f97c6adc5efc 07-Jun-2016 Robert Carr <racarr@google.com> Merge "SurfaceFlinger: Add mode to apply position with resize." into nyc-dev am: c3da482bb8 am: 3fee6ca1d9
am: f7b6b5d956

* commit 'f7b6b5d956f96458567eae519a926a6f51b077c0':
SurfaceFlinger: Add mode to apply position with resize.

Change-Id: Ib4476cc6aff4b4f39093a5047182f3f30ac57a77
3fee6ca1d93c1d4b822d2dcd36c61f9722dd88b9 07-Jun-2016 Robert Carr <racarr@google.com> Merge "SurfaceFlinger: Add mode to apply position with resize." into nyc-dev
am: c3da482bb8

* commit 'c3da482bb8081ee2c19b5965585267b8e21cfc7e':
SurfaceFlinger: Add mode to apply position with resize.

Change-Id: Icedb7a6e37da9338b1194edaa32a67257640969f
82364e3cea0bf88fa8147766433329b3dd5148b8 15-May-2016 Robert Carr <racarr@google.com> SurfaceFlinger: Add mode to apply position with resize.

For some cases, like scaled windows with shadows,
we need to be able to apply the position concurrent with
window resize. This is because the scaling of the shadows causes
the top left coordinate of the non shadow surface content
to change before and after the resize.

Bug: 28899837
Change-Id: I522eacfbbcd79707dc1e5ab71901a263b3004ba9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
be515e1f4c232fec9a555076fac43b97400d71e1 02-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Re-enable fence tracker by default" into nyc-mr1-dev am: 30689c9e4c
am: 22fa825ebb

* commit '22fa825ebbf318dc7942c18a057791a54c7b9bff':
SF: Re-enable fence tracker by default

Change-Id: If988c4a07b5fd20c2fae16e29a9a5cb699329716
5045ab2bb14110f577e3cfff8acfae906dc29935 18-May-2016 Pablo Ceballos <pceballos@google.com> SF: Re-enable fence tracker by default

- Don't check whether the fences have completed or not unless the data
has been requested.

Bug 22431447

Change-Id: Id4cb8bfba38547884849ef23c9b6f42f0d4d0750
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b871b7afa1202d6622432e6164903d5156e6257b 25-May-2016 Dan Stoza <stoza@google.com> Merge "BufferQueue/SF: Add OccupancyTracker" into nyc-mr1-dev am: faa71321b0
am: 3bfd2e196d

* commit '3bfd2e196d248536207bf1e0acfe86bd4d786d1d':
BufferQueue/SF: Add OccupancyTracker

Change-Id: I0afeef4817c982bff0c0034b162aff91d5cd5bb1
faa71321b0862fac97ad1f7825860fb740cc8507 25-May-2016 Dan Stoza <stoza@google.com> Merge "BufferQueue/SF: Add OccupancyTracker" into nyc-mr1-dev
83630f285013d0dc69b616264ccd79cdabf2f11b 25-May-2016 Robert Carr <racarr@google.com> Merge "SF: Force empty sync transactions to apply anyway" into nyc-dev am: 7443c1f253 am: 2d10b6df79
am: 864652f92f

* commit '864652f92f498b867b593acce5c7a79a55075f40':
SF: Force empty sync transactions to apply anyway

Change-Id: Ib26d08538b9d9fbe953a601208c90ece61126e12
7443c1f253008acd868af1e35449dd5eb3139c8d 25-May-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SF: Force empty sync transactions to apply anyway" into nyc-dev
2a7dbb4135976b01015d237ac95d5eeb3ed7a85c 24-May-2016 Robert Carr <racarr@google.com> SF: Force empty sync transactions to apply anyway

Following the change to not flush transactions in the screen shot
path, this enables the use of empty synchronous transactions as a
flush mechanism for previous asynchronous transactions.

Bug: 27098060
Change-Id: I282fdfffb72db148edcbf1ded65b15816fc714a2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f0e0f93d3d634d0fc02b51d72071b63c8cd2989a 24-May-2016 Dan Stoza <stoza@google.com> Merge "SF: Remove forced transaction on screenshot" into nyc-dev am: 854071a38f am: 7c1e3865a9
am: 4a8ac7cb46

* commit '4a8ac7cb46500538b964bc8247ff3159fb65d9f5':
SF: Remove forced transaction on screenshot

Change-Id: Id3378fca35a988b475ec06e4888c5883cbeacac4
854071a38f250bd0638f1dfdb99b9ccc0010e7d0 24-May-2016 Dan Stoza <stoza@google.com> Merge "SF: Remove forced transaction on screenshot" into nyc-dev
6b5d740d54fd3cf9f0f57098e981141ca0c02d9f 24-May-2016 Dan Stoza <stoza@google.com> Merge "HWC2: Fix breakage from header change" into nyc-dev am: 80bc52aefa am: fce9f9cfce
am: 8827b8a75e

* commit '8827b8a75eb858ae3778fb491b136a4a029107a4':
HWC2: Fix breakage from header change

Change-Id: I282f18bdaccc9c792ec967775bf4779f6d91ed2c
5cf424bc129f01ee12c7a4fbea1664276d29f970 20-May-2016 Dan Stoza <stoza@google.com> HWC2: Fix breakage from header change

Updates the shim and adapter to handle the header changes introduced
by "HWC2: Add format to VD create, surface damage" in libhardware.

Bug: 22767098
Change-Id: I8142301c121d9b5602a4455f3fbadefefd685cf0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
14e54ba747942312f5cd143a27e603eacd7573f7 16-May-2016 Dan Stoza <stoza@google.com> SF: Remove forced transaction on screenshot

Removes the forced transaction that screenshots used to perform
before capturing the screen. This was initially added to prevent
screenshot capture from sneaking in between when a transaction is
closed and when it is actually applied (at the next vsync), but in
the presence of deferred transactions today, forcing a transaction
to occur doesn't guarantee that the last transaction that
WindowManager pushed has actually been committed yet, since it may be
waiting for a buffer with which to synchronize.

If WindowManager wants to guarantee some arrangement of windows is
present for a screenshot, it needs to set the synchronous flag to
true when calling closeGlobalTransaction and wait for the call to
return.

Bug: 27098060
Change-Id: Iaa36d76df521076cc8ed16576f651543bae419a8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e77c7669bee30b7c0099172cf0c38cef92412040 13-May-2016 Dan Stoza <stoza@google.com> BufferQueue/SF: Add OccupancyTracker

Adds an OccupancyTracker to BufferQueue. This module keeps track of
how many buffers are in the queue over time, which, in combination
with various aggregation of these statistics, allows SurfaceFlinger
to report what fraction of the time a given layer was double- or
triple-buffered.

Change-Id: Ida6e967dc5483c00a633e9fe03998e420dd88502
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fb9d4c34d09c4c1f128abe045dcc6cbbb1ae0188 11-May-2016 Dan Stoza <stoza@google.com> Merge "Merge "SF: Apply translations to transparent region" into nyc-dev am: df98fb952f am: 624eb0c228" into nyc-mr1-dev-plus-aosp
am: 1ba29bdefd

* commit '1ba29bdefdb61d76573fb547e3cd7b398dfa7f79':
SF: Apply translations to transparent region

Change-Id: I46515daa4f98e0e2f9d46ea07e9f16b90fb05fad
22f7fc45af6ce8c1a2b9543315347bd44d1c9e08 11-May-2016 Dan Stoza <stoza@google.com> SF: Apply translations to transparent region

Correctly applies translation-only transforms to the transparent
region so that it aligns with the layer bounds in screen space.

Bug: 28220791
Change-Id: If9137b873f4b89890127671d8c45745e079f1cbc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c406791ead6d864ec693ad01a80c5f471bdc2a7a 03-May-2016 Chih-Hung Hsieh <chh@google.com> Fix google-explicit-constructor warnings.

Bug: 28341362
Change-Id: I7e061f68acdde368a3b63c029b928133646ebff2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0a3c4d6f8c95a89875455e989278a440822968d7 19-Apr-2016 Dan Stoza <stoza@google.com> DispSync: Don't resync if HW vsync is unavailable

Don't attempt to resync to hardware vsync if it's not available (if
the display is blanked), which should prevent unusual sequences of
commands (enable vsync, then unblank) to hardware composer.

Bug: 28177844
Change-Id: I9d6046fb0a346830e98829fd250642f0809d7e31
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6328134d8f3969e5cf345bec84b2c6455afc6a34 19-Apr-2016 Tim Murray <timmurray@google.com> Merge "Revert "Revert "DispSync: Always resync after inactivity""" into nyc-dev
4a4e4a239f034cb8af2df9a438b26c3bc088889c 19-Apr-2016 Tim Murray <timmurray@google.com> Revert "Revert "DispSync: Always resync after inactivity""

This reverts commit 67264e930992e43ef3351b04692d4ca59cbb01ad.

We've fixed the kernel issues this exposed.

bug 28198793

Change-Id: Ie895cc0a815094cce4bee3b2bf45800ee1e2fdc3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c3574f7b0141c69fdca25ccafb80ff334462f9a3 24-Mar-2016 Robert Carr <racarr@google.com> Add setOverrideScalingMode to SurfaceControl

Provide an interface for the window manager to override
the client specified scaling mode. This makes it possible
for the window manager to force windows to be scaleable
for animations, etc, even when a resize is pending.

Bug: 27891386
Change-Id: Ic4aae9917bd6869ee0dbb425979b4e21c68342a3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ccf8058396c3ac8d1e296b9c0ba5f6317cc90661 15-Apr-2016 Tim Murray <timmurray@google.com> Merge "Revert "DispSync: Always resync after inactivity"" into nyc-dev
67264e930992e43ef3351b04692d4ca59cbb01ad 14-Apr-2016 Dan Stoza <stoza@google.com> Revert "DispSync: Always resync after inactivity"

This reverts commit f34b9be610ce286af224364cb6e69ef6f7697ee9.
Bug: 28160740

Change-Id: I48a5bd66712651b42fdc0aaf1492899d7b032977
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7e5e1287276efba71cceec75c495c21ecec4f147 11-Apr-2016 Dan Stoza <stoza@google.com> Merge "DispSync: Always resync after inactivity" into nyc-dev
97a46df0ee9708822f190a76047c490f54c199cd 09-Apr-2016 Dan Stoza <stoza@google.com> Merge changes I0f07043f,Ib4635ee4,I472ad9f0 into nyc-dev

* changes:
Plumb HDR capabilities up to SurfaceComposerClient
HWC2: Add getHdrCapabilities to C++ shim
HWC2: Add getHdrCapabilities stub to adapter
c4f471e75a8ec64ec34e3f2944a5a756215d0bec 24-Mar-2016 Dan Stoza <stoza@google.com> Plumb HDR capabilities up to SurfaceComposerClient

Plumbs HDR capabilities up from HWC2 through SurfaceFlinger and
ISurfaceComposer to SurfaceComposerClient.

Bug: 25684127
Change-Id: I0f07043ff42bfc7a159f785fee3e84936dc3c280
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f34b9be610ce286af224364cb6e69ef6f7697ee9 06-Apr-2016 Dan Stoza <stoza@google.com> DispSync: Always resync after inactivity

Changes DispSync to enable hardware vsync immediately when new frames
arrive after a period of inactivity.

No matter how hard we try, we can't avoid drifting over time without
being able to detect error based on display retire fences. By enabling
hardware vsync immediately, we avoid having a weird period or phase
offset relative to hardware while we retrain the model. Once the model
has locked, we turn hardware vsync back off to save power (until we
detect drift again).

Bug: 26255070
Change-Id: If4dd17c2d541015c730f47d824359d7cb4b52c3c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2dc3be88bd85791556ab0e6df6a080989886749e 06-Apr-2016 Dan Stoza <stoza@google.com> SF/HWC2: Reorder makeCurrent to avoid deadlock

Now that we are deferring the release of FramebufferSurface buffers
(so that we can return a non-speculative fence), we end up holding
two acquired buffers during the call into HWComposer::commit (whereas
we previously would have only been holding one, with the other having
been released). This means that if the EGL implementation dequeues a
buffer as part of eglMakeCurrent, neither of the FramebufferSurface
buffers will be free, and the call to dequeueBuffer will block.

This change fixes that issue by reordering eglMakeCurrent to occur
after the deferred release.

Bug: 25684127
Change-Id: I6ec55b3f7b7d0e0f5be6029751cb086feeb52fbe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
69a1a389321447301a8eaba235190dc1229aefbd 31-Mar-2016 Pablo Ceballos <pceballos@google.com> SF: Disable FenceTracker from makefile

- Add tracing to the FenceTracker.
- Disable it by default with #ifdefs, it can be enabled in the
makefile.

Bug 27882222

Change-Id: I640e028c4dc97b46e800a7f21cdb2cb6a4b4ff18
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
830f5004da53a83e23b4102ba9b72e4cb366cb34 25-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Add FenceTracker" into nyc-dev
acbe67888f0bd65d5400400f0115bae6bd6199dc 04-Mar-2016 Pablo Ceballos <pceballos@google.com> Add final crop implementation

Bug 26559810

Change-Id: Idaccd13cd625c92d18665ddecebdbb266ea365f3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
40845df1285b387bcbf8f43ac72228eee2606d80 26-Jan-2016 Pablo Ceballos <pceballos@google.com> SF: Add FenceTracker

FenceTracker tracks all fences in SurfaceFlinger. These timestamps
could be used for debugging, profiling, or be exposed to the
application.

Change-Id: I4297a661c0a7530e744168ac7a2a66c4bca92fd5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f3209b03b3adbf6868c2dcadb07adc5f865f5688 10-Mar-2016 Prathmesh Prabhu <pprabhu@google.com> Do not queue trivial buffer for unsupported screenshot request.

When screenshot is not supported, we queue an empty buffer to the
requesting producer. Besides returning a useless screenshot, this
overwrites the valuable error code, returning ERROR_OK whenever we
successfully return the trivial buffer.

Instead, refuse to queue the trivial buffer, and return the original
error code.

This replaces the workaround proposed in
I6da5d2fdecdef6c87d4dd7b353e2464678800110

BUG:27505438
Change-Id: I597a9be25071d2a6ddafb7d39cc1b09fb48d5fd0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3dcabfab7ef80df5884b269fec17350a26da6f51 02-Mar-2016 Robert Carr <racarr@google.com> Latch transform with geometry state.

WindowManager would like this feature for animating
windows between sizes. For example, if we are animating
from a smaller to larger window, we need to complete the resize
at the beginning of the animation to avoid up-scaling. However
to avoid artifacts we need the window to appear at its old size
following this resize, so we use the transform to scale down. However
as the transform is latched immediately, we result in a frame where
the window is too small, until the resize is complete. This is
a change in behavior but it's hard to understand how it could
cause errors. Previously if someone wished to set the transform
and resize a window in the same transaction, then the results
would be undefined (depending on the state of the window buffer),
and there would be no avenue for synchronization.

Bug: 26454664
Change-Id: I4e8475967e0a19aa5879af965a5716eb173f9700
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9e56aa0fdb5f7121b9b975c6c16db103ea4d2fe9 02-Nov-2015 Dan Stoza <stoza@google.com> Switch SurfaceFlinger to HWC 2.0

Enables SurfaceFlinger to speak to version 2.0 of the Hardware Composer
HAL instead of version 1.x (also removing support for the framebuffer
HAL). By default, however, this functionality is disabled. In order to
enable it, USE_HWC2 must be set to true in Android.mk.

Change-Id: I4589e02ac2165236b10ff2f7cb772f87e0d3daab
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b5b3563058c178811d434ab6e8c4ead4a519701b 23-Feb-2016 Pablo Ceballos <pceballos@google.com> SF: check secure layers in screenshot message handler

- Instead of checking for the presence of secure layers on the Binder
thread, check in the message handler. Transactions may have occurred
in between when the check is done and when the screen shot message
is handled.

Bug 23757877

Change-Id: Iec74193996ca72c60f86f7c0f0b2a5dea8d19543
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
70982a5f95f68295244e5f6cc037c193713a5259 12-Jan-2016 Dan Stoza <stoza@google.com> Revert "libgui: Remove custom BufferQueue allocators"

This reverts commit acd56150573d3a6d449c0de01f93c6f269d121e3.

Change-Id: I877f63a57fbddb4dcff71b3909b460ecc05981eb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
acd56150573d3a6d449c0de01f93c6f269d121e3 08-Jan-2016 Dan Stoza <stoza@google.com> libgui: Remove custom BufferQueue allocators

Removes the ability to set a custom GraphicBuffer allocator for a
BufferQueue. Custom-allocated buffers may still be used through the
attachBuffer call.

Change-Id: I127bdfb496fc089a61c7e266c8bd2b906d41f32e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
47db6ebf45c74b6de94afed05c0aa9c1d8a0fda8 08-Dec-2015 Pablo Ceballos <pceballos@google.com> SF: Prevent accidentally re-adding a removed layer

Bug 25887783

Change-Id: Ib13ebdfb55d40c0f2175b2bc521214a07281e69a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7dde599bf1a0dbef7390d91c2689d506371cdbd7 22-May-2015 Dan Stoza <stoza@google.com> Support SurfaceView synchronization.

Add API for fetching the next frame number to be produced by
a given buffer producer. Add an API to SurfaceComposer to
defer execution of the current transaction until a given frame number.
Together these may be used to synchronize app drawing and surface
control updates.

Change-Id: I8e0f4993332ac0199c768c88581a453fefbaff1d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
71b2947cfd1be2795a2e1313f4b799c5588c3430 04-Sep-2015 Dan Stoza <stoza@google.com> am afdbddbe: am e5ce0db8: am f090d598: am 3e4c8ccc: Merge "SF: Add colorTransform to DisplayInfo" into mnc-dr-dev

* commit 'afdbddbef57b3ffafa5b6a2107f37fda06dec9d4':
SF: Add colorTransform to DisplayInfo
f2699fc3a8c12b2bf95120c068801e050168bd96 31-Aug-2015 Dan Stoza <stoza@google.com> SF: Add colorTransform to DisplayInfo

Adds the colorTransform field, which defines a vendor-specific color
transform (e.g., wide gamut, sRGB, etc.) to the DisplayInfo class, and
populates it from the HWC interface.

Bug: 20853317
Change-Id: I153edc36a361407656f3eb5082b96c2da2ecbec7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
29370d3bd744209a5cd6cb6384139486c3405f75 06-Aug-2015 Pablo Ceballos <pceballos@google.com> Merge "libgui/SF: Fix some code warnings"
53390e1e8c33ebee5bb8100e846f5263ba05ff73 04-Aug-2015 Pablo Ceballos <pceballos@google.com> libgui/SF: Fix some code warnings

A couple of fixes to satisfy the Eclipse static code analysis tool.
- Initialize all members in constructors
- Remove unused forward declarations
- Add parentheses when combining logical and bitwise operators
- Fix a case statement with no break (it was intentional)

Change-Id: Icecb8cc98c6f58b97ab33fffb621f0edc33a7d3c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
47b11d38b3ce686bf5feeccb5e151f4542a7c301 05-Aug-2015 Dan Stoza <stoza@google.com> am bc120be8: am 2121b937: am 04eeb288: am 50be1df7: Merge "SF: Track missed frames and optionally drop them" into mnc-dr-dev

* commit 'bc120be8d7ff639408048fc3f105abd0aa6cfbe2':
SF: Track missed frames and optionally drop them
0a688f5005b512b96d676a7fa6e23be9132a492c 31-Jul-2015 Yusuke Sato <yusukes@google.com> Record an event log when service.bootanim.exit is set

to track (user-perceived) OS boot performance.

Bug: 21331462
Change-Id: I54200c9a3bfce1edfd8cbdf05d850bdf199f48f2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
14cd37cf3d7d783eaeb4cfb5f1f9e712d3b49578 09-Jul-2015 Dan Stoza <stoza@google.com> SF: Track missed frames and optionally drop them

Adds code to track whether SurfaceFlinger has sent two frames to HWC in
the same vsync window. This can occur if one frame is delayed so far
it slips into the next window or just if one frame takes an abnormal
amount of time. If this occurs, it shows up as FrameMissed in systrace.

Also adds a property debug.sf.drop_missed_frames which, if set, tells
SurfaceFlinger to skip sending a frame to HWC (i.e., calling
prepare/set) when we detect this condition, which can help prevent
backpressure from the HWC implementation.

Bug: 22513558
Change-Id: I2df0d44cec5fd6edba419388d8c90b5710d1a5b6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6a25a2872852f23058268adcec61600460fcdfb6 30-Jun-2015 Dan Stoza <stoza@google.com> am 806334aa: am 1998615f: Merge "sf: Initialize EventThread before creating HWC"

* commit '806334aacd089d1c419ed77021a2b1bb4f7644ef':
sf: Initialize EventThread before creating HWC
231160866738f6ed2175701f300fed1a8e8e02b0 18-Jun-2015 Dan Stoza <stoza@google.com> libgui/SF: Propagate SECURE Layer flag changes

This allows changes to the SECURE flag to propagate down to
Layers in SurfaceFlinger so that WindowManager can change it on the fly
in response to device policy updates.

Bug: 20934462
Change-Id: I558f6d22c6273be373f1f480365e42536af18a33
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f9481058101c4e2b38c74048feac383664691d03 16-Jun-2015 Saurabh Shah <saurshah@codeaurora.org> sf: Initialize EventThread before creating HWC

Once HWC is created, it could use any of the provided hooks, which
could lead to a crash if the EventThread (handler) isn't initialized
prior to creating HWC.

Change-Id: I5ea35fe9bcb150fb74aae1295b798bd787ad6cee
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
40da48bfdf5d2d199aac55891d2f37822cdbee88 30-Oct-2014 Tatenda Chipeperekwa <tatendac@codeaurora.org> sf: Add a NULL check in getDisplayConfigs

Validate the display binder by adding a NULL check in getDisplayConfigs.
This will prevent a false match if the caller queries the display
configs for an inactive display (whose binder is NULL by default).

Without this change we might end up attempting to index the display
config array, which is unpopulated for inactive displays, and this will
result in a crash. (See getDisplayInfo in SurfaceComposerClient.cpp for
an example of this scenario)

Change-Id: Ib32a7dc8378d3438df0dba1ecd608bbcfc837717
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
23e16bb5dae277cd20a739ca56553ae931c43ccf 30-Oct-2014 Tatenda Chipeperekwa <tatendac@codeaurora.org> sf: Add a NULL check in getDisplayConfigs

Validate the display binder by adding a NULL check in getDisplayConfigs.
This will prevent a false match if the caller queries the display
configs for an inactive display (whose binder is NULL by default).

Without this change we might end up attempting to index the display
config array, which is unpopulated for inactive displays, and this will
result in a crash. (See getDisplayInfo in SurfaceComposerClient.cpp for
an example of this scenario)

Change-Id: I1a12f43b7c375b9c01998dadd5b658275c733fb2
(cherry picked from commit ac71c26e9180d9d181be5ec9e45da72d39144a8b)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
65dc7eeff096c3b909d7932c8a94e61c31f76831 10-Jun-2015 Dan Stoza <stoza@google.com> SF: Swap w/h when capturing rotated screenshots

Swaps width and height when capturing a screenshot that is rotated by
90 or 270 degrees.

Bug: 8433742
Change-Id: Ibf0b604f541e3cc271e56fe0ad04dc366beb5d79
(cherry picked from commit 3502416204d9dbd905012ee586d8bd145323809f)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3502416204d9dbd905012ee586d8bd145323809f 10-Jun-2015 Dan Stoza <stoza@google.com> SF: Swap w/h when capturing rotated screenshots

Swaps width and height when capturing a screenshot that is rotated by
90 or 270 degrees.

Bug: 8433742
Change-Id: Ibf0b604f541e3cc271e56fe0ad04dc366beb5d79
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8b04725f1426d7543b5f38283ee53c95f071a7bc 11-Apr-2015 Jeff Brown <jeffbrown@google.com> Bypass surface flinger permission check for calls from system.

Early during the boot, before activity manager is ready to handle
permission checks, the system needs to be able to change the display
state. Added a hardcoded exemption for AID_SYSTEM (which already
has permission to talk to surface flinger anyhow).

Bug: 19029490
Change-Id: I6222edcab8e394e5fb6adf7a982be446e4505a1e
(cherry picked from commit 3bfe51d7901e99e7f122f76ed2708e2b67b71cf9)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8e8eba5091de03d33d667ce1e6ba5fe7072926ba 21-Oct-2014 Dan Stoza <stoza@google.com> SF: Skip render-to-texture for color transforms

In cases where SurfaceFlinger is applying a color matrix (usually for
accessibility features), we previously would perform a render-to-
texture for the initial composition, and then apply the matrix during
a copy to the framebuffer. This changes that behavior to just apply the
matrix during composition without a render-to-texture pass.

This may result in a perceived change of the image in cases with alpha
blending, since the blending is performed at a different stage of the
pipeline and the system effectively performs non-linear blends.
However, neither this nor the prior render-to-texture pass is strictly
correct in that regard, and this approach is less error-prone and
likely faster.

Change-Id: I2110ff0374f61d76df7b087dde8a1ed98990440c
(cherry picked from commit f008799d3753e52c10849824ff8146985ea66284)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b64d87515212d795405c6b3622dd365202eb4c39 21-May-2015 Michael Lentine <mlentine@google.com> Fix surfaceflinger tests.

Update the screenshot code and add correct return values to surface flinger's
capturescreenshot function.

Buf: 18138368

Change-Id: Ieb42d289088589f941502fbd69da7aa939265e07
(cherry picked from commit 5a16a62950de06d48769e29f0c68a154ed7a7a89)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f008799d3753e52c10849824ff8146985ea66284 21-Oct-2014 Dan Stoza <stoza@google.com> SF: Skip render-to-texture for color transforms

In cases where SurfaceFlinger is applying a color matrix (usually for
accessibility features), we previously would perform a render-to-
texture for the initial composition, and then apply the matrix during
a copy to the framebuffer. This changes that behavior to just apply the
matrix during composition without a render-to-texture pass.

This may result in a perceived change of the image in cases with alpha
blending, since the blending is performed at a different stage of the
pipeline and the system effectively performs non-linear blends.
However, neither this nor the prior render-to-texture pass is strictly
correct in that regard, and this approach is less error-prone and
likely faster.

Change-Id: I2110ff0374f61d76df7b087dde8a1ed98990440c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5a16a62950de06d48769e29f0c68a154ed7a7a89 21-May-2015 Michael Lentine <mlentine@google.com> Fix surfaceflinger tests.

Update the screenshot code and add correct return values to surface flinger's
capturescreenshot function.

Buf: 18138368

Change-Id: Ieb42d289088589f941502fbd69da7aa939265e07
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7d89d06a6fe1bfadfe277f19dbb7e4aa021444e0 30-Apr-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Limit to 4k Layers

Sets a limit of 4k Layers which SurfaceFlinger will allow to be in
existence at any given time. An attempt to create Layers in excess of
this limit will fail with NO_MEMORY.

Bug: 20674586
Change-Id: I2dfaf59643d826f982b2fa44e8a9ed643176d972
(cherry picked from commit e7f8dde3f3c398c1ea1bec14e76725a760f71d31)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e7f8dde3f3c398c1ea1bec14e76725a760f71d31 30-Apr-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Limit to 4k Layers

Sets a limit of 4k Layers which SurfaceFlinger will allow to be in
existence at any given time. An attempt to create Layers in excess of
this limit will fail with NO_MEMORY.

Bug: 20674586
Change-Id: I2dfaf59643d826f982b2fa44e8a9ed643176d972
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d5296b342e51bd41c9b1d26e98978d9b9ef23a89 16-Apr-2015 Dan Stoza <stoza@google.com> am 66dc4ee3: am b47584f4: am 2e398e64: Merge "SF: Permit changing DispSync offsets at runtime"

* commit '66dc4ee3729c4e6fea624805a1e58843ce920477':
SF: Permit changing DispSync offsets at runtime
91dea34652ff891192148b4062a80c2e8f0852ce 15-Apr-2015 Dan Stoza <stoza@google.com> am 19f06de0: am 40b2a8b4: am e7d20eb0: Merge "SurfaceFlinger: Pass surface damage to HWC"

* commit '19f06de0930e0f741ed113c37faf306fceee39bd':
SurfaceFlinger: Pass surface damage to HWC
db4ac3ce63074f5602b46074ffeabfea4a14d032 14-Apr-2015 Dan Stoza <stoza@google.com> SF: Permit changing DispSync offsets at runtime

This modifies EventThread such that its phase offsets for both
Choreographer and SurfaceFlinger may be modified at runtime. It also
plumbs this functionality up to the SurfaceFlinger debug interface so
that it is possible to rapidly test different offsets without
restarting the framework.

Change-Id: I426873f8553f931250dfebc9a8a4a78e9f1f4309
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ee44edd0acccbf5eaa918d75737c3b65ee04fff7 23-Mar-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Pass surface damage to HWC

Passes the surface damage from the incoming SurfaceFlingerConsumer
BufferQueue down to the hardware composer HAL interface, if the
HWC version number is 1.5 or greater.

Bug: 11239309
Change-Id: Ic4305210593874a8d6deba3319055b2b8c57e926
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3bfe51d7901e99e7f122f76ed2708e2b67b71cf9 11-Apr-2015 Jeff Brown <jeffbrown@google.com> Bypass surface flinger permission check for calls from system.

Early during the boot, before activity manager is ready to handle
permission checks, the system needs to be able to change the display
state. Added a hardcoded exemption for AID_SYSTEM (which already
has permission to talk to surface flinger anyhow).

Bug: 19029490
Change-Id: I6222edcab8e394e5fb6adf7a982be446e4505a1e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5b20fd0882e6a1754cad7342f7ceda3753e8f567 24-Mar-2015 Jesse Hall <jessehall@google.com> am 28c03cca: am c2a5b469: am a527c07b: Merge "Fix mistake using width instead of height."

* commit '28c03cca9835957f6e304b18358243b184fa46f8':
Fix mistake using width instead of height.
0e7497957a029fd123b429388d84bba2930fddef 23-Mar-2015 Christopher Ferris <cferris@google.com> Fix mistake using width instead of height.

Found by rodrigo.chiossi@intel.com.

Change-Id: I49d590ed39f6b47ba58a77a75d66b2964ea1cb1d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
35283ef01b53c6fce3be11158100dd950780f19e 10-Mar-2015 Dan Stoza <stoza@google.com> am 105aa28e: am b275b4dc: am 3949f664: Merge "SurfaceFlinger: Fix null pointer exception"

* commit '105aa28eeff9d31eebc7645aecb7630918a09b2a':
SurfaceFlinger: Fix null pointer exception
b275b4dc3e5dcbae1e171bd51165a93f16332ef4 09-Mar-2015 Dan Stoza <stoza@google.com> am 3949f664: Merge "SurfaceFlinger: Fix null pointer exception"

* commit '3949f664c71ad1269ee0c921d176e3b4484015cc':
SurfaceFlinger: Fix null pointer exception
24a42e9f54e971a17b829e85681c68d60a178d26 09-Mar-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Fix null pointer exception

Fixes a null pointer exception in getActiveConfig

Bug: 19416124
Change-Id: I45a01f67affb63a348866ce42a6013c5eb71fe8f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b90cf07f8b3a8fe76e40b997924c2509d04575f4 05-Mar-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Add --static-screen stats

Adds a --static-screen option to dumpsys SurfaceFlinger, which
displays screen-on time broken down by the time between the prior
frame and the current frame. An example dump looks like this:

$ adb shell dumpsys SurfaceFlinger --static-screen
Static screen stats:
< 1 frames: 12.235 s (3.5%)
< 2 frames: 29.898 s (8.7%)
< 3 frames: 15.370 s (4.4%)
< 4 frames: 13.103 s (3.8%)
< 5 frames: 15.780 s (4.6%)
< 6 frames: 2.022 s (0.6%)
< 7 frames: 0.201 s (0.1%)
7+ frames: 256.887 s (74.4%)

The buckets are exclusive, so '< 3 frames' covers the interval
[2, 3) frames

Bug: 19543586
Change-Id: I3253a54c23995d25e96016997acedd0775956b60
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
22d0bdf326de00dd50a388b55540123228cbb025 27-Jan-2015 Dan Stoza <stoza@google.com> resolved conflicts for merge of 1665c8e1 to lmp-mr1-dev-plus-aosp

Change-Id: I0be2ecb8085f2cd9560138460bcc27d71c011608
1665c8e1012e535743683d9812bf28c35ee2f10a 27-Jan-2015 Dan Stoza <stoza@google.com> Revert "SurfaceFlinger: Attempt to attribute fds to layers"

This reverts commit 03eccb6616744c3789b6018680de7bf5a18f71ce.

Change-Id: I4f0da7bb62bf77bb3d399aee601beae5e03928fe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a5cbb1f18b6eb4e0db27d98bea0731393b7438d1 17-Jan-2015 Dan Stoza <stoza@google.com> am ef1c17ae: SurfaceFlinger: Make log message 64-bit compatible

* commit 'ef1c17ae9417abc1e21e49dbc629e448efc947dc':
SurfaceFlinger: Make log message 64-bit compatible
3372cc25df255b94e4eb75920afaf43ee5edc39f 17-Jan-2015 Dan Stoza <stoza@google.com> resolved conflicts for merge of 03eccb66 to lmp-mr1-dev-plus-aosp

Change-Id: I1f38cbe7019b2b48b1094dee154ad97c23fd22c2
ef1c17ae9417abc1e21e49dbc629e448efc947dc 17-Jan-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Make log message 64-bit compatible

Fixes the build on 64-bit targets that complain about using a size_t
with a %d in a format string

Change-Id: I7dfcd3a49eb0dbc5dffeb82bb7208de7f7925f08
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
03eccb6616744c3789b6018680de7bf5a18f71ce 16-Jan-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Attempt to attribute fds to layers

This tracks fds when layers are created and destroyed in an effort to
determine which specific app (if any) is active when fds are leaked

Bug: 19017008
Change-Id: I1f1d5a9cbc1399e3df3a2d350324f80b3a4e3477
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9c22ac77e41b8bbddbb64959acabce3f3a07345d 13-Jan-2015 Jesse Hall <jessehall@google.com> am 5b730570: Merge "surfaceflinger: use Mutex timedLock instead of tryLock loop"

* commit '5b730570be2bd1f90346a5921d0b70dc11351396':
surfaceflinger: use Mutex timedLock instead of tryLock loop
fcd15b478c20f579388bb1368f05098dca534639 23-Dec-2014 Jesse Hall <jessehall@google.com> surfaceflinger: use Mutex timedLock instead of tryLock loop

Rather than trying to acquire the state lock without waiting three
times at 1 second intervals in SurfaceFlinger::dump(), just try to
acquire the lock once with a 1 second timeout. Avoids spurious mutex
acquire failures that lead to flaky
com.android.cts.jank.opengl.CtsHostJankOpenGl results.

Bug: 18842510
Change-Id: I00ce6109647de2aef8831dd2f8fa98652ba7f4e0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
db5827d314ddca3d473947b4ef49e811fad70069 03-Dec-2014 Dan Stoza <stoza@google.com> am 5878444f: SurfaceFlinger: Listen to HWC invalidate

* commit '5878444fb8da043021f30d3de739531f15390df5':
SurfaceFlinger: Listen to HWC invalidate
5878444fb8da043021f30d3de739531f15390df5 03-Dec-2014 Dan Stoza <stoza@google.com> SurfaceFlinger: Listen to HWC invalidate

"Do less work when using PTS" broke the invalidate path up from HWC
to SurfaceFlinger. When HWC would signal an invalidate, SurfaceFinger
would wake up, see no new buffers, and go back to sleep. This is fine,
except when the invalidate is a result of an HDMI hotplug, in which
case the screen remains blank. This change makes that functionality
work again.

Bug: 18564815
Bug: 18558468
Change-Id: I2e2171d86839945f4e4e6555d66f7e2895bd096a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
686c5be4722dce02ae8e5580d6677f1eeea22464 18-Nov-2014 Dan Stoza <stoza@google.com> am 6b9454d1: SurfaceFlinger: Do less work when using PTS

* commit '6b9454d1fee0347711af1746642aa7820b1ea04d':
SurfaceFlinger: Do less work when using PTS
6b9454d1fee0347711af1746642aa7820b1ea04d 08-Nov-2014 Dan Stoza <stoza@google.com> SurfaceFlinger: Do less work when using PTS

Currently, SurfaceFlinger is very dumb about how it handles buffer
updates at less than 60fps. If there is a new frame pending, but its
timestamp says not to present it until later SurfaceFlinger will wake
up every vsync until it is time to present it. Even worse, if
SurfaceFlinger has woken up but nothing has changed, it still goes
through the entire composition process.

This change (mostly) fixes that inefficiency. SurfaceFlinger will
still wake up every refresh period while there is a new frame
pending, but if there is no work to do, it will almost immediately go
back to sleep.

Bug: 18111837
Change-Id: I7825bacd37f40bf26edcc6a5e0f051dce45291fb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e12cfc23b2399ded0cc4608e47c5ba864fc5ab7d 17-Nov-2014 Marco Nelissen <marcone@google.com> am 55f71bc0: Merge "Replace IInterface::asBinder() with a static"

* commit '55f71bc0800b9ec7a779c5d30d5a90e074c2526b':
Replace IInterface::asBinder() with a static
097ca275f4717a2c47a5d49f302ed2b72c8a1370 14-Nov-2014 Marco Nelissen <marcone@google.com> Replace IInterface::asBinder() with a static

so we can do NULL checks again, and update calls to IInterface::asBinder()
to use the new static version.

Change-Id: Ia7b10eb38ca55b72278bfd33d3bf647f338b4e6a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4037c458a7594cb3cd81a14e7e974abc28180187 13-Nov-2014 Andreas Gampe <agampe@google.com> resolved conflicts for merge of 07dffa18 to lmp-mr1-dev-plus-aosp

Change-Id: I42d8bc291f4f48f3098754b076889159c4b20e41
89fd4f7fa6bd17ce5400979c3b9e5ba0bf7e919e 13-Nov-2014 Andreas Gampe <agampe@google.com> Frameworks/native: Wall Werror in surfaceflinger

Turn on -Wall -Werror in services/surfaceflinger. Fix warnings.

Change-Id: Ifef830300d9d4bc657d8f1257c02bfe8c2b4d9c5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ff520bb93812f9892da526ace81efce9b0872503 03-Nov-2014 Naseer Ahmed <naseer@codeaurora.org> am 7aa0c47e: sf: Add a NULL check in getDisplayConfigs

* commit '7aa0c47e4205c6fca136c38f272d911c25c8a8fa':
sf: Add a NULL check in getDisplayConfigs
7aa0c47e4205c6fca136c38f272d911c25c8a8fa 03-Nov-2014 Naseer Ahmed <naseer@codeaurora.org> sf: Add a NULL check in getDisplayConfigs

Validate the display binder by adding a NULL check in getDisplayConfigs.
This will prevent a false match if the caller queries the display
configs for an inactive display (whose binder is NULL by default).

Without this change we might end up attempting to index the display
config array, which is unpopulated for inactive displays, and this will
result in a crash. (See getDisplayInfo in SurfaceComposerClient.cpp for
an example of this scenario)

Change-Id: I1a12f43b7c375b9c01998dadd5b658275c733fb2
Acked-by: Tatenda Chipeperekwa <tatendac@codeaurora.org>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
18b846dda798709796be078a7978d885685df9a4 31-Oct-2014 Jesse Hall <jessehall@google.com> am c7636f60: Merge "surfaceflinger: fix -Wsign-compare warnings" into lmp-mr1-dev

* commit 'c7636f606270a4b79d745ec1acf049daedfa0e2f':
surfaceflinger: fix -Wsign-compare warnings
784421160727c434c2a2897ed3345445fcc30f75 08-Aug-2014 Jesse Hall <jessehall@google.com> surfaceflinger: fix -Wsign-compare warnings

warning: comparison of integers of different signs: 'int' and 'size_t'
(aka 'unsigned int') [-Wsign-compare]

arning: comparison of integers of different signs: 'int32_t' (aka
'int') and 'const uint32_t' (aka 'const unsigned int')
[-Wsign-compare]

Change-Id: I823257aa7218c5fd492a3277853210db539bb2e2
(cherry picked from f9bfdc6c9449143eed674c03e15dd8278296d32b)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d77021637e28e66be3fcc097b16869df69717df9 30-Oct-2014 Dan Stoza <stoza@google.com> am 1f3efb11: Don\'t run large virtual displays through HWC

* commit '1f3efb11ff8c884a254f4272f0d1ee0b77ceff2f':
Don't run large virtual displays through HWC
1f3efb11ff8c884a254f4272f0d1ee0b77ceff2f 16-Oct-2014 Dan Stoza <stoza@google.com> Don't run large virtual displays through HWC

This change watches for a MAX_VIRTUAL_DISPLAY_DIMENSION value, which
will be set (if necessary) in BoardConfig.mk. If the value is set,
any virtual displays that have a width or a height greater than that
dimension will bypass the hardware composer HAL and be handled only
by SurfaceFlinger.

Bug: 17701816
Change-Id: Ia6ca44dfd6a7a9bc0f054493d3f13006bc32fa14
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0b91d7e27718fc530bcad78a7ff2a51b90142059 24-Oct-2014 Riley Andrews <riandrews@google.com> am 131866e1: Merge "Add glFlush in surfaceflinger screenshot code." into lmp-mr1-dev

* commit '131866e1a4cb3c592f923e95a8c1a66291e2057a':
Add glFlush in surfaceflinger screenshot code.
9707f4df640c3369f873a934bb05ffa5a68a5640 24-Oct-2014 Riley Andrews <riandrews@google.com> Add glFlush in surfaceflinger screenshot code.

After creating a syncKHR object with type EGL_SYNC_NATIVE_FENCE_ANDROID,
glFlush must be called before the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute
is populated with a sync fd. We currently call eglDupNativeFenceFDANDROID
before issuing the flush.

Bug 18052459
Taken verbatim from matthew.k.gumbel@intel.com.

Change-Id: I3781d14f92862076e2bca7d27341a6dc6e7e3775
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
11f2e08a66f2463cbfd9cbef5c34da7ddfe2613a 22-Oct-2014 Jesse Hall <jessehall@google.com> am 8ad8c0a7: am afe2b1fa: surfaceflinger: don\'t close fence fds after passing to queueBuffer

* commit '8ad8c0a775a1d4592479731973238b82480f76b2':
surfaceflinger: don't close fence fds after passing to queueBuffer
afe2b1fadd29149ceed639357e44e06e97c3a5ca 21-Oct-2014 Jesse Hall <jessehall@google.com> surfaceflinger: don't close fence fds after passing to queueBuffer

ANativeWindow::queueBuffer takes ownership of the fence fd passed to
it, and will close it before returning. SurfaceFlinger's screenshot
code was also closing the syncFd it passed to queueBuffer. Most of the
time this meant the second close() silently failed, but in a rare race
condition the file descriptor could be reused between the two
close()s.

Bug: 17946343
Change-Id: Ib74fcb1dce52cc21328059c99b7c4c76f41aa3a5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
27b780b517eb18582f978da64febb31ecfa8e4bf 16-Oct-2014 Dan Albert <danalbert@google.com> am 9cc84950: Merge "Don\'t check if this == NULL."

* commit '9cc849500df0bba42d3ed19b90c38ff1dffd2262':
Don't check if this == NULL.
759115cd6d6e4f7909342e25f1002a9d74ceee5e 16-Oct-2014 Dan Albert <danalbert@google.com> am 9cc84950: Merge "Don\'t check if this == NULL."

* commit '9cc849500df0bba42d3ed19b90c38ff1dffd2262':
Don't check if this == NULL.
9cc849500df0bba42d3ed19b90c38ff1dffd2262 16-Oct-2014 Dan Albert <danalbert@google.com> Merge "Don't check if this == NULL."
3f121fc650d72d0103cef8e6a651093fb1589e0a 01-Oct-2014 Michael Lentine <mlentine@google.com> When eglMakeCurrent fails we need to fix the egl state.

Bug: 16676660

Change-Id: Ie7bee9c78378b9e9206060444319e6ee35e1ab74
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
67d8bd66aaf04805cb8f2616ba964141b865e3b9 11-Sep-2014 Lajos Molnar <lajos@google.com> surfaceflinger: add getDisplayStats() method

This is used by media service to schedule video frames at the
proper time, based on precise vsync timings.

Bug: 14659809
Change-Id: I1a90603f3dc09dca9aa4f90a3aa845fab56e0a5e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1474f8864faafebc92ff79959bb5c698bd29b704 09-Sep-2014 Dan Albert <danalbert@google.com> Don't check if this == NULL.

Entering a method with this == NULL is undefined behavior. Clang whines
about this.

Change-Id: Ibde628395ca10dfef0d2f59e81280576f104b83c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9e0e103b654b93ac526c27fd3106caac1d3006fc 10-Sep-2014 Dan Albert <danalbert@google.com> Silence warnings about unused parameters.

Change-Id: I503aafbdeaec3f53241872dc52af9f8b73a1416c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c3ebe66b49cfba035e1fd0e160a13db38eb81b0e 05-Sep-2014 Riley Andrews <riandrews@google.com> Add rotation to surfaceflingers screen cap.

+ This is needed so that activity manager does not
have to do cpu side rotations when capturing recents
thumbnails.

Change-Id: If998008e675ad01305db8399fd643cf4608b7025
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d4548dd0272f5a4edee1d7ff070458728848b35c 20-Aug-2014 Jesse Hall <jessehall@google.com> am 514e30a9: am c3d1889e: Merge "surfaceflinger: skip composition for empty frames" into klp-modular-dev

* commit '514e30a96cefad109509ce01622fa7f82f3f318c':
surfaceflinger: skip composition for empty frames
514e30a96cefad109509ce01622fa7f82f3f318c 20-Aug-2014 Jesse Hall <jessehall@google.com> am c3d1889e: Merge "surfaceflinger: skip composition for empty frames" into klp-modular-dev

* commit 'c3d1889e508038efe240ed1974ed377a2e12835c':
surfaceflinger: skip composition for empty frames
b7a0549c983bef103ce07eb3af5905febc6e538e 15-Aug-2014 Jesse Hall <jessehall@google.com> surfaceflinger: skip composition for empty frames

By not committing the results of composition for empty frames, we
avoid spitting out series of black frames for virtual displays that
don't have visible layers. We still draw one black frame when going
from having layers to not having any. In particular, this avoids
having a series of empty frames due to re-compositing the primary
display in the period between creating the virtual display and adding
layers to it.

Bug: 16786752
Change-Id: I7e9b2ed2e407d8d49c7af736b447d4c6181b0ad8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
866399093f9f60e7305f291e688abb456bace710 15-Aug-2014 Riley Andrews <riandrews@google.com> Take advantage of sync points during screen cap.

Do not wait for the screen capture to complete within surface flinger,
instead pass a sync point back with the captured gralloc buffer.

Change-Id: I7137c0e0fc710688d1d61f189159418fb27ea263
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a02e9484be6894f8a4db7049d432f534a4e0a676 31-Jul-2014 Eric Penner <epenner@google.com> Merge "SurfaceFlinger: Prevent deadlock by updating an atomic layer set." into lmp-dev
51c59cd1e73be3787eb75bebd87fc41739c65adb 29-Jul-2014 Eric Penner <epenner@google.com> SurfaceFlinger: Prevent deadlock by updating an atomic layer set.

Bug: 12934849

Change-Id: I9dede7316f1e967de4140bd731ac810115ea302f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9ae79d869a37633fa956a4f16f3fa45b23c189f1 31-Jul-2014 Michael Lentine <mlentine@google.com> Build fix for size_t on 64bit.

Change-Id: Ic16895b30d78ba8a635b709adbae31a590501b20
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7306c670eb3ddb471d983a7458eb9f522afd0763 30-Jul-2014 Michael Lentine <mlentine@google.com> Add error for format and make sure setActiveConfig fails with an invalid mode.

Change-Id: Iacdb5cbad125787f96c64c88d432fc541c4cad1a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
47e45405d1533aa73307014f7bf371e118695cf3 19-Jul-2014 Michael Lentine <mlentine@google.com> Allow for resizing of Virtual Displays.

Modify SurfaceFlinger to use VirtualDisplaySurface in all cases when a virtual
display is used. Add functionality in VirtualDisplaySurface to resize the
buffers aquired in the QueueBufferOutput. Add transaction support in
SurfaceFlinger for resize. Add the modification of the size in DisplayDevice.

Change-Id: Iae7e3556dc06fd18d470adbbd76f7255f6e6dd6b
Tested: None
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6c9e34a98a63033b80bd1c24c7aa1304f912f10a 14-Jul-2014 Michael Lentine <mlentine@google.com> Modified SurfaceFlinger to implment setActiveConfig and getActiveConfig.

This can be used to change the current display mode of the device.

Change-Id: Icdc3fb58389b861dc77b68102083da6f7a96eccb
Tested: None
(cherry picked from commit 2651fa94635a96d653038fb389a0dd827338f8d3)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
03414a1cfe6c1222fd7723949bd622f9cba145aa 01-Jul-2014 Riley Andrews <riandrews@google.com> Turn on support for async cursor update in surfaceflinger.

If available, surfaceflinger will use the hwc setCursorPositionAsync()
api to change the position of supported cursor layers outside of
the usual prepare/set loop.

Change-Id: Ib3fc5c0c390b3489ddbba202379840a1d2748917
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b154c42c39c1499c26d88fff8ca642cd86f91098 13-Jul-2014 Jesse Hall <jessehall@google.com> Improve memory coherence management in screenshot code [DO NOT MERGE]

The existing code worked in practice, but wasn't quite correct in
theory and relied on implementation details of other code. It's still
somewhat unusual and subtle, but now is correct-in-theory (I believe)
and a little better documented.

Bug: 16044767
Change-Id: I22b01d6640f0b7beca7cbfc74981795a3218b064
(cherry picked from commit c61576794e75898a829eac52fc524c8e907b4b02)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
24cd98eef88ac93f80c327f8d74f0a1ae0aceee4 13-Jul-2014 Jesse Hall <jessehall@google.com> Compile libsurfaceflinger with Clang and -std=c++11 [DO NOT MERGE]

This is necessary to use C11/C++11 stdlib atomics, which the next
change will do. This change also fixes a couple bits of syntax that
both GCC and Clang refuse to compile in -std=c++11 mode.

Change-Id: Ia14d9d6b537a3bb106c23e19a277e48be180754c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
eac96b9bfd476e1c7866e5ae685e941be97513dd 19-Jun-2014 Dan Stoza <stoza@google.com> Merge "SurfaceFlinger: Fix rect out-of-bounds checks"
91b2ca8562763c981c4ce93148db80adb51d0cb6 13-Jun-2014 Andy McFadden <fadden@android.com> Add two new display info fields

This adds SurfaceFlinger's app VSYNC offset and buffer deadline
values to DisplayInfo.

Bug 14612039

Change-Id: Ie0ab21d388fe2764f2b6f71bd1cefa33dc861a73
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
be31f447984b3ab4ac011353b6b53216b4335e04 11-Jun-2014 Dan Stoza <stoza@google.com> SurfaceFlinger: Fix rect out-of-bounds checks

Rects' right and bottom edges are treated as exclusive, so when
checking against maximum width and height, we should use > instead
of >=.

Change-Id: Ifcdf6813c13fcab1a55f16c21064e765e93d49f0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
20071e5028adb6d7ced81843d33e4d0baa0768ed 11-Jun-2014 Wengang Wu <wgw@motorola.com> am e3d37a7b: Enable support RGBX_8888 for omap3

* commit 'e3d37a7b55f86f5d005dd67f828dcf51fe60c0f6':
Enable support RGBX_8888 for omap3
e3d37a7b55f86f5d005dd67f828dcf51fe60c0f6 06-Jun-2014 Wengang Wu <wgw@motorola.com> Enable support RGBX_8888 for omap3

Bug: 14995811
Change-Id: Iaeb5a5ad0e3bcf215613f24f2570ae0d8267c016
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7227b96a73aaca975df0a04613f317e6f42545ed 12-Jun-2014 Prashant Malani <pmalani@google.com> Merge "surfaceflinger: Replace blank/unblank with setPowerMode"
1210f2ab822e4c24333abd4af498ff20af0224fa 11-Jun-2014 Wengang Wu <wgw@motorola.com> am 20071e50: am e3d37a7b: Enable support RGBX_8888 for omap3

* commit '20071e5028adb6d7ced81843d33e4d0baa0768ed':
Enable support RGBX_8888 for omap3
645b1f7ffb41d21a60765d1ec54ba82f14a36a59 10-Jun-2014 Andy McFadden <fadden@android.com> Replace "lower power mode" experiment

This replaces the previous low-power mode experiment, which
discarded refresh events, with a new experiment that alters
the refresh period.

(see also I2849e5ea335c0d2509fea1c315392bce7f20451d )

The feature is enabled by specifying a nonzero value for the
"refresh skip count", which indicates the number of periods
to skip. For example, the command:

adb shell service call SurfaceFlinger 1016 i32 1

sets a skip count of '1', yielding a 30Hz refresh rate on a device
with a 60Hz display. Changing the last value to '2' would set the
refresh to 20Hz. '0' returns to the default behavior.

Bug 15523257

Change-Id: I00039c22a55750e74035644c63800e4bee1c774a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5167ec68fed047bf65b1eb0c6091534682135eef 22-May-2014 Andy McFadden <fadden@android.com> Disable DispSync resync when not needed

If app and SF events aren't using phase offsets, we don't need
to maintain the DispSync model. We just turn hardware VSYNC on
whenever something wants to draw. This avoids some edge cases
where we were doing too much resync work.

Also, updated the systrace output. The "VsyncOn" line was a
combination of SF and app event threads, and would occasionally
be very weird. Removed VsyncOn, renamed VSYNC to VSYNC-app,
and added VSYNC-sf.

Also, added more details to the --dispsync dumpsys output.

Also, renamed global constants to not look like local variables.

Bug 15516453

Change-Id: I0da10b72f0d9a7b7eb5202d87cc18967f698adbd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2c9b11f0291210c9b9513a1a0cce6afebd361b3b 25-May-2014 Prashant Malani <pmalani@google.com> surfaceflinger: Replace blank/unblank with setPowerMode

We replace the blank/unblank calls in surfaceFlinger with a more generic
setPowerMode() routine.

Some displays support different power modes (for example, with reduced
color palettes). Depending on the use case we should be able to toggle
these modes, so as to achieve incremental power savings.

Initially, three power modes will be supported:
- HWC_POWER_MODE_OFF
- HWC_POWER_MODE_DOZE
- HWC_POWER_MODE_NORMAL

HWC_POWER_MODE_OFF will correspond to blanking the display, while
HWC_POWER_MODE_NORMAL will correspond to unblanking. HWC_POWER_MODE_DOZE
will put the display into a low power setting, if it is supported in
hardware.

If such a low power mode is not supported, it should be treated as a
call to set the mode to HWC_POWER_MODE_NORMAL.

As a consequence of adding the mPowerMode field, the mScreenAcquired is
no longer required, and thus references to it are removed and replaced
equivalent references to mPowerMode.

We also add the glue code to connect the services invocation of setting
a power mode and the HAL implementation in HWComposer.

Bug: 13472578
Change-Id: I431595ecf16d2f2c94259272db3dd42f29636204
Signed-off-by: Prashant Malani <pmalani@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c18790018be5d7ea7061ccbc81f3044e74adc823 23-May-2014 Dan Stoza <stoza@google.com> SurfaceFlinger: Add sourceCrop to screenshot

Adds a sourceCrop Rect parameter to screenshot commands, which allows
clients to capture only a portion of the screen instead of the whole
screen.

Bug: 15137922
Change-Id: I629447573cd34ffb96334cde7ba02490b9ea06d8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
39cde06aee5bc9338b1ed26513233cb54e9b446d 09-May-2014 Andy McFadden <fadden@android.com> am b6601961: Merge "DO NOT MERGE Add "dumpsys SurfaceFlinger --dispsync"" into klp-modular-dev

* commit 'b66019615da8750588f1233a77b9c686b0a248c3':
DO NOT MERGE Add "dumpsys SurfaceFlinger --dispsync"
a7f75c0dfbe6cda235123ccbb5a81638a5432f02 09-May-2014 Andy McFadden <fadden@android.com> Merge "Add "dumpsys SurfaceFlinger --dispsync""
232f5bc675f92015190e39d46586e6f87cb6fbeb 08-May-2014 Andy McFadden <fadden@android.com> DO NOT MERGE Add "dumpsys SurfaceFlinger --dispsync"

Dumps the current DispSync state.

Bug 14651879

(this is a near-cherrypick of Ide4e6dbd58b117bc1a6b97b57d10cd92ec86dc84)

Change-Id: I6e6c8452ede5c2d5098db1b884d28226e77d9a03
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c751e92c56de5f335a36e68607c7a6c627dcd0dc 08-May-2014 Andy McFadden <fadden@android.com> Add "dumpsys SurfaceFlinger --dispsync"

Dumps the current DispSync state.

Bug 14651879

Change-Id: Ide4e6dbd58b117bc1a6b97b57d10cd92ec86dc84
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
dd02391756dff240c178f7cba21d73d62821007e 06-May-2014 Dan Stoza <stoza@google.com> Merge "Enable changing display configuration"
7f7da32569f8e0b3d383a40b95f8ac1d55afd801 03-May-2014 Dan Stoza <stoza@google.com> Enable changing display configuration

This allows querying and switching display device configurations
through the ISurfaceComposer/SurfaceComposerClient interface.

Bug: 14320401
Change-Id: I8c22165698950e5da32204c1c4da92122f91a715
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
41d67d7ab4da1c393497a620a116a854b3c618e7 26-Apr-2014 Andy McFadden <fadden@android.com> Improve SurfaceFlinger PTS estimation

Get the next refresh time from DispSync instead of guessing based
on the current time.

Change-Id: I8dc72a3217bfd4e9b4c905034194d1a298cad69a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f52b3c88f18c0546526996c839fbce74172e11c7 25-Apr-2014 Ruchi Kandoi <kandoiruchi@google.com> SurfaceFlinger: Adds the functionality to reduce refresh rate to half of
the default.

Feature added for the low power mode.

Change-Id: I2849e5ea335c0d2509fea1c315392bce7f20451d
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bba1385d1cfdbe80d7e5f441d943edd4c5708eca 23-Apr-2014 Dan Stoza <stoza@google.com> am f3c07d4f: Fix virtual display nesting

* commit 'f3c07d4f70f33c2fe5b14ca8fbcdfa4133cc72c7':
Fix virtual display nesting
f3c07d4f70f33c2fe5b14ca8fbcdfa4133cc72c7 05-Feb-2014 Dan Stoza <stoza@google.com> Fix virtual display nesting

This fixes the cycling rendering loop caused by nesting virtual
displays by preventing them from recomposing if their contents
haven't changed.

(cherry-pick from master I600365c0fd5d3ad93e04295d26cf9de177ffc79b)

Bug: 12101046
Change-Id: I6182993d53537781aedb522f97a50f06eed8b80f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d85084b2b65828442eafaff9b811e9b6c9ca9fad 20-Mar-2014 Svetoslav <svetoslavganov@google.com> Adding render stats APIs to UiAutomation (framework native).

bug:12927198

Change-Id: Ibb1c07f7d89e11281e5c1f27f412a29ac6f9c4ab
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8b834ffd9b1c5df77413e99a3fdfacf6cd89ed52 28-Mar-2014 Jesse Hall <jessehall@google.com> am 1b751203: am 50ef8562: Merge "GraphicProducerWrapper may return false transact status"

* commit '1b7512036f3ea55cb1f62777ba6e56aad781f11c':
GraphicProducerWrapper may return false transact status
1b7512036f3ea55cb1f62777ba6e56aad781f11c 28-Mar-2014 Jesse Hall <jessehall@google.com> am 50ef8562: Merge "GraphicProducerWrapper may return false transact status"

* commit '50ef8562fe7289495ad8592226f3c4d546119892':
GraphicProducerWrapper may return false transact status
c2633ce19bdbca4cbf8d6a225ede68a0afd693b9 20-Mar-2014 bdeng3X <bingx.deng@intel.com> GraphicProducerWrapper may return false transact status

GraphicProducerWrapper(GPW) changed how the methods of
BpGraphicBufferProducer(BpGBP) are executed.
First, "fake" BpGBP is created. Its remote is GPW. The GPW has
wrapped the real BpGBP.
All the method calls to the fake BpGPB will be intercepted by
the GPW inside it when the methods run into remote()->transact().
Then the GPW will invoke the transact() of the real BpGBP. And
Everything runs well except that the GPW forgets to store the
transact status and always return NO_ERROR to the fake BpGBP.

It would be disastrous if the binder call of the IGBP failed and
the out parameter "reply" of transact() was in unkown state.
E.g. the queueBuffer() in the fake BpGBP will try to operate on
the "reply". This will crash the SurfaceFlinger.

Change-Id: I01b31f64e1fc92804da3f16c1fb1420dcfb3b855
Signed-off-by: bdeng3X <bingx.deng@intel.com>
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b9b088375d33a87b201cdbe18be71802e2607717 13-Mar-2014 Dan Stoza <stoza@google.com> Remove deprecated BufferQueue constructor

Bug: 13415624
Change-Id: I9fe15e45daa7351f1db34ee75bfee6f19cb347d3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8bf3b1a4964188d4ad0b96cd12174f2ba5c1eddd 18-Mar-2014 Wonsik Kim <wonsik@google.com> Merge "Revert "Implement video plane layer""
29fa9590ad32d918cb32cc88898ec53d28e1ad5a 17-Mar-2014 Wonsik Kim <wonsik@google.com> Revert "Implement video plane layer"

This reverts commit f837c93a1b392dbc4f7099d0c4fb723e32ca438e.

Change-Id: I6a1aa9ad0aca023267dc53d19c950b1535123ca7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
55886cb12828a2cb57b82efaf30050ea9dc418bb 08-Mar-2014 Greg Hackmann <ghackmann@google.com> am 7429e4f7: am 112aa42e: Merge "SurfaceFlinger: fix 64-bit format string warnings"

* commit '7429e4f7d43cd42563ce77a3a4a861a392bc750f':
SurfaceFlinger: fix 64-bit format string warnings
7429e4f7d43cd42563ce77a3a4a861a392bc750f 08-Mar-2014 Greg Hackmann <ghackmann@google.com> am 112aa42e: Merge "SurfaceFlinger: fix 64-bit format string warnings"

* commit '112aa42e91b4bb0cde334753e2ad05e3f248b377':
SurfaceFlinger: fix 64-bit format string warnings
86efcc0cbc1d94250b72ef1f2ea8700a04cd2781 07-Mar-2014 Greg Hackmann <ghackmann@google.com> SurfaceFlinger: fix 64-bit format string warnings

Change-Id: Idacfbf0601743fba1c5de7632201a66a307a2710
Signed-off-by: Greg Hackmann <ghackmann@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f837c93a1b392dbc4f7099d0c4fb723e32ca438e 24-Feb-2014 Wonsik Kim <wonsik@google.com> Implement video plane layer

Binding with video source will follow.

Change-Id: Ic14e9757f5b61f4055cbeda47c1bafae0a621abb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
44c35ec4a94eb33f7ee0df085c5d2d56d99962cf 30-Jan-2014 Andy McFadden <fadden@android.com> Allow "opaque" flag to be updated. DO NOT MERGE

Moves the "opaque layer" from Layer to Layer::State. This allows
it to be updated as part of a transaction.

Bug 12387406

Change-Id: I0a114ce6adf77cd12fb08f96e0691b76c475768d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c701401f8cec2e5309f8b57e2b97baced5093274 15-Feb-2014 Dan Stoza <stoza@google.com> Allow disabling layer rotation during screenshots

Add the ability to ignore layers' transformation matrices during
screenshot capture, which will allow the window manager to capture
unrotated images for recents during the device rotation animation.

Bug: 11805195
Change-Id: I854d87bc84ca06ef9a054a454af1c080ee66fbb8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7143316af216fa92c31a60d4407b707637382da1 05-Feb-2014 Dan Stoza <stoza@google.com> Fix virtual display nesting

This fixes the cycling rendering loop caused by nesting virtual
displays by preventing them from recomposing if their contents
haven't changed.

Bug: 12101046
Change-Id: I600365c0fd5d3ad93e04295d26cf9de177ffc79b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4125a4ffaf374ca9c0773f256998557d3325343e 30-Jan-2014 Andy McFadden <fadden@android.com> Allow "opaque" flag to be updated

Moves the "opaque layer" from Layer to Layer::State. This allows
it to be updated as part of a transaction.

Bug 12387406

Change-Id: I0a114ce6adf77cd12fb08f96e0691b76c475768d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
524672571f1df138eb913e672aaa74e0257aa8c0 03-Jan-2014 Jesse Hall <jessehall@google.com> am 03691218: am e5f7bf74: am b6c21004: Merge "Implement per-display EGLConfig and configless EGLContext"

* commit '03691218ada2fb7e084ad4ae7ddd54f9b28d5611':
Implement per-display EGLConfig and configless EGLContext
10ca42cbdc75c6a36d0b72dadbe845d990e31e95 03-Jan-2014 Jesse Hall <jessehall@google.com> am 4c37d088: am 6c7dcfa9: am 662d3134: Merge "Move EGLConfig selection to RenderEngine"

* commit '4c37d0886ca06c290e205cad2798406361bbbf53':
Move EGLConfig selection to RenderEngine
19e872912af66c53a4350afcc333bbafaf6a2294 24-Dec-2013 Jesse Hall <jessehall@google.com> Implement per-display EGLConfig and configless EGLContext

Bug: 12230666
Change-Id: Icca608b108cbdcab9cf01a9236d8cdbda000a836
Signed-off-by: Jesse Hall <jessehall@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
05f8c703d4a050669ff8f406be3a9dc2357935f7 24-Dec-2013 Jesse Hall <jessehall@google.com> Move EGLConfig selection to RenderEngine

Bug: 12230666
Change-Id: I8d1111a7e0fd9d9e2525e6a80da8ce46d7dd085d
Signed-off-by: Jesse Hall <jessehall@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cd65a2c51e2f0d7756274fad0ad2c2fe698d2229 16-Oct-2013 Jamie Gennis <jgennis@google.com> am bbfbe93c: am 0a645cc5: SurfaceFlinger: give SF its own vsync phase

* commit 'bbfbe93c0d2d6c7818e23219d2925f02ddf5bd92':
SurfaceFlinger: give SF its own vsync phase
5727fc08ba39bb53e9191447e1b3144ea244ae0e 16-Oct-2013 Jamie Gennis <jgennis@google.com> am 47c772e8: am d1700756: SurfaceFlinger: Add EventControlThread

* commit '47c772e8ec28eb0a3df9c8edd252f292c7c8e152':
SurfaceFlinger: Add EventControlThread
c6694b4cb4829164cd490869c557103f310fd761 16-Oct-2013 Jesse Hall <jessehall@google.com> resolved conflicts for merge of e94d204a to master

Change-Id: Idb2030dbb25a2e4b972492587558b25a305e68bd
0a645cc5a935e67a8d1effc7679a838160b971d8 15-Oct-2013 Jamie Gennis <jgennis@google.com> SurfaceFlinger: give SF its own vsync phase

This change allows SurfaceFlinger to run at a different vsync phase offset from
that used by external listeners.

Bug: 11175503
Change-Id: I561c53a5659fa6dc1e3e4ae30340f3c1a6adceb4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d1700756ec9520c3fba22f9a14fd064a6e288810 14-Oct-2013 Jamie Gennis <jgennis@google.com> SurfaceFlinger: Add EventControlThread

This change adds a new thread for calling HWComposer's eventControl
asynchronously. The DispSync-based vsync approach ends up enabling and
disabling HWComposer's vsync callbacks at arbitrary times, and some HWComposer
implementations do not have these calls optimized.

Bug: 11175503
Change-Id: I719be82bd200b391c61d40863b991c7b59acdfd6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
948fe0ce74c13e1bbff233883c158519fa8fb293 14-Oct-2013 Jesse Hall <jessehall@google.com> Disable hardware vsync when blanking the screen

Bug: 11220224
Change-Id: I99d0a42e1a6bb0aaf89706f6d100e9ef2a5deaa4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
95e4a7d9f357d276fa0dcecd3936b0e95c473a4f 10-Oct-2013 Andy McFadden <fadden@android.com> am c00ab7b5: am 2d8d120d: Fix blank / partial screenshots

* commit 'c00ab7b5aafb7625ad7ebd2af107936df3efc98b':
Fix blank / partial screenshots
2d8d120dc175c131a75e93fb1de61a9f432ddce9 10-Oct-2013 Andy McFadden <fadden@android.com> Fix blank / partial screenshots

The screen capture code wasn't waiting for the render to finish,
so sometimes you'd see an empty or partial image.

Bug 11131777

Change-Id: Ic64087322ce3bb15bb5f4fb1eb07579880fe6197
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b85d2cf0a20e46261db8fee4839840f0ef715c68 09-Oct-2013 Jamie Gennis <jgennis@google.com> resolved conflicts for merge of 790b6d09 to master
faf77cce9d9ec0238d6999b3bd0d40c71ff403c5 31-Jul-2013 Jamie Gennis <jgennis@google.com> SurfaceFlinger: SW-based vsync events

This change adds the DispSync class, which models the hardware vsync event
times to allow vsync event callbacks to be done at an arbitrary phase offset
from the hardware vsync. This can be used to reduce the minimum latency from
Choreographer wake-up to on-screen image presentation.

Bug: 10624956
Change-Id: I8c7a54ceacaa4d709726ed97b0dcae4093a7bdcf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
794c5ba973f6d107a8277f3f389cb3051c6ce5d7 04-Oct-2013 Alan Viverette <alanv@google.com> Simplify color adjustment using homogeneous coordinates

Change-Id: Ie31abacb134c29d82a6041fa7d521f68a1a273af
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c5214289d6279d71d7396a941e5ad6969ba053dc 02-Oct-2013 Dave Burke <daveburke@google.com> am 9b4b1180: am 06993503: Merge "only clear FB when asked for the opaque layer" into klp-dev

* commit '9b4b1180941f4d2ef9d3e7bd26bc1855ff9fb141':
only clear FB when asked for the opaque layer
0699350336cccc244bb6c52a0d910f9599253812 02-Oct-2013 Dave Burke <daveburke@google.com> Merge "only clear FB when asked for the opaque layer" into klp-dev
fee52e20b9fc9a02dbeeb75458972c14682c5400 02-Oct-2013 Jesse Hall <jessehall@google.com> am f3fa0712: am 93573e91: Merge "Treat composition frames with no layers as using GLES composition" into klp-dev

* commit 'f3fa0712282e760c316f44cba05f884f9399b98f':
Treat composition frames with no layers as using GLES composition
93573e91c22ba8329222c69cd7f099f5703fb444 02-Oct-2013 Jesse Hall <jessehall@google.com> Merge "Treat composition frames with no layers as using GLES composition" into klp-dev
0c6fd94c13402ef56010cc2f122768bf9bf35dd9 02-Oct-2013 Jesse Hall <jessehall@google.com> am 92d7c3ee: am b65f32eb: Fix two EGLConfig selection bugs

* commit '92d7c3ee03109cf2d465a103b828b7d7d3ee9848':
Fix two EGLConfig selection bugs
ac68302e1cde8b931073929311fd6654a3253fc7 02-Oct-2013 Mathias Agopian <mathias@google.com> only clear FB when asked for the opaque layer

a layer need to be considered NOT opaque if it has a
plane-alpha.

Bug: 10846930
Change-Id: Ibd8981b63ede4560c7096bacc4cff46a7eb2a8bb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d05a17fbb3772051d287f1f8830a7f00964f7ec2 01-Oct-2013 Jesse Hall <jessehall@google.com> Treat composition frames with no layers as using GLES composition

When there are no window layers for a display, SurfaceFlinger clears
the undefined region using GLES. Some of the places that check for
GLES composition weren't considering this special case, in particular:

- We were skipping the eglSwapBuffers() on these frames.
- We were putting VirtualDisplaySurface in HWC-only composition mode.

This change centralizes the logic for this special case.

Bug: 10957068
Change-Id: I2deaf2ed101e8ea76708862a6bb67751b6078794
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b65f32ebe2c86869b07ac1c986660dfb2187b7d3 28-Sep-2013 Jesse Hall <jessehall@google.com> Fix two EGLConfig selection bugs

This fixes two bugs introduced by
Change-Id: Ia8cc084c02a0e3de910def024da8a08d02bbd89d

(a) There is no invalid EGLConfig value, in particular zero is valid.
Checking return values of eglGetConfigs and eglChooseConfig is the
only way to determine success.
(b) The "simple" EGLConfig query used as the emulator fallback should
not include EGL_RECORDABLE; the emulator doesn't have it.

Bug: 10935622
Change-Id: Ib798a24e7cf06a679811c46eaa45d39174a715ec
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2b3d0c407987f6f47ccc2e9ebd6c61dbd0c37306 26-Sep-2013 Mathias Agopian <mathias@google.com> am 0ff4b283: am 6da15f46: fix crashers with wifi/virtual displays

* commit '0ff4b28396d77a0ed2f191836895a891108a8b5b':
fix crashers with wifi/virtual displays
6da15f46f5f8b38e31384d641f8d3db2c3c6ea30 26-Sep-2013 Mathias Agopian <mathias@google.com> fix crashers with wifi/virtual displays

Bug: 10647742
Change-Id: I4b8ed9da52ef95af3a3b3a04b98514a3776a674d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1c479c56da44c8942ab3d858ebcc19e4a6f76786 20-Sep-2013 Mathias Agopian <mathias@google.com> am 754bad45: am d555684c: reinstate black-screenshot debugging code

* commit '754bad4534e9a2de8b4e3ecbe097993c71246f91':
reinstate black-screenshot debugging code
4d5755389d111eb58ba5bdade84a39614dd222ed 20-Sep-2013 Mathias Agopian <mathias@google.com> am f589dd29: am e2a3e872: Merge "Fix GLES context version selection" into klp-dev

* commit 'f589dd2915587994d3dd36eff2191962fe0b71c0':
Fix GLES context version selection
d555684cb36dfb959694db76962e570184f98838 20-Sep-2013 Mathias Agopian <mathias@google.com> reinstate black-screenshot debugging code

turned off by default.

Bug: 10809349
Change-Id: I3e6b8c7860e6b0e122b8f07de4020967cd1f005c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2185f8b420ee1b150f761893a9c47cffff645cde 19-Sep-2013 Mathias Agopian <mathias@google.com> Fix GLES context version selection

Explicitly selects an ES 2.0 config first, then an ES 1.x config,
before attempting the fallback path for the emulator.

Bug: 10820214
Change-Id: Ia8cc084c02a0e3de910def024da8a08d02bbd89d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cd9fd427ac4ee8312fd42b8e643805861d9d94b2 17-Sep-2013 Jesse Hall <jessehall@google.com> am b8080d9a: am 2a36497e: Merge "Stop using default value for Surface producerControlledByApp parameter" into klp-dev

* commit 'b8080d9a3b760617c5dde7b1d2d63aa2bcecf3a7':
Stop using default value for Surface producerControlledByApp parameter
83cafffeac037ab2f9d00f98f8d2f3da8fc9b857 17-Sep-2013 Jesse Hall <jessehall@google.com> Stop using default value for Surface producerControlledByApp parameter

Bug: 10785749
Change-Id: Ifbf9340e5eabe621a69e990ec3e05ac51f8db66a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9c5a3335110769993d3fe997bdf1d594954d4304 13-Sep-2013 Alan Viverette <alanv@google.com> Add API for pushing color transforms to SurfaceFlinger

BUG: 9057596
Change-Id: Iea0953366eac875b7968897a75472c25a137edb5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ff2ed70fa30f04b90dd1a2c06ec2319e157152d7 02-Sep-2013 Mathias Agopian <mathias@google.com> color blindness enhancement

This is an attempt at improving the experience of
users with color vision impairement.

At this time this feature can only be enabled for
debugging:

adb shell service call SurfaceFlinger 1014 i32 PARAM

with PARAM:
0 : disabled
1 : protanomaly/protanopia simulation
2 : deuteranomaly/deuteranopia simulation
3 : tritanopia/tritanomaly simulation
11, 12, 13: same as above w/ attempted correction/enhancement

The enhancement algorithm tries to spread the "error"
such that tones that would otherwise appear similar can be
distinguished.

Bug: 9465644

Change-Id: I860f7eed0cb81f54ef9cf24ad78155b6395ade48
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
931bda1c472ba8c8e965bdba6757ff94154df903 29-Aug-2013 Mathias Agopian <mathias@google.com> reset the gl viewport at each frame for each display

Bug: 10097128, 9506003
Change-Id: Ie0403a631e339a9134216224f3366f46ece58b53
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9414d67f46d315873502b909ee51bab7abf3f9cc 24-Aug-2013 Mathias Agopian <mathias@google.com> make sure SF initialization is ran at target priority and correct thread group

SF can spawn threads (indirectly) during initialization
and we want those to be spawned at URGENT_DISPLAY_PRIORITY
(in theory they should set their own, but some code lives
in vendor libraries and doesn't).

Bug: 10430209
Change-Id: I5b3a8f979297de287614c8eafd8267bef1176e4b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4ceff3d5efd27c164788bb2b3f0fd17c691a0204 22-Aug-2013 Mathias Agopian <mathias@google.com> screenshot layers wouldn't work in some cases

specifically when the display size and the screenshot window
size didn't match, the buffer would be rejected.
We simply fix this by setting the scalling mode to
"SCALE_TO_WINDOW".

Bug: 9992306
Change-Id: Ib821767899af330bb70d3cbbfa7d41b02794a075
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d2cf8c2f07b4285a224acd262e6f052c37dbc0b0 21-Aug-2013 Jesse Hall <jessehall@google.com> Merge "Provide HWC prepare with a valid output buffer" into klp-dev
028dc8f2d72bc7cd4fbe7808781443125a742f78 21-Aug-2013 Jesse Hall <jessehall@google.com> Provide HWC prepare with a valid output buffer

We weren't dequeing and setting the output buffer until just before
set(). This didn't allow HWC to make decisions in prepare() based on
the output buffer format, dimensions, etc.

Now we dequeue the output buffer at the beginning of the composition
loop and provide it to HWC in prepare. In GLES-only rendering, we may
have to cancel the buffer and acquire a new one if GLES requests a
buffer with properties different than the one we already dequeued.

Bug: 10365313
Change-Id: I96b4b0a851920e4334ef05080d58097d46467ab8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4f4f0943489d9113c66ac22b58cfba8c21dfa879 20-Aug-2013 Mathias Agopian <mathias@google.com> SurfaceFlinger now runs in the process's main thread

it used to spawn its own thread and return the main thread
to the binder thread pool -- this was confusing the naming
of things in the kernel.

Bug: 10331839

Change-Id: I2d13a6d73409a38109300fcbe6a04b4c41cb5d00
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9e663de4fe1dcc872373ee530c60a375624671c3 16-Aug-2013 Jesse Hall <jessehall@google.com> Use new HWC display type/count constants.

Change-Id: I774d0c68906ac6dc69268f708c30a6b0868b8816
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3f84483382be2d528918cc1a6fbc6a7d68e0b181 08-Aug-2013 Mathias Agopian <mathias@google.com> SurfaceFlinger now uses GLES 2.x when available

Bug: 8679321

Change-Id: I2b152d01fb4e2de2ea9fe87f1ddbd6826d7520d7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5ff5a84e4829bad9eb44cc9a32d8579ca089051b 14-Aug-2013 Mathias Agopian <mathias@google.com> allow "system" screenshots even when the secure flag is set

we need too allow this case so that things like the rotation
animation can work.
with this change we only permit these screenshot if the
destination is SurfaceFlinger itself.

Bug: 10235036
Change-Id: I66fea5391e52b0d7f17f25827572b236f2d9eb71
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a6bb107434ad36739c21e1f72ac8d0107808a7b9 08-Aug-2013 Mathias Agopian <mathias@google.com> make sure we have a context when creating the 1st surface

also add an option to dump the stack trace when
calling a GL function without a context.

Change-Id: I57b72bb8c322ac4253c3077bf150621bd9863b69
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6c913be9ca95fd6b556d056e165a4ba6dc69795b 08-Aug-2013 Jesse Hall <jessehall@google.com> Add ISurfaceComposer::destroyDisplay

Bug: 10191053
Change-Id: Ia89286f95421344a60ffedaaca5825c4e3cd7f9e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3ca76f416bc8665a97636ca8a2d0128b9da9d92c 07-Aug-2013 Mathias Agopian <mathias@google.com> remove support for glReadPixels screenshot path

this was only needed on some chipset we're not
supporting in KLP.

Change-Id: I2e8fc07f135030bd61d2e241a8e426f1a4316425
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
db89edc94bd2a78226b407f9f7261e202e7fa325 02-Aug-2013 Mathias Agopian <mathias@google.com> All consumers now take an IGraphicBufferConsumer instead of a BufferQueue

this means they only have access to the consumer end of
the interface. we had a lot of code that assumed consumers
where holding a BufferQueue (i.e.: both ends), so most of
this change is untangling in fix that

Bug: 9265647
Change-Id: Ic2e2596ee14c7535f51bf26d9a897a0fc036d22c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
aaff4ef717c08f6aed7ccd96e1d65222ceb4fd17 30-Jul-2013 Mike J. Chen <mjchen@google.com> SurfaceFlinger: Set the result of binderized screencapture

A recent change to screencapture to have the call to
IGraphicBufferProducer happen on the incoming binder
thread didn't set the result so the result was always
returned as NO_ERROR.

This made screencap fail on some devices (e.g. Wolfie)
which relies on some kind of fallback mechanism to
generate the screencap but the fallback mechanism
doesn't get triggered because the error isn't returned.

Bug: 9989385

Change-Id: I2aee91ea1034869fcbb0f49b9a0087c3cff43bbe
Signed-off-by: Mike J. Chen <mjchen@google.com>
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5773d3f5b2694c647e010246dff99acc70131289 26-Jul-2013 Mathias Agopian <mathias@google.com> get rid of PixelFormatInfo and simplify things

Change-Id: I025a362cc12d5b9b794fac14be500e25aab65396
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6547ff4327aa320fbc9635668d3fc66db7dd78f6 17-Jul-2013 Jamie Gennis <jgennis@google.com> surfaceflinger: add frame duration logging

Change-Id: Ib414a45e7e191f23a2726cbbbeb606e9ce68a3b5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
38efe86d9459cf5c96a24a34cc5cbf31fdba7e19 07-Apr-2013 Jesse Hall <jessehall@google.com> Rewrite VirtualDisplaySurface

The previous implementation assumed that the HWC could read and write
the same buffer on frames that involved both GLES and HWC composition.
It turns out some hardware can't do this. The new implementation
maintains a scratch buffer pool to use on these mixed frames, but on
GLES-only or HWC-only frames still does composition directly into the
output buffer.

Bug: 8384764
Change-Id: I7a3addb34fad9bfcbdabbb8b635083e10223df69
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2ed0fe59b482f8d6b35a50ebc8e9e060813f4568 09-Jul-2013 Mathias Agopian <mathias@google.com> fix a bug where surfaceflinger and system_server could deadlock

because surfaceflinger handles screenshot in a different
thread from the binder thread that requested it and because
the IGraphicBufferProducer is a synchronous interface
calling back into the system server; it is possible for
the latter to run out of binder threads (b/c it holds
a lock while calling into SF).

The solution is to make sure all calls on IGraphicBufferProducer
happen on the incoming binder thread. We achieve this by creating
a IGBP wrapper which is given to the screenshot code.

Bug: 8734824

Change-Id: I2be85660d9dc65d239d68f6d3ab3c973c13b34cc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
547e98f33c829eb2e3948a57e491a9106afa1f5e 09-Jul-2013 Mathias Agopian <mathias@google.com> Merge "Refactor SF. Move all GL operations in their own class."
fee2b463c5fbe8fa0132d03634ccc02ea55c1505 03-Jul-2013 Mathias Agopian <mathias@google.com> Debug code for detecting all black pixels screenshots

Bug: 9120292
Change-Id: If60db32524db973bb1f905ba3cb415c2a1cd7e71
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
875d8e1323536e16dcfc90c9674d7ad32116a69a 08-Jun-2013 Mathias Agopian <mathias@google.com> Refactor SF. Move all GL operations in their own class.

this is the first step to add support for GLES 2.x, this
change breaks the dependency of SF on GLES 1.x by moving
all operation into their own class.

Bug: 8679321

Change-Id: I0d2741eca2cefe67dfd9cf837cac10c4d126928b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1eae0ee49402c39f1b08cc8fec129023f86494b7 06-Jun-2013 Mathias Agopian <mathias@google.com> clean-up SurfaceFlinger a bit

- most methods on Layer didn't need to be virtual
- more consistency in naming drawing/current state

Change-Id: Ieb7b4951b40fc673b807994ed21ae4aea7281068
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7cc6df59572582652078df5aeac9e6c67d7fa81e 05-Jun-2013 Mathias Agopian <mathias@google.com> fix a possible deadlock when removing a layer and destroying a client

generally the last reference to a Layer is released in commitTransaction()
with mStateLock held. Layer itself only holds weak references to Client,
however, ~Layer() briefly promotes this weak reference -- during that time
the all other strong references to that Client go away, ~Layer is left with
the last one... then hell breaks loose as ~Client is called, which in turn
needs to acquire mStateLock.

We fix this by holding a temporary copy of the drawing state during
the transaction so that the side-effects of copying the current
state into the drawing state are seen only after mStateLock has
been released.

Bug: 9106453
Change-Id: Ic5348ac12283500ead87286a37565e8da35f1db2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
29c3f352797d9d2ddf055d8f888e7694ef8b3947 22-May-2013 Jesse Hall <jessehall@google.com> Prevent opaque windows from making framebuffer translucent

To keep the code readable now that we have four different texenv
configurations, this change separates the decisions about what
configuration to use from the GL calls to set up the configuration.

Bug: 8963244
Change-Id: Ia07a306a7809ba8f93493d0160ccbd509e948581
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
59eaeed5fabc27942d62327fa460ebb8bd2f3822 14-May-2013 Jesse Hall <jessehall@google.com> am 28fc78bf: am e8fed71d: Merge "Abort surface composition if hw surface is invalid"

* commit '28fc78bf5fbb6288a27f3f25565a960a1873b0ef':
Abort surface composition if hw surface is invalid
28fc78bf5fbb6288a27f3f25565a960a1873b0ef 14-May-2013 Jesse Hall <jessehall@google.com> am e8fed71d: Merge "Abort surface composition if hw surface is invalid"

* commit 'e8fed71da2d3e03ef933d308520bab5b860f05aa':
Abort surface composition if hw surface is invalid
c8c71096195de0128e57574b1ddf685838ceb2f0 05-Mar-2013 Michael Chock <mchock@nvidia.com> Abort surface composition if hw surface is invalid

If an invalid display device is detected during surface composition
(e.g., a simulated secondary display is removed), abort the
composition.

Change-Id: Ia6afb2e287882d8ae0614eb25463d3f85b687adf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0aea53ff3f71f9f8df55d1cf58fd586442582643 24-Apr-2013 Mathias Agopian <mathias@google.com> use a Framebuffer Object to render all screenshots

this allows us to render into a buffer with a
pixelformat of our own choice; this is much faster
on all platform.

Bug: 8582615
Change-Id: I61298fc8e43fa6f92044c5123955cb5c7897dab7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3e25fd8609b100a75721be82d1d499f0ae9083cb 22-Apr-2013 Mathias Agopian <mathias@google.com> Add a --color option to dumpsys SurfaceFlinger

colorize a bit the output of dumpsys SurfaceFlinger to
make it easier to read. Right now it will bold the
title of each section and use green for the name of
each layer.

Change-Id: I0d9f18d115401cb45109d244ef3a278481f68cc6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
74d211ae26a0257c6075a823812e40b55aa1e653 22-Apr-2013 Mathias Agopian <mathias@google.com> clean-up/simplify all dump() APIs

remove the scratch buffer parameter and use
String8::appendFormat() instead.

Change-Id: Ib96c91617c8e7292de87433d15cf6232b7d591b0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bd1153382e7a9d89922bea999a52ca21d46d6caa 19-Apr-2013 Mathias Agopian <mathias@google.com> allow dumpsys SurfaceFlinger in user builds from the shell user

Bug: 8659013
Change-Id: I1de43bb5808cb8c1103cfc73dca59ff70fc13f91
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5e5bed60d03b5556ada351b010ed14ae8f1515ae 12-Apr-2013 Chet Haase <chet@google.com> Merge "DO NOT MERGE Make sure surfaces always have latest orientation info" into jb-mr2-dev
180f10de6f504d2ba56ff32ae8ed53c58bb458e9 11-Apr-2013 Mathias Agopian <mathias@google.com> Improve screenshot performance on some devices (DO NOT MERGE)

this affects devices that need a glReadPixels(). We use
a FBO instead of a GlConsumer as an intermediate render target, this
saves 2 calls to eglMakeCurrent().

On Galaxy Nexus this allows us to go from ~135ms to ~35ms for
recent's screenshots.

Bug: 8582615
Change-Id: I6b25291ecc235f1927579bbb2db3c731e985c6e8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
91d25932b6651b20159a737da6140cf8a6aaaf08 12-Apr-2013 Chet Haase <chet@google.com> DO NOT MERGE Make sure surfaces always have latest orientation info

When the screen is turned off, the current stack is set to -1. This causes
logic in iSurfaceFlinger's handleTransactionLocked() function to fail to
match the current stack, and the latest orientation is not set into the
layer. This causes BufferQueue, later, to potentially set an obsolete
transformHint on a created surface (such as in the case with ImageWallpaper's
Egl surface, in the bug below).

The fix is to note this situation and use a default value for the DisplayDevice,
which should have the current orientation information.

Issue #8508397 ImageWallpaper sometimes rendered in wrong orientation causing a ~30-40% drop in graphics performance

Change-Id: Ibae15d73b289a8343c67f4f6bb77fdf11dd95ee7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9eb1f0558b5fc78920602afe7bcfa3115bb1f6be 11-Apr-2013 Mathias Agopian <mathias@google.com> fix another bug where screenshots could end-up all black

SF transactions were always handled on VSYNC which allowed
the screenshot to sneak-in between closing the transaction
and vsync (before it's latched), resulting in a screenshot
with the previous state.

we now always force transactions to happen immediately
before screenhots.

Bug: 7552304
Change-Id: I0afc86b7e8366173daff5b9988bbb4d2a0f43860
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1c569c4d45f89ec05abf8f8fe3a560e68bf39a8e 05-Apr-2013 Jesse Hall <jessehall@google.com> Tell HWComposer the dimensions of virtual displays

HWComposer queries the HWC for dimensions of physical displays, but
can't do that for virtual displays. The dimensions are used to set the
display frame of the framebuffer target layer passed to HWC, and
implicitly the dimensions of the virtual display.

Bug: 8316155
Change-Id: I9cbd2530d2fa878f86128a1472def520b5d694a5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6d5b8e600e77164d3b5e51b89bf9c940fd7b4ea2 05-Apr-2013 Jesse Hall <jessehall@google.com> Merge "Clean up HWC state when releasing a DisplayDevice" into jb-mr2-dev
2ca79399b933935eb1b6c0ec1f746f8c4475369c 03-Apr-2013 Mathias Agopian <mathias@google.com> latch transparent region hint only when we get a new frame

since the transparent region hint really depends on the
content of the window containing the SurfaceView
(it's calculated by the view hierarchy based on
overlapping views), it makes sense to latch it only when
the content of the window (the app) changes.

This should help fixing drawing artifacts when changing the
layout of a window containing a SurfaceView.

Bug: 8511430
Change-Id: Ic3aa668495293cb4d82a2cd7dcf3b6a337287678
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ca08833d5ea99130797e10ad68a651b50e99da74 29-Mar-2013 Mathias Agopian <mathias@google.com> don't use compile-time configuration of libgui as much as possible

We now detect at runtime which sync features to use, which
allows us to remove a lot of the compile-time configuration
options. There is still one option though, to disable
KHR_fence_sync on some devices (which are more efficient
without it).

- added a backdoor to get the vendor's EGL strings

the new logic is:
- use always ANDROID_native_fence_sync if available
- fallback to KHR_fence_sync if available and not disabled
by the compile-time option
- use KHR_wait_sync if available and either of the above is
enabled

Change-Id: I9c4b49d9ff1151faf902cc93bd53ea5f205aaabf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
02d86567d95b99e1142941ed7ec23a4465822813 25-Mar-2013 Jesse Hall <jessehall@google.com> Clean up HWC state when releasing a DisplayDevice

DisplayDevices can be released when DisplayManager removes them from
the display list, or (for virtual displays) when the surface is set to
NULL. We were only cleaning up HWC resources associated with the
display in the first case.

Bug: 8384764
Change-Id: Id3d226dd7178fbe6d0a2ac4e2660b864ee073de3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ffe1f19ca9707f84cb9fdb06209bf36cd8c2ef0a 22-Mar-2013 Jesse Hall <jessehall@google.com> Fix virtual displays for HWC<=1.1

If we're using a HWC that doesn't support virtual displays, or we have
more virtual displays than HWC supports concurrently, the
VirtualDisplaySurface should simply be a passthrough from source
(GLES) to sink.

This change also tries to distinguish between display types and HWC
display IDs a little better, though there's more to do here. Probably
needs a higher-level rethink; it's too error-prone now.

Bug: 8446838
Change-Id: I708d2cf262ec30177042304f174ca5b8da701df1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
48bc05b56df9919fc39c5f2e3ea6535560eec98f 21-Mar-2013 Jesse Hall <jessehall@google.com> Fix dump when virtual display exists

SurfaceFlinger::getLayerSortedByZForHwcDisplay only worked for builtin
displays.

Bug: 8384764
Change-Id: I989275407fb2f06d166a6e70321c3211e27e562e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ed985574148a938bc3af24442eead313cc62521c 22-Mar-2013 Mathias Agopian <mathias@google.com> make sure screenshot are in a format supported by Bitmap.java

Change-Id: I0fb9cc4088f9c1fd27e6c017b0a7c5617adb4660
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
50210b9a8d19cb90fc283d8d99e46cd34ac17d2e 22-Mar-2013 Mathias Agopian <mathias@google.com> fix a typo that broke all screenshots

Bug: 8450197

Change-Id: I5b986cc0ff9c5e689d06a51ba68ab537d03d1f3d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b4b1730abb7824dc084468c4942f010d94a7e039 21-Mar-2013 Mathias Agopian <mathias@google.com> only use glReadPixels() when needed when taking screenshots

some drivers don't support this yet, so we use a system
property to enable the glReadPixels "workaround" for them:

ro.bq.gpu_to_cpu_unsupported=1

Change-Id: I74d6a3a8f0cee8d5a507b72c760cf247e39195e0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
abe815dd6978b718c04f6e22e1a893d2b51d11a1 20-Mar-2013 Mathias Agopian <mathias@google.com> rework how we take screenshots for a CPU consumer

We're not using IMemoryHeap as a transport anymore,
instead we're providing a CpuConsumer and use the
IGraphicBufferProducer version of the screenshot API.

However, some GPU drivers don't support properly
a GPU to CPU path, to work around this, we use a
temporary BufferQueue on the server side for the
GL rendering, and we use glReadPixels into the
CpuConsumer (we're now using a CPU to CPU path
which is always supported).

Currently this "wrapping" is always performed,
but it can be bypassed on devices that support
the GPU to CPU path.

This also addresses a DoS attack vector on
SurfaceFlinger, where an application could
consume all of SF's filedescriptors by creating
a lot of screenshots in a row.

Bug: 8390553

Change-Id: I9e81514c2a7711b9bb393f74305be7d2abe08f1c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fae23b8757a6e1b70997db28a2eaf34f9ddc9b84 19-Mar-2013 Jesse Hall <jessehall@google.com> Merge changes I61ae54f3,I57cb668e,I7a3f1e1a,Id28a2f9b into jb-mr2-dev

* changes:
Add BufferQueueInterposer and use it for virtual displays
Add DisplaySurface abstraction
Fix argument types in IGraphicBufferProducer methods
Minor cleanups/fixes before virtual display refactoring
99c7dbb24994df2f3e175f7b25dd2c9dd92a72f0 14-Mar-2013 Jesse Hall <jessehall@google.com> Add DisplaySurface abstraction

DisplayDevice now has a DisplaySurface instead of using
FramebufferSurface directly. FramebufferSurface implements
DisplaySurface, and so does the new VirtualDisplaySurface class.
DisplayDevice now always has a surface, not just for virtual displays.

In this change VirtualDisplaySurface is just a stub; buffers still go
directly from GLES to the final consumer.

Bug: 8384764
Change-Id: I57cb668edbc6c37bfebda90b9222d435bf589f37
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7adb0f8a9fdb961692ffd2f0c65cacb155143f64 07-Mar-2013 Jesse Hall <jessehall@google.com> Minor cleanups/fixes before virtual display refactoring

None of these should change behavior, except for removing some
incorrect log messages when using a virtual display.

- HWComposer::getAndResetReleaseFenceFd() checks the HWC version, so
no need to do that in the DisplayDevice::onSwapBuffersCompleted().
However, it should check that mFramebufferSurface is not NULL like
it is for virtual displays.
- Comment that FramebufferSurface::dump() overrides the non-virtual
ConsumerBase::dump(), and fix it so the right thing happens
regardless of the static type of the pointer/reference the callee
has. FramebufferSurface::dump() could be removed right now, but I'd
need to bring it back in a later change.
- Use the right enum for validating display type ids.
- Don't try to send hotplug events for virtual displays.
- Mark virtual displays as connected so HWComposer::prepare() doesn't
think something is wrong when it gets a non-NULL layer list.
- Remove unused FramebufferSurface methods.

Bug: 8384764
Change-Id: Id28a2f9be86b45f4bb7915fdf7752157035f4294
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
041a075262ef5fc886e46fd4eec3dd79ee2e60c0 16-Mar-2013 Mathias Agopian <mathias@google.com> don't allow screenshots without the READ_FRAMEBUFFER permission

the recent screenshot rework allowed the older screenshot
interface to work without that permission

Change-Id: I6c4743f4591c81106e3b823d55a055f7b4907de1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7670d3cb2b5d38c60135f34a2446e1ae809d1b32 16-Mar-2013 Mathias Agopian <mathias@google.com> Merge "get rid of purgatory and fix QueuesToWindowComposer query" into jb-mr2-dev
a493be5825d15f6a94d1afb5910db075a2a7abc1 16-Mar-2013 Mathias Agopian <mathias@google.com> don't capture hidden layers in screenshots

Bug: 8389956
Change-Id: I9ed836395258732c743c6fd44092bd01020dde13
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6710604286401d4205c27235a252dd0e5008cc08 15-Mar-2013 Mathias Agopian <mathias@google.com> get rid of purgatory and fix QueuesToWindowComposer query

the purgatory list wasn't needed anymore; in fact it had no effect as
buffer life-time management is now handled by the BufferQueue.

For QueuesToWindowComposer we keep a list of wp<> on the IBinder
for IGraphicBufferProducers we hand over to clients so we can
easily check if an IGraphicBufferProducer is ours. We clean-up the
list when our IGraphicBufferProducer are destroyed.

Bug: 8349142
Change-Id: I1aa06652ade8c72d0004a3f5e6c3d6e8a82fc2ae
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6a531717cddf1d30be0946884d21c27e5b6b390c 13-Mar-2013 Mathias Agopian <mathias@google.com> size IMemoryHeap properly for screenshots

since we're using glReadPixels(), we only need to use
the width (as opposed to the stride) of the source
screenshot.

Bug: 8374664
Change-Id: I145c80f4fff5444df7c77c4f52e70a7203caddbd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6 13-Mar-2013 Mathias Agopian <mathias@google.com> get rid of ISurface

ISurface was only used to get the IGraphicBufferProducer from
a Layer. It's now replaced by a BBinder subclass / IBinder and
is only used as a handle to the surface, to both refer to it
and manage its life-time.

Also cleaned-up a bit the ISurfaceComposer interface and
"create layer" code path.

Change-Id: I68d0e02d57b862cffb31d5168c3bc10cea0906eb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b7a5b05b53b81cb24849c7e9934c941f64e05a42 12-Mar-2013 Mathias Agopian <mathias@google.com> Fix missing recents screenshots

We were using the "visible layer list" when taking screenshots,
which doesn't work when a layer is behind other opaque layers
and therefore hidden.

We fix this by using the full layer list, filtered by the
layerstack of the display we're looking at.

Bug: 7552304
Change-Id: I4b6f77e5511aea94f8d218975b6e22738e7e5d5b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d577641411f067c93aabcd2acf7ce06862fb26d3 08-Mar-2013 Mathias Agopian <mathias@google.com> make sure to call compositionComplete after taking a screenshot

older drivers which are doing implicit synchronization need this
or they could deadlock.

Bug: 8341885
Change-Id: Icd980a6be16071678d6151e34725b3c1c547d7ee
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2be4e8ff23f24285f4c195ba5537c7a51c13be4d 07-Mar-2013 Mathias Agopian <mathias@google.com> workaround to fix screenshot leak on N4

Bug: 8322020

Change-Id: Ie60af0eb431866b8d64b2674ae7bd8b5ee05f5d6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
438ca07b6ba74235e87bfbd78c94874d8bbde391 07-Mar-2013 Mathias Agopian <mathias@google.com> Merge changes I66511c08,Ia051949f,Ic7451365,I5b571a4c into jb-mr2-dev

* changes:
Get rid of LayerBase.
Make LayerDim a regular Layer instead of a LayerBase
fold LayerBaseClient into LayerBase
Remove support for ScreenshotLayer
13127d8921356dff794250e04208c3ed60b3a3df 06-Mar-2013 Mathias Agopian <mathias@google.com> Get rid of LayerBase.

The functionality of LayerBase and Layer is folded
into Layer. There wasn't a need for this abstraction
anymore.

Change-Id: I66511c08cc3d89009ba4deabf47e26cd4cfeaefb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b79f61d41ef053bee1087ec612896c59f95f9686 06-Mar-2013 Mathias Agopian <mathias@google.com> fold LayerBaseClient into LayerBase

Change-Id: Ic745136522df59c42f0885fd969e75ea55d09f01
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
089a15298e045598bf15fd2a46284c34dd56384c 05-Mar-2013 Mathias Agopian <mathias@google.com> Remove support for ScreenshotLayer

Change-Id: I5b571a4cf3faa77d2c4aca916fa4bd00a1065bb9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
175264b09c6080b29a23fc9f545d4b99445714bd 06-Mar-2013 Jeff Sharkey <jsharkey@android.com> Return NO_MEMORY when glReadPixels() fails.

Change-Id: Ic66134ef457e8442ae9135e9ec50e3d02932a253
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
306f18c5fb15ac05db09ece7241af02b9713a23d 05-Mar-2013 Mathias Agopian <mathias@google.com> Merge "rework screenshot API and implementation" into jb-mr2-dev
eabe3140f11e515639e7a70a1286dd6af7352c9e 05-Mar-2013 Jesse Hall <jessehall@google.com> Merge "Init displays to null layer stack" into jb-mr2-dev
2a9fc493dfdba67108e4335bb1fe931bc1e2a025 01-Mar-2013 Mathias Agopian <mathias@google.com> rework screenshot API and implementation

- SurfaceFlinger now supports to take a screenshot
directly into an IGraphicBufferProducer

- reimplement the IMemoryHeap screenshot on top
of the above

- reimplement LayerScreenshot such that its
BufferQueue is directly used as the destination
of the screenshot. LayerScreenshot is now a thin
wrapper around Layer

Bug: 6940974

Change-Id: I69a2096b44b91acbb99eba16f83a9c78d94e0d10
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
01e29054e672301e4adbbca15b3562a59a20f267 20-Feb-2013 Jesse Hall <jessehall@google.com> Init displays to null layer stack

When a display is added, initialize it to use an empty layer stack, so
if it is somehow visible it will show black. It will be assigned the
real layer stack -- along with a projection and other properties -- by
window manager soon. Normally a display remains blanked until window
manager has decided what to show on it, but for HDMI connected at boot
that isn't currently the case.

Bug: 7258935
Change-Id: Ic9bb25f7a9b8d9d3772b097ab1d6fa03bc8780a1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5219a06d61ac4517506500363c5e8a5972dd7ac9 27-Feb-2013 Mathias Agopian <mathias@google.com> set correct crop rectangle in LayerBase::setCrop

The crop always had left=top=0, because the crop position
and the layer's transform were merged together in
computeBounds() (which really used to compute the
bounds in screen space, which we usually call the
"frame" elsewhere in the code)

Note: in practice this crop value is not used by
hwc, because it's overridden in Layer::setGeometry(), which
is why this bug was never apparent.

Change-Id: I1ec6400a8fc8314408e4252708f43ea98c2fe64e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a9a1b006e48320f5c501473e51e6c4a5f7a17b88 28-Feb-2013 Jesse Hall <jessehall@google.com> Initialize DisplayData fences to NO_FENCE, not NULL

Also fix another place that was checking for NULL fence rather than
Fence::isValid().

Bug 8283950

Change-Id: Ie06db327eb416828d8dac139171d96d4470b2e35
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e3c697fb929c856b59fa56a8e05a2a7eba187c3d 15-Feb-2013 Mathias Agopian <mathias@google.com> Refactoring: Rename SurfaceTextureClient to Surface

Change-Id: Ibed34175ae273608393aaa5f0a7df207dc40d709
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ac9fa427d4a86745e60a5f7fd8e3ea340c4db907 12-Feb-2013 Mathias Agopian <mathias@google.com> get rid of Surface identity and token

we use the IBinder instead.

Change-Id: I4aa0b58869ba43f19980013620051e5a261b062d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4b0eba949cc026ffb2c75313042d8a7bcb3fcf86 05-Feb-2013 Jamie Gennis <jgennis@google.com> SurfaceFlinger: add win anim frame time tracking

This change makes the 'dumpsys SurfaceFlinger --latency' command with no extra
args dump the frame timestamp data for the most recent frames that
SurfaceFlinger generated that included window animation transaction changes.

Change-Id: I8bded1ea08a4cddefef0aa955401052bb9107c90
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c19c15174b1a07c5d18f45f26bee7893481ab41d 12-Jan-2013 Andy McFadden <fadden@android.com> Merge "Add some comments."
8f06a8c2c80491465e8742c1bf45315dab7017e3 11-Jan-2013 Andy McFadden <fadden@android.com> Reduce C++11 warnings

A few typecasts to fix "narrowing conversion" complaints.

Change-Id: Ib2118079a2ca33959c748d03d8c6f1722d62e8fe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
882e3a39ed770b335a203e233b57127fde1c839e 09-Jan-2013 Andy McFadden <fadden@android.com> Add some comments.

Also, minor tweak to SurfaceTextureLayer.

Change-Id: If616d5ee4e8226dd0e16c5dbb0e0f80db553110e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2adaf04fab35cf47c824d74d901b54094e01ccd3 18-Dec-2012 Andy McFadden <fadden@android.com> Rename ISurfaceTexture and SurfaceTexture

The C++ class names don't match what the classes do, so rename
ISurfaceTexture to IGraphicBufferProducer, and SurfaceTexture to
GLConsumer.

Bug 7736700

Change-Id: Ia03e468888025b5cae3c0ee1995434515dbea387
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
392edd88cb63d71a21a86a02cf9c56ac97637128 30-Nov-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: Move GraphicBufferAlloc to libgui

This change moves the GraphicBufferAlloc class from SurfaceFlinger to libgui.

Change-Id: Idf31d2004efa2651b60590733f73c4a7b831e8a9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9913b9941ef90a98d826f3338c0a1ec3e4497b8c 28-Nov-2012 Mathias Agopian <mathias@google.com> am a7da0dda: am 98cbec81: am efd614b8: Merge "make transform hint multi-display aware" into jb-mr1.1-dev

* commit 'a7da0dda39cf1e807eea1304b48d4583e7329b72':
make transform hint multi-display aware
a7da0dda39cf1e807eea1304b48d4583e7329b72 28-Nov-2012 Mathias Agopian <mathias@google.com> am 98cbec81: am efd614b8: Merge "make transform hint multi-display aware" into jb-mr1.1-dev

* commit '98cbec81be1d39223e33abde9ac35e43b62918bf':
make transform hint multi-display aware
6edebdf6003d7efdbf9ca5dc83fef17b750693f1 09-Nov-2012 Jesse Hall <jessehall@google.com> Create builtin display tokens on demand

For hotpluggable builtin displays (currently just HDMI), create the
display device IBinder token when the display is connected and destroy
it when the display is disconnected. Previously we created the tokens
at startup and never changed them. This made it so that when comparing
current and drawing state, we couldn't tell whether a display had been
disconnected and reconnected.

Bug: 7491120
Change-Id: I2ac82b864e10cb1cd0a308782d7e0ab9745c5d81
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8430095879d2fa6878e68f8f12da4e704815ac09 22-Nov-2012 Mathias Agopian <mathias@google.com> make transform hint multi-display aware

if a layer is not mirrored, we now use its display
as the source for the transfrom hint calculation
instead of always using the default (main) display.

this change does two thing:
1) we make updateTransformHint take a DisplayDevice
as a parameter instead of hard-coding the
main display.

2) each time we do a transaction that could change
the hint, we go through all layers and
figure out which display should be used for their
transform hint.

Bug: 7599344
Change-Id: I9b04a95e6c372dd770bacf81d8ef6f8e31b87b83
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
692c723e84e6f2747447d871d468ff50e5c73f19 09-Nov-2012 Jesse Hall <jessehall@google.com> Create builtin display tokens on demand

For hotpluggable builtin displays (currently just HDMI), create the
display device IBinder token when the display is connected and destroy
it when the display is disconnected. Previously we created the tokens
at startup and never changed them. This made it so that when comparing
current and drawing state, we couldn't tell whether a display had been
disconnected and reconnected.

Bug: 7491120
Change-Id: I23b77037dc0f548d549abf580339edd0e3c626e9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2788a3526d7abb9afc64d10118a03734327a89e7 06-Nov-2012 Mathias Agopian <mathias@google.com> am 731e0331: am e70fbe8b: am 02b95105: fix transitions from hwc to GLES composition

* commit '731e0331eb402ec4564b69eaeb8b605a8b800b1b':
fix transitions from hwc to GLES composition
02b95105754b1859a97e234b79f41489a4677c20 06-Nov-2012 Mathias Agopian <mathias@google.com> fix transitions from hwc to GLES composition

If we switched from HWC to GLES but the dirty region was empty
(could happen if the dirty region is outside of the screen for instance), we
need to force a full screen composition.

In this change we ignore the dirty region for the purpose of
rejecting the whole update and we rely on the fact that it will later
be expanded to the whole screen. This was the least risky fix.

Bug: 7467760, 7452931
Change-Id: I2132f2f963b00a3ce7150adadb107b0367b3862e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
766dc49c17dda977bf7b93a5fd8da41c0b737611 31-Oct-2012 Mathias Agopian <mathias@google.com> rework a bit how we scissor the display

the scissor rect is now computed once by DisplayDevice
and is combined with the "undefined" region so that
the letter-boxed area of the screen get cleared in
drawWormhole.

Bug: 7149437
Change-Id: Id2f30516a5786f32eace7f876ff32028f954f357
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f45c510009edab4a3e93f8d66b2e30aa26759fed 25-Oct-2012 Mathias Agopian <mathias@google.com> partially implement external display clipping

we perform external display clipping only on the GL
side (ie: not done on the h/w composer side, which is
harder and would be too risky). in practice this means
that WFD will be clipped properly, while HDMI *may* or
may not depending on how hwc is used.

Bug: 7149437
Change-Id: I92d4d04220db72b6ffb134c7fa7a93af569723a5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d17e3b5f6cf71eb52bc81f37719254ce08244b34 22-Oct-2012 Mathias Agopian <mathias@google.com> prevent a client from crashing surfaceflinger

a misbehaving or malicious client could cause SF to crash
by providing a "fake" IInterface. we now check the
IInterface we get is our own and local.

Bug: 7278879
Change-Id: Ia19d05902d4b2385c5a16416148378d4998833fd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
dd3cb84cfbe8068790c6233b5829fae9c4a0ee93 20-Oct-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: add support for secure displays

This change adds support for displays that are not allowed to display surfaces
with the eSecure flag set. All non-virtual displays are considered secure,
while virtual displays have their secure-ness specified at creation time.

Bug: 7368436
Change-Id: I81ad535d2d1e5a7ff78269017e85b111f0098500
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7c41bf7092b75dba6029cd3bbc842d3a2661b0aa 17-Oct-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: change the animation timeout

This change changes the animation transaction timeout from 500us to 5s.

Bug: 7362633
Change-Id: I9bed8e74f726dae2daa398afc29babcea00d5b04
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
db9b41fd157279d1b988a854e0d7c5b43c2fac38 16-Oct-2012 Mathias Agopian <mathias@google.com> fix a corruption in blank/unblank

we were holding a reference (ie: pointer) to a sp<DisplayDevice>
while processing the message. Meanwhile the object itself could
go away and we would end up accessing a dead object.

the root cause of the problem is that we are accessing mDisplays[]
in a few places outside of the main thread.

Bug: 7352770
Change-Id: I89e35dd85fb30e9a6383eca9a0bbc7028363876c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2d5e230292c27d59f4c096bc742a0a19abf811c1 16-Oct-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: add animation transactions

This change adds a transaction flag for WindowManager to indicate that a
transaction is being used to animate windows around the screen. SurfaceFlinger
will not allow more than one of these transactions to be outstanding at a time
to prevent the animation "frames" from being dropped.

Bug: 7353840
Change-Id: I6488a6e0e1ed13d27356d2203c9dc766dc6b1759
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9e9689c11148521d2c16a121a0b87b062be0714c 11-Oct-2012 Andy McFadden <fadden@android.com> Fix HDMI unblank behavior

Two issues:

(1) We were announcing the hotplug event before we were ready to
handle blank/unblank events, so we were losing the initial unblank
that power manager sends us when HDMI is first plugged in. This
left the display blank until you toggled the device power off/on.

(2) We were retaining fbTargetHandle for HDMI after the display was
disconnected. The value didn't get updated when HDMI was reconnected
because the display was blank, so we didn't go through that code
path. So, when HDMI was re-connected, we passed stale data into
the HWC.

Bug 7323938

Change-Id: I2335d24fd7b0f00bb23fc63aa7bcf44cb8857c73
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3292cae8c37fc8d7cd8bf77fafaa55e6fc7a8cc5 09-Oct-2012 Mathias Agopian <mathias@google.com> don't automatically unblank external displays

this should be handled by the display-manager. we were doing
that in SF because until recently we didn't have enough support
in the HAL. however, this is now causing other problems when
plugging hdmi while the screen is off for instance.

Bug: 7150885
Change-Id: I739b209056a765d38d05295cf202f67ee0f506ae
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cb55857bbde34a06c19dde3db5064d1717a0173e 05-Oct-2012 Mathias Agopian <mathias@google.com> fix dumpsys Layer name when using multiple displays

Bug: 7288401
Change-Id: I14beeef58fac5270cef3b611e18c163060efe6c3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9a14392256354538f1f43a5e80fe46c2c2b965cb 05-Oct-2012 Jesse Hall <jessehall@google.com> Ignore display state changes for disconnected displays

When a display is disconnected, removing it from SurfaceFlinger's
display list is non-atomic with removing it from the Display Manager
and any in-flight transactions. So SurfaceFlinger might get a display
state change transaction for a display it has already forgotten about.
Just ignore these.

Bug: 7288082
Change-Id: Ic27e55377f3db40fb34e3b1cd67e43297df117a2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
81cd5d3b94d21253a0be925f4ae58cc7f4afeef7 04-Oct-2012 Mathias Agopian <mathias@google.com> make sure we don't call into the HWC HAL when not needed

when enabling/disabling vsync we now make sure to
not call into the HAL if the state wouldn't change.

Bug: 7274951

Change-Id: Ie24a6d68888a51b577acf9c2a973d85437cbacaf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
27ec5739bc05330e08b02f25b62a8f597bad897a 03-Oct-2012 Andy McFadden <fadden@android.com> Fix crashes after HDMI disconnect

The display was being removed from SurfaceFlinger's list before we
had a chance to reset HWComposer's layer list, so we were passing
stale data into the hardware composer (which has its own per-display
data). This resulted in "invalid gralloc handle" complaints.
We now clear the layer list immediately after removing the display.

The display was being removed while its EGLSurface was still
"current", resulting in "cancelBuffer: BufferQueue has been
abandoned" complaints. We now call makeCurrent on the primary
display before removing the external display.

Bug 7274254

Change-Id: Ia59e3a61d7ec46488b96bf93ec5e4ed3488b70e4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
135e5899f70a67e62baaf6dbec7ba2ce611ca16a 01-Oct-2012 Mathias Agopian <mathias@google.com> save/restore viewport properly when taking screenshot

Bug: 7241739
Change-Id: Iba8b9ffc75ab47fbc56169e65da26d96850a9297
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bae92d0d605e99a14731add4f11b72413b2835e5 28-Sep-2012 Mathias Agopian <mathias@google.com> reset GL viewport and project when caputring the screen

Bug: 7241739
Change-Id: I3bb5214b070384de9be2026647865c6c236a4331
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c01a79d77b829e7de86ef137694e8ad708470ca1 28-Sep-2012 Andy McFadden <fadden@android.com> Pass display arg to blank/unblank

This allows us to blank and unblank displays other than the built-in
display (e.g. HDMI).

Bug: 7240511
Change-Id: I89ea13f9e497be74c3e1231d0c62fb558e93e0f8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a4310c8be2dc3406a668ee99020d52187173232f 26-Sep-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: don't always set HWC_GEOM_CHGD

This change fixes a bug in SurfaceFlinger that caused the HWC_GEOMETRY_CHANGED
flag to be set every flip.

Change-Id: I4f395a2883bcbb53b23b3d14941aff108739c9f0
Bug: 7234237
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a8026d21f3f2f09e3416cbd33c277fbd15d8cf4e 25-Sep-2012 Jesse Hall <jessehall@google.com> Stop using transparent region for computing visible regions

The transparent region hint is computed only from view layout
locations, ignoring post-layout translation. If a SurfaceView is layed
out with no other views above it, but a view is moved above it
post-layout, that view's layout bounds would be subtracted from the
window's transparent region instead of its drawing bounds. Prior to
this change, the view would not be visible (except where its layout
bounds and drawing bounds overlap).

With this change, composition uses visible regions computed without
regard to the transparent regions. However, if all of a layer's
visible region is transparent, it will be removed from the list of
layers to composite. This doesn't fix the root problem of incorrect
transparent regions, and doesn't prevent bad composition in all cases.
But it does avoid it for some existing apps, whiel still allowing the
transparent region hint to save power in the important
fullscreen-video-in-a-SurfaceView case.

Bug: 7179570
Change-Id: I47cf939e12129b167afa344b8b036e8827103ac8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
722b98f9dfe8f04de8734630198b99a6cd024118 26-Sep-2012 Mathias Agopian <mathias@google.com> add support for EGL_FRAMEBUFFER_TARGET_ANDROID

we now try first with EGL_FRAMEBUFFER_TARGET_ANDROID, and
pick the first config we find. Otherwise, we revert to
the old algorithm.

Bug: 7232584

Change-Id: I8d5c5a4ce48420832c2e2828718a8f53325effb0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7b1905113712281c777b230648d3fbb69ae4f42c 26-Sep-2012 Mathias Agopian <mathias@google.com> fix a crasher when running out of memory

MemoryHeapBase::getBase() returns MAP_FAILED in case or
OOM, not null which is what SF was checking against.

This addresses one of the issues of bug 7230543.

Bug: 7230543
Change-Id: I763a88f64a2f9ff75eb139cfbaf9a1a9746c5577
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bb53b0e4b97634bc31808965f81b3ab4193d0e84 25-Sep-2012 Mathias Agopian <mathias@google.com> When "show visible regions" is enabled we were missing a call to HWC

Bug: 7204034
Change-Id: I64dd78362fa75149513a7d9ff92dde175e9b4958
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4803b74e2a12a508f7bbfde6f6a962fe3299c61c 25-Sep-2012 Andy McFadden <fadden@android.com> Show build config in dumpsys SurfaceFlinger

This adds a line to the "dumpsys SurfaceFlinger" output that shows
build-time configuration values.

Example:
Build configuration: [sf HAS_CONTEXT_PRIORITY] [libui] \
[libgui USE_FENCE_SYNC]

Bug 7206633

Change-Id: Ibe1856b459d34a4be6ee83a4ebfd2807e6cc68a0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2a23184e4109060ec772763e80dae2132cf9d2eb 25-Sep-2012 Mathias Agopian <mathias@google.com> don't call eglMakeCurrent() before calling HWC commit() on HWC 1.1

this call is not needed and misleading on HWC 1.1; it can also have
a negative performance impact when multiple displays are used.

Bug: 7124069
Change-Id: I47cd25c9d6e69abcc9333b9ecd5044e8fb1919ec
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9e2463e71796964cfaa06bf09a880875ac3537bc 22-Sep-2012 Mathias Agopian <mathias@google.com> add/remove displays properly on hotplug events

Bug: 7191563
Change-Id: I8f0fbf3b29658c9479443141798e6f288a1f2d52
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4c0751a1f6e4ee941791012b31f9dbc65601e1d6 21-Sep-2012 Mathias Agopian <mathias@google.com> return an error, as expected, when querying a disconnected display

Change-Id: I405a3a7bb42b9bbd2ec7bfe09e60e1b7acf7389d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f5a33928349bebc8eebc9f466618997e98c24e68 20-Sep-2012 Mathias Agopian <mathias@google.com> we now correctly set-up connected screens during boot

Change-Id: Ie8b1a3b97ad1821cc970e43abe96c8cec7135b66
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
148994e5f33ce240ff24ceb5bc0500b7f2001959 20-Sep-2012 Mathias Agopian <mathias@google.com> We now report hotplug events to the framework

Change-Id: I2d6b7787d39e5929485a551e4982498c5053c211
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1604f777d11c40daae8ec91d8ea75625996bfbac 19-Sep-2012 Mathias Agopian <mathias@google.com> one more step toward HDMI support

getDisplayInfo() now returns proper information for
HWC managed displays.

hotplug is sitll not supported; so this is not fully correct
as the information returned will be bogus if the HDMI screen
is not plugged in.

Bug: 7191563
Change-Id: If55d8e829fae0443571548155007f486cdf9bc9f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492 21-Sep-2012 Mathias Agopian <mathias@google.com> GraphicBufferAlloc class was declared twice

this was confusing because the one in FramebufferSurface
wasn't in fact being used

Change-Id: Ied45aec20d804cfbe52440f9b2f2852a85c757cf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f21cffa7d707dad10b2974c58c91482f7ca689ac 20-Sep-2012 Jesse Hall <jessehall@google.com> Allow 16-bit color EGLConfigs

The emulator without GPU acceleration only supports 16-bit
framebuffers.

Bug: 7185810
Change-Id: I883180367bf5b291d5e70427ab586d2e17868a96
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1d12d8a8e61163b35cf42c51c558a67138014e82 18-Sep-2012 Mathias Agopian <mathias@google.com> improve logging of external displays

Change-Id: I041aebb7fc655aeca98bbf698d15e05d7c12cac9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8dfa92fef9759a881e96ee58d59875d35023aab9 18-Sep-2012 Andy McFadden <fadden@android.com> Plumb display name into SurfaceFlinger

The Surface createDisplay() call takes a display name for debugging.
This change carries it through SurfaceFlinger and displays it in
the "dumpsys SurfaceFlinger" output.

Bug 7058158

Change-Id: I79f3474a8656ff1beb7b478e0dbf2c5de666118a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
da27af9832a0170f1fc40ef3f21371c4d30d21b3 14-Sep-2012 Mathias Agopian <mathias@google.com> add support hwc 1.1

Bug: 7124069

Change-Id: I53d705105c4ad8954d3f50ee4f4c8b7ec936b871
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cde87a3b9d3f8dc15232d927b56ee9e5e520f58d 13-Sep-2012 Mathias Agopian <mathias@google.com> refactor things a bit

- decouple GL and main display initialization
- ensure that each "supported" display has its own FramebufferSurface
- onScreenAcquired/Released now takes a display

Change-Id: If34a05f3dea40f6c79db77f4dde283a2580daac4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6905205c8d130b6ea3a813c1b9283492ed183367 15-Sep-2012 Andy McFadden <fadden@android.com> Fix transform hints

The hints were being set a little too late, so the pre-rotation stuff
wasn't quite working.

Bug 7054997

Change-Id: Id8d5c626db7a76f768ba762a145b315878ee08e6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6e220a6ce6971555b883f4852c6e5d4c7a617815 14-Sep-2012 Jeff Brown <jeffbrown@google.com> Fix display projections when translated.

There are two different translations to apply in the logical
orientation, one before scaling and one after.
So translate, scale, translate then rotate.

Bug: 7139798
Change-Id: I0726991cadb62988390e77503dbbaed54f07bfe3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ce3a0a541c3dde1330551bd7a048cd9d92335c00 13-Sep-2012 Mathias Agopian <mathias@google.com> don't call hwc with non-empty layer lists for blanked displays

we now make sure to take the blanked state of a display into
account when we build its list of visible layers, this ensures
that we won't call prepare/set with a non-empty list when the
display is blanked.

Possibly fixes 7075380, 7103553, 7130187, 7016215

Bug: 7075380
Change-Id: I9fdd2e73d1b7621eaeca3d4ac2ae60d9fb1b3631
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
43601a2dc320a271ff8c3765ff61414a07221635 12-Sep-2012 Andy McFadden <fadden@android.com> Reduce failure uncertainty

This adds a trivial workaround for a one-shot boot time crash, plus
an explicit check and abort for a failure condition that currently
presents as a less obvious failure.

Bug: 7145521, 7147557
Change-Id: I548f6a9caa9f0bd5710aaecea0e1c6c7c8f2f281
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b0d1dd36f104c0b581674adc7f830cbf44b7db06 10-Sep-2012 Andy McFadden <fadden@android.com> Reshuffle FramebufferSurface

FramebufferSurface no longer speaks directly to the FB HAL. Now
everything goes through HWComposer (which may or may not be
connected to a hardware composer).

Added display index arg to some query methods.

Change-Id: Id3e157d2d4e3555d33afbb703e518b6e92e2d6d5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4c05dd175ee3bd5119eecf368742b6510a8cfa6c 09-Sep-2012 Jeff Brown <jeffbrown@google.com> Ensure that viewport and frame are initialized.

onInitializeDisplays() was posting a transaction with changes
to the display projection. Unfortunately, it only set the
display orientation field and left viewport and frame
uninitialized.

The uninitialized values flowed downstream and found themselves
baked into a bogus DisplayDevice mGlobalTransform. That transform
was then applied to some Rects which were turned into Regions
that were them combined with other Regions.

Under certain situations, the uninitialized data might have
a largish value, resulting in the creation of Regions with
components in excess of the Region max-value limit of 0x7ffffff
(note that this is not INT_MAX). Later when performing a
binary operation using the Region, the Spanner would loop
indefinitely trying to figure out how to stuff a humongous
region inside of a max-value region. Not content to try
just once, the Spanner would continue trying again and
again, pegging the CPU and hanging surface flinger during boot.

Insanity soon followed.

Bug: 7130713
Change-Id: I0016f0c9662185be833474c212a1dd408096ae23
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4fb3999cea652617be5125f8a42c257467bf3c77 07-Sep-2012 Jeff Brown <jeffbrown@google.com> Fix display projection.

Change-Id: I0f253dc3759b99e05ff8344b0f513d8c289702e7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1501d54d63c55dc4e8f4c6eeaeac35aca6660ffc 05-Sep-2012 Mathias Agopian <mathias@google.com> minor cleanup

Change-Id: Ied80e14878e92a506930f7a5a55adde8f260ec70
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
00e8c7a88a5b9c4104a71013a713acd3e4d3b77b 05-Sep-2012 Mathias Agopian <mathias@google.com> display projection API now has a single function instead of 3

Change-Id: I9bf46d372b77d547486d4bbe6f1953ec8c65e98f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
da8d0a5c0cf9d41915d3b106cad4aaec3e767c11 05-Sep-2012 Mathias Agopian <mathias@google.com> implement display viewport and frame

note: viewport clipping is not implemented yet

Change-Id: I7fde7c4de075d409d95c48bb20ba8ee017f6f00a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
63f165fd6b86d04be94d4023e845e98560504a96 31-Aug-2012 Keun young Park <keunyoung@google.com> add libsurfaceflinger_ddmconnection for PDK build

- the library is dlopened from libsurfaceflinger
- the library built only when libnativehelper exists

Bug: 7089510
Change-Id: Ib3ea1029d7e8f6e055f4b759d0bf68f5123fa8a1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9ca48916bc9408d0f3f8ac95469ced0a6a342aca 30-Aug-2012 Jesse Hall <jessehall@google.com> If there is no hwc, call eglSwapBuffers for the main display

Bug: 7068568
Change-Id: I6a0309613fe3619d065b9047af6c3fb32b510d97
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
93997a8a75942b4d06cf50925de5bede489cc134 30-Aug-2012 Mathias Agopian <mathias@google.com> fix a crasher when setting a display to a null surface

Bug: 7076303
Change-Id: I843dd4ee4a603b8ad51bc1ad14e429db15050bec
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
85d751cba5d4386c739dbf9dd8f7bbf8c493ade9 30-Aug-2012 Mathias Agopian <mathias@google.com> we were sometimes not setting fences properly

this would happen when the composition was handled
entirely in h/w composer, in this case, we would
not set the fences for any involved layers.

Bug: 7049373
Change-Id: I1439dc156ce23c24041cdfbbebfe8ff4fdf790f8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7e7ed7f77a3963a3542bde529d2797a239e2798b 28-Aug-2012 Mathias Agopian <mathias@google.com> the layer list per display could contain non-visible layers

this happened because we didn't check that the visible
region was within the bounds of the display.

Bug: 7064121
Change-Id: I2e81850a3dc3d1474253520ad7f9e559c26d5a96
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
55801e41e6d7306d75d8134dd69d7d8cbbfbc63c 28-Aug-2012 Mathias Agopian <mathias@google.com> we were not always clearing the screen properly

Change-Id: I269dd866e965aebd9b3c4667095818202982f4a3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2a 28-Aug-2012 Mathias Agopian <mathias@google.com> Eradicate DisplayID.

DisplayDevices are now keyed of the wp<IBinder> the client uses.
DisplayID has now become DisplayType which is just used to identify
physical displays (as opposed to virtual displays such as wifi displays).

Change-Id: I0c5968f2c902dcd699a7e0afacf833ff070c12ea
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9d4e3d2f42e93e2d12bacabe97d307d30c3c20dd 25-Aug-2012 Jeff Brown <jeffbrown@google.com> Banish DisplayID from the SurfaceFlinger API.

Use only display tokens in the API to refer to new displays.

Don't require the caller to specify the display when creating
a surface (since in general a surface could be shown on
any display).

This is intended to be a minimum change just to update the API.
Note that SurfaceFlinger still uses DisplayID in a few places
internally that might cause some features not to work properly
when there are multiple displays (LayerScreenshot, for example).

Change-Id: I3d91eec2da406eefd97bcd53655d403ad865a7e6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
13a082e160c2d1d8006b93a555a57035213d568b 24-Aug-2012 Andy McFadden <fadden@android.com> Added display initialization method

The primary display device was being configured to "blank" by
default, which prevented the boot animation from appearing
(unless you got lucky with the hardware composer state).

Bug 6975688

Change-Id: I0fa52e9e719c6e997c5725a7baf15d9718461b78
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0bceb84773882b796d9dacbaf96167cb15928d78 24-Aug-2012 Jamie Gennis <jgennis@google.com> surfaceflinger: fix display id selection

This change fixes display ID selection so that it never chooses negative
numbers as display IDs.

Change-Id: I5af1acc7b1270b371595e096b18e2a6ad250c7ba
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9b6a395e65ff88ab79fe92d6f112c434441ca606 24-Aug-2012 Andy McFadden <fadden@android.com> Revert "Added display initialization method"

Something doesn't seem right (again).

This reverts commit 53ade0853ca003c9e917b5e7d34e1b1338d7b87d.

Change-Id: Id5786997ca9dd2a447363e8ac95213ea37468504
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
53ade0853ca003c9e917b5e7d34e1b1338d7b87d 24-Aug-2012 Andy McFadden <fadden@android.com> Added display initialization method

The primary display device was being configured to "blank" by
default, which prevented the boot animation from appearing
(unless you got lucky with the hardware composer state).

Bug 6975688

(This reverts an earlier revert.)
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e60b0687c8d49871d0c8786cabe6851f7a7783b5 22-Aug-2012 Mathias Agopian <mathias@google.com> HWComposer now has its own concept of display IDs

HWComposer can now create IDs representing a display
it can deal with. IDs MAIN and HDMI are reserved.
SurfaceFlinger associate HWComposer IDs with a
DisplayDevice and uses that when it talks to HWComposer.

A DisplayDevice doesn't have to have a HWComposer ID,
in that case it just can't use h/w composer composition.

Change-Id: Iec3d7ac92e0c22bf975052ae2847402f58bade71
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f1bf89dd88f3926faaec77b9322b2a580691960d 22-Aug-2012 Ramanan Rajeswaran <ramanan@google.com> Revert "Added display initialization method"

This reverts commit 3f3956236aac97b6aa25fa89f0983d5e9d065fdb

Change-Id: Ia2a15d9a5db88add6019edf9d955cef1f73d432d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3f3956236aac97b6aa25fa89f0983d5e9d065fdb 21-Aug-2012 Andy McFadden <fadden@android.com> Added display initialization method

The primary display device was being configured to "blank" by
default, which prevented the boot animation from appearing
(unless you got lucky with the hardware composer state).

Bug 6975688

Change-Id: Idaa0d0b98ebb331a17d1b16774c6b05bfa1e8728
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cd60f99aba9e750700a967db30b74a29145739cf 17-Aug-2012 Mathias Agopian <mathias@google.com> refactor compositing code to avoid multiple eglMakeCurrent() calls

when multiple displays are connected, we ended-up having to
call eglMakeCurrent() twice per display due to a limitation
in EGL. this fixes that.

Change-Id: I11e4584df50f8c24bbecee74e37b28b3ee031d2f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5f20e2d4462da3471f59152b32cd8640fa4a21da 11-Aug-2012 Mathias Agopian <mathias@google.com> reimplement wifi display hack with new external display SF framework

fix a few bugs with external displays

- HWComposer doesn't really handle multiple displays yet
so there is a lot of ugliness there

- We also need to make sure that external displays are not
blanked by default

- due to some EGL limitations surfaces being swapped need
to be current

Change-Id: I82bff05b43bcebd8da863c7c76b4edbc3bc223a9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
818b46058aa3006e1d3c178abd36d4f10823f5d9 17-Aug-2012 Mathias Agopian <mathias@google.com> display states can't share the dirty flags

Change-Id: Ifade9f2f1a0df9a36aede77a6cf5eee4be534f98
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
111b2d89221722d38f5b5b3ba65904ec22421839 17-Aug-2012 Mathias Agopian <mathias@google.com> binder interfaces can't be compared directly

we always need to compare their binder

Change-Id: I70d554ebc5009fe81e87923235f91451f32e1a30
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
13233e067b8f71adc3a0ade5f442265e1f27084b 16-Aug-2012 Mathias Agopian <mathias@google.com> oopsie, missed a spot when fixing b/6970310

Change-Id: Ia320fddc7cc4b0666a4fee678af710ecf5f83ff5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3559b07a885bcdff51a6dffb8e3a5ac5adf3a220 15-Aug-2012 Mathias Agopian <mathias@google.com> we were mistakenly optimizing out SF's main transactions in some cases

due to a typo, SF's main transaction was conditional to having a
display transaction.

more correct fix for 6970310

Bug: 6970310
Change-Id: Iafd8c4e02afa5db829cc1c65950cfcc74754c6af
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
01eb979243a57bd33f8389aeeade8024dd0258c0 15-Aug-2012 Jeff Brown <jeffbrown@google.com> Fix layer removal transaction.

Layers were not properly being removed because we were
setting the wrong transaction type flag at the time of
removal.

When layers are removed, we must use eDisplayTransactionNeeded,
not eTransactionNeeded, to ensure that the mLayersRemoved
flag is checked and the appropriate cleanup occurs.

Bug: 6970310
Change-Id: Id4b2897a34d4ac00aa0f92349c0ec6db95c1aaf7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ea599dfff03b45903dae3288274c31cb24fd483f 13-Aug-2012 Jesse Hall <jessehall@google.com> Don't crash when recovering from WM death

Bug: 6956162
Change-Id: I27244b960c77187b4c4cd7297989c4c872e94a3a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
20128300e0cb7f459a60cfbcddb48190ce6545ed 14-Aug-2012 Mathias Agopian <mathias@google.com> make sure to repaint the screen when unblank()ing

Change-Id: I38e3a8e6bb31ef3d2f1fcaec7490cb92a4427db2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8b736f138cfd9b239a2c7073347a13c489534ae1 14-Aug-2012 Mathias Agopian <mathias@google.com> xdpi / ydpi were reported as 0

Bug: 6975723
Change-Id: Ia7fa37ec11e2308804f5034959a37e508d292d31
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e57f292595bec48f65c8088b00ff6beea01217e9 10-Aug-2012 Mathias Agopian <mathias@google.com> make multi-display more real

- displays are represented by a binder on the client side
- c++ clients can now create and modify displays

Change-Id: I203ea5b4beae0819d742ec5171c27568f4e8354b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ef7b9c7eac036cc1230c64821039d18f8cbd2c1c 11-Aug-2012 Mathias Agopian <mathias@google.com> screenshots could stop working after camera was used

once a secure window is put on screen the display
would retain its "secure" flag forever, preventing
screenshots from being taken.

Bug: 6933967
Change-Id: I5be8355145ca7d580d84552311642f8fa912fe6a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3165cc21cfea781988407b19bd83292b19f05f55 09-Aug-2012 Mathias Agopian <mathias@google.com> libgui includes refactoring

Change-Id: I1d24ec17f5003ec2abab5f7472daaff4cc4cc2d3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1e26087493ac0e7d7dc6dea8ad85cfef08b3271f 09-Aug-2012 Mathias Agopian <mathias@google.com> Add a display parameter to HWComposer where needed

- also replace C casts with C++ casts
- only the interface is changed, HWComposer still doesn't
fully handle multiple displays

Change-Id: I48eb89bff2edb76bf1d4d41f46802b9b2a7166a8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
28947d7fbf9f486539322e8e12dd057568e180c2 09-Aug-2012 Mathias Agopian <mathias@google.com> now able to set the layer stack on a DisplayDevice

Change-Id: Ia9691cf221b9444c243eb468d9e276a30e600b6b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1a4d883dcc1725892bfb5c28dec255a233186524 03-Aug-2012 Jamie Gennis <jgennis@google.com> surfaceflinger: refactor FrambufferSurface

This change refactors the FramebufferSurface class to inherit from the new
ConsumerBase class.

Bug: 6620200
Change-Id: I46ec942ddb019658e3c5e79465548b171b2261f2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4297734c1156fd8ede7e9c61b1e439f9e1c18cd9 05-Aug-2012 Mathias Agopian <mathias@google.com> turn DisplayDevice into a reference-counted object

it's safer this way because this object owns an
EGLSurface which cannot be easily reference-counted.

it also gives us the ability to sub-class it, which
we might want to do soon.

Change-Id: I07358bb052dc5a13b4f2196b2c2b6e6e94c4bb4f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
888c822c4cb6976aab9256c58bae9e17e3e55c5c 05-Aug-2012 Mathias Agopian <mathias@google.com> remove a dependency of DisplayDevice on the refresh rate

this remove a dependency (not all) on FramebufferSurface

Change-Id: Ie07ce70760cdcedfb41b5b41bea8da45637bf474
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c1d359d42b753fcc2426d66a0f782f7c300893bc 05-Aug-2012 Mathias Agopian <mathias@google.com> break SF dependencies on libdvm and libandroid_runtime

these libraries are only needed for debugging and are now
linked at runtime if needed.

Change-Id: I03f138523c6de166a1e2700d4454d4a854aee145
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
92efd84f37ce5a8aae74dc9086f825a67b6894e9 03-Aug-2012 Mathias Agopian <mathias@google.com> screen-off animation won't be handled by SF anymore

Change-Id: Idc41386804ae7d7eb981c36e1bc55c270870c8d0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
92a979a92c34b7de609ce2b1662c73bb8a2728b9 03-Aug-2012 Mathias Agopian <mathias@google.com> We now have a real list of displays.

displays can be dynamically added or removed, and the
list is part of the SF's transaction.

Change-Id: I4186ea39f1317c0e7c044f869004017738968fab
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fcb239d3dac8bc80f28177f1951611c1d43286ff 03-Aug-2012 Mathias Agopian <mathias@google.com> don't filter when capturing a screenshot unless needed

bug: 6919952
Change-Id: Ia6fbe9bc7e533a64cfdd6ef7f0cd6b9f11feb947
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3 02-Aug-2012 Mathias Agopian <mathias@google.com> cleanups in preparation of bigger changes

- fix typo drawForSreenshot misspelled
- get rid of DisplayDeviceBase
- removed unused or unneeded code
- always pass a DisplayDevice to Layer methods that are called
on a per-display basis (to make it clear that this could be
called more than once per composition).

Change-Id: Id948b7e09fe5c06db0e42d40d6ed75dd095c7f44
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0f2f5ff75b7b48ceb64270655ee6b62d09bf4d00 01-Aug-2012 Mathias Agopian <mathias@google.com> rename DisplayHardware to DisplayDevice

Change-Id: I3f7250cd914e0da4f9ec2c9403587bbe12f3cc62
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
be246f86bd6378a5110e81e9d9068ab03c3b077e 01-Aug-2012 Mathias Agopian <mathias@google.com> Layers are now sorted by layer-stack first, then by z-order

Change-Id: I7a82929df5ba87b9d88cc5be87e1a233bc4628e9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
52bbb1ae239c8a4d05543a23fa8c08467d09c3b2 01-Aug-2012 Mathias Agopian <mathias@google.com> getting closer to final main composition loop

Change-Id: Icd63782366ffd11d9ea00c925ae5783ed7440cdb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
87baae104a3e4c2059990b01c393476065c558b0 31-Jul-2012 Mathias Agopian <mathias@google.com> get rid of global regions that should be tracked per display

Change-Id: I3b871860cc29f1b2fdcc22b0c577a6eae65d9296
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
34a09ba1efd706323a15633da5044b352988eb5f 30-Jul-2012 Jesse Hall <jessehall@google.com> Move eglSwapBuffers out of HWComposer

Commit 8630320 moved the eglSwapBuffers fallback (for devices with no
HWC implementation) from DisplayHardware to HWComposer. But HWComposer
only knows about the framebuffer EGL display and surface handles if
there is a HWC, so it was always passing bogus handles.

This change moves the eglSwapBuffers fallback up to SurfaceFlinger,
which has access to the framebuffer EGL handles.

Bug: 6886613
Change-Id: Iad3f5ff7c90ee48d7053999e6a4548d6794b6ebd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c666cae2d5995097ec49a87e375e2afdd92802b7 26-Jul-2012 Mathias Agopian <mathias@google.com> get rid of the shared-memory control block

Change-Id: If814060aca1d2ff2619d4adcd57296983d207f7f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
028508cad5ef63ef9fbd42c14e76658e4fd9ebf2 26-Jul-2012 Mathias Agopian <mathias@google.com> hopefully fixe a race condition in sf initialization

if we received a vsync event during SF init, we could crash
as not all objects were ready to go.

Change-Id: Ie11b46e3eb1b37a709dd8757843d444f93dd0189
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8630320433bd15aca239522e54e711ef6372ab07 25-Jul-2012 Mathias Agopian <mathias@google.com> split HWComposer out of DisplayHardware

we will only ever have a single instance of HWComposer, so
it's now an attribute of SurfaceFlinger, instead of being part
of DisplayHardware.

DisplayHardware now just represents a "display" (it should be renamed).

Change-Id: Iec191e57686868e1df6daa8b880a286c9fefde56
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
98a121aa916eb7acbf11df0e3e31a6fede6fc9dd 25-Jul-2012 Mathias Agopian <mathias@google.com> get rid of ro.sf.hwrotation, it's not used anymore

Change-Id: I2ee469ac89ecd65d7187be5cab08b5cc18f67cbe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8785578391eacd4192333d7b0ce3afedd7d163e6 25-Jul-2012 Mathias Agopian <mathias@google.com> add a layerStack attribute to Layers.

this attribute can be set through a regular transaction using
SurfaceComposerClient (just like any other attribute, eg: position or size)

Change-Id: I701a47c677ea6442ca713728a93335328cd2b172
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8b33f032327f8de0dcc0e6d0d43ed80f834b51f6 25-Jul-2012 Mathias Agopian <mathias@google.com> update SF binder protocol to support setting display attributes

no change of functionality -- the old behavior is implemented
on top of this new protocol.
this new protocol will allow, eventually, to pass informations
about displays and layer stacks.

Change-Id: Ic6c2295e61ec8ecbc8ce01ab7664e35d928202fc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
921e6ac4b7610a178285898d191eb0e3afe906c0 24-Jul-2012 Mathias Agopian <mathias@google.com> SurfaceFlinger cleanup

mostly refactored SurfaceFlinger.h, but also removed dead code.
cleaned-up a few includes as well.

Change-Id: Ib15f4ffe567912b61ee98aa076c6a283b72811b5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
6ee93c0d36dff1339eb2428be2d65441398e6e5f 23-Jul-2012 Jesse Hall <jessehall@google.com> Increment iterator on early-out too

Bug: 6860046
Change-Id: I82f9e4062cb58d5479c9d8dc5f2f0770a1dcc605
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a6b32db164e7834e211261046f3229bf50bc0098 20-Jul-2012 Jesse Hall <jessehall@google.com> Handle empty HWC layer list when composing

Bug: 6777877
Change-Id: I71e9b948d04dda33d45cfa986d9c7e28328cf749
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a49126087b4494f4ef50873f3a3f6727265f6621 12-Jul-2012 Mathias Agopian <mathias@google.com> factor EGL/GL and surface creation out of DisplayHardware

Change-Id: Icd85a6a4caad06f056578008af3e21666fa8b1f4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3b1d2b6b2bbfb5df46b1059ec52360974e6f1428 11-Jul-2012 Mathias Agopian <mathias@google.com> mVisibleLayersSortedByZ is now maintained per display

Change-Id: Idcdb77eba1a3f99b3e4b2150128a82acaffcd2a8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4fec873a98f7b4380720cd1ad006f74c8cdc73da 29-Jun-2012 Mathias Agopian <mathias@google.com> one more step towards multiple display support

- remove dependency on cached state in validateVisibility
- get rid of mVertices and mTransformedBounds
- get rid of validateVisibility
- get rid of unlockPageFlip
- handleTransaction now returns a dirty region
- computevisibileregion now uses window-manager space
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c5c5a14c06de249d8e0445fd24699e1d9aa04549 03-Jul-2012 Jesse Hall <jessehall@google.com> Only set acquire fences on overlay layers

Change-Id: I08e8173f83580de5a4e43a0ba5ea03e5ec6e8782
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1b03149f3533db04e72e088d3fdd09d0087ca594 21-Jun-2012 Mathias Agopian <mathias@google.com> get rid of GraphicPlane

its functionality is now folded into DisplayHardware
there will be more changes in that area.
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3094df359d1e6e2ae8ca4e935cc093f563804c96 19-Jun-2012 Mathias Agopian <mathias@google.com> First prototype atttempting to support an external display

both API and implementation will change, this is just a prototype
intended to show feasability.

SurfaceFlinger is passed an ISurfaceTexture through a new
callback, it is in turn used to create an EGLSurface which
surfaceflinger will draw into in addition to the main screen.

Change-Id: Id0bbb0b854bb7bae44d57246a90b65d4567f9a21
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ef19414bd8b77a26f5751f3845be79025a8263fe 14-Jun-2012 Jesse Hall <jessehall@google.com> Transfer HWC release fences to BufferQueue

After a HWC set, each SurfaceFlinger Layer retrieves the release fence
HWC returned and gives it to the layer's SurfaceTexture. The
SurfaceTexture accumulates the fences into a merged fence until the
next updateTexImage, then passes the merged fence to the BufferQueue
in releaseBuffer.

In a follow-on change, BufferQueue will return the fence along with
the buffer slot in dequeueBuffer. For now, dequeueBuffer waits for the
fence to signal before returning.

The releaseFence default value for BufferQueue::releaseBuffer() is
temporary to avoid transient build breaks with a multi-project
checkin. It'll disappear in the next change.

Change-Id: Iaa9a0d5775235585d9cbf453d3a64623d08013d9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
aa049f0d19684cf92f2f6510133a33138845dcd3 20-Jun-2012 Mathias Agopian <mathias@google.com> am 8aaf3e47: am a67e418e: Exit boot animation cleanly.

* commit '8aaf3e47a51aa0beebecc8c536504d310d07cda9':
Exit boot animation cleanly.
a67e418e1fda219f6cc0a7e420bcf5cc4f9fe710 20-Jun-2012 Mathias Agopian <mathias@google.com> Exit boot animation cleanly.

The desc.txt file can now mark parts as 'must finish cleanly' by using
'c' as the part line prefix rather than 'p'. If so indicated, if the
bootanimation is asked to quit it will do so only after waiting to
finish that part.

I considered either making init.c service killing smarter or promoting
bootanim to be a bindable service with a requestExit method. However,
these changes are probably too big/risky given our ship date. So
I used a property as a mailbox between SurfaceFlinger and bootanim.

Bug: 6679877
Change-Id: Id7dca22caa50b450fff25ca94f7242d971034f41
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5df996211d4e263feb862121cfafa7f9c8eeda68 19-Jun-2012 Mathias Agopian <mathias@google.com> fix typo in makefile LOCAL_CFLAGS was spelled LOCAL_CLFAGS

Change-Id: I58b96d28f608ce16fcad5ed0efb887e582779e03
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
db403e8ff0d7727015e1a5009bab20eb7ec205bc 19-Jun-2012 Mathias Agopian <mathias@google.com> split-up Client.h out of SurfaceFlinger.h

Change-Id: I1993bf23e417163749d886283563a93d50b361b4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3e8b853d67c737abdb363f9c978e7d83eac4d888 14-May-2012 Mathias Agopian <mathias@google.com> refactor HWComposer to break dependency with the HAL headers

HWComposer must abstract the HWC HAL entirely, so that the
HAL can continue to evolve (and break binary compatibility)
without breaking SurfaceFlinger. The HWC data structure had
leaked outside of HWComposer, this is now fixed.

We now have an abstract interface that provide all the
needed functionality, HWCompose provides concrete
implementations of it based on the the HWC version.

Change-Id: I40c4676dc986b682ede5520a1c60efe64037b0bb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8e533069e5721e55cb9768e140e16546c3a4a8b6 07-Jun-2012 Colin Cross <ccross@android.com> surfaceflinger: replace early suspend with binder call from PowerManager

SurfaceFlinger will no longer directly synchronize with early suspend.
Instead, PowerManagerService will synchronize with SurfaceFlinger to
ensure that a black frame has been drawn on the display, and then
trigger all early suspend handlers.

Change-Id: I07acdd628440d23fdb69db94319ec5d65d3f4919
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a4c5b19dd711abecf87ff1e04e530edec58a0d8c 05-Jun-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: remove all GLES scissor calls.

Bug: 6576505
Change-Id: I494b7627f2e271a234706bf49a9490f8ac56c77a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ed9807bd7dbd4863841e251138392c54755eb394 18-May-2012 Mathias Agopian <mathias@google.com> we need to wait for vsync when doing the screen-off animation

Bug: 6511421
Change-Id: I7a85a55e66a3a8d9937df575e98a5efec01a634f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f15a83f5814219c167f87cb8aaea622fc8493499 11-May-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: add a crop to the layer state

This change adds a crop rectangle specified in window coordinates to the layer
state. The all window pixels outside this crop rectangle are treated as though
they were fully transparent. This change also adds the plumbing necessary for
WindowManager to set that crop.

Change-Id: I582bc445dc8c97d4c943d4db8d582a6ef5a66081
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
56a2bbe70876c1ac4e18b3740722c01d69bca2fd 19-Apr-2012 Mathias Agopian <mathias@google.com> SF needs to render even if we don't have a h/w composer

Bug: 6350574, 6361055
Change-Id: Iab92cc31bab4771fca63619c8e3105c759535f72
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b9494d5c9d44e4a59b6d510fea1665de434f3c6b 18-Apr-2012 Mathias Agopian <mathias@google.com> make sure to clear the framebuffer when using overlays

Bug: 6354761, 6353719
Change-Id: I0739de3fee7c54c14b294ffd768b70ee1f541d9e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f74e8e0602100e048c13ea262f0c19c3b8738b6f 16-Apr-2012 Mathias Agopian <mathias@google.com> don't attempt to clip layers anymore using glScissor

this seems to hurt performance on some GPU. this change
might negatively affect performance on other GPUs though, but
probably in less time-sensitive cases. If this becomes a
problem it might become necessary to pre-clip the geometry
(so that we don't have to use glScissor).

This improves the rotation animation quite a bit.

Change-Id: I5dbe1286f7ad858ef2c1e1ad9a07ee3f26c0b1f3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a2f4e56fec0fb36c4a370eb23d6e9dc57f250b59 16-Apr-2012 Mathias Agopian <mathias@google.com> get rid off preserve backbuffer optimization in SF

this optimization didn't improve performance and in fact
seemed to hurt more than anything else. it also made
things a lot more complex as it introduced edges cases
when switching to/from h/w composer.

Change-Id: Iaafc235e175f5740cd98bff914d706e02ab88bb8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8acce2046ac7086c3dcfb1fc7c9c39f31de48694 14-Apr-2012 Mathias Agopian <mathias@google.com> make sure to repaint the screen when screen turns on

Bug: 6336168
Change-Id: Ic6f11b6bf6c3d849f5cb6ac95961d10d7f88e4ec
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
69a655caef30663403802281210363f643ceb946 12-Apr-2012 Mathias Agopian <mathias@google.com> Revert "handle surfaces posts independently from composition"

This reverts commit 562f4b2c1e555b853997113bb54b21303d642bc6.

Change-Id: I96efe11c2f0494ed2d57fc580e49c598d913830e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
562f4b2c1e555b853997113bb54b21303d642bc6 25-Mar-2012 Mathias Agopian <mathias@google.com> handle surfaces posts independently from composition

surfaceflinger will now handle each surface post
as soon as possible and handle the composition
itself at VSYNC time as usual.

Change-Id: I6b1ae33fd56062d86e5419ebab8def0ca5803fbf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
22ffb117b0c2a906bd04aef9738a52223cdd1dce 11-Apr-2012 Mathias Agopian <mathias@google.com> make sure to disable VSYNC while screen is off

Change-Id: If1894c43b0a39a2851e1280a35ae77bccd6d9abd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b60314a12f3336b27d73920805ab07cbc498d857 11-Apr-2012 Mathias Agopian <mathias@google.com> rework screen on/off code

Change-Id: I13f71e850592a588bbd4805b1830c503bd4decb4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cb9732a951d20cacb7ebe2dab132b5738226b1b6 04-Apr-2012 Mathias Agopian <mathias@google.com> refactor / simplify EventThread

Change-Id: I3981c6fba93b7b985174b2a7045e24db2c0b4428
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4b2ba53423ac2dc795a5a0bf72f6d787d9dc8950 29-Mar-2012 Mathias Agopian <mathias@google.com> better workaround for bug: 6020860

this prevents the GPU from running when composition
is fully handled by overlays. this should improve
animations a bit.

Change-Id: If4ae584b7a3976e6bdd36e318686ac3940b6b075
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3854ed549012f2abf8fea7b0e6db30b104ea5547 23-Mar-2012 Colin Cross <ccross@android.com> surfaceflinger: disable ddms debugging on pdk builds

DDMS debugging depends on non-pdk apis, disable it when a pdk
build is selected.

Change-Id: I6376b5c4cf49f2c51f35f8d567f7c6d18daf893f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b5dd9c0fee3b3d6d35035dfb992951ebea3e0e4e 22-Mar-2012 Mathias Agopian <mathias@google.com> rewrite density calculation code so it's understandable

Change-Id: I1016cd5fd75355abe4ab879d04f4849bd2dd4122
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b267579ba8dfe3f47d2a481c5a3c2254e3d565a1 23-Feb-2012 Daniel Lam <dalam@google.com> SurfaceTexture: Fully refactored from BufferQueue

SurfaceTexture and BufferQueue are separate objects.

Change-Id: I230bc0ae6f78d0f9b2b5df902f40ab443ed5a055
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fddc28d87136b55f0d9613e5f8ecd64a6aca018d 12-Mar-2012 Mathias Agopian <mathias@google.com> add ATRACE logs for screenshots

Change-Id: Ie8146c4d7608159e9d28b7338f9109b8fcdf955f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
35aadd6be249da4bd4851692e6aff757c91b32a7 09-Mar-2012 Mathias Agopian <mathias@google.com> fix surfaceflinger's dumpsys

Change-Id: I7b95c3e04f145003f9c0eef321a21f3f36dfe835
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
841cde55549cea7a344a1705b18d57a0c6c8ec45 02-Mar-2012 Mathias Agopian <mathias@google.com> add more ATRACE

Change-Id: I6cc5759fb0a05427680488fd12ae797e77644f3d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1c8e95cf86f2182986385bc1ee85f13f425f3a3a 24-Feb-2012 Jamie Gennis <jgennis@google.com> Add tracing to various graphics components.

This change adds ATRACE call tracing to BufferQueue,
SurfaceTextureClient, SurfaceTexture, SurfaceFlinger, Layer, and EGL.

Change-Id: I9d75ed26f5a3f0d1af635da38289520134cfbbb7
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
90ac799241f077a7b7e6c1875fd933864c8dd2a7 26-Feb-2012 Mathias Agopian <mathias@google.com> fix libgui header location

Change-Id: Iec71706cdd4f29c6904993648ce873e83ef9cafe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ff615cc7a1cceedd705b0623b058c54669b29596 24-Feb-2012 Mathias Agopian <mathias@google.com> deprecate L_8, LA_88 and RGB_332 in sdk

re-add support for pixelformats L_8, LA_88 and RGB_332 in libui
for backward compatibility.

This may or may not fix 6058926

Bug: 6049685
Change-Id: Ic1b8b4cc994522f7fe664da64c0ef76b98bc6d53
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fbc7922ec87298601ba6a3be1bd9f83ffaf9a233 24-Feb-2012 Mathias Agopian <mathias@google.com> workaround for an issue where the screen would flicker sometimes

bug: 6020860
Change-Id: I97807db66b66c5f4dcbed0df79d5d257cfc7c0bd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4d143eed994778d37eb09bb5d452c26f12bca6e1 24-Feb-2012 Mathias Agopian <mathias@google.com> fix an issue in SF where we could miss some updates

Change-Id: I7d350bc05d1596655baddff3deaebaba58c9bcc0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
751d0bb9b2f73f7e7ca3fbb0ed7ede7fd63b813a 21-Feb-2012 Mathias Agopian <mathias@google.com> Merge "SurfaceFlinger: set wrap mode on screenshot texture"
1676828d115301ee1d0d4ffa68f832cecc0bbff1 07-Feb-2012 Dianne Hackborn <hackbod@google.com> Merge "Return information about whether overlays are disabled."
12839bee29bdcc65731b4d42029cc59e2320c5c4 07-Feb-2012 Dianne Hackborn <hackbod@google.com> Return information about whether overlays are disabled.

Change-Id: I85ae42e9f28461f5142cc6b3c8e25ff3f195805a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f6de1c04ffc2c7a739578b7612944fddb7011ab7 05-Feb-2012 Mathias Agopian <mathias@google.com> fix a crasher when starting SF with the screen off

SF could end-up in an infinite crash-loop during startup if it
was stopped while the screen was off. This happened because
the thread that manages screen blanking was started before
other important pieces of SF were initialized.

Change-Id: I0dded11dbf2395fdd57b673859a7aa0fa9eb32b6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
303d538bb012e82c6b9a98c4930a03455000f761 05-Feb-2012 Mathias Agopian <mathias@google.com> ui freeze workaround: reenable triple buffering mode

we're seeing UI freezes when window updates and
composition are separated. for now we workaround this
by always doing a composition after window updates on
vsync. triple buffering is reenabled for performance.

Change-Id: I693d705000b7452489bb0b4918fbeadb9879315c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c95dbdc236acf002b5f8aed8c8a9e43047fc75b5 05-Feb-2012 Mathias Agopian <mathias@google.com> improve SF dumpsys
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b048cef231075a5e41d224b73fe11fec62f335b1 05-Feb-2012 Mathias Agopian <mathias@google.com> fix UI freezes

In some situations SF would mark a window as "has a pending update"
but would never process that update because the window is not
visible (fully transparent, hidden by another window, etc...), this
window would then be "stuck" until some other window updated.

Change-Id: Ifa18a9aef3a53f2593b473556702688ae62d9503
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c9ca7011501cb8730ce4e6e527cb402adb7a0178 04-Feb-2012 Mathias Agopian <mathias@google.com> attempt to fix an ANR in various apps

recent changes in SF introduced a hang where some windows would
stop being refreshed.
This is an attemp to fix that.

Change-Id: I6aa32ac0d6f1c0a6aea8f6195825dc4f4e6f93f9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
99ce5cdeb383216dee95af4d90e47406b0948ea1 01-Feb-2012 Mathias Agopian <mathias@google.com> separate transactions from updates

with this changes, SF transactions are handled as soon as possible
but do not trigger updates. the update is delayed until the next
vsync.

this allows us to work much better without requiring triple-buffering.

Change-Id: I1fa10794d0cf742129f0877698b7b1e1f2ec7401
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8aedd4737d6ce8548d2fd5def65b1e1737283821 25-Jan-2012 Mathias Agopian <mathias@google.com> SF now synchronizes to VSYNC

Change-Id: Ic5e4f2ea9927ce133eef9499c03161325e9d02c5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ad8d13c8858b33e3efef42086875c0b0836d2296 30-Jan-2012 Mathias Agopian <mathias@google.com> remove unneeded code

Change-Id: I07e2fca7274d2e12bf5b4aee0050794bdb97a8b3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
25e66fc324bbc004fa8902b2d4699e41bb601104 29-Jan-2012 Mathias Agopian <mathias@google.com> added a few more commands to SF's dumpsys

--latency-clear [name]
clears the latency data for the specified layer or for
all layers if none is specified

--list
prints the list of all layers regardless of their visibility

Change-Id: I7c07ae020f838c173b98ee50f3fb3e93da78acbb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
82d7ab6c7e0cf971e515134ccf072682dd1a2cdb 20-Jan-2012 Mathias Agopian <mathias@google.com> improve SurfaceFlinger dumpsys

It is now possible to say:

dumpsys SurfaceFlinger --latency

to print latency information about all windows

dumpsys SurfaceFlinger --latency window-name

to print the latency stats of the specified window

for instance: dumpsys SurfaceFlinger --latency SurfaceView

The data consists of one line containing global stats, followed by
128 lines of tab separated timestamps in nanosecond.

The first line currently contains the refresh period in nanosecond.
Each 128 following line contains 3 timestamps, of respectively
the app draw time, the vsync timestamp just prior the call to set and
the timestamp of the call to set.

Change-Id: Ib6b6da1d7e2e6ba49c282bdbc0b56a7dc203343a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e8696a40e09b24b634214684d18526187b316a2f 16-Jan-2012 Jamie Gennis <jgennis@google.com> hack up frame latency measurement

Change-Id: I6d9a466a23285304f0e229a5649815636ab5d6af
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1db13d79518f600d65a4fc006fe42900b890966e 19-Dec-2011 Glenn Kasten <gkasten@google.com> Get AID_GRAPHICS from right place

Change-Id: I97b1754dc7260fec083275c71a8f71ebfb2cefa8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b1d1c6d4c2eb942e18a59a8cdf1c7c4f0f03ef1b 13-Jan-2012 Michael I. Gold <gold@nvidia.com> SurfaceFlinger: set wrap mode on screenshot texture

Some implementations of NPOT, particular those derived from core
GLES2, require the wrap mode to be CLAMP_TO_EDGE. Set the required
wrap mode for the screenshot texture so it passes the completeness
check.

Change-Id: I735016123e4acaf54b40d1435bd70281cef88a31
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
55ef343331f5efbfe3e01bc9993d94faea236048 07-Jan-2012 Mathias Agopian <mathias@google.com> remove dead/usnused code

Change-Id: I6fa2bc6ee01790abd2c1533f043d61a5e5c8d26e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e6f43ddce78d6846af12550ff9193c5c6fe5844b 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
32397c1cd3327905173b36baa6fd1c579bc328ff 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c267bab3d1c7980a03541283e88c0b6df378b826 05-Jan-2012 Steve Block <steveblock@google.com> Merge "Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE"
2adea706d445e837053403a00286a21c00e22649 05-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use the standard CC_LIKELY and CC_UNLIKELY macros"
99ed22412db547c59d3da08114d9d5a586442b30 15-Dec-2011 Glenn Kasten <gkasten@google.com> Use the standard CC_LIKELY and CC_UNLIKELY macros

Several source files privately defined macros LIKELY and UNLIKELY in terms
of __builtin_expect. But <cutils/compiler.h> already has CC_LIKELY and
CC_UNLIKELY which are intended for this purpose. So rename the private
uses to use the standard names.

In addition, AudioFlinger was relying on the macro expanding to extra ( ).

Change-Id: I2494e087a0c0cac0ac998335f5e9c8ad02955873
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a19954ab377b46dbcb9cbe8a6ab6d458f2e32bca 04-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ib08fe86d23db91ee153e9f91a99a35c42b9208ea
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9d4536835248525f32f1504a3d28d5bbfa0a2910 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
478ae5eb5a0047e1b2988c896cff6363b455ee50 07-Dec-2011 Mathias Agopian <mathias@google.com> Improve the VSYNC api a bit.

- add the ability to set the vsync delivery rate, when the rate is
set to N>1 (ie: receive every N vsync), SF process' is woken up for
all of vsync, but clients only see the every N events.

- add the concept of one-shot vsync events, with a call-back
to request the next one. currently the call-back is a binder IPC.

Change-Id: I09f71df0b0ba0d88ed997645e2e2497d553c9a1b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
43bfe7f047668a5b74fefb8cfecbf070f637201b 03-Dec-2011 Jesse Hall <jessehall@google.com> am a91e54fe: am f57c1388: Merge "SurfaceFlinger: fix layer removal race condition" into ics-mr1

* commit 'a91e54fed6a0690d59c97bab9b081b2614880563':
SurfaceFlinger: fix layer removal race condition
2f4b68d21c1a58cbcb1e6929fb241e425a8f7b5d 02-Dec-2011 Jesse Hall <jessehall@google.com> SurfaceFlinger: fix layer removal race condition

Layer::lockPageFlip() and layer::onRemove() could be called on
different threads and race such that lockPageFlip() successfully
called mSurfaceTexture->updateTexImage() but then gets NULL back from
mSurfaceTexture->getCurrentBuffer(), leading to a crash.

This change moves Layer::onRemove() calls to
SurfaceFlinger::commitTransaction() so they happen after the Layer is
done being drawn from and only happen on the main surfaceflinger
thread.

Change-Id: I4b550caadff4cc1878d7c3bca6129193fb0c713e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
79544364aa3c088fa7fbfadfc169086653389555 30-Nov-2011 Mathias Agopian <mathias@google.com> am e2970700: am e8ba2aba: Merge "add a way to access the version string of the h/w implementation of EGL" into ics-mr1

* commit 'e2970700e921da4226061988a6e8953b1fbfb5a9':
add a way to access the version string of the h/w implementation of EGL
bc2d79ed7ada6243f3690f94ab512c0ddcdbed12 30-Nov-2011 Mathias Agopian <mathias@google.com> add a way to access the version string of the h/w implementation of EGL

we use a hidden egl extension. the version string is printed
in SF's dumpsys log.

Change-Id: I123eb4bde6de462bb2404c67b74d6d6219a48d6a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d0566bc26fcf6ca396118701fa11900b627f2c09 18-Nov-2011 Mathias Agopian <mathias@google.com> Add support for sending VSYNC events to the framework

use gui/DisplayEvent to receive the events. Events are
dispatched through a unix pipe, so the API is compatible
with utils/Looper. see gui/DisplayEvent.h for more info.

Bug: 1475048
Change-Id: Ia720f64d1b950328b47b22c6a86042e481d35f09
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
439cf8576d3b846c0aa0944d84372259bf075d51 29-Nov-2011 Mathias Agopian <mathias@google.com> Fix build.

Revert "Add support for sending VSYNC events to the framework"

This reverts commit f3918c5bd4bc9f02f74da42995564150ca2dd382.

Change-Id: I998e3e1aa3fa310829ae973b64fe11b01f6f468f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
461afeb9fde149f9455acbadf1257d08d33e8eb3 18-Nov-2011 Mathias Agopian <mathias@google.com> Add support for sending VSYNC events to the framework

use gui/DisplayEvent to receive the events. Events are
dispatched through a unix pipe, so the API is compatible
with utils/Looper. see gui/DisplayEvent.h for more info.

Bug: 1475048
Change-Id: If4126023fc9c067e56087ec7d16a8fd542ce1794
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f61c57fe2e955e1c195bb0ca2dd7bcdaa922d5a9 24-Nov-2011 Mathias Agopian <mathias@google.com> rewrite SF's message loop on top of Looper

Change-Id: Ib56139f87a5c0b124e34da5c8151207219b2577b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
386aa98c4ffb9b805303e683f0a7b925b44d04db 08-Nov-2011 Mathias Agopian <mathias@google.com> Fix an issue where we could wait for a non-existing transaction

This fixes the issue:
"Call not sent" dialog takes too long to dismiss after hitting OK"

Note: the system would recover after a 5 second timeout.

Bug: 5534520
Change-Id: Ifa37e594b50581f498479a5858672441b3d7dd87
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4a9ac37fe26644bb5253d15eec08be2edb896642 01-Nov-2011 Mathias Agopian <mathias@google.com> Fix rotation displays frame N-1 briefly while rotating

The ScreenShot layer is now created hidden. The screenshot itself
is aquired during the transaction when the layer is made visible.
This guarantees the screenshot and the layer happen atomically
with respect to screen updates.

Bug: 5534521
Change-Id: Ida23e1f13d5716ec83b78a15712e0646d6cf8729
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
62f7114719d2009dca7dd120f0fe29a24bd77a40 27-Oct-2011 Mathias Agopian <mathias@google.com> fix Corrupted graphics while playing You Tube on orientation change

Bug: 5432124
Change-Id: If948b9797b1ec6fff80ca5ea94508abcaced9f31
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
51726c381e23d148867c760d06306dfa940b4d15 22-Oct-2011 Mathias Agopian <mathias@google.com> am aa938c8d: Merge "mDirtyRegion is single threaded, but could be accessed from a hwc thread" into ics-mr0

* commit 'aa938c8d9c0e71c9b556657cb33794210ce6ebf8':
mDirtyRegion is single threaded, but could be accessed from a hwc thread
0dfb7b73a468698622d6c0423f0d5471a6f5d375 22-Oct-2011 Mathias Agopian <mathias@google.com> mDirtyRegion is single threaded, but could be accessed from a hwc thread

We now have mInvalidateRegion which holds the region to invalidate, it
can be set from any thread as long as mInvalidateLock is held. We use
fine-grained locking here because mInvalidateRegion can be set from anywhere,
in particular frmo HWC callbacks.

Bug: 5466774
Change-Id: Iafca20aa3f5b25a87755e65bde7b769aa8f997bc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7ec662c07aea2a76394cd69f19be0f9a7d87b701 21-Oct-2011 Mathias Agopian <mathias@google.com> am 16bece04: Merge "added dpi and refresh rate info in SF\'s dumpsys" into ics-mr0

* commit '16bece04bdbac9af5228436f70267ec5763315de':
added dpi and refresh rate info in SF's dumpsys
d5e4ef9e439317e2525a51106dbc509d3982de24 21-Oct-2011 Mathias Agopian <mathias@google.com> added dpi and refresh rate info in SF's dumpsys

Change-Id: I2327248eb1993689367e3daeaccba74c172dfceb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
818fb243572f8e1f408ba9fc35ef61bbedbd9ce1 19-Oct-2011 Dave Burke <daveburke@google.com> am 70ac412b: Merge "Add a LayerScreenshot" into ics-mr0

* commit '70ac412b2fe7be2507189a9fdfb30c43b36d56ac':
Add a LayerScreenshot
675370ab9aadd148ba2cc15b3078c915811355a1 19-Oct-2011 Mathias Agopian <mathias@google.com> am f7613743: Merge "Don\'t call hwc set() if there is nothing new to do" into ics-mr0

* commit 'f7613743f29f38cbbaf4ae09996c380845a17daf':
Don't call hwc set() if there is nothing new to do
5ba8f366bd81348ac8b0e3a09fa122f3098b4363 19-Oct-2011 Mathias Agopian <mathias@google.com> am 23bf2505: Merge "Make sure set GL state properly" into ics-mr0

* commit '23bf250522b7dff9acd14c5900b66b1df9c76745':
Make sure set GL state properly
118d0245ee0a3b107055782aa8b555404b6f0280 14-Oct-2011 Mathias Agopian <mathias@google.com> Add a LayerScreenshot

A LayerScreenshot is a special type of layer that contains a screenshot of
the screen acquired when its created. It works just like LayerDim.

Make sure to call compositionComplete() after rendering into a FBO.

Bug: 5446982, 5467587, 5466259
Change-Id: I5d8a1b4c327f9973d950cd4f4c0bca7f62825cd4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
3a3cad30c40c8eb87671262a9fe7f0e214b6a934 19-Oct-2011 Mathias Agopian <mathias@google.com> Don't call hwc set() if there is nothing new to do

there was situations where SF's main loop would run (as if there was
an invalidate), but the dirty region was empty (so no new buffers
were retired). In this case we return early and don't swap, which
would cause drawing artifacts.

Bug: 5476838
Change-Id: Id3b7bf4b7aabec7919c50d9278eb2165973a4c3d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c492e67810814bf86301abffe1d31598b775cf45 18-Oct-2011 Mathias Agopian <mathias@google.com> Make sure set GL state properly

when taking a screenshot, in particular, we could end up
with stale GL state when drawing LayerDim which resulted
in incortect rendering.

Bug: 5467587
Change-Id: Id9fbed2843481d31063620f3662b364c7e3ac781
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cdec8f01aae14ed59fbc57cb2ce97a6602f4b9a1 17-Oct-2011 Mathias Agopian <mathias@google.com> am 840b8a67: Revert "Add a LayerScreenshot"

* commit '840b8a678537519c27ddf2f818494eaa20a135d4':
Revert "Add a LayerScreenshot"
5bacca6238adba927f9e9b27087e134e9a3c2561 17-Oct-2011 Mathias Agopian <mathias@google.com> am 4fb6416e: Merge "we need to guarantee that h/w comp set() is called when a buffer has been retired" into ics-mr0

* commit '4fb6416e3a21031a88921a784ae62b13d8a1a39f':
we need to guarantee that h/w comp set() is called when a buffer has been retired
090cb44b945bfe2711344a5331814bd6412ab437 17-Oct-2011 Elliott Hughes <enh@google.com> Merge branch 'master' of ssh://android-git:29418/platform/frameworks/base
e9800c83114988b6f8cc25bb9d508ebb322f9903 17-Oct-2011 Mathias Agopian <mathias@google.com> Revert "Add a LayerScreenshot"

This reverts commit d6809f40cf61203573ec5dbc437f695cd132cc18.
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a44b04163957d6086362f6f365443c4c93379031 17-Oct-2011 Mathias Agopian <mathias@google.com> we need to guarantee that h/w comp set() is called when a buffer has been retired

removed a test that could violate this guarantee. note that we
have no proof tha this ever happened, but consequences could be
hard lock-ups.

the code here was intended to track the region to update for displays
that can do partial update. the logic discarded the update entirely
if that region was empty. instead we just redraw the whole thing
(note that we should never be there with an empty region and retired
buffers though).

Bug: 5466259

Change-Id: I91ccab3b1a599e729e438eb833939e2236da6854
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a402c4c9913cfbc6c3da21719c57a93a11f091f0 15-Oct-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: Remove display freezing code

This change removes the dead code from SurfaceFlinger that resulted from
disabling support for freezing the display.

Change-Id: I4e5ff00c94b4c7a79af2f65c9850c135210068ed
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
28378392fd5aa3e0a392c9eb64634055678c3987 13-Oct-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: make sync transactions explicit

This change enables a layer or orientation update transaction sent to
SurfaceFlinger to explicitly request a synchronous transaction.

Change-Id: I97cbba610c13679849f66114b216fa6dbf12f2a9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f171ab6da9cf9793093e50947aacdab8f2b0c9b2 14-Oct-2011 Mathias Agopian <mathias@google.com> Add a LayerScreenshot

A LayerScreenshot is a special type of layer that contains a screenshot of
the screen acquired when its created. It works just like LayerDim.

Bug: 5446982
Change-Id: I7814aff2380e7e146937f2b641907be2a30c76cc
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b8d69a55f1c187a35ac41e69de63251f5501b6f4 11-Oct-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: update orientation via transactions

This change merges the ISurfaceComposer::setOrientation functionality
into ISurfaceComposer::setTransactionState. It enables the window
manager to atomically update both the display orientation and the
position and size of the windows in a single transaction with
SurfaceFlinger.

Bug: 5439574
Change-Id: I18a8ccc564d7d760ef8afb2d015ccdb7a7963900
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f7cdd053fe1fee093f6b0973ad5723765f98a48d 11-Oct-2011 Mathias Agopian <mathias@google.com> fix an issue where the screen could stay off

this would happen when toggling on/off/on very fast, the screen
could stay black (while the panel is on).

Bug: 5429724
Change-Id: Ic8aa6aff066e6267923c0d47ef65e314e7bb6d41
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a9040d0eefa34a78ca68b6e7901e1703e74aeb7c 11-Oct-2011 Mathias Agopian <mathias@google.com> Fix screen off animation when in landscape

Change-Id: I4bc5b12d7a64a4bf8b9a851594be4d60b790d1ed
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9575f60722f7a4f54384fe0be6938a8de48dc23a 07-Oct-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: screenshots w/ protected buffers

This change modifies SurfaceFlinger's screenshot behavior when a layer
with a protected buffer is visible. The previous behavior was to simply
fail the screenshot. The new behavior is to render the screenshot using
a placeholder texture where the protected buffer would have been.

Change-Id: I5e50cb2f3b31b2ea81cfe291c9b4a42e9ee71874
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
059fd18396605592ec538b9e5574a80a8987d10d 23-Sep-2011 Mathias Agopian <mathias@google.com> Merge "don't clear the framebuffer when the framebuffer is not used"
cd20eb09c4752531c1ab1a0084474ef530a5d44f 23-Sep-2011 Mathias Agopian <mathias@google.com> don't clear the framebuffer when the framebuffer is not used

when areas of the FB are undefined (transparent windows on top of
nothing), we clear those areas before composition.
however, it makes no sense to do this when the FB is not in use
(case where hwc handles all layers)

Bug: 5360529
Change-Id: If51bb669307e8419bbe1f3a89d1c88e0ec1f216c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
21230c6410bdab13cd2bd274da54b1e4061b6035 21-Sep-2011 Jeff Brown <jeffbrown@google.com> Handle orientation changes more systematically.
Bug: 4981385

Simplify the orientation changing code path in the
WindowManager. Instead of the policy calling setRotation()
when the sensor determined orientation changes, it calls
updateRotation(), which figures everything out. For the most
part, the rotation actually passed to setRotation() was
more or less ignored and just added confusion, particularly
when handling deferred orientation changes.

Ensure that 180 degree rotations are disallowed even when
the application specifies SCREEN_ORIENTATION_SENSOR_*.
These rotations are only enabled when docked upside-down for
some reason or when the application specifies
SCREEN_ORIENTATION_FULL_SENSOR.

Ensure that special modes like HDMI connected, lid switch,
dock and rotation lock all cause the sensor to be ignored
even when the application asks for sensor-based orientation
changes. The sensor is not relevant in these modes because
some external factor (or the user) is determining the
preferred rotation.

Currently, applications can still override the preferred
rotation even when there are special modes in play that
might say otherwise. We could tweak this so that some
special modes trump application choices completely
(resulting in a letter-boxed application, perhaps).
I tested this sort of tweak (not included in the patch)
and it seems to work fine, including transitions between
applications with varying orientation.

Delete dead code related to animFlags.

Handle pausing/resuming orientation changes more precisely.
Ensure that a deferred orientation change is performed when
a drag completes, even if endDragLw() is not called because the
drag was aborted before the drop happened. We pause
the orientation change in register() and resume in unregister()
because those methods appear to always be called as needed.

Change-Id: If0a31de3d057251e581fdee64819f2b19e676e9a
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9c6e297271ec9af9d974242d89cfa08cb6ceaa0a 21-Sep-2011 Mathias Agopian <mathias@google.com> fix transition from full overlays to fb

we need to clear the whole framebuffer in that situation because
we can't trust the content of the FB when partial (fb preserving)
updates are used.

Bug: 5318492

Change-Id: I3f0e01b0fb665a34e44d88ad9f0f54a5d990060b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0656a68380d01de4136933901b2c322cf9ab0d7e 21-Sep-2011 Mathias Agopian <mathias@google.com> rename mInvalidRegion to mSwapRegion

Change-Id: I946cbc782c0c84645843ea44c3d8b04a0a2fe658
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fb4d5d5726c172adbe62341d99a2148685a98379 21-Sep-2011 Mathias Agopian <mathias@google.com> improve hwc dumpsys

we now log the buffer's format

Change-Id: I9d3ad8018e884240a153de3baefb6331cb014d0f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f9abeb956fb95682d77005ea0dc506a805f52a04 09-Sep-2011 Mathias Agopian <mathias@google.com> Fix another problem with refreshing the screen when switching to/from overlay

the previous fix was incorrect. See comment in setupHardwareComposer for
full explanations.

Change-Id: Ib24a9af000b8f95cf7319f9272d34997064ceb6d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
22da60c3e64cd57535cbba063c07127814a2b52f 09-Sep-2011 Mathias Agopian <mathias@google.com> Improve SF dumpsys output wrt HWC

Change-Id: Ibdb7930fa3b521bfd3f44750ed98cfd75f9a01fe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f384cc3008a25ad1b00403aca0cc001547f029c6 09-Sep-2011 Mathias Agopian <mathias@google.com> Fix an issue is SF that caused drawing artifacts when hwc changed mode

we were not redrawing and/or clearing the FB properly when
hwc moved a layer from/to FB to/from OVERLAY.

In these cases we needed to expand the dirty region to include
the layer that changed mode.

Also split composeSurfaces() which was becoming quite large.

Change-Id: Id6fa1acfc4ff694037fddf7efd037a4405732073
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7ee4cd5556cef1878e1d4729f1b389f186311027 02-Sep-2011 Mathias Agopian <mathias@google.com> fix a bug that caused the off animation to not show sometimes

this happened when the overlays were in use, since the animation
is rendered in the FB and the FB is not used.

we now have a way to turn hwc off temporarily.

Change-Id: I3385f0c25bb9cc91948e7b26e7cd31ed18c36ace
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f914e7ffad20c0a39d86376c703cd98c086e774a 02-Sep-2011 Mathias Agopian <mathias@google.com> Fix various flickering / artifacts

these were due to the "preserve backbuffer" optimization
interfering with hw composer. basically the screen needed
to be redrawn in the areas that move from GL to
overlay.

Bug: 5245513
Change-Id: I9bf75c4fe905f3ef62005e52108b94edae692304
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
b0610335d745718f5ee54f15ef1a492921d759f4 25-Aug-2011 Mathias Agopian <mathias@google.com> Fix screenshots

Change-Id: If904634e64b154bbe336d5789dd1209b8ae871fb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0abe83a680d1f410c28b755eb4b3d6bee30c39dd 25-Aug-2011 Mathias Agopian <mathias@google.com> Fix Recent thumbnails aren't taken when leaving an activity via notification

When taking screenshots we need to use the full drawing state list
instead of the visible list.

Bug: 5186823
Change-Id: I214ee0203aaf8e2c038e44581f7f1ae36edf08c5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a45836466c301d49d8df286b5317dfa99cb83b70 24-Aug-2011 Mathias Agopian <mathias@google.com> Add a debug option to turn the "transformation hint" off

transformation hint is disabled with:

adb shell service call SurfaceFlinger 1009 i32 1

Change-Id: I9aafe6f280f88ce41569ed69a06dc522b10e3a88
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
53331da007b56e0cb4201728de99c8c29bcfaa9a 23-Aug-2011 Mathias Agopian <mathias@google.com> fix "show screen update" debug option.

Change-Id: I7d8b24124768b5f7d59d3bb0b019e9baaa0dfc4f
NOTE: from now on, this also disable the h/w composer
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
582270d69db94286a248bd829f1ae6f910d45124 18-Aug-2011 Jamie Gennis <jgennis@google.com> SurfaceTexture: fix queues-to-composer

This change fixes the NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER query of
Surface and SurfaceTextureClient. Surface now uses the inherited
SurfaceTextureClient implementation of this query. SurfaceTextureClient
now queries SurfaceFlinger to determine whether buffers that are queued
to its ISurfaceTexture will be sent to SurfaceFlinger (as opposed to
some other process).

Change-Id: Iff187e72f30d454229f07f896b438198978270a8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8afb7e39a83a3e31170612d562eb08508e328388 16-Aug-2011 Mathias Agopian <mathias@google.com> as a debug option SrufaceFlinger can now connect to DDMS

this is disabled by default. To enable:
setprop debug.sf.ddms 1

this debug option requires to restart SurfaceFlinger

Change-Id: Ic2f8050b29911b55bcd21721648b6978700c277d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
47d0812977b7acc4fed6a823203770a57f7a6b78 12-Aug-2011 Mathias Agopian <mathias@google.com> SurfaceFlinger doesn't rely on having a custom RefBase destructor

we just use a message to the main thread to
destroy our GLES state.
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c10d9d90b2088a3304076e0dc4bf05cdbb5d45ab 21-Jul-2011 Mathias Agopian <mathias@google.com> clean-up. get rid ofunused code and members in Surface[Control].cpp

Change-Id: Ia7790ae28af2c2ac99eae01c2c5044ace4a490a4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ad70186f80355e55ddad2a66b5fd174a1c019c2d 15-Jul-2011 Mathias Agopian <mathias@google.com> dump GLES strings in SF dumpsys log

Change-Id: I438d511159b2bd915c84954f30574340017d4f47
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ffcf4657718831edecb6ff2ed1b45ac8bf8b9a58 08-Jul-2011 Mathias Agopian <mathias@google.com> fix screen on/off animation (again)

- surfaceflinger now uses the GL-convention of
placing the origin in the left-bottom corner

- map texture coordinates of the screen capture
properly

- add the ability to control the animation
speed through a debug property

Bug: 4989276

Change-Id: Ifb3297bb578078b47146fff666c01f85417e0d6f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7e918860f9d496bf0c4b7e1649216c9209c57850 06-Jul-2011 Mathias Agopian <mathias@google.com> Merge "don't kill surfaceflinger when system process dies"
1f339ff3875afad128a8e16ee6395c5fad295826 02-Jul-2011 Mathias Agopian <mathias@google.com> don't kill surfaceflinger when system process dies

Change-Id: I2d3ed87b590f9ccea3fa4af41d92911de070b315
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d9e8c64c3dce1612eb948a5c16ba4ff62202b423 01-Jul-2011 Mathias Agopian <mathias@google.com> return an error code with gralloc buffer allocation failures

Change-Id: I471e5d37ea7a42fc8a0f93446ee3b4229da37807
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
2dbf9fffb2c99bc7f9dadf226772fd8cafc7826f 01-Jul-2011 Mathias Agopian <mathias@google.com> fix screen on/off animation, which was flipped

Bug: 4673549
Change-Id: Ia9766754687b89c1ee24b2dbe918c11290ebe038
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
698c0873cf2e07bdc7fd1e72169aee2a19fa40d7 29-Jun-2011 Mathias Agopian <mathias@google.com> SF transactions are now O(1) wrt IPC instead of O(N).

Change-Id: I57669852cbf6aabae244ea86940a08a5a27ffc43
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
99b49840d309727678b77403d6cc9f920111623f 28-Jun-2011 Mathias Agopian <mathias@google.com> PermissionCache caches permission checks

This is intended to absorb the cost of the IPC
to the permission controller.
Cached permission checks cost about 3us, while
full blown ones are two orders of magnitude slower.

CAVEAT: PermissionCache can only handle system
permissions safely for now, because the cache is
not purged upon global permission changes.

Change-Id: I8b8a5e71e191e3c01e8f792f253c379190eee62e
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a67932fe6864ac346e7f78b86df11cf6c5344137 20-Apr-2011 Mathias Agopian <mathias@google.com> unify SurfaceTexture and Surface

Add the concept of synchronous dequeueBuffer in SurfaceTexture
Implement {Surface|SurfaceTextureClient}::setSwapInterval()
Add SurfaceTexture logging
fix onFrameAvailable
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ca4d3602c07837d0b2ac6878685a8e327b5f30f0 20-May-2011 Mathias Agopian <mathias@google.com> Fix a race that could cause GL commands to be executed from the wrong thread.

Change-Id: Ia3d407f7bf2f5553f46cfdade70b7b0badb35beb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
dea20b1f343012d58ca9eb381684b26a168dc127 04-May-2011 Mathias Agopian <mathias@google.com> Fix a race in SurfaceFlinger that could cause layers to be leaked forever.

The transaction flags were atomically read-and-cleared to determine if
a transaction was needed, in the later case, mStateLock was taken to
keep the current state still during the transaction. This left a small
window open, where a layer could be removed after the transaction flags
were checked but before the transaction was started holding the lock.
In that situation eTraversalNeeded would be set but only seen during the
next transaction cycle; however, because we're handling this transaction
(because of another flag) it will be commited, "loosing" the information
about the layer being removed -- so when the next transaction cycle due
to eTraversalNeeded starts, it won't notice that layers have been removed
and won't populated the ditchedLayers array.

Change-Id: Iedea9e25fee8dd98a0c5bd5ad41a20fcadf75b47
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4f113740180b6512b43723c4728f262882dc9b45 04-May-2011 Mathias Agopian <mathias@google.com> Fix a race-condtion in SurfaceFlinger that could lead to a crash.

Client::mLayers could be accessed from different threads.
On one side from Client::attachLayer() which is currently
called from a binder thread; on the other side from
Client::detachLayer() which is always called from the main
thread.

This could lead to a corruption of Client::mLayers.

We fix this issue by adding an internal lock to Client.

Change-Id: Ib1317d7750ed5030e6f577efe34b69fc10198bd3
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0ef4e15a6c12778daf464a4953d7e15e651f49ac 20-Apr-2011 Mathias Agopian <mathias@google.com> Get rid of the "pid" parameter from createSurface

Change-Id: I28635e3f803e6abe965d79998e305f54a202465d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4cb18881b55b82a24873ccd8e298bc2d5a9c17e5 09-Apr-2011 Mathias Agopian <mathias@google.com> Fix a GraphicBuffer leak in SurfaceTexture

This leak was intentional, it was there to deal with the fact that
some gralloc implementations don't track buffer handles with
file-descriptors so buffers needed to stay alive until there were
registered, which is not guaranteed by binder transactions.

In this new implementation, we use a small BBinder holding a
reference to the buffer, which with tuck into the parcel. This forces
the reference to stay alive until the parcel is destroyed, which
is guaranteed (by construction) to happen after the buffer is
registered.

this allows the public facing API to not expose the previous hack.

Change-Id: I1dd6cd83679a2b7457ad628169e2851acc027143
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1bbafb96101de04c43adb5e3ca2494070d20a46a 12-Mar-2011 Mathias Agopian <mathias@google.com> Fix some const-ness and comments

mDrawingState doesn't need to be accessed by the
mStateLock, because by definition it's only accessed
from the main thread.

Similarily, the list of layers in the drawing state
cannot change (ie: is const).

Change-Id: I2e5da7f4d8caee7af7802b432cd45cc81c7c08b0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
7a4d0dfd43558c299e6af6c4910ef76db9db3172 10-Mar-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: Respect the PROTECTED gralloc bit.

This change makes SurfaceFlinger treat layers for which the active
buffer has the GRALLOC_USAGE_PROTECTED bit set as if they have the
'secure' flag set.

Change-Id: Ic60b6513a63e4bb92ec6ce9fd12fd39b4ba5f674
Bug: 4081304
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
134f0422866e8985188ed10dfbdcb8e6c34b87f7 08-Mar-2011 Jamie Gennis <jgennis@google.com> ANativeWindow: add queues-to-window-composer check.

This change adds a new 'method' to the ANativeWindow interface to check
whether buffers queued to the window will be sent directly to the system
window compositor.

Change-Id: I4d4b199e328c110b68b250029aea650f03c8724d
Bug: 3495535
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1c71a47a6db679a3212f0c99e14f330d6da500fa 03-Mar-2011 Mathias Agopian <mathias@google.com> remove some logs

Change-Id: Ia476184048ee419e19330a56dc8e6553189f6a24
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d1ad86f66b070eaf81f8bee41a2528d5da9363f1 28-Feb-2011 Jamie Gennis <jgennis@google.com> am e630e5f4: am 919853ce: Merge "Prevent SurfaceFlinger from using layer token 31." into gingerbread

* commit 'e630e5f49ba15005172dceeda7299569b2d2351f':
Prevent SurfaceFlinger from using layer token 31.
8a08392833a2db80aef20fba8a43f0829a096e13 11-Feb-2011 Jamie Gennis <jgennis@google.com> Prevent SurfaceFlinger from using layer token 31.

Bug: 2964479
Change-Id: I81e948924bff35b8b300d409f2c09f3779bcdeec
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bce26daaaf4ea245ccb09d75a378d294e518d945 03-Feb-2011 Mathias Agopian <mathias@google.com> [3418265] apply layer transformations to the DimLayer.

with this change DimLayers will behave just like any other layer,
in particular they'll respect the layer transformations.

Change-Id: Icb4a1275e8bca9e3deb5f57c9f9219aaa69f9877
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0d1561275e80073807ac04728951782d943f8882 26-Jan-2011 Mathias Agopian <mathias@google.com> fix [3385504] Surface flinger hang when adding dim surface

Change-Id: I8e0cda414bcad5854d2ca5dde8370bfd8b2e5ea4
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
d1a99ec6b2f23db5662e6d2ccf7b40d96869eccb 19-Jan-2011 Mathias Agopian <mathias@google.com> fix [3361121] hang in glClear() - device unresponsive, OTA fails (DO NOT MERGE)

Generally we never want to lock a buffer for write access if it is at
the "head" on the surfaceflinger side. The only exception (1) is when
the buffer is not currently in use AND there is at least one queued
buffer -- in which case, SurfaceFlinger will never use said buffer
anymore, because on the next composition around, it will be able to
retire the first queued buffer.

The logic above relies on SurfaceFlinger always retiring
and locking a buffer before composition -- unfortunately this
didn't happen during a screenshot.

This could leave us in a situation where a buffer is locked by the
application for write, and used by SurfaceFlinger for texturing,
causing a hang.

Here, we fix this issue by never assuming the exception (1), it was
intended as an optimization allowing ANativeWindow::lockBuffer() to
return sooner and was justified when most of SF composition was
done in software. The actual buffer locking is now ensured by
gralloc. We could have handled screenshots in a similar way to
a regular composition, but it could have caused glitches on screen,
essentially, taking a screenshot could cause to skip a frame.

now that we removed the notion of a "inUse" buffer in surfaceflinger
a lot of code can be simplified / removed.

noteworthy, the whole concept of "unlockClient" wrt. "compositionComplete"
is also gone.
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
53a67e1663564efd691461659634f9e908407112 15-Jan-2011 Mathias Agopian <mathias@google.com> partially fix [3306150] HTML5 video with H/W acceleration blackout (DO NOT MERGE)

We used to guarantee that a layer in SurfaceFlinger would never be
destroyed before all references (to its ISurface) on the client
side would be released. At some point, this guarantee got
relaxed to allow to free gralloc resources sooner. This last
change was incorrect, because:
- in implementations with reference-counting the gralloc resources
wouldn't be released anyways, until all the mapping were gone
- in implementations without ref counting, the client side
would most likely crash or do something bad
- it also caused the SharedBufferStack slot to be reallocated
to another surface, which could be problematic if the client
continued to use the surface after the window manager destroyed it.

So, we essentially reinstate the guarantee that layers won't be
destroyed until after all references to their ISurface are
released.

NOTE: This doesn't entirely fix 3306150 because there is another
problem there where the Browser continues to use a surface after it
has been destroyed.

also improve SurfaceFlinger 'dumpsys' log

list the purgatory, which shows windows that have been closed,
but for which the client still has references.
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
cfb676f1aeb8648699bf23e987c3a752275519ca 17-Dec-2010 Mathias Agopian <mathias@google.com> fix a small bug that caused screenshot to show garbage in some cases (DO NOT MERGE)

we were not clearing the screen entirely, which caused garbage when
the screen wasn't entirely covered by windows.

Change-Id: Ia7aa13c36a8a314e0e8427d419b16b9aa2165ddf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
5dc7e7da9273a5b40a85f8f6177793a23669cf98 15-Dec-2010 Mathias Agopian <mathias@google.com> workaround [3201922] display not on: log full of gralloc errors (DO NOT MERGE)

we make sure to call compositionComplete after everytime we do
composition with the GPU (even for the screenshot case), which is
where the buffer locks are released.

Change-Id: I450430d1e4d1ee9ce1023970642378c42cdcfa4c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0c2648ab644b22100c1e80801d05278f9ac729e9 25-Jan-2011 Mathias Agopian <mathias@google.com> tone down the log spew regarding taking screenshots.

Change-Id: I673806bda23eba6aab25f7505b7e0170afc9920b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a9f54a77cd4057b0fddb0c6886357152548bf891 20-Jan-2011 Mathias Agopian <mathias@google.com> Merge "fix [3369743] SurfaceFlinger reads hardware composer hints before calling hwc.prepare()" into honeycomb
2bd1d95efecffad447afd682ffe605bbf8c79d62 20-Jan-2011 Mathias Agopian <mathias@google.com> clean-up unneeded code

now that we removed the notion of a "inUse" buffer in surfaceflinger
a lot of code can be simplified / removed.

noteworthy, the whole concept of "unlockClient" wrt. "compositionComplete"
is also gone.

Change-Id: I210413d4c8c0998dae05c8620ebfc895d3e6233d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
48b888aab9fdcfba250722dffbdffe61f11c64f3 20-Jan-2011 Mathias Agopian <mathias@google.com> improve SurfaceFlinger 'dumpsys' log

list the purgatory, which shows windows that have been closed,
but for which the client still has references.

Change-Id: I5168bb88cb328d5d77d71d0871deb9190f493126
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f20a32415d055336bc6016fa2de36d126db32746 20-Jan-2011 Mathias Agopian <mathias@google.com> fix [3369743] SurfaceFlinger reads hardware composer hints before calling hwc.prepare()

Change-Id: If3277c7b9d4cb8ef20d1706155fac7b87e64fb20
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c1d1b0d9b74d8f55346d0b84f369e48ecf2e0d33 16-Jan-2011 Mathias Agopian <mathias@google.com> Add logs when taking a screenshot to help tracking issue 3361121

Change-Id: I61d1e072ebe7061ee1d7255f6121b684e2923d1b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0d3dcc4aab864e4e4086b070c08949d369239f22 15-Jan-2011 Mathias Agopian <mathias@google.com> Merge "partially fix [3306150] HTML5 video with H/W acceleration blackout" into honeycomb
76cd4ddc6ad664257739b3d3713fd9ebdc9a4ad9 15-Jan-2011 Mathias Agopian <mathias@google.com> partially fix [3306150] HTML5 video with H/W acceleration blackout

We used to guarantee that a layer in SurfaceFlinger would never be
destroyed before all references (to its ISurface) on the client
side would be released. At some point, this guarantee got
relaxed to allow to free gralloc resources sooner. This last
change was incorrect, because:
- in implementations with reference-counting the gralloc resources
wouldn't be released anyways, until all the mapping were gone
- in implementations without ref counting, the client side
would most likely crash or do something bad
- it also caused the SharedBufferStack slot to be reallocated
to another surface, which could be problematic if the client
continued to use the surface after the window manager destroyed it.

So, we essentially reinstate the guarantee that layers won't be
destroyed until after all references to their ISurface are
released.

NOTE: This doesn't entirely fix 3306150 because there is another
problem there where the Browser continues to use a surface after it
has been destroyed.

Change-Id: I305c830dd722b30a6d53cbf3a9c714fd3cf7eb06
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a49576f06b73893fd957d974382390a47b44589e 14-Jan-2011 Mathias Agopian <mathias@google.com> Merge "fix [3312683] Camera mirroring problem after switching from back to front camera" into honeycomb
ad456f9878ff7c176499e7b992f9ff1cb3e9cdee 14-Jan-2011 Mathias Agopian <mathias@google.com> fix [3312683] Camera mirroring problem after switching from back to front camera

the crop as well as buffer orientation can change at every frame, when that happens
we need to reset the hwc HAL (ie: set the GEOMETRY_CHANGED flag).
currently we achieve this by taking the same code path than an actual geometry change
which is a bit more heavy than necessary.

Change-Id: I751f9ed1eeec0c27db7df2e77d5d17c6bcc17a24
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
9a78c90cd46b2a3bd637b056873149d3b94384b4 13-Jan-2011 Jamie Gennis <jgennis@google.com> Fix remote GraphicBuffer allocation in SurfaceFlinger.

This change fixes a horrible hack that I did to allow application
processes to create GraphicBuffer objects by making a binder call to
SurfaceFlinger. This change introduces a new binder interface
specifically for doing this, and does it in such a way that
SurfaceFlinger will maintain a reference to the buffers until the app is
done with them.

Change-Id: Icb240397c6c206d7f69124c1497a829f051cb49b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
495633406580685dfaa41979bbae47fc5f77fefe 20-Dec-2010 Jamie Gennis <jgennis@google.com> Add the ISurfaceComposer::createGraphicBuffer IPC.

This change adds a new binder method to the ISurfaceComposer interface.
This IPC is intended to allow SurfaceFlinger clients to allocate gralloc
buffers using SurfaceFlinger as a proxy to gralloc.

Change-Id: Ide9fc283aec5da6268ba62cfed0c3319a50b640d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f653b897a449e10d6cbfb6e0812f7b0bb02d6482 17-Dec-2010 Mathias Agopian <mathias@google.com> fix a small bug that caused screenshot to show garbage in some cases

we were not clearing the screen entirely, which caused garbage when
the screen wasn't entirely covered by windows.

Change-Id: Ie9ab9b94eabfa6cafddf45bb14bc733bdc8d35c0
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e6f0984361f634ff36bc0ad1c2d45f4554619ac8 15-Dec-2010 Mathias Agopian <mathias@google.com> workaround [3201922] display not on: log full of gralloc errors

while we're waiting for the real fix in the gralloc/gpu driver,
this workaround should resolve the issue.

we make sure to call compositionComplete after everytime we do
composition with the GPU (even for the screenshot case), which is
where the buffer locks are released.

Change-Id: I3cb5ad67d48c81a23100172bab77e86a70e29152
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ebeb7095961e09f5cff0c7cf2c04fa4770b2e033 15-Dec-2010 Mathias Agopian <mathias@google.com> fix debug.sf.showbackground

Change-Id: Ie4eeca006ad6d8030900d8cb0029e4d1c22474fb
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
bf2c6a6c8f1df40ac94e28b948754bb9739daaca 11-Dec-2010 Mathias Agopian <mathias@google.com> [3258939] Need snapshot to limit which layers are included

Change-Id: Id7351a0e3f53dde99b291cffba553d89fd4d7ca9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1293a8eb567fd63c072a6970fa9dcf37d076059f 09-Dec-2010 Mathias Agopian <mathias@google.com> More clean-up. Get rid off the "blur" effect in SurfaceFlinger

For multiple reason, this effect is not maintainable and was never
used due to its abysmal performance. it'll be resurected when it can be
implemented efficiently.

Change-Id: Id4222c9b86c629275cdec18873ef07be8723b6d2
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a5529c8778c2f407f482fc12165aeb76c0f505c2 08-Dec-2010 Mathias Agopian <mathias@google.com> remove support for PUSH_BUFFER surfaces and overlays

the same functionality is now supported through
the h/w composer HAL, and YUV support in the GPU.

Change-Id: I8146605449954b8e8fd7f78810b7d873c2d8f5bf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
1d21a9cafc534c34a2f28c985c4c7aa176d0e67b 02-Dec-2010 Erik Gilling <konkers@android.com> surfaceflinger: add support for gralloc dump hooks

Change-Id: Ib6f539ed0132b70d040d653c03d52cc04249ac3c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
e24cc7a38dce071267156a9345e9ec3f27890daf 08-Dec-2010 Mathias Agopian <mathias@google.com> [317580] fix issue where the screen wouldn't be rotated properly in bypass mode

In some situations, the screen transformation would not be
applied while in bypass mode.

Change-Id: I3d6dd52e4c12b11aae97b54bf8e2322536eee37f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
22c67843bebd2083053af5992befe7ebd50303a5 02-Nov-2010 Mathias Agopian <mathias@google.com> [3171580] SurfaceFlinger Bypass mode. (DO NOT MERGE)

This is a poor's man precursor to the h/w composer HAL.
Basically we detect when a window is full screen and in
that case we bypass surfaceflinger's composition step, which
yields to much improved performance.

Change-Id: Ie03796ae81a1c951949b771c9323044b980cb347
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
37b126a3b274e1930fbbddcdf3ec708d13d01801 10-Nov-2010 Jamie Gennis <jgennis@google.com> Remove a problematic empty update optimization.

This change removes an optimization from SurfaceFlinger that skipped
composition when it got window updates that had an empty dirty region.
This optimization caused problems because it would skip the hwcomposer
set call, which could leave the window's previous frame buffer bound to
an overlay plane. When the application subsequently dequeued and tried
to lock its next buffer (which would be the buffer currently bound to
the overlay), the lock call would block until the next hwcomposer set
call (which may never happen).

Change-Id: I563b626a1d52c1f30eb82489eae0ceb4edc79936
Bug: 3138752
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
0a96e3c31f137fd4e271c1fb2aef9aa0b6e79ce0 16-Oct-2010 Mathias Agopian <mathias@google.com> am 9f6d18ca: am 04358138: Merge "[3095807] screen takes a long time to turn on" into gingerbread

Merge commit '9f6d18cadf9ac50062063f5f5ff5de7f6895696a'

* commit '9f6d18cadf9ac50062063f5f5ff5de7f6895696a':
[3095807] screen takes a long time to turn on
fb3051b15e15b0f57196e0f2bc6ba8570f7ffe5e 16-Oct-2010 Mathias Agopian <mathias@google.com> am 7e9a54d4: am d4e03f37: addresses parts of 3096779 and 3097475

Merge commit '7e9a54d460030a871a4f05e61e943c6a694e9ef8'

* commit '7e9a54d460030a871a4f05e61e943c6a694e9ef8':
addresses parts of 3096779 and 3097475
1cc53746aa8f548349385af7134af1135cfd1d5e 16-Oct-2010 Mathias Agopian <mathias@google.com> am a8faf91f: am 6d71f6a0: Merge "fix [3095607] Gingerbread screen turn-on animation does not show the last frame" into gingerbread

Merge commit 'a8faf91fa558be1235d508e776eb24be4429585c'

* commit 'a8faf91fa558be1235d508e776eb24be4429585c':
fix [3095607] Gingerbread screen turn-on animation does not show the last frame
c9ce8cbe3bc1cd75598ab67081fe8b96199bfd31 15-Oct-2010 Mathias Agopian <mathias@google.com> am 3d4a9774: am b0e020ab: Merge "may fix 3097381 and 3097482. don\'t abort on/off if the animation fails" into gingerbread

Merge commit '3d4a9774ced0c704da455c5bd9989127e90ba133'

* commit '3d4a9774ced0c704da455c5bd9989127e90ba133':
may fix 3097381 and 3097482. don't abort on/off if the animation fails
e33a35f02576b482a5ac4891a78f6e72fb4c0dea 15-Oct-2010 Mathias Agopian <mathias@google.com> am 5bfa3a34: am 011b5bcc: Merge "implement part of [3094280] New animation for screen on and screen off add support for screen on animation" into gingerbread

Merge commit '5bfa3a34eaef759c3ec4def76f646eb1c0bf997f'

* commit '5bfa3a34eaef759c3ec4def76f646eb1c0bf997f':
implement part of [3094280] New animation for screen on and screen off
a6546e5af4ce0cff01cd13605fc3eb16325feac3 14-Oct-2010 Mathias Agopian <mathias@google.com> [3095807] screen takes a long time to turn on

turn on animation is now ~200 ms (12 frames).

Change-Id: I49ca9e8d0afa566349d360b3b6c88f0d55aa6e75
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
abd671a08a41519a7ab3d438a500efe0ef0bfc1d 14-Oct-2010 Mathias Agopian <mathias@google.com> addresses parts of 3096779 and 3097475

3097475: Animation setting should control the screen on animation
3096779: CRT power-on animation can briefly show the top app instead of lockscreen

There is now a parameter that controls wether the ON and/or OFF animation are
performed. we also always clear the screen to black on power off, to make
sure it won't briefly appear on power on.
HOWEVER, 3096779 is not 100% fixed in the case where we're doing the animation
because there is a race, where SF doesn't wait (b/c it doesn't know) for the
framework to have redrawn the lockscreen.

Change-Id: Ie0f02c9225fcdf24b1e8907e268eb7da2c5b0a03
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a7f0373533e590fdca1400f90e6657ebb2dd5f17 14-Oct-2010 Mathias Agopian <mathias@google.com> fix [3095607] Gingerbread screen turn-on animation does not show the last frame

always redraw the screen entirely after the power-on animation, because:
- the animation may not run (ie: on the emu)
- the animation may not contain the video planes
- the interpolation may not be perfect and not land exactly on the last frame

Change-Id: I9ba40f537b1e94464f8a3ed6f81e7c2f552df51d
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
015fb3fb41ffe04475ab2b604cc30cc1c031815a 14-Oct-2010 Mathias Agopian <mathias@google.com> may fix 3097381 and 3097482. don't abort on/off if the animation fails

now that sf handles more of the screen on/off state, we don't want to abort
because/if the animation fails for some reason (which will be the case on the
emulator).

Change-Id: I239e0a39cf8aff3074647e82db92de4a0bf0e494
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
503d2d4a08370209dc83330bd00997ba9512f46f 14-Oct-2010 Joe Onorato <joeo@google.com> am 9a12a3c8: am ba799098: Merge changes I76513387,I335fb671 into gingerbread

Merge commit '9a12a3c8d4bb20042cf69e07d268e3a04ac71f96'

* commit '9a12a3c8d4bb20042cf69e07d268e3a04ac71f96':
Remove dead code, and make the animation a setting.
turn off the electron beam
9daa5c9b9dd286cbbf5d43f7e45a5e9e4048e855 13-Oct-2010 Mathias Agopian <mathias@google.com> implement part of [3094280] New animation for screen on and screen off
add support for screen on animation

Change-Id: If50cf52ae04b95b42da7d74cf7fa96d5cb54d238
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
59119e658a12279e8fff508f8773843de2d90917 11-Oct-2010 Mathias Agopian <mathias@google.com> turn off the electron beam

Change-Id: I335fb6719f1d5a3f1c6f37a046fd1c2c4ed2bbc6
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
df85c455c34a920d22a8e3f7459a1cc615efcd27 29-Sep-2010 Mathias Agopian <mathias@google.com> refactored screenshot code

the core screenshot function now can capture the screen at any lower resolution
performing bilinear filtering.

we also now have some client code to interface with the screenshot service.

it's now possible to request a screenshot at a lower resolution.

Change-Id: I33689bba98507ab928d0898b21596d0d2fe4b953
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
74c40c0a273dbfd7d10617c4cc1b0c066bfc812e 29-Sep-2010 Mathias Agopian <mathias@google.com> refactored screenshot code

the core screenshot function now can capture the screen at any lower resolution
performing bilinear filtering.

we also now have some client code to interface with the screenshot service.

it's now possible to request a screenshot at a lower resolution.

Change-Id: I5a3b0e431421800e3aad601d9af8f94adffbc71f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a3aefeb1c31618dcc897da22d2d2f741104e3fe3 25-Sep-2010 Mathias Agopian <mathias@google.com> am 495ad4f2: am beabe75a: Merge changes I1f7c4535,I741c68a2 into gingerbread

Merge commit '495ad4f22096aa172d025c16c25497e7dad8f2bd'

* commit '495ad4f22096aa172d025c16c25497e7dad8f2bd':
simple test app for screen capture API
add support for [1974164] Be able to take a screen shot on the device
1b0b30d04304392748a8a4ab5a69e52a19f51b3a 24-Sep-2010 Mathias Agopian <mathias@google.com> add support for [1974164] Be able to take a screen shot on the device

screenshots are taken using ISurfaceComposer::captureScreen() which returns
the size of the screenshot and an IMemoryHeap containing the data.
screenshots have limitations:
- they will always fail if a secure window is up on screen
- require GL_OES_framebuffer_object extension
- in some situation, video planes won't been captured

Change-Id: I741c68a2d2984fb139039301c3349e6780e2cd58
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8372785879d329f592f6883620b5a32d80d74691 24-Sep-2010 Mathias Agopian <mathias@google.com> dump HWC state in dumpsys

Change-Id: Ifbb38ca1ac9685776250e01c8d02021b35af72cf
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
73d3ba9e50be1014aa21ec4bbdc874be394accb4 23-Sep-2010 Mathias Agopian <mathias@google.com> add a way to toggle the h/w composer at runtime

to DISABLE the h/w composer:
adb shell service call SurfaceFlinger 1008 i32 1

to ENABLE the h/w composer:
adb shell service call SurfaceFlinger 1008 i32 0

the state is dumped in "dumpsys SurfaceFlinger"

Change-Id: I23e2242d42c6e3fd5261a83332dd900b189e38ce
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
fe0a0af7bdab1e61fdb00f4705ccff5b46c19d8e 17-Sep-2010 Mathias Agopian <mathias@google.com> am 793b2293: am 1bcb8b1a: Merge "surfaceflinger / GL extensions cleanup" into gingerbread

Merge commit '793b2293797ea930078640c4827d3cbdf449c227'

* commit '793b2293797ea930078640c4827d3cbdf449c227':
surfaceflinger / GL extensions cleanup
7f198b6bff54af3c8e8ac32b83ffc6488e773ac1 16-Sep-2010 Michael I. Gold <gold@nvidia.com> surfaceflinger / GL extensions cleanup

Add correct enumerants for OES_EGL_image_external to glext.h.
SurfaceFlinger now checks for the correct extension name.

Change-Id: I2ba2728a01fa2260bd086d2df4316c68f694a9b1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
c479e18db0216f7096fefe85ffa71ab00329aef3 15-Sep-2010 Mathias Agopian <mathias@google.com> resolved conflicts for merge of 48a86240 to master

Change-Id: I2305fef9f4dd46183337217d822df3c675b6b6e5
35b48d10bc9e064201d3d54d2d476314684a7a05 14-Sep-2010 Mathias Agopian <mathias@google.com> Add logging of various important graphics events

There are 16 events logged in the event log:
SF_APP_DEQUEUE_BEFORE
SF_APP_DEQUEUE_AFTER
SF_APP_LOCK_BEFORE
SF_APP_LOCK_AFTER
SF_APP_QUEUE

SF_REPAINT
SF_COMPOSITION_COMPLETE
SF_UNLOCK_CLIENTS
SF_SWAP_BUFFERS
SF_REPAINT_DONE

SF_FB_POST_BEFORE
SF_FB_POST_AFTER
SF_FB_DEQUEUE_BEFORE
SF_FB_DEQUEUE_AFTER
SF_FB_LOCK_BEFORE
SF_FB_LOCK_AFTER

all events log the buffer conserned and a timestamp in microseconds.

by default the logging is not enabled, to turn it on:
adb shell service call SurfaceFlinger 1006 i31 1
adb shell setprop debug.graphic_log 1

The effect is immediate in SurfaceFlinger, but applications need to be
restarted.

Change-Id: Ifc2e31f7aed072d9a7dede20ff2ce59231edbec1
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
586a0deb76012c4347298c11df460631853b67f8 09-Sep-2010 Antti Hatala <ahatala@nvidia.com> surfaceflinger: composite HWC_SKIP_LAYER layers

Change-Id: I363ede63287ae903d66d0d419343f4ecd81bcc00
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8392b504bdf63ac7820c79c7217a89f2b2411bd0 08-Sep-2010 Antti Hatala <ahatala@nvidia.com> surfaceflinger: unlock clients only after flip

Change-Id: I039291a36f05bbaa02b29325d4012114abd784b9
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
89c2dd2cc27ead77da131fe27810c99a11a92ad7 11-Aug-2010 Jamie Gennis <jgennis@google.com> Change the framework to use the new camera preview path.

This change makes the camera HAL interface take an ANativeWindow interface from
which all the camera preview buffers will be allocated. The framework code
running in application processes now passes a Surface object rather than an
ISurface to the camera server via Binder when setting the preview surface. The
camera server then forwards that Surface object (which implements the
ANativeWindow interface) to the camera HAL, which uses it to communicate with
SurfaceFlinger to allocate the camera preview buffers.

Change-Id: Ie438f721559cd7de5e4f848a26d96360dda07b5f
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
8b42e8a5d87dcdc8ea31368ab88de49b72ab5432 16-Aug-2010 Andreas Huber <andih@google.com> Squashed commit of the following:

commit 35cc68814a9537c31fde146e171e7b0bbdfe211e
Author: Andreas Huber <andih@google.com>
Date: Mon Aug 16 08:48:42 2010 -0700

Only enable support for yuv to yuv conversion on passion, where it's available, use the slower yuv->rgb565 path everywhere else.

commit d8ac5a8814103e60d11d2acf61997fc31a1dc58d
Author: Andreas Huber <andih@google.com>
Date: Fri Aug 13 13:56:44 2010 -0700

The software renderer takes over all rendering, converting from yuv to yuv if possible and rgb565 otherwise.

commit 684972074b74318bdcb826ed9b5b0864d2d2e273
Author: Andreas Huber <andih@google.com>
Date: Fri Aug 13 09:34:35 2010 -0700

A first shot at supporting the new rendering APIs.

Change-Id: Iea9b32856da46950501f1a700f616b5feac710fd
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
000ca8fa9a1a92aa2f132ba41d11ece6d01cdadd 18-Aug-2010 Mathias Agopian <mathias@google.com> revert hwcomposer HAL changes. DO NOT MERGE.

This reverts commit:
94364b91a2894bf037b8beb027132fbb812e1434
f8e705dea48f77f1c2532fdbadd4997dd1851af0
b59beb5ca68d0228f60dda60d85e2d0226b33215
e0d5f5bcf5a8b26f4ad75f549cbf380b2c9faf20
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
ae957658688ce174a8d58434b4567d022c22a6cf 13-Aug-2010 Erik Gilling <konkers@android.com> surfaceflinger: don't check HWComposer numLayers unless one exists

Change-Id: I4b83f7bf7ba1318c70054117f14e759fe0ad105c
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
24925bfba22ac24de8dedc8f2c1cad5be7ade14f 13-Aug-2010 Erik Gilling <konkers@android.com> surfaceflinger: don't check HWComposer numLayers unless one exists

Change-Id: I6524f46910b761cff3ef696edf5a65a424879faa
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
45721773e1a68e96da4b6cc04cef276bae7ca3e9 13-Aug-2010 Mathias Agopian <mathias@google.com> Fix a couple issues with the new hwcomposer HAL

- we now clear the framebuffer upon request from the HAL
- the HAL list size could get out of sync with reality
- there was also an issue where sometime we could run past the list

Change-Id: Ic3a34314aed24181f2d8cc787096af83c046ef27
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a350ff98692b3a50cad5cc93f9f83221242ca86a 11-Aug-2010 Mathias Agopian <mathias@google.com> call into hwcomposer HAL when present

Change-Id: I70f31c69a9436a43860e78977442863ecba6d27b
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
f6679fc6f70939643901f29a9a69e40c603e6e5f 11-Aug-2010 Mathias Agopian <mathias@google.com> get rid of our LayerVector implementation

we now use SortedVector<> with a special compare implementation.

Change-Id: I910459cf3b3c8993b55ad0786a8c348369262de5
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
4da751999358fffa4cefc4c8046dab72045925f6 11-Aug-2010 Mathias Agopian <mathias@google.com> keep a list of visible sorted surfaces

Change-Id: Ib815eeff894f8a3b1e79fbbf8186d5d91bb60285
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
a1e6bc864fb821c1b470b7aad9b75c441f54eeb4 15-Jul-2010 Mathias Agopian <mathias@google.com> added BinderService<> template to help creating native binder services

Change-Id: Id980899d2647b56479f8a27c89eaa949f9209dfe
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
81bac09fa6b01dd1495644d9c825c3666762fced 15-Jul-2010 Mathias Agopian <mathias@google.com> move native services under services/

moved surfaceflinger, audioflinger, cameraservice

all native services should now reside in this location.

Change-Id: Iee42b83dd2a94c3bf5107ab0895fe2dfcd5337a8
/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp