History log of /frameworks/native/services/surfaceflinger/Layer.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9640da6f89e18e095ff4e1d21feb812a24fd1a32 27-Jun-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Last minute log removal.


Test: Log removed!
Change-Id: I4593352cf565603a4507c6ef13504b167d882eec
(cherry picked from commit 4e10a52dc5da22b5617069999c9986c59357e2a7)
e41dbe6ab1d412efd67fdc8344be8da8b19426d2 13-Jun-2017 Chia-I Wu <olv@google.com> surfaceflinger: distinguish mCurrentParent/mDrawingParent

Updates to wp<> is not atomic. We cannot use/update it at the same
time from the main thread and a binder thread. With this change,
binder threads use mCurrentParent with the external state lock held.
The main thread uses mDrawingParent.

This is also an alternative fix to bug 62099658 and allows us to
revert "SurfaceFlinger: Update parent pointer while performing

Bug: 38505866
Bug: 62099658
Test: boots and no repro (but I can never repro)
Change-Id: Id286a437537daaeec5eee5de62b1d9df245ece53
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)
41b08b5e97b04d726fb8bbacddbce563a1c890f9 02-Jun-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Fix final cropping of child layers.

Straightforward mistake documented by the test case. Not sure how it
made it this long.

Test: Included in Transaction_test.cpp. Manual from bug. go/wm-smoke.
Bug: 37511473
Change-Id: I87a57825cca879c5519fe72fef199168f7c23479
98b0fd5fc28b07b6b488bc599a3448ebcacb6acc 01-Jun-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Update parent pointer while performing transaction.

To understand the change at a high level, notice that all the usage
of getParent() is assosciated with the drawing state. We see in this way
that the parent is a part of the drawing state and should only be updated
when transactions occurs.

More specifically we can consider the following scenario:

1. Imagine that we have a visible surface, with a visible child surface
2. Now imagine we create a new surface, which is hidden, and post a buffer to it.
It is configured such that it would be visible if it were not hidden.
3. We open a transaction
4. We reparent the child from the old surface to the new one
5. We show the new surface
6. We close the transaction

At this point we would expect the child to remain visible, as it is atomically
reparented with the visibility change of the parent. However prior to this CL
we see a flash, as the sequence can continue as follows:

7. Closing the transaction triggers setClientState, causing Layer::reparentChildren
which would call setParent updating the parent pointer.
8. setClientState updates the current but not drawing visibility of the new parent and marks
a transaction to occur.
9. We return to the main thread, MESSAGE_REFRESH occurs before MESSAGE_TRANSACTION
and we render a frame
10. We observe the child window as invisible, as it has the new parent
but it's new parent is not yet visible.

We simply have to ensure the parent pointer is updated at transaction time.
I chose a location in commitChildList where mDrawingChildren was copied
from mCurrentChildren as it seemed to express the intent well.

Test: Difficult to automatically test. Manually try resizing Chrome/Youtube/etc in docked stack before flicker should be ~1/10 after flicker should be <1/100 (I haven't seen one yet)
Bug: 62099658
Change-Id: I3721d16361b53128146510d3fda43e1c12f93223
7bf247e2db180da661b18084d50e0b389686fc0c 18-May-2017 Robert Carr <racarr@google.com> SurfaceFlinger: setGeometryAppliesWithResize crop latching fixes.

The same sort of thing we had with setPosition...not sure why I didn't
realize we would need the fixes here too! In particular we need to ensure
the following scenarios work:

1. Additional calls to set(Final)Crop while in the setGeometryAppliesWithResize
state are eventually applied.
2. Additional calls to set(Final)Crop while in the setGeometryAppliesWithResize
state are not immediately applied.
3. In LayerRejector.cpp we have to be sure we are not just latching a buffer
at the old size, which we still allow. This is the correct time to latch
the transparentRegion as it is content dependent, but doesn't represent
a size changing.

The difference between this and the original CL which was reverted has to do with
point 3. The original CL tried to solve point 3 by moving the latching logic from
the LayerRejecter in to Layer::doTransaction. However, in general doTransaction
will not be called in between Latching the buffer and drawing the frame, so this
introduced errors. The new test "FinalCropLatchingBufferOldSize" encapsulates this.

Bug: 37621737
Bug: 37531386
Test: Included in Transaction_test.cpp
Change-Id: I14bd09d01ac6b85895caa1b707d6fa7dac962074
3851225fddb6f1755a8034aa7a9f9ae7397b56a9 17-May-2017 Chia-I Wu <olv@google.com> surfaceflinger: clear HWC layers in Layer::onRemoved v2

Explicitly destroy HWC layers in Layer::onRemoved rather than doing
that implicitly in the destructor. The layer may be destructed by
any thread that holds a sp<Layer>, but only the main thread should
talk to the composer.

v2 fixes build breakage for non-HWC2 targets.

Bug: 38151478
Bug: 37978067
Test: manual
Change-Id: I8858fc46de1fc6facded219740b931c6486e317e
900e6fc9b9c7353ad919e44e1a45a67426d115c4 18-May-2017 Przemyslaw Szczepaniak <pszczepaniak@google.com> Revert "surfaceflinger: clear HWC layers in Layer::onRemoved"

Causing failures due to lack of clearHwcLayers in git_master and few
other branches/builds. Looks like clearHwcLayers needs USE_HWC2
to be defined, seems to be not defined in few branches/builds?

This reverts commit 06837418fe9fb0c6deeab7d62ac5bf65c7bb2b98.

Change-Id: Ic0e3a99b45543503d5fa8a90f3569764ebe922e3
06837418fe9fb0c6deeab7d62ac5bf65c7bb2b98 17-May-2017 Chia-I Wu <olv@google.com> surfaceflinger: clear HWC layers in Layer::onRemoved

Explicitly destroy HWC layers in Layer::onRemoved rather than doing
that implicitly in the destructor. The layer may be destructed by
any thread that holds a sp<Layer>, but only the main thread should
talk to the composer.

Bug: 38151478
Bug: 37978067
Test: manual
Change-Id: If6fcfaa5a70d247b751f2b4d9aec9eca890e3aa5
a3ed032256c475ce13c52b0261da6a5e2ffa77be 16-May-2017 Rob Carr <racarr@google.com> Revert "SurfaceFlinger: setGeometryAppliesWithResize crop latching fixes."

This reverts commit 1e079c2804edfae77925150280fe79418e58750b.

Bug: 38331032
Change-Id: Ib703b7b80a940550487a80d8ad62947e4becae93
1e079c2804edfae77925150280fe79418e58750b 09-May-2017 Robert Carr <racarr@google.com> SurfaceFlinger: setGeometryAppliesWithResize crop latching fixes.

The same sort of thing we had with setPosition...not sure why I didn't
realize we would need the fixes here too! In particular we need to ensure
the following scenarios work:

1. Additional calls to set(Final)Crop while in the setGeometryAppliesWithResize
state are eventually applied.
2. Additional calls to set(Final)Crop while in the setGeometryAppliesWithResize
state are not immediately applied.
3. When we latch the buffer completing the resize...current hasn't been swapped
to drawing...which means our location in LayerRejector.cpp was the wrong
place to update the crop. This raises questions about whether the
Transparent region latching works.

Bug: 37531386
Test: Included in Transaction_test.
Change-Id: I5140d44fd5e591a4afe5bddc201db45f7bcb5674
2a58963cd96546bc645d05c3d1421a506f42bb64 04-May-2017 Albert Chaulk <achaulk@google.com> Surfaceflinger: Propagate type & UID from parent layers

Bug: 36589137
Test: Launch chrome in VR (surfaceview has a parent)
Change-Id: I9320a8df249d1d5790323b22f0ba88a792f9468f
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

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
1725eeeb7db8a2c933dcc9d01cce14e17c76c6e6 27-Apr-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Correct extra parent scaling with buffer transforms.

We need to account for the buffer transform when calculating the extra
parent scaling.

Bug: 37673612
Test: Regression test included in Transaction_test
Change-Id: Ice21f1ecf3789358646d95c753ee361f50c0d246
5edb1add8b35c0d63645cb53fb175d459a689da5 25-Apr-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Fix destruction of relatively Z-ordered layers.

We need to explicitly remove a layer from it's Z-order relative when
the layer is removed from compositing, and not rely on being the last
reference. In particular, at the time we are generating the list
of visible layers by traversing, any layer which had just been removed
will still be alive (but abandoned) with a ref in the previous list
of visible layers. So we will succeed in promotion, and copy it to the new
list. This way the layer achieves eternal life even after onRemoved is called.

Bug: 36693738
Test: Manual from BR
Change-Id: Ic6c3f64ceb0f603e7c0e51b136c23839858aa639
9b429f41cbd5964f96f9fb746af3b6932e4acc66 17-Apr-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Inherit non-transform Scaling from parent.

When a Layer is fixed-size, we may apply additional scaling
to the buffer not accounted for in the transform. This means
that if the WindowManager calls setSize we will scale the parent
surface but not the child surfaces, breaking the contract that
the WM can treat the child surfaces as pixels in the parent.

Test: Included test in Transaction_test.
Bug: 36820947
Bug: 37344435
Change-Id: I5478bad176388fe8e5407379bc36cdfd6600ab97
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
7dcda8011de1753b0d9f4bf640733f83db601cec 13-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "SurfaceFlinger: Add parent-less relative layering." into oc-dev
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

Test: Included in transaction tests. Also manual test of bug repro steps with accomp frameworks/base CL
Bug: 36693738
Change-Id: I921852d3d34f67f79ec745b9703f9e679867e7a1
1f42e3a02c4f9a1ba1916a2f0e47082bedb73e41 10-Apr-2017 Daniel Nicoara <dnicoara@google.com> VR: Update VR HWC to use buffer metadata passed by SurfaceFlinger

Without gralloc1 support, need to pass buffer metadata in order to
import native buffers and used them as graphic buffers.

Bug: 36481301
Test: Compiled and ran on device; Verified VR Window Manager properly
displays SurfaceFlinger buffers.

Change-Id: I8426be1d79dcc2fbd631c399427ae03cb2afc21d
5d94389241cc651e6bd327ab80eba3ad476f3724 22-Mar-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Add wide-color support to SurfaceFlinger

Test: manual testing
Bug: 29940137

Change-Id: I9358b3c982e0205e598fd20cbf8d2e956591b3ac
cae605cd5668f8107e340ad8a672c7f034147401 29-Mar-2017 Robert Carr <racarr@google.com> Fix seamless rotation with SurfaceView WM bypass.

First a brief review on seamless rotation. In seamless rotation
the WM will do the following atomically:

1. Update the display transform.
2. Set window transforms to make the surfaces at their old size appear
at the correct location in the new coordinate space.
3. Set a flag to undo the transforms when the surfaces resize.

However, windows with NATIVE_WINDOW_TRANSFORM_DISPLAY needed to be special cased.
The flag will perform step 2 in terms of buffer mapping, but not in terms of bounds
computation. So to compensate the WM would apply the transform to the bounds,
set these bounds, and then skip applying the transform matrix (as the buffer is
transformed by the flag).

Now that the WM can't see the Camera view, it can't implement this special logic
and the Camera view inherits the parent transform. We compensate for this in
SurfaceFlinger by omitting parent rotation transform components for
Surfaces with NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY. To some extent this
breaks arbitrary rotation for surfaces with NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY
but this is essentially ok:

1. We lived with that bug until N-MR1
2. We fixed it in N-MR1 because the camera was falling back to ROTATE
a lot which shouldn't be happening anymore, following introduction
of specifying rotation animation in manifest.

Test: Rotate camera, disable HWC, rotate camera some more. Switch to front camera, repeat.
Bug: 36230754
Bug: 36727915
Change-Id: Ied390c9cb3968fcce32a84ee7947f699746fdc81
6452f12c95e855a96ab8f690f28914cd37de762b 21-Mar-2017 Robert Carr <racarr@google.com> SurfaceFlinger: Inherit Alpha for child surfaces.

Necessary for various animations to work correctly and
for the general goal of treating child surfaces like
pixels in the parent surface.

Test: Includes new test in SurfaceFlinger_test
Bug: None yet ;)
Change-Id: Ic8309518bd327bbba6ad2f79f265e24cf37898e7
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

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
d8ab4396a858a9c929a1bb3cadf7705fb8061574 21-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "egl: Remove retire event."
9551fd3acc2b0bbdfed02ed2bf97c5e560933abe 21-Oct-2016 Courtney Goeltzenleuchter <courtneygo@google.com> Add getDataSpace to layer class

Test: TBD
Change-Id: I1d583bc6dae4cfb1569f053b2480e94b6ca9cc6f
4e606e3901b500bdd0f3ea21b8cb63734087bf0a 16-Mar-2017 Brian Anderson <brianderson@google.com> egl: Remove retire event.

Test: adb shell /data/nativetest/libgui_test/libgui_test

Change-Id: Ibf63d22e42ae52307662107eec50f80de0e703f5
f8b4ca51111cd2e566d1774ac464da859db78976 16-Mar-2017 Romain Guy <romainguy@google.com> Revert "Get rid of IGraphicBufferAlloc"

This reverts commit 78491c9f694cb0767996503c629776a8eda950d7.

Change-Id: I78d5c0a30ab80265f697f681387872b6763b2d1e
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
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
aaff73f92a2fcadda8c765eb9b02f2849418a873 13-Feb-2017 Chia-I Wu <olv@google.com> surfaceflinger: simplify HWC buffer cache clean up

When a Layer is no longer connected, we destroy the associated HWC
layers on next call to SurfaceFlinger::rebuildLayerStacks or when
the Layer is destroyed. There is no need to listen to
onBuffersReleased. Besides, we need to perform the cleanup from the
main thread as we only talk to HWC process from the main thread.

While at it, move HWComposerBufferCache to its own files.

Bug: 35320590
Test: manual
Change-Id: Ifa32f24076b094c8fa9cda8572b03d5bfb8e0b93
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
ecf0fa5340c54757870881c5d24eb331c517d78c 03-Mar-2017 David Reveman <reveman@google.com> [surfaceflinger] Set blend mode correctly when using HWC2.

HWC1 code will reset blend mode to None using setDefaultState() but
HWC2 just leaves the layer in the previous state. The result is that
once blend mode is set to something other than HWC2::BlendMode::None
we can never go back to HWC2::BlendMode::None and HWC2 implementations
are forced to use blending when not necessary.

Bug: 35915184
Test: manually verified using overdraw feedback on arc enabled chromebook
Change-Id: I86957439bad0a1be9faa56df491d8415c4cdd2c2
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.
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
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
cb6e1e385edd44fbc68718e792b7180b1015d438 22-Feb-2017 Robert Carr <racarr@google.com> SurfaceControl: Correct setMatrix parameter naming.

The first parameter dsdx controls the X scaling. The last parameter
is called dtdy but controls the Y scaling. Clearly this was meant to be
named dsdy. You can verify this with a quick look at Transaction_test.

Test: Tried various stuff, phone still works.
Change-Id: Ie9e898443350ffdcf227888a8d85efdbe1b6b033
fb94f1db72bd769d4a63e2baf0b5a4ca5da7a86f 17-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Break a dependency of libui on libandroid"
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.
873e2eee781f323a8aa0283cab5924fa4cd7ecfe 17-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Move FloatRect from libgfx to libui"
a9347647eca3101c014be902b713772de3977d87 14-Feb-2017 Mathias Agopian <mathias@google.com> Break a dependency of libui on libandroid

This was only a header dependency, but it still
created a circular dependency, which will cause
problems in another CL.

We fix this by creating a libarect static library
containing only that header. both libui and
libandroid now depend on it and reexport the

We also make sure rect.h ends-up in the right

Test: built and booted device
Bug: 35164655

Change-Id: Iba25b8b801b26b26ec1401c00caf367a06f197ca
0ed70ddebe2a392c32b010e00229b9f0e2fd2e09 17-Feb-2017 Romain Guy <romainguy@google.com> Merge "Add RGBA 10:10:10:2 format for surfaces"
5a423eaa86f4c990afcef8c55e3949d0872068b4 16-Feb-2017 Dan Stoza <stoza@google.com> Move FloatRect from libgfx to libui

Moves FloatRect from libgfx (which is being disintegrated) to libui

Test: Builds and sailfish boots
Change-Id: I68c1b7d86a363066fe4d6f0c038ca9d92d7ab9c7
541f22658ab1617c9d12c98684ab40248df8749b 11-Feb-2017 Romain Guy <romainguy@google.com> Add RGBA 10:10:10:2 format for surfaces

Bug: 2984164
Test: CtsHardwareTestCases
Change-Id: Ifc90e413f414a19ac09e923e48ec7ff45d3e930b
5ea5e5905170f32d5cf45ad35c552d64743892c3 02-Dec-2016 Brian Anderson <brianderson@google.com> Fix unexpected FrameEvents on BufferQueue reconnect

Helps reduce the number of ALOGE's being hit
when switching between apps.

* Notify Layer when the Producer disconnects.
* Avoid sending event deltas from a previous connection.
* Avoid releasing a frame more than once.

Test: adb shell /data/nativetest/libgui_test/libgui_test

Change-Id: I64f314be72ddb154b584d726ac382cd468e345bf
8cc8b10e27d515a6962ae6c66a62387ced45f5fe 21-Oct-2016 Brian Anderson <brianderson@google.com> Clean up FrameTimestamp log messages.

Test: Log message changes only. Existing tests pass.

Change-Id: I032c76393a4949b291c3a650279367caf05a775c
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

Change-Id: I406814258613b984b56488236632494f2f61ff2e
748a163bf020d9eb53ce610fad90241fc52940af 10-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix small child layer transparent region error"
06d63de03cb2a551ca99608f5aa0c4f3e200b0fc 04-Jan-2017 Chia-I Wu <olv@google.com> surfaceflinger: cache HWC client targets and buffers

Remember HWC client targets and buffers, and make sure we send each
unique slot/handle pair only once. This allows the composer to
clone/register/retain each buffer only once.

Test: builds and boots
Change-Id: Ib485189043a9c132031e82d4d7380ace3bf9453d
de9ec44905aca4f0ef4f473065b0e7d93d7e1cfe 09-Feb-2017 Robert Carr <racarr@google.com> Fix small child layer transparent region error

Just turned transparent region back on in my SurfaceView port
and saw things were pretty broken.

Test: Manual
Change-Id: I3ab5520ecd226c86ef903767f6a562af7d7eb16d
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
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
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
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
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
146abf38c2442b77dc78a0565ad010376c9d1b69 24-Jan-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Merge "Make dataspace accessible to surface flinger"
f6386862dffb0fb9cb39343d959104a32e5e95b7 01-Nov-2016 Brian Anderson <brianderson@google.com> Add a DequeueReady FrameEvent

Test: adb shell /data/nativetest/libgui_test/libgui_test

Change-Id: I98ffd4123fc50b5f560e432f4078408c913c8edf
bb09b436fa119ad8b97f1bf5c04cc5aa10b5f1f0 30-Nov-2016 Courtney Goeltzenleuchter <courtneygo@google.com> Make dataspace accessible to surface flinger


Keep track of dataspace in GLConsumer and make it
available to surfaceflinger's Layer class.

Test: TBD
Change-Id: I099dc6d8424909c5fc31bfe2d05a656695c4251b
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
71bded513d37a6c1260b4a62c69ecc0d24be95f7 19-Oct-2016 Dan Stoza <stoza@google.com> Create libgfx, starting with FloatRect

Creates libgfx, the future home of everything currently in libui and
libgui, which will be rigorously checked with -Weverything (with a few
common-sense exceptions) and clang-tidy and formatted using the included
.clang-format file.

Starts by moving FloatRect out of services/surfaceflinger since it will
be used by other libgfx primitives later.

Test: m
Change-Id: I5045ac089020e6ee380e81e8735117c500264b37
e2caadca83c8842bbfe74e21f11b9e2b5aeb4e13 15-Dec-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add fp16 pixel and window formats"
9698c2f193666ab506a6edf113c5a77d0d0acb3b 15-Dec-2016 Brian C. Anderson <brianderson@google.com> Merge "Use FenceTime to share fence times and reduce open fds."
ff415149dc5a83a4eb5960daf2cb2c310ef89847 14-Dec-2016 Romain Guy <romainguy@google.com> Add fp16 pixel and window formats

Bug: 32984164
Test: compile
Change-Id: I8303afbf857796295a280c0d9438a3c403a11437
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

Change-Id: Ifd4301affe1b24705b2bee7608c5a2c09dfb4041
873228ef930efe2f37ec15a5dc8ae15240cd81d1 13-Dec-2016 Fabien Sanglard <sanglardf@google.com> Merge "Delete unused clip parameter in drawWithOpenGL"
7dbd305c7c0bebadc84d9a38012642f94ab4743f 10-Dec-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Reduce indentation with early return"
28e98084bdadcf3001a3e24034c5c98057dd2398 05-Dec-2016 Fabien Sanglard <sanglardf@google.com> Reduce indentation with early return

Change-Id: Ib2e7236b3fedf219db933085d26c6ea9b762f649
1748719ea1b69cc7ad111d8c6149d692b9f056f8 07-Dec-2016 Fabien Sanglard <sanglardf@google.com> Delete unused clip parameter in clearWithOpenGL

Change-Id: Idc31d6cfe0c804fd6c5528432e1179f920e231b3
8578980f7dd775d7044780de85ac3103989ba7d7 07-Dec-2016 Fabien Sanglard <sanglardf@google.com> Delete unused clip parameter in drawWithOpenGL

Change-Id: Ia4662ccf9b5544c1a8c5252b4c8485fddd09e713
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
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

Change-Id: I8a64579407cc2935f5c659462cb227b07ba27e43
dbd0ea80021cbc61c578385f534f41a33338085b 22-Jul-2016 Brian Anderson <brianderson@google.com> Rename posted to requestedPresent for getFrameTimestamps

Test: Just a rename.

Change-Id: I63aa5b1b84715de2bebffb25f92bd826323a9acb
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

Test: adb shell /data/nativetest/libgui_test/libgui_test

Change-Id: I868c2ef93964656d7e41848243433499e7f45fe7
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
* 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

Change-Id: I27d484bfd48f730bdcea2628f96795c6f4b4df7b
e773265edc75bbe042840f69696dd03b1bdacfd9 08-Nov-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Delete surfacefinger Layer::latchBuffer code"
bc01dccc455ace377eec9058e65764114b2b780c 13-Oct-2016 Fabien Sanglard <sanglardf@google.com> Delete surfacefinger Layer::latchBuffer code

Delete unreachable code.

Change-Id: I6d895838cc4e0b84642f2c67d44306ba23696329
cd6fd5463d2e9b87504e29a39ac5f2395010805b 13-Oct-2016 Fabien Sanglard <sanglardf@google.com> Refactor surfacefinger latchBuffer: Create method

Shortens latchBuffer method, extracting transaction
credential verification to dedicated function.

Test: On device
Change-Id: Ia7c2f977a85d1c1afd87425588c07eb756b00f15
7b1563a0e8e742315a16c9a7b27537dbcd13d09a 13-Oct-2016 Fabien Sanglard <sanglardf@google.com> Refactor surfacefinger Layer::latchBuffer

Take out Rejecter class declaration out of the method. This
increases readability and shortens latchBuffer method by 200 lines.

Change-Id: I8b07c63f8ed6408e68d5696d0666e65a3b14bd4c
f5702ff8b1919e0a5d342ad04ac486bbcde41461 03-Nov-2016 Dan Stoza <stoza@google.com> SF: Request SF wakeup for pending transactions

When a Layer receives a pending transaction, it sets a flag on itself
that it needs a transaction to be handled, but it doesn't notify
SurfaceFlinger to iterate through the layers and check for that flag.
In some cases, this led to transactions never being processed, which
can hang an application trying to push buffers that are part of a
synchronized transaction. This change pokes SurfaceFlinger when setting
the Layer flag so that it doesn't slip through the cracks.

Bug: 32541494
Test: Two successful monkey runs
Change-Id: I4b906eee8004fad1938aa94a1aa0a0c7ea289102
223eb91c416f4acb3e635f1dccf5e5ba74c0d866 13-Oct-2016 Fabien Sanglard <sanglardf@google.com> Refactor Surfaceflinger Layer::latchBuffer

Reduces indentation of 300 lines via an early return if no work
is detected.

Change-Id: I08fe2a3e2808ae58e3da28a1c2f7d28e7a4a98af
9d96de49673cb6c916bfb797aad4f4e024ea73ca 11-Oct-2016 Fabien Sanglard <sanglardf@google.com> Revert "Delete HWC1"

This reverts commit 90f923493fa053655a203c34ea491086aeb07602.

Change-Id: If9da49e3bc85f8ff21ac1bd22a6bab97e9aa3103
90f923493fa053655a203c34ea491086aeb07602 03-Oct-2016 Fabien Sanglard <sanglardf@google.com> Delete HWC1

After 10 years of good service, HWC1 is not needed anymore since HWC2
is now mandatory.

Change-Id: I5768b50c89854688ba31032f01ea231699393e5b
3d1d280fa3cbc30700f728a4b13e5308315433d3 27-Sep-2016 Colin Cross <ccross@android.com> Rename dump methods to dumpState

The dump methods shadow the IBinder dump method. The warnings were being
hidden by the use of -isystem to include frameworks/native/include.

Bug: 31752268
Test: m -j
Change-Id: Iafc64da43032d5d9d84b64640e70d93fd7051bcf
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
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
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
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
d140bf8cce87d4b6315616377401f575722a0460 05-Aug-2016 Pablo Ceballos <pceballos@google.com> SF: Change rounding behavior in setGeometry am: 51450039e2 am: fe341317d8
am: 6d9171c77d

Change-Id: I949262c1d530f10393e7044ee2751021fc7da61c
6d9171c77d7a0309ff55d3dcbd79b42c8ecdd49c 05-Aug-2016 Pablo Ceballos <pceballos@google.com> SF: Change rounding behavior in setGeometry am: 51450039e2
am: fe341317d8

Change-Id: I084385b24f0817ece6989c83cc682129001daa8d
51450039e2fd266b31f33dfd1b4353bc1b0b145a 03-Aug-2016 Pablo Ceballos <pceballos@google.com> SF: Change rounding behavior in setGeometry

- Add an option for a transform to round outwards instead of to the
nearest pixel.
- Use this new rounding behavior when converting the crop rectangle
from display-space to layer-space. Otherwise a pixel that will
partially be on the screen might be marked as transparent.

Bug 30510632

Change-Id: I1aece177cc29c54ee0d4a2c919e47442eb455f30
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
b203e3cf262df06248d52797593678a756aba094 28-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Clear transform for SolidColor layers am: c6c8954b42 am: bc028a8e49
am: cb585c99a9

Change-Id: Ibb250079d4149f6fd78489f1b949733875921618
cb585c99a9e0eb3f8386efb2f09483919f393291 28-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Clear transform for SolidColor layers am: c6c8954b42
am: bc028a8e49

Change-Id: Ia0677c2fc2bab208cff34841c740949d2a5aedda
c6c8954b4258ed61790dcc95ff1d049be3e8422d 27-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Clear transform for SolidColor layers

Clears the transform for SolidColor layers, since it doesn't make sense
to transform layers without a buffer.

Bug: 30429522
Change-Id: Ib2f4889531556c7ab00e3b270319c321e9f32c84
f10620fb579d61b8ec503bdd02d3026cff42f9bc 26-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Use SolidColor composition for DimLayer am: 0a21df7838
am: 257b657893

Change-Id: Ie353a1dc8a644f8e9e5003a8f1b8f6943cd41a9e
257b6578930fd93814bcb34cd7541796bf9ca5d0 26-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Use SolidColor composition for DimLayer
am: 0a21df7838

Change-Id: Ia387db5ce9efa85f9a0d55d4795e3e66a4caa21c
0a21df783892acc5cff0c39c79b0aa602074af7e 20-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Use SolidColor composition for DimLayer

Switches SurfaceFlinger to try to use SolidColor HWC device
composition for DimLayers instead of always falling back to client

Bug: 30216498
Change-Id: Ia8af95d214ba72b5657f32f7827a1e6278629f17
665490affbfb14d9a15923d2757d133f0089b498 22-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Kill logspam for non-HWC virtual displays am: ec0f717dfd
am: 38f86bcab0

Change-Id: I5234ed58634ef92ec7bb3d194222f6ccd0c98c97
38f86bcab04ac9ced86ce2826097bde6ce147016 22-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Kill logspam for non-HWC virtual displays
am: ec0f717dfd

Change-Id: Ib2eab1e0dfd44063f7840bcd900c9dad783635f9
468051e20be19130572231266db306396a56402b 14-Jun-2016 Irvel <irvel@google.com> Integrate SurfaceInterceptor into SurfaceFlinger

Change-Id: If18d967f2b69ed219f17a9afedb61884ad5f1dc8
ec0f717dfd3821cbc648198c6d3b98fcc3b53369 21-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Kill logspam for non-HWC virtual displays

Removes some logspam and fixes some non-errors which were reported as
errors when running a virtual display that is not backed by hardware

Bug: 30022738
Change-Id: Ie966e37d95f53bcc050eef064d24bbe26748b7fd
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
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
2605348b41d63fe34c941b6963158d559b30f792 07-Jul-2016 Dan Stoza <stoza@google.com> SF: Only latch buffers after fence signals
am: 1ce6581ac7

Change-Id: Iee9f7e4199539775c6097c73bd6f25bc36a92753
1ce6581ac788eaad58fd3329c2154af7dd74aa3d 16-Jun-2016 Dan Stoza <stoza@google.com> SF: Only latch buffers after fence signals

Changes SurfaceFlinger to only latch a buffer after its corresponding
acquire fence has signaled. This will enable us to move
SurfaceFlinger closer to vsync since there is no risk of fence waits
blocking composition.

Bug: 29413700
Change-Id: I26f4fd600c1611b8d736ec654d1f0f02cf69ae5f
d99daf4fe6e32f3d15482141abf79ef81327fdf4 22-Jun-2016 Robert Carr <racarr@google.com> Merge changes from topic \'seamless-rotation\' into nyc-mr1-dev
am: 4bfbe1f7ef

Change-Id: I05be2795f7b09b92f79627f991c01d7e32840121
4bfbe1f7eff1782ad1f9874954fa2703207317df 22-Jun-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes from topic 'seamless-rotation' into nyc-mr1-dev

* changes:
Reset mFreezePositionUpdates earlier.
SurfaceControl: Add getTransformToDisplayInverse
Change setPositionAppliesWithResize to apply to all geometry.
7920c657c62278dbceeb38838b4955101dd75b2c 22-Jun-2016 Dan Stoza <stoza@google.com> HWC2: Don\'t set null handle for client layers
am: e24da966b1

Change-Id: Ib572bf53756351bce11a20c28dca2362c7433562
a392073ff99c39b52bee88578c37d6a12235faf5 21-Jun-2016 Robert Carr <racarr@google.com> Reset mFreezePositionUpdates earlier.

We are resetting mFreezePositionUpdates
too late, in the case that the state changes during
latch buffer, we will return to recompute the visible regions
before updating mActiveBuffer.

Bug: 28823590
Change-Id: I17afc32d55d092ea0814b560846b922dd9e24c43
367c5684f4d417e5176bec12d67f4e2e42738fe0 20-Jun-2016 Robert Carr <racarr@google.com> SurfaceControl: Add getTransformToDisplayInverse

For seamless rotation, the window manager needs
access to this flag, as it will apply the inverse
display transform itself to all other windows.

Bug: 28823590
Change-Id: Ifeee1078a9cb4cd01c8052570c137c6228b2f13d
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
e24da966b14e5b952ee11a7d13bb1539be2a5c8e 22-Jun-2016 Dan Stoza <stoza@google.com> HWC2: Don't set null handle for client layers

Removes the code that explicitly set a null buffer handle for client

Bug: 29463310
Change-Id: I570e6041ba72d64971bb6c364e8e7b6f84eeff08
a26e6618867f0a587942fa737b14dc67c2f0c9a9 09-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge \"Plumbing for getting FenceTracker timestamps\" into nyc-mr1-dev
am: 9e8143ec78

Change-Id: Ife1f3e19cc0bde26960c5a480d4fe81188c4c8f3
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
f7b6b5d956f96458567eae519a926a6f51b077c0 07-Jun-2016 Robert Carr <racarr@google.com> Merge "SurfaceFlinger: Add mode to apply position with resize." into nyc-dev am: c3da482bb8
am: 3fee6ca1d9

* commit '3fee6ca1d93c1d4b822d2dcd36c61f9722dd88b9':
SurfaceFlinger: Add mode to apply position with resize.

Change-Id: I91f64e194199f1277a9b4e76c68faddcc7ef6660
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
a9f472162084aa7e78e684d86914a21e1a234317 06-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Also edit currentState in doTransaction" into nyc-dev am: d224e6111b
am: 12863b2a1d

* commit '12863b2a1d7c97e99b7201ae6209f5c861fd46a7':
SF: Also edit currentState in doTransaction

Change-Id: Ia1367baa3da6415e46caccc1ec75c8ac9026d131
d21cb6d2d9a5819c3427df1be4470bcc8baf3c6a 06-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Also edit currentState in doTransaction" into nyc-dev
am: d224e6111b

* commit 'd224e6111bf4532fb1c1fc021c20285b38bc80ec':
SF: Also edit currentState in doTransaction

Change-Id: I6bcd675d033cc1ef46d3498174b2bc52a0072f99
12863b2a1d7c97e99b7201ae6209f5c861fd46a7 06-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Also edit currentState in doTransaction" into nyc-dev
am: d224e6111b

* commit 'd224e6111bf4532fb1c1fc021c20285b38bc80ec':
SF: Also edit currentState in doTransaction

Change-Id: I30b6170c8f41a7e330511ad70abd2257a34bdee2
7d05257585918bd578bc0bc18f32571a48a7304a 03-Jun-2016 Pablo Ceballos <pceballos@google.com> SF: Also edit currentState in doTransaction

Bug 28899837

Change-Id: I46c8301549c627c5d1c7efa661055aba787a33d6
3bfd2e196d248536207bf1e0acfe86bd4d786d1d 25-May-2016 Dan Stoza <stoza@google.com> Merge "BufferQueue/SF: Add OccupancyTracker" into nyc-mr1-dev
am: faa71321b0

* commit 'faa71321b0862fac97ad1f7825860fb740cc8507':
BufferQueue/SF: Add OccupancyTracker

Change-Id: I868b56c8502033877b08146c1cffeaaa263acc64
faa71321b0862fac97ad1f7825860fb740cc8507 25-May-2016 Dan Stoza <stoza@google.com> Merge "BufferQueue/SF: Add OccupancyTracker" into nyc-mr1-dev
d3e7cc010b361958a14f007d7ea23a892fd05df2 18-May-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Fix arbitrary rotation with inverse display transform" into nyc-dev
am: 885ac76b90

* commit '885ac76b90e2f3e5cfaec7bbc8ff2e1de8d62435':
SF: Fix arbitrary rotation with inverse display transform

Change-Id: I1d67ba1dd7589d35d8a23bda701896b802c38a79
20829ec6f4defb154ce0c92eb356b75b1bfa26e9 18-May-2016 Dan Stoza <stoza@google.com> HWC2: Set composition type before setting buffer
am: 0f67b3f01f

* commit '0f67b3f01fc74bbd8cf4be24fce4a1e42f102282':
HWC2: Set composition type before setting buffer

Change-Id: Id90777e83c0455cd95c28acb94d1ed791222851c
885ac76b90e2f3e5cfaec7bbc8ff2e1de8d62435 18-May-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Fix arbitrary rotation with inverse display transform" into nyc-dev
0f5131fe72f3e7ca599946536d1f6028bb93398d 17-May-2016 Pablo Ceballos <pceballos@google.com> SF: Fix arbitrary rotation with inverse display transform

Bug 28043535

Change-Id: I8b939e17f91cf7e5b617bbcceb9df4efcc9d0161
0f67b3f01fc74bbd8cf4be24fce4a1e42f102282 17-May-2016 Dan Stoza <stoza@google.com> HWC2: Set composition type before setting buffer

SurfaceFlinger was incorrectly setting the buffer handle before
setting the composition type. This led to cases where the layer was
initially marked as Invalid or Client, allowing HWC2 to ignore the
buffer handle, even though the layer was later changed to Device
before presentation.

Bug: 28814745
Change-Id: I41189495dcb254f04e6b2b329c044301c5cff97c
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

Change-Id: Ida6e967dc5483c00a633e9fe03998e420dd88502
3666cc2bae3f73e90c9eb6d8a6d4ce623ee9f745 11-May-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Set state modified flag when changing sizes" into nyc-dev
am: 0abac03fc9

* commit '0abac03fc9d415b27e3f93d76859aae5f7c3050f':
SF: Set state modified flag when changing sizes

Change-Id: Ifd3ee6abdc12d141a7de0f2a2f3800017da6a69e
39c88e8c7d870486f703408dafd0a62e7420df05 11-May-2016 Pablo Ceballos <pceballos@google.com> SF: Set state modified flag when changing sizes

The BufferRejecter updates the Layer state when it gets the first
buffer of the new size after a size change has occurred. When this
happens make sure to set the state modified flag.

Bug 27780983

Change-Id: Id8c628c40164110e75f8defd68ca895d72ed2e83
4c3bbb1d90c5f5caf2e1c19a2aa3978d5a04abfb 02-May-2016 Dan Stoza <stoza@google.com> Merge "SF: Clear local sync points on hide and destroy" into nyc-dev
am: 54ebc56413

* commit '54ebc564132c4c734d5917baa5c91a36c6f915ef':
SF: Clear local sync points on hide and destroy

Change-Id: Ife257492cfa0c34e67fae6568a3b9aee2570c8f8
c8145170a4b3bfdcfd6bd08b61ad55ae4eac9cc9 29-Apr-2016 Dan Stoza <stoza@google.com> SF: Clear local sync points on hide and destroy

Clears out a Layer's local sync points when the layer is destroyed
and when it is hidden, so that any Layers waiting for frames to
appear on that Layer are not blocked when attempting to apply

Bug: 28399096
Change-Id: I380a83624f9d7ea5797f66daa711ae4b80475bdf
76ddac5f35f6c5967fffb49103e750bb69ec707e 21-Apr-2016 Pablo Ceballos <pceballos@google.com> Merge "BQ: Replace items from back of queue" into nyc-dev
am: 9461b93f7e

* commit '9461b93f7e46e71dd43b021084012ec337a5cee3':
BQ: Replace items from back of queue

Change-Id: I3efbf1485d2fbb4dc5fed5e4b6fa5884faa0e6c7
4d85da4a77203f4c361e48699e5598ebe8c77b32 20-Apr-2016 Pablo Ceballos <pceballos@google.com> BQ: Replace items from back of queue

It's possible to have one or more non-droppable items in the queue
ahead of a droppable item. In that case we want to replace the
droppable one at the end of the queue. By changing the policy to
always replace the last item in the queue (if it's droppable) we
ensure that there will never be more than one droppable item in the
queue and that it will always be the last one.

Bug 27129258

Change-Id: I9a6234fe12a0095ccb93ceb9cdb74616944900b0
3f59b10742eca3aafb1b14f79a08463015671872 19-Apr-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Fix camera orientation on virtual displays" into nyc-dev
am: 55b29f2

* commit '55b29f2ec5d62a13eb374501ebc4691eadd3997a':
SF: Fix camera orientation on virtual displays

Change-Id: I9993f7ffd7e34ea6fb81edb8006ea3d635ae1eb4
55b29f2ec5d62a13eb374501ebc4691eadd3997a 19-Apr-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Fix camera orientation on virtual displays" into nyc-dev
021623b5a82e44e8dc1a7def1abfed351187593c 16-Apr-2016 Pablo Ceballos <pceballos@google.com> SF: Fix camera orientation on virtual displays

preview always look upright on the device display. This commit changes
the behavior of this flag slightly. Instead of applying the inverse
transform of the current display when compositing, apply the inverse
transform of the primary display to all displays. This assumes that
the camera orientation is tied to the primary display.

Bug 2628180

Change-Id: I0da22423490a93fe943fd59e6c122aa6aaf30b11
7a776ec3717bfe45d48f1c03987c8657ad8a56d5 18-Apr-2016 Robert Carr <racarr@google.com> Add setOverrideScalingMode to SurfaceControl
am: c3574f7

* commit 'c3574f7b0141c69fdca25ccafb80ff334462f9a3':
Add setOverrideScalingMode to SurfaceControl

Change-Id: I8752f95ed3d596c8648e5d527aae4cae00e171b9
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
6451ddb8f107b2fd57c956e74935ac62b91c8a2d 15-Apr-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Don\'t pop pending state into mCurrentState" into nyc-dev
am: 9eb286a

* commit '9eb286a074a8b2764b69339b0958dc5b176f1a8d':
SF: Don't pop pending state into mCurrentState

Change-Id: Ieb6b0f2a24a00b4c54b0a544b81fc72899305036
05289c2b78d21308a95ea6ef8f1d8f24359147cd 15-Apr-2016 Pablo Ceballos <pceballos@google.com> SF: Don't pop pending state into mCurrentState

Let mCurrentState always represent the most up to date state, even if
there are transactions we don't want to commit yet. Past snapshots of
the state are kept in mPendingState. In doTransaction(), grab the
correct pending state from mPendingState, but save it to a local copy
that gets committed rather than overriding mCurrentState.

Bug 27205755

Change-Id: Ib0ea809da1954409787c52b8f41d7963a57a6a4c
ab8649138e30e350ae15911dfff7c709f127f2e3 29-Mar-2016 Robert Carr <racarr@google.com> Merge changes I653b84e7,Ieafdc14a into nyc-dev
am: abddf72

* commit 'abddf727041d2ea0e678442b2d7905afc8b33bd4':
Apply position updates immediately.
Move crop outside of geometry state.

Change-Id: I7d4b9d49f6807748592c32432e4ab80da59bad37
abddf727041d2ea0e678442b2d7905afc8b33bd4 29-Mar-2016 Rob Carr <racarr@google.com> Merge changes I653b84e7,Ieafdc14a into nyc-dev

* changes:
Apply position updates immediately.
Move crop outside of geometry state.
69663fb0de2f112f525c4dcd7e2f7e0c879daaa4 28-Mar-2016 Robert Carr <racarr@google.com> Apply position updates immediately.

Restores the behavior prior to moving transform
in to geometry state. Now geometry state and scaling
mode only control parameters which would cause
buffer scaling.

Bug: 27729195
Bug: 27687126

Change-Id: I653b84e74407f2533c92f7647e2609fc043ed0a4
2dcb363c6e86b463a9f4e5925746e2f1089aef16 17-Mar-2016 Pablo Ceballos <pceballos@google.com> Rename single buffer mode to shared buffer mode

Change-Id: Id43d0737d9367981644e498942ebc0077d61038c
(cherry picked from commit 3559fbf93801e2c0d9d8fb246fb9b867a361b464)
b5d3d2657bad1f012377dfacd354d3100a65768a 25-Mar-2016 Robert Carr <racarr@google.com> Move crop outside of geometry state.

Prior to this CL, if Layer crop is changed while a
surface resize is pending, the crop will not be
applied until a buffer latches at the new size. This
CL makes the crop apply immediately. We can see this
is the desired behavior by looking at the two cases
where a resize is pending.

1. A resize is pending to make the surface smaller.
In this case we need to be able to immediately update the crop so that
we can shrink the visible region of the surface at an interactive rate
with input. The window manager currently uses big surfaces and scaling
modes to accomplish this.
2. A resize is pending to make the surface larger.
In this case it doesn't matter. If we expand the crop immediately to
the new surface size, then we have simply uncropped an area which is
by definition transparent pixels (as we haven't latched a buffer
at the new size yet).

This change has conceptual soundness as well. We can see that the
scaling mode will not affect properties that affect scaling (transform,
width/height) but not properties which do not (crop).

Bug: 27729195
Bug: 27687126
Change-Id: Ieafdc14aeecb23085793e3056a746d6f344781df
59d12e90ae09171fc8b50fd8fd02e3247c04840c 28-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "Rename single buffer mode to shared buffer mode" into nyc-dev
e2e39a3bb49291837c55844d73d779c6fcf4262c 25-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Add FenceTracker" into nyc-dev
am: 830f500

* commit '830f5004da53a83e23b4102ba9b72e4cb366cb34':
SF: Add FenceTracker
830f5004da53a83e23b4102ba9b72e4cb366cb34 25-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Add FenceTracker" into nyc-dev
61be455e943463e72fa108fb01e3d1608446f03a 23-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "Add final crop implementation" into nyc-dev
am: 41371bf

* commit '41371bfa0dad4a4332a8cc30b066d95546e4c4fc':
Add final crop implementation
acbe67888f0bd65d5400400f0115bae6bd6199dc 04-Mar-2016 Pablo Ceballos <pceballos@google.com> Add final crop implementation

Bug 26559810

Change-Id: Idaccd13cd625c92d18665ddecebdbb266ea365f3
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

Change-Id: I4297a661c0a7530e744168ac7a2a66c4bca92fd5
3559fbf93801e2c0d9d8fb246fb9b867a361b464 17-Mar-2016 Pablo Ceballos <pceballos@google.com> Rename single buffer mode to shared buffer mode

Change-Id: Id43d0737d9367981644e498942ebc0077d61038c
bf4f9107e9ced8662cd55a4382d715a41be7c74f 10-Mar-2016 Dan Stoza <stoza@google.com> Merge "HWC2: Track move of transform into Geometry" into nyc-dev
am: 52448f381c

* commit '52448f381cfdd08bda31bc38e193a661e01c9626':
HWC2: Track move of transform into Geometry
baf416d62eec3045ba4fd61f2df60f3e82f12d52 10-Mar-2016 Dan Stoza <stoza@google.com> HWC2: Track move of transform into Geometry

Changes a line where we missed the move of transform into Geometry to
fix the HWC2 build.

Bug: 26454664
Change-Id: Ib44ec8705b81da2aa1b99e61449609371e533297
261b94b5d76ce8db8305380816811bb507f09e9c 04-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "Revert "SF: detachLayer from Client earlier on destruction"" into nyc-dev
am: 99dccfc3ec

* commit '99dccfc3ec4b304d1ee3497ecbcc3322a84cf606':
Revert "SF: detachLayer from Client earlier on destruction"
8ea4e7b878540647bb7ceeaa1d62d50cd458d9c6 04-Mar-2016 Pablo Ceballos <pceballos@google.com> Revert "SF: detachLayer from Client earlier on destruction"

This reverts commit e338df1c2ff4ed2cd575a0e3193ef77c9cd9cb72.

Bug 27330889

Change-Id: I7e62ac2623bd0e1304f36a895ee2b5f9160e2a7e
c01b8d93a057654ed22990e7f48de7478bd8d3cd 03-Mar-2016 Robert Carr <racarr@google.com> Merge "Latch transform with geometry state." into nyc-dev
am: fb47fe7d27

* commit 'fb47fe7d27aa8a0adcccf311b6a5ab4cab4fd49d':
Latch transform with geometry state.
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
c9d972065c44860306add0172b5185bd8611f9ee 03-Mar-2016 Dan Stoza <stoza@google.com> resolve merge conflicts of 7dbaaf19eb to nyc-dev-plus-aosp

Change-Id: I7c85803051511d932ddf5cd7f97dda9ea3145520
4b2a105055d37579f1d234c02f4e14c38ca3ed43 03-Mar-2016 Zhiquan Liu <zhiquan.liu@intel.com> "#warning" conflict with -Werror

if code run #warning, it will have compile error.

Change-Id: Ic7f05cd722c14f3c5da89e2c3792615dd15cb798
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>
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
aaf51e52cfa937a8938a4429a14432a8424c66d0 20-Feb-2016 Pablo Ceballos <pceballos@google.com> Merge "Add interface for controlling single buffer auto refresh" into nyc-dev
792e529dee5b6cf839b982b4b06a37fbf1d3e28a 11-Feb-2016 Dan Stoza <stoza@google.com> SF: Prevent non-sync transactions from syncing

Clears the sync handle and frame number after registering a deferred
transaction to prevent other non-synchronized transactions from
erroneously getting marked as synchronized.

Also changes the application of pending states such that all valid
pending transactions are applied instead of breaking after the first

Bug: 27061473
Change-Id: I98f0f26e9d9bb0d266563f209e94dfd776d8f8ea
ff95aabbcc6e8606acbd7933c90eeb9b8b382a21 14-Jan-2016 Pablo Ceballos <pceballos@google.com> Add interface for controlling single buffer auto refresh

- Adds a boolean to BufferQueue that controls whether or not auto
refresh is enabled in SurfaceFlinger when in single buffer mode.
- Adds plumbing up to ANativeWindow.
- When enabled, it will cache the shared buffer slot in Surface in
order to prevent the Binder transaction with SurfaceFlinger.

Bug 24940410

Change-Id: I83142afdc00e203f198a32288f071d926f8fda95
cac353808ec1048333d7fd2f3d596fb4db567aa3 27-Jan-2016 Dan Stoza <stoza@google.com> SF: Modify transaction/buffer sync logic

Reorganizes the transaction/buffer synchronization logic to only
consider the head of the incoming BufferQueue instead of all buffers,
and fixes some potential race conditions.

Bug: 25951593
Change-Id: Ib2b08e7be571eb8bbd8c364fb85acf0e046b439c
e338df1c2ff4ed2cd575a0e3193ef77c9cd9cb72 03-Dec-2015 Pablo Ceballos <pceballos@google.com> SF: detachLayer from Client earlier on destruction

- When a Layer is destroyed the Layer destructor isn't called until
the next vsync refresh. However, the onRemoved() callback is called
on the next invalidate. So it's possible to submit a transaction on
the layer in between the call to onRemoved() and the destructor
being called.
- Call detachLayer() from onRemoved() instead of from the destructor
so that any transactions on a destroyed Layer will fail to get the
Layer object even if the destructor has yet to be called.

Bug 25887783

Change-Id: Ic2371f695bc91aa7120bf6506bb834ceb536420e
3bddd5b7731fafd2c60e75416ccd091972d196ae 19-Nov-2015 Pablo Ceballos <pceballos@google.com> SF: Don't use pointer if promote() fails

Bug 25759725

Change-Id: I51f82154bf86ded24503c07f1932b115aa709cd4
04839abb2dbfe7afe57ccc91902870aab52d30b8 13-Nov-2015 Pablo Ceballos <pceballos@google.com> SF: Initialize mSingleBufferMode

Bug 25586311

Change-Id: I2d66542c6ecb762924fa002e5487188703be8515
063121849890da78b1ad7fb96c54c795de5d1fd6 08-Oct-2015 Pablo Ceballos <pceballos@google.com> SF: Force refresh when in single buffer mode

- Add a boolean to BufferItem to track whether single buffer mode is
enabled. When it is, force SurfaceFlinger to acquire a new buffer
and refresh on every vsync.

Bug 24940410

Change-Id: Iea67330c416b6fb14500865f98c67f1c12f23197
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
19e3e06e3c65a7c001a6fe0971744ba5ff536515 20-Aug-2015 Pablo Ceballos <pceballos@google.com> BQ: Modify consumer buffer count interfaces

- Rename setDefaultMaxBufferCount() to setMaxBufferCount(). Modify it
to be hard maximum on the number of buffers that can't be overwritten
by the producer.
- Enforce the maximum buffer count in setMaxAcquiredBufferCount(),
setMaxDequeuedBufferCount(), and setAsyncMode().
- Remove mOverrideMaxBufferCount as it's no longer needed since
overriding is no longer possible.
- Expose setMaxAcquiredBufferCount() in GLConsumer.
- Remove disableAsyncBuffer(), it was only being used for single buffer
mode. Single buffer mode is now achievable with setMaxBufferCount().

Bug 13174928

Change-Id: Ia33799f42751272a711fbd8559f7602ce9f18e4f
d87defaf486ff4e9c0066754564851cfb7be49ed 30-Jul-2015 Dan Stoza <stoza@google.com> SF: Allow present if sideband stream changed

Allows the sideband layer to be passed all the way to HWC instead of
getting blocked by the updated PTS tracking code.

Bug: 22291067
Change-Id: Ic2f20a7528e276fff054e86ca35789c26873b348
0eb2d398669bf11207c0fb22b11439250da0c8dc 06-Jul-2015 Dan Stoza <stoza@google.com> SF: Ignore PTS more than one second in the future

Some of this logic already existed, but when we optimized
SurfaceFlinger to avoid unnecessary wake-ups, we didn't carry the logic
over into the new readiness test. shouldPresentNow now returns true if
the timestamp is more than a second in the future (since it's likely a
bogus timestamp and should be ignored).

Bug: 21932760
Change-Id: Ib50970a4eb621588c0b60766c8d8d1a8bddf853b
db4850c01ff02bf7f936aa427e1fa8af9abc8f22 26-Jun-2015 Dan Stoza <stoza@google.com> libgui: Fix handling of rotated surface damage

Incoming surface damage was not aware that the EGL implementation was
rotating buffers in response to SurfaceFlinger's transform hint. This
didn't affect all cases because the effect was to apply a 90 degree
rotation instead of a 270 degree rotation. For full-screen updates,
things more or less worked, but in other cases this caused corruption.

This fixes that by correctly undoing the effect of rotated buffers on
the incoming surface damage, and then passing that damage down
untouched to HWC.

Bug: 22068334
Change-Id: I226ecfc7a91fe2e16edd2aa6d9149f0d26b529d6
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
17833a1b0d70cd5cea342cadea9fdbbf16748bc6 05-Jun-2015 Dan Stoza <stoza@google.com> SF: Don't crop surface damage against viewport

Apply the display transform to surface damage, but don't intersect it
with the viewport.

Bug: 21486007
Change-Id: I94e697cea52096a960385d5f3b89609fdcf30a02
65476f3332641066a99e22338bf5cf49ce4af642 14-May-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Handle EGL errors more cleanly

Adds some more safety checking for cases where we get an error while
trying to create the EGLImage. The checking puts the Layer into a
failed state after detecting an error, since the shadow queue may no
longer be synchronized.

Bug: 20957332
Change-Id: I68b4c40eab3e58731b875ed5752f2c7d17f14bcb
a4650a50a0b35e9e4342d6600b6eb24fd94bb8e5 12-May-2015 Dan Stoza <stoza@google.com> Fix PTS handling for buffer replacement

This changes the way that SurfaceFlinger's shadow buffer management
works such that instead of tracking the size of the shadow queue in the
BufferQueue, SF tracks the last frame number it has seen, and passes
that into the acquireBuffer call. BufferQueueConsumer then ensures that
it never returns a buffer newer than that frame number, even if that
means that it must return PRESENT_LATER for an otherwise valid buffer.

Change-Id: I3fcb45f683ed660c3f18a8b85ae1f8a962ba6f0e
12e0a27aa30d9db10eafe88904d3eb8fdcbcfa71 05-May-2015 Dan Stoza <stoza@google.com> SF: Apply pending transactions to new sidebands

When a Layer's sideband stream is set, apply any pending transactions.
Otherwise they would never be applied since sideband streams don't
trigger updates by pushing new buffers.

Bug: 20125898
Change-Id: I0c7a91cdf84e6205801f4ab64eee0b09e4c0b3e0
(cherry picked from commit 3b04e1383eca6cb1d43ebe23a421c427007690c7)
ecc504043fddb7a75042ce402c67aedfac04d5e2 28-Apr-2015 Dan Stoza <stoza@google.com> SurfaceFlinger: Fix PTS on stale buffers

SurfaceFlinger's (Layer's) shadow copy of the BufferQueue queue was
getting out of sync for a few reasons. This change fixes these by
doing the following:

- Adds a check to re-synchronize the shadow copy every time we
successfully acquire a buffer by first dropping stale buffers before
removing the current buffer.
- Avoids trying to perform updates for buffers which have been rejected
(for incorrect dimensions) by SurfaceFlinger.
- Adds IGraphicBufferConsumer::setShadowQueueSize, which allows the
consumer to notify the BufferQueue that it is maintaining a shadow
copy of the queue and prevents it from dropping so many buffers
during acquireBuffer that it ends up returning a buffer for which the
consumer has not yet received an onFrameAvailable call.

Bug: 20096136
Change-Id: I78d0738428005fc19b3be85cc8f1db498043612f
(cherry picked from commit 2e36f2283f48ab764b496490c73a132acf21df3a)
9e9b0445544f11fdbf21a29601567af2d1819a30 22-Apr-2015 Dan Stoza <stoza@google.com> SF: Always perform sideband transactions

On normal Layers, we defer applying resize transactions until a buffer
of the correct size arrives. This breaks with sideband streams, because
buffers are not seen by SurfaceFlinger. This change applies
transactions immediately for Layers which have a sideband stream
attached to avoid that problem.

Bug: 20428254
Change-Id: I379d8aaef460d467cdf8432764b4a504928fb65a
(cherry picked from commit c300b8b506536e1bf94ffd8a3b75d46e776923e0)
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
11611f9be590480d7ea27bf0153558573ddcded2 12-Mar-2015 Dan Stoza <stoza@google.com> DO NOT MERGE SurfaceFlinger: Stop using IGBC::BufferItem

Switches all uses of IGraphicBufferConsumer::BufferItem (and
BufferQueue::BufferItem) to the BufferItem in libgui. Depends on
frameworks/native I699ed0a6837076867ca756b28d1ffb2238f7a0d9.

Cherry pick of I187b3a7d05196b6289596afac8fb9a9d4aebff76

Change-Id: I5bc79fb96b6cba6021af64b20890967aa3b7fcbf
82c6bcc9705eabcaf5b9e45bc81867b0e2d61a02 20-Feb-2015 Eino-Ville Talvala <etalvala@google.com> DO NOT MERGE Add dataSpace to buffer queues; remove old format enums.

- Wire up new dataSpace parameter through buffer queue stack
- Update tests to include the parameter
- Switch eglApi to using dataSpace to indicate sRGB gamma/linear
- Remove RAW_SENSOR in favor of RAW16
- Remove use of sRGB format enums
- Add default dataspace to buffer queue core
- Add query for default dataspace

Cherry pick of I070bd2e7c56506055c419004c29e2e3feac725df

Change-Id: I461952389c18051176c6b75e664f20ad369f5760
1e6116621bc2f7aedfd52a5f1327b530328435b0 25-Nov-2014 Michael Lentine <mlentine@google.com> am b947f29a: Merge "Add clamp to Layer and update Transform inverse." into lmp-mr1-dev

* commit 'b947f29a6af1622cda16d0b7112595082750dd07':
Add clamp to Layer and update Transform inverse.
28ea217ff4e0aa9b03dfc12b6f47cccc6aaaae08 20-Nov-2014 Michael Lentine <mlentine@google.com> Add clamp to Layer and update Transform inverse.

Ensure that the adjusted transparent region is within
the display bounds by clamping after the transformation
is applied and clean up transform's inverse function.

Bug: 18452546

Change-Id: Ia473e483ee8374177bcb84d8192eb1f0e86f022a
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
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
8dc55396fc9bc425b5e2c82e76a38080f2a655ff 04-Nov-2014 Dan Stoza <stoza@google.com> Add a BufferItem parameter to onFrameAvailable

Passes the BufferItem for the queued buffer to the onFrameAvailable
callback so the consumer can track the BufferQueue's contents. Also
adds an onFrameReplaced callback, which is necessary if the consumer
wants to do anything more than simple queue length tracking.

Bug: 18111837
Change-Id: If9d07229c9b586c668e5f99074e9b63b0468feb0
6c925ede620f4080227bb1fe8a41e4b4502348f8 27-Sep-2014 Michael Lentine <mlentine@google.com> Fixed discrepancy between crop and frame transparencies.

Bug: 17662777
Change-Id: I0d65d9b912a37a60e4c1d2e2e198f7709460917c
5bf786d8f00ff8eee64ebf330dac55e33a0f97b1 30-Sep-2014 Jesse Hall <jessehall@google.com> surfaceflinger: recompute visibility after sideband stream change

We normally recompute layer visibility when a layer gets its first
buffer; before then it's treated as invisible. Sideband layers never
get a buffer (as far as SurfaceFlinger knows), so never became
visible. Now we also recompute visibility when a layer gets a new
sideband stream.

Bug: 17752511
Change-Id: I84e150f196eb2eb7bcd2616248e5e3fa73624809
7b90258c7b1b6caf7fbbf62423723d0f4cdc79aa 20-Aug-2014 Michael Lentine <mlentine@google.com> Fix inverse orientation when original is not applied first.

Change-Id: I6f1a11950c77c99800acbf08a672bc1b2310b0b5
1440963470cda68be762957e2efb7ecbe1570366 19-Aug-2014 Michael Lentine <mlentine@google.com> Fix camera orientation by swapping horizontal and vertical flips when needed.

Bug: 16637957

Change-Id: I66de597546fdc19e0af9e6150ca20460ab36bf8b
f75514079434cefcdb746e8b083708d6de5f86ff 19-Aug-2014 Michael Lentine <mlentine@google.com> Incorporate TransformToDisplayInverse into the crop calculation.

Change-Id: Ia9757b3a43d3b8f99df9fef2ed4d11c43b5abdd2
5af281f4abb0401ebb4e614291a19780b71f236c 07-Aug-2014 Michael Lentine <mlentine@google.com> Fix HWComposer Surface Crop when surface is rotated

Bug: 15091149

Change-Id: I97ecd8af9636da9403fafdb3f9b846f95053ebb7
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
1681d95989271f3a9ac0dbb93d10e4a29f2b4444 28-Jun-2014 Ruben Brunk <rubenbrunk@google.com> Add sticky transform to surfaceflinger.

Bug: 15116722

- Adds a sticky transform field that can be set from a
SurfaceFlinger client Surface. This transform is
added to any transform applied to the Surface.

Change-Id: Idaa4311dfd027b2d2b8ea5e2c6cba2da5779d753
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
cf8684b2063c0458da634be0fae7ccabf3f50176 10-Apr-2014 Svetoslav <svetoslavganov@google.com> Merge "Adding render stats APIs to UiAutomation (framework native)."
d85084b2b65828442eafaff9b811e9b6c9ca9fad 20-Mar-2014 Svetoslav <svetoslavganov@google.com> Adding render stats APIs to UiAutomation (framework native).


Change-Id: Ibb1c07f7d89e11281e5c1f27f412a29ac6f9c4ab
4cd47b2e0eac8eb1c4a9d69e716e6dc0e2da7227 10-Apr-2014 Wonsik Kim <wonsik@google.com> Merge "Fix sideband stream issues"
b3d0bdf0dbc19f0a0d7d924693025371e24828fd 08-Apr-2014 Dan Stoza <stoza@google.com> BufferQueue: Remove Bn version of create*

It turns out that there's no reason to have both I* and Bn* versions
of the createBufferQueue method, so I removed the Bn* version.

Change-Id: I66aeb09e10458ae540ddf1f38d2d0154ea8f315b
afe3081e0e224a3d88da2e8f211e994f833cc6bb 31-Mar-2014 Wonsik Kim <wonsik@google.com> Fix sideband stream issues

- Notify a listener when sideband stream is set
- Mark a layer as visible when sideband stream is set, even though
no buffer is queued.

Change-Id: I9652bf530f2b5ce331533ec1bb3b10a815ca191c
b9b088375d33a87b201cdbe18be71802e2607717 13-Mar-2014 Dan Stoza <stoza@google.com> Remove deprecated BufferQueue constructor

Bug: 13415624
Change-Id: I9fe15e45daa7351f1db34ee75bfee6f19cb347d3
399184a4cd728ea1421fb0bc1722274a29e38f4a 04-Mar-2014 Jesse Hall <jessehall@google.com> Add sideband streams to BufferQueue and related classes

Sideband streams are essentially a device-specific buffer queue that
bypasses the BufferQueue system. They can be used for situations with
hard real-time requirements like high-quality TV and video playback
with A/V sync. A handle to the stream is provided by the source HAL,
and attached to a BufferQueue. The sink HAL can read buffers via the
stream handle rather than acquiring individual buffers from the

Change-Id: Ib3f262eddfc520f4bbe3d9b91753ed7dd09d3a9b
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
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
c1c05de415854eb7a13a16b7e22a22de8515123a 18-Sep-2013 Mathias Agopian <mathias@google.com> fix camera API 2.0 orientation

we add a flag to ANativeWindow::setBufferTransform that means
"apply the inverse rotation of the display this buffer is displayed
onto to".

Bug: 10804238
Change-Id: Id2447676271950463e8dbcef1b95935c5c3f32b2
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

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

Bug: 9465644

Change-Id: I860f7eed0cb81f54ef9cf24ad78155b6395ade48
19733a32799f792125913e746e8644d16f8dc223 29-Aug-2013 Mathias Agopian <mathias@google.com> minor clean-up of the GLESRenderer

Change-Id: I978dea25b7687fbbbb283f09c24e115d9bad49a2
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

Bug: 9992306
Change-Id: Ib821767899af330bb70d3cbbfa7d41b02794a075
0e8f1443b87f9009159cef6394de48894f98f826 21-Aug-2013 Mathias Agopian <mathias@google.com> Fix a bug where non-cropped layer could be scaled incorrectly

If a layer is not cropped but its bounds are outside of the
viewport (i.e.: clipped), the crop rectangle passed to
hw composer would be invalid because it started invalid
in the first place (to indicate "no crop").

Bug: 10410944
Change-Id: I4ae4d49a1adef0be7fa4304ecf84b1a5b7d03fe0
49457ac092071a8f964f7f69156093657ccdc3d0 15-Aug-2013 Mathias Agopian <mathias@google.com> Encapsulate textures into their own Texture class

the main reason for doing this is so that we can have
access to informations about a texture (like its dimension)
close to where we generate and use shaders in ES 2.0.
Previously, there wasn't any way to get to a texture's size
from a RenderEngine implementation.

Bug: 8679321

Change-Id: I388b338a70d07e3e8177dde248710ea1e4c82dff
e048a4374c4e355c361f5eec0482ac85df0c73fe 16-Aug-2013 Jesse Hall <jessehall@google.com> Merge "Add support for EGL_KHR_gl_colorspace" into klp-dev
5cdc8994a0ecd751a6350b16a1bef8b6b0d09b11 14-Aug-2013 Mathias Agopian <mathias@google.com> don't reallocate the mesh each time we use it

the Mesh object can be part of each Layer (at least currently).
also reworked the Mesh code a bit to make it easier to access
the vertex data.

Change-Id: I0490851ba898f0aa2e55b62958dcd8bdb535e98b
3f84483382be2d528918cc1a6fbc6a7d68e0b181 08-Aug-2013 Mathias Agopian <mathias@google.com> SurfaceFlinger now uses GLES 2.x when available

Bug: 8679321

Change-Id: I2b152d01fb4e2de2ea9fe87f1ddbd6826d7520d7
c2e41222bf02a6579763974f82d65875cfa43481 08-Aug-2013 Jesse Hall <jessehall@google.com> Add support for EGL_KHR_gl_colorspace

Change-Id: I684d0b8556cd6c84ee4b4d67e1bb95c3b96fccfb
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
c2414bb0989763641ca57cf72c11ef6d86565a23 26-Jul-2013 Mathias Agopian <mathias@google.com> get rid of HAL pixelformats 5551 and 4444

Change-Id: I39409103144c1ba09078c4ddc323a58987fb09ea
dd533712f8dd21c0dadfd5ce8a0ad85aa3e96ada 27-Jul-2013 Mathias Agopian <mathias@google.com> make transparent pixels transparents again

apparently boolean logic in hard...

Change-Id: Ie70401fe12e0fa00b0b8c7cc475c1438cdbbf531
5773d3f5b2694c647e010246dff99acc70131289 26-Jul-2013 Mathias Agopian <mathias@google.com> get rid of PixelFormatInfo and simplify things

Change-Id: I025a362cc12d5b9b794fac14be500e25aab65396
6547ff4327aa320fbc9635668d3fc66db7dd78f6 17-Jul-2013 Jamie Gennis <jgennis@google.com> surfaceflinger: add frame duration logging

Change-Id: Ib414a45e7e191f23a2726cbbbeb606e9ce68a3b5
595264f1af12e25dce57d7c5b1d52ed86ac0d0c9 17-Jul-2013 Mathias Agopian <mathias@google.com> BufferQueue improvements and APIs changes

this is the first step of a series of improvements to
BufferQueue. A few things happen in this change:

- setSynchronousMode() goes away as well as the SynchronousModeAllowed flag
- BufferQueue now defaults to (what used to be) synchronous mode
- a new "controlled by app" flag is passed when creating consumers and producers
those flags are used to put the BufferQueue in a mode where it
will never block if both flags are set. This is achieved by:
- returning an error from dequeueBuffer() if it would block
- making sure a buffer is always available by replacing
the previous buffer with the new one in queueBuffer()
(note: this is similar to what asynchrnous mode used to be)

Note: in this change EGL's swap-interval 0 is broken; this will be
fixed in another change.

Change-Id: I691f9507d6e2e158287e3039f2a79a4d4434211d
8f938a53385a3c6d1c6aa24b3f38437bb2cc47ae 13-Jul-2013 Mathias Agopian <mathias@google.com> always pass the BufferQueue explicitely to consumers

Change-Id: I883b0a7b19d8e722f9ab714ba6f49e658b02ca86
c33f9a76b5dff1a9b4e4d0c76459c0d5b36a0d74 11-Jul-2013 Andy McFadden <fadden@android.com> Merge "Pay attention to buffer timestamps"
1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd 28-Jun-2013 Andy McFadden <fadden@android.com> Pay attention to buffer timestamps

When acquiring a buffer, SurfaceFlinger now computes the expected
presentation time and passes it to the BufferQueue acquireBuffer()
method. If it's not yet time to display the buffer, acquireBuffer()
returns PRESENT_LATER instead of a buffer.

The current implementation of the expected-present-time computation
uses approximations and guesswork.

Bug 7900302

Change-Id: If9345611c5983a11a811935aaf27d6388a5036f1
6b44267a3beb457e220cad0666c039d3a765cdb2 10-Jul-2013 Mathias Agopian <mathias@google.com> fix SF buffer cropping

When a buffer had a crop (meaning its content is scaled to the window size)
and a window crop was defined, the resulting crop couldn't be expressed
properly because h/w composer's API was limited to integers, since
this is fixed in h/w composer 1.3, we take adventage of this to
make sure we get the correct crop.

this bug could result in the buffer being scaled by an incorrect ratio and
be slightly offset; moreover, it would produce different results from the
GL code path, which is always correct.

Change-Id: I8e20e00b6e26177d14f4ab4d2cd581e26c818892
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
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
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
f3e85d432749ca77ad707bec523b67d741d43e6e 11-May-2013 Mathias Agopian <mathias@google.com> take the "transparent region" into account for blending

until now it was only used to discard a layer entirely.
we're now reducing the size of the layer if it is still
visible, if possible.

this works for instance when a surfaceView is used and
only the menu bar is displayed over it.

Change-Id: I3f5527c5cd1e69ecc968272c8948f1513ada8c55
6c7f25afb75ac155bad0b3bc17c0089d0337d060 10-May-2013 Mathias Agopian <mathias@google.com> reformat Rect.{cpp|h}

Change-Id: I45b1f6646541a1abacce1e70df00a770e47b820e
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
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
6c67f0fe457f758fc875e1178d8fd5258fd8f6df 13-Apr-2013 Mathias Agopian <mathias@google.com> make sure to update the "current state" when we "fake" the transaction

this mimics the code we used for the size. basically we need to
also update the "current state" because it gets copied to the
"drawing state" when a transaction occurs, and it would
"undo" our change.

Bug: 8511430
Bug: 8581533
Change-Id: I08c02abbf21b7f168f7124cd14ee717d7d3d502c
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
13f01cbdbd34779a234bc674df79e23672fd5c0b 20-Mar-2013 Jesse Hall <jessehall@google.com> Pass sp<Fence>s around instead of file descriptors

Change-Id: Iac70584a2207940730e8f803a543e4e9a4000c47
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
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
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

Change-Id: I66511c08cc3d89009ba4deabf47e26cd4cfeaefb
b79f61d41ef053bee1087ec612896c59f95f9686 06-Mar-2013 Mathias Agopian <mathias@google.com> fold LayerBaseClient into LayerBase

Change-Id: Ic745136522df59c42f0885fd969e75ea55d09f01
a8bca8d84b559e7dcca010f7d6514333004020c7 28-Feb-2013 Mathias Agopian <mathias@google.com> refactor the crop region for hwc is calculated/set

- the crop region is now always calculated and set
in LayerBase::setGeometry which uses new virtuals to
access the "content" crop and transform (which are
provided by the Layer subclass)

Change-Id: Ib7769bdec0917dd248f926600c14ddf9ea84897a
789a6c3f1dfe22a1ffea7f39b2098d7842cd1f30 25-Feb-2013 Jamie Gennis <jgennis@google.com> SurfaceFlinger: fix a couple NULL fence checks

This change replaces checks for a NULL fence pointer with calls to
Fence::isValid. There should no longer be NULL fences.

Change-Id: If17c9c132fcb1801531bf7588f8ba53476c57dad
1df8c345854155cbbcb9f80de9d12d66ea70ac08 20-Dec-2012 Jamie Gennis <jgennis@google.com> libgui: disallow NULL Fence pointers

This change eliminates the uses of a NULL sp<Fence> indicating that no waiting
is required. Instead we use a non-NULL but invalid Fence object for which the
wait methods will return immediately.

Bug: 7892871
Change-Id: I5360aebe3090422ef6920d56c99fc4eedc642e48
351c2941736039c495dd7ac849ec64fbf7f3ff05 11-Feb-2013 Jamie Gennis <jgennis@google.com> Merge changes I8bded1ea,I7478293e

* changes:
SurfaceFlinger: add win anim frame time tracking
SurfaceFlinger: remove a driver bug workaround
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
9f8386e1118c10dd4927f62637ec7162569bdbdc 30-Jan-2013 Mathias Agopian <mathias@google.com> Add support for plane-alpha in HWC

Change-Id: I218e7dd5f23de535aabce61e993002ab6cb46cdd
33c544c4d3af8bae518474df6a9da9b7c349b91a 04-Feb-2013 Jamie Gennis <jgennis@google.com> SurfaceFlinger: remove a driver bug workaround

Change-Id: I7478293e87899d6e467db8c2f9e295935c8b1d4e
882e3a39ed770b335a203e233b57127fde1c839e 09-Jan-2013 Andy McFadden <fadden@android.com> Add some comments.

Also, minor tweak to SurfaceTextureLayer.

Change-Id: If616d5ee4e8226dd0e16c5dbb0e0f80db553110e
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

Bug 7736700

Change-Id: Ia03e468888025b5cae3c0ee1995434515dbea387
97eba8904c2f221c42a9473407223a4c3a213f75 12-Dec-2012 Andy McFadden <fadden@android.com> Avoid unnecessary texture bind

In SurfaceFlingerConsumer, check to see if native fence sync is
enabled. If so, defer the texture binding step to Layer::onDraw.

Change-Id: I7d4034a31c0143207eea2509dfa13ef3820f9b8c
bf974abe92f7495529916fe0f483f3b56e7c30e3 05-Dec-2012 Andy McFadden <fadden@android.com> Refactor SurfaceTexture a bit.

Rearranges updateTexImage() so that the SurfaceFlinger-specific
behavior is in a new SurfaceFlingerConsumer subclass.

SurfaceTexture behavior should not be altered. Instead of
acquire-bind-release we now do acquire-release-bind, but since
it's all done with the lock held there shouldn't be any
externally-visible change.

Change-Id: Ia566e4727945e2cfb9359fc6d2a8f8af64d7b7b7
46b6bce198c81ce9a4e0583e876d080ad48db003 08-Dec-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: work around a driver bug

Change-Id: I4490f308b12e9b6fda2ea7255eb19d867d6d008c
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
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
82dbc7429f5f9f2b303b31dc5b9f2bfd1bbe6add 09-Nov-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: refactor frame time tracking

This change moves the frame time history tracking code out of Layer and into a
new class called FrameTracker. It also changes the tracking to use signal
timestamps from fences when available for more accurate results.

Change-Id: I323c5f075c58bf86ce363b52af885ad0f6365f2b
a4a3149a36bc69a06e4824aeae909ab910661070 29-Oct-2012 Igor Murashkin <iam@google.com> Change ConsumerBase's FrameAvailableListener to be a weak pointer

This prevents strong reference cycles when the listener implementation also
holds a strong pointer to the ConsumerBase

Bug: 7425644
Change-Id: I1514b13a32b18d421c902dddebec0765a989c55c
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
ab10c5804c250e7f392c8262f687766edec2e9f4 27-Sep-2012 Andy McFadden <fadden@android.com> Recompute visible regions more vigorously

Some of the code in latchBuffer was calling invalidateHwcGeometry,
but that didn't cause the SurfaceFlinger visible region code to
re-evaluate the layer's visibility. Set the recomputeVisibleRegions
"out" parameter instead.

Bug 7235797

Change-Id: If6ba33fbd1a594cd64cc5253aebf752d6ceda1c9
eba8c688f633f3f3f1b75c2bc64faf799dd2b5f2 20-Sep-2012 Mathias Agopian <mathias@google.com> calculate wether we filter on a per-display basis

Change-Id: I79d80b432b20b3d02428da19add464ac1e2b9378
3941cb240d438bfdebe24920bb2ada86456a0bf9 18-Sep-2012 Jamie Gennis <jgennis@google.com> SurfaceTexture: default to doing GL sync

This change makes updateTexImage default to performing the necessary
synchronization and adds an argument for SurfaceFlinger to disable that
synchronization so that it can be performed lazily.

Change-Id: I7c20923cc786634126fbf7021c9d2541aa77be5d
Bug: 6991805
da27af9832a0170f1fc40ef3f21371c4d30d21b3 14-Sep-2012 Mathias Agopian <mathias@google.com> add support hwc 1.1

Bug: 7124069

Change-Id: I53d705105c4ad8954d3f50ee4f4c8b7ec936b871
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
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
61e04b92bdeafc6fca89052d14dab1bd0c384a71 10-Sep-2012 Jamie Gennis <jgennis@google.com> SurfaceTexture: use eglWaitSync

This change adds a compile-option to use eglWaitSyncANDROID to ensure that
texturing operations that access the current buffer of a SurfaceTexture do not
occur until the buffer is completely written. It also moves this
synchronization into a new SurfaceTexture method called doGLFenceWait and
changes SurfaceFlinger's Layer class to use that method rather than performing
its own wait on the fence.

Change-Id: I70afa88086ca7ff49a80e3cd03d423767db7cb88
71e83e1202dc87afde9c0c31f31c129f3f99263f 05-Sep-2012 Mathias Agopian <mathias@google.com> the visibleRegion was never set in hwcomposer

Bug: 7089478
Change-Id: I13b031b23ce908d33f431a04e1cf87831b551260
c39736088398a9b4367b30fc307ed7de96ac342e 01-Sep-2012 Mathias Agopian <mathias@google.com> the visible region sent to HWC was garbage

we used to have a visibleRegion object per layer, but now
it's per screen; so at somepoint the code got changed to
calculate the per-screen visible region on the stack and that's
what got passed to HWC.

we're now setting the visibleRegionScreen at each frame and
freeing at after the HWC set() call. We use the underlaying
SharedBuffer so that in most cases we don't have to allocate,
free or copy memory around.

Bug: 7089478
Change-Id: I24fa556c76613a225d9fe7a6c6b727bb476144d8
31a353da225af5329735451c761b430d82dfda1b 25-Aug-2012 Jamie Gennis <jgennis@google.com> BufferQueue: clean up buffer counting

This change is a clean up of some of the handling of the maximum number of
buffers that are allowed at once. It mostly renames a few member variables and
methods, but it includes a couple small refactorings.

Change-Id: I9959310f563d09583548d4291e1050a7bbc7d87d
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
3165cc21cfea781988407b19bd83292b19f05f55 09-Aug-2012 Mathias Agopian <mathias@google.com> libgui includes refactoring

Change-Id: I1d24ec17f5003ec2abab5f7472daaff4cc4cc2d3
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
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
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
0f2f5ff75b7b48ceb64270655ee6b62d09bf4d00 01-Aug-2012 Mathias Agopian <mathias@google.com> rename DisplayHardware to DisplayDevice

Change-Id: I3f7250cd914e0da4f9ec2c9403587bbe12f3cc62
52bbb1ae239c8a4d05543a23fa8c08467d09c3b2 01-Aug-2012 Mathias Agopian <mathias@google.com> getting closer to final main composition loop

Change-Id: Icd63782366ffd11d9ea00c925ae5783ed7440cdb
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
a49126087b4494f4ef50873f3a3f6727265f6621 12-Jul-2012 Mathias Agopian <mathias@google.com> factor EGL/GL and surface creation out of DisplayHardware

Change-Id: Icd85a6a4caad06f056578008af3e21666fa8b1f4
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
c5c5a14c06de249d8e0445fd24699e1d9aa04549 03-Jul-2012 Jesse Hall <jessehall@google.com> Only set acquire fences on overlay layers

Change-Id: I08e8173f83580de5a4e43a0ba5ea03e5ec6e8782
dc5b485f74edf2d2f31c62054eb6c180421a3ade 30-Jun-2012 Jesse Hall <jessehall@google.com> Pass fence to HWC on first use of buffer

Also do a CPU-wait on the fence before using it for GL composition.

Change-Id: I0f645a42a44803276cae11b904e5a26d65871562
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.
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
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
0cd545f14261d829513e0d6e8fa5e4e4f3372b3d 07-Jun-2012 Mathias Agopian <mathias@google.com> sometimes we would incorrectly scale the content of a surface

this would happen when a resize was pending (ie: we have received
and processed a resize transaction but have not received a buffer
with the right size) and a new transaction came in that didn't
involve a resize, for instance a translate-only transaction.

in this case, we would incorrectly update the drawing state
with the pending size, eventhough we still don't have a buffer
for it.

the solution is quite simple, we never allow the size to propagate
from current to drawing state during the regular transaction processing
(unless we are in fixed-size mode -- meaning we don't need to have
a matching size buffer), this propagation happens later once we
receive the buffer.

Bug: 6624163
Change-Id: I11a97e4b88a7f3a0571ddcfe99c86cb04ce01a4d
4824d40a35333182c2eb3593511b9bcbecd0a943 05-Jun-2012 Mathias Agopian <mathias@google.com> sometimes SF would not process a surface resize

this would happen when a window started with size A, was
resized to B and immediately resized to A. In this situation
the erquested and active size would be the same, and SF
would think a transaction wasn't needed.

we fix this by always comparing the requested sizes.

Also, make sure to set mRefreshPending once we're sure
we have succesfully called updateTexImage().

Bug: 6580962
Change-Id: I2c48b4df7f05fd35c9e1d2dd82095b0f3d5a0b6a
e31564d8eb0ab67e167a888eccce20f5b4e4ef45 30-May-2012 Mathias Agopian <mathias@google.com> Fix a crasher is surfaceflinger.

this bug introduced recently would happen when the very first
buffer of a surface was rejected for not having the right size

Bug: 6577035
Change-Id: I9fabf20006019f2a6c308be7c7f5c05bdcfd5014
2c8207e9627fe6c7a90e31fae8d71ae49df56845 24-May-2012 Mathias Agopian <mathias@google.com> add the ability to reject buffers in SurfaceTexture::updateTexImage

SurfaceFlinger is using this new feature to reject buffers that
don't have the right size.

Bug: 6498869
Change-Id: I8a7250a47db6c082a357b703feb3b9d0fc8d3443
702634a4dad85cfc292618ac91eda6c00f42b7c5 24-May-2012 Mathias Agopian <mathias@google.com> refactoring in preparation for bug:6498869 fix

here we just shuffle a bit the code inside lockPageFlip(),
we move the code that handles the buffer size closer to the call
to updateTexImage(). no functionality change.

Change-Id: Ie3193cd86cd32cf3c89532449fd747d145ca0ab6
05cec9d1275fd939c2d1aec235dca2bdb8edef63 23-May-2012 Mathias Agopian <mathias@google.com> improve resize transactions

use a flag instead of pre-committing the "requested" state
to prevent propagation or "requested" to "active", which makes
things a lot clearer when reading the code.

also avoid going through the "resized" code-path when requested
size is equal to "active" size.

Bug: 6498869
Change-Id: I24f893ba0ec5ca06aac5b8da9818989ae7ce4005
419e196e639c8adb875da2765abcef95017b6d4a 23-May-2012 Mathias Agopian <mathias@google.com> Improve debug logs and minor clean-up

Bug: 6498869
Change-Id: I14d1b4d6960b87b5a7c4d7e20b92538edd9331ff
b30c415539813b96a831b75d07f3d12aef1aeab7 17-May-2012 Mathias Agopian <mathias@google.com> Fix "Battery/Status/Clock status bar area flickers when dragging down"

The crop is now handled like a resize, it's latched only when we
receive a new buffer in the case we have a resize in the same

Bug: 6498869
Change-Id: I9f3cbbe08fb19443899461ec441c714748a4fd1a
93ffb86b909005bbee4993fc9053f017466311c7 17-May-2012 Mathias Agopian <mathias@google.com> minor refactoring in praparation of crop fix

Bug: 6498869
Change-Id: I12a6f9a9fdfd2ea1db3fbe5fc8cb443aeaedb328
cbad735d8cc4ff360341bf12d8c388edcbc78ce3 15-May-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: recompute visible regions less

This change removes some visible region recomputation that was needed to handle
the SCALING_MODE_FREEZE cropping. We've changed things to use a window crop
from the WindowManager instead, so this is no longer needed.

Bug: 6299171
Change-Id: I32fbc2b689c985837126d8ba3d9a91e79613ffbf
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
51dcd581b1fb1bcea7cac9b969123abda13e34ab 10-May-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: recompute visible regions more

This change makes a change in the crop, scaling mode, transform, or buffer
dimensions trigger a recomputation of the visible regions of a window. With
the new cropping behavior for SCALING_MODE_FREEZE all of these can now affect
the visible region.

Bug: 6470541
Change-Id: I1904e47efbd708e28bf189f637d24dbef65cd41e
161534a3c5ee77bc91e7a73ffb6274f35324f8b5 07-May-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: SCALING_MODE_FREEZE cropping support

This change adss support for applying a buffer crop to layers with the
SCALING_MODE_FREEZE scaling mode. These layers do not scale the image, but
rather treat all pixels outside the crop rectangle as fully transparent.

Change-Id: I762518e56a37aef7747f9b581df2f2589b232c49
Bug: 6299171
cbb1a95819ec302ae15e4a1162a8b1349ae5c33e 09-May-2012 Jamie Gennis <jgennis@google.com> SurfaceFlinger: tell SurfaceTex about filtering

This change makes SurfaceFlinger set the filtering-enable on each layer's
SurfaceTexture before querying the texture matrix to use for GLES composition.

Change-Id: I40c3defd73ebf96e3cabb3bfdb1fc97f2036753a
a0db308c3d62301ae41b2e2bcf295c4ee4c7b08e 23-Apr-2012 Mathias Agopian <mathias@google.com> remove SurfaceTexture::connect()

use BufferQueue::connect() instead

Change-Id: I04aab7cf11304bf962cde38470747f3b19ddba42
7f42a9c47c5a7f40cf02032d286d6bd62f28e650 24-Apr-2012 Mathias Agopian <mathias@google.com> triple buffering is now controled by BoardConfig and enabled by default

triple buffering.

Change-Id: I9875d6ddefd23c1af9e51e7ee7dec1bacd1e6799
b267579ba8dfe3f47d2a481c5a3c2254e3d565a1 23-Feb-2012 Daniel Lam <dalam@google.com> SurfaceTexture: Fully refactored from BufferQueue

SurfaceTexture and BufferQueue are separate objects.

Change-Id: I230bc0ae6f78d0f9b2b5df902f40ab443ed5a055
ed61a47c5b23e277d20a49fceb16d6ba5896b7d2 28-Feb-2012 Mathias Agopian <mathias@google.com> Merge "a window could get stuck to gpu composition"
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
ec923ee0d0e6f95bd56275214c252cb57bb8cfd4 28-Feb-2012 Mathias Agopian <mathias@google.com> a window could get stuck to gpu composition

this could happen after an orientation change. basically
we need to triger a geometry-changed when the very first buffer
is received

Change-Id: I097e411fd6612c18725737cffccdbf6b2af3511c
90ac799241f077a7b7e6c1875fd933864c8dd2a7 26-Feb-2012 Mathias Agopian <mathias@google.com> fix libgui header location

Change-Id: Iec71706cdd4f29c6904993648ce873e83ef9cafe
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
4d143eed994778d37eb09bb5d452c26f12bca6e1 24-Feb-2012 Mathias Agopian <mathias@google.com> fix an issue in SF where we could miss some updates

Change-Id: I7d350bc05d1596655baddff3deaebaba58c9bcc0
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
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

this allows us to work much better without requiring triple-buffering.

Change-Id: I1fa10794d0cf742129f0877698b7b1e1f2ec7401
8aedd4737d6ce8548d2fd5def65b1e1737283821 25-Jan-2012 Mathias Agopian <mathias@google.com> SF now synchronizes to VSYNC

Change-Id: Ic5e4f2ea9927ce133eef9499c03161325e9d02c5
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

prints the list of all layers regardless of their visibility

Change-Id: I7c07ae020f838c173b98ee50f3fb3e93da78acbb
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
e8696a40e09b24b634214684d18526187b316a2f 16-Jan-2012 Jamie Gennis <jgennis@google.com> hack up frame latency measurement

Change-Id: I6d9a466a23285304f0e229a5649815636ab5d6af
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
4c4163b53e262ff9cc10c819321d4ae03c2d7d46 22-Oct-2011 Xavier Ducrohet <xav@android.com> Fix software GL renderer.

Change-Id: I07ab2709fa694e41aa3fcc5b9dfc809f55853ab4
818fb243572f8e1f408ba9fc35ef61bbedbd9ce1 19-Oct-2011 Dave Burke <daveburke@google.com> am 70ac412b: Merge "Add a LayerScreenshot" into ics-mr0

* commit '70ac412b2fe7be2507189a9fdfb30c43b36d56ac':
Add a LayerScreenshot
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
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
cdec8f01aae14ed59fbc57cb2ce97a6602f4b9a1 17-Oct-2011 Mathias Agopian <mathias@google.com> am 840b8a67: Revert "Add a LayerScreenshot"

* commit '840b8a678537519c27ddf2f818494eaa20a135d4':
Revert "Add a LayerScreenshot"
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.
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
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
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
ed984d9406b5a4062db93319e6f94d5f9fd19648 27-Sep-2011 Jamie Gennis <jgennis@google.com> Merge changes Ib302d79e,Ib4ee085f

* changes:
SurfaceFlinger: set layer names on SurfaceTextures
SurfaceTexture: add name support
1b5f4e61ff481387215d98c3266871bfd465bce5 27-Sep-2011 Jamie Gennis <jgennis@google.com> Merge "SurfaceFlinger: fix setting default buffer size" into ics-factoryrom
2a0d5b608447a880beff5149805425f02691442b 27-Sep-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: fix setting default buffer size

This change makes SurfaceFlinger update a SurfaceTextureLayer's default
buffer size in response to a window resize even if the Layer is in fixed
size mode.

Change-Id: I3871c8f19a045d03904d1284390cad7659be71ff
Bug: 5366426
36d2c1f02c58d8b5d2706960f370c9d74aafd740 27-Sep-2011 Jamie Gennis <jgennis@google.com> Merge "(DO NOT MERGE) SurfaceFlinger: fix isOpaque check in lockPageFlip" into ics-factoryrom
8d91b425078083d0e4967dcd8d669d9f7196123a 24-Sep-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: fix the transform hint

This change fixes the transform hint to use only the global display
transform rather than incorporating the transient layer-specific
transform used during animations.

Bug: 5366891
Change-Id: I5408dcd3f4771d010953e8a696a484c835bfe81e
a249f2d11249ff37c48119020b797ad437ddef2c 17-Sep-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: set layer names on SurfaceTextures

This change sets the SurfaceTexture name string to match that of the
layer to which it belongs.

Change-Id: Ib302d79e916a36ab1e54cb9ff477c3b857bd957b
351a513b12622781de9580b3c96fd0a8578b563b 15-Sep-2011 Jamie Gennis <jgennis@google.com> (DO NOT MERGE) SurfaceFlinger: fix isOpaque check in lockPageFlip

This change fixes an issue where Layer::isOpaque was being called in
lockPageFlip to get the opaqueness for the new buffer before
mActiveBuffer was updated.

Bug: 5321313
Change-Id: Ibb5d7d3f4e9a2b1448e117a484a0d9f9ca5fc9de
945d291699e439c6cbc6192164e0fa53d9a03c3a 15-Sep-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: fix isOpaque check in lockPageFlip

This change fixes an issue where Layer::isOpaque was being called in
lockPageFlip to get the opaqueness for the new buffer before
mActiveBuffer was updated.

Bug: 5321313
Change-Id: Ibb5d7d3f4e9a2b1448e117a484a0d9f9ca5fc9de
c7f3381c3b2945e441747130eae88214435d0819 31-Aug-2011 Mathias Agopian <mathias@google.com> fix display artifacts in preview screen in timelapse video mode

We were not updating the h/w composer state when the buffer size

We also didn't update the h/w composer state when the transformation
matrix changed (which is related to the above issue, since it would
probably change when the buffer size changes).

Also moved updating the crop to setGeometry(), since we decided
that the "crop" change requires the GEOMETRY_CHANGED flag (ie:
not need to do this every frame)

Bug: 5238473

Change-Id: Ia7b47e145b48581b568d89d9aa2c14ff778be862
85b6f7afeab61b75e4326639a9f4cb61523ea997 25-Aug-2011 Jamie Gennis <jgennis@google.com> Merge "SurfaceFlinger: use the HWC gralloc usage bit"
45d845190d26ae27de45390460f50a6a8639e2e5 24-Aug-2011 Mathias Agopian <mathias@google.com> Merge changes I14e03939,I9aafe6f2

* changes:
Fix an issue where Surface::lock() would never update the output region
Add a debug option to turn the "transformation hint" off
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
f7ae69d4bd292110da976c8ae766a8ef083d731f 23-Aug-2011 Mathias Agopian <mathias@google.com> Minor cleanup

Change-Id: Ic042043c54631b5a5c74d20136addb2c08515ea9
3599bf2c0727bc33e8136f5163eee6f398545e05 10-Aug-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: use the HWC gralloc usage bit

This change makes SurfaceFlinger always use the
GRALLOC_USAGE_HW_COMPOSER usage bit when allocating buffers that may be
passed to the HWComposer.

Change-Id: I70362a8ede2b359fb2046853f85149d597465817
d992db3827016388e8069f5793b031153d423501 19-Aug-2011 Mathias Agopian <mathias@google.com> give the proper orientation to the h/w composer HAL

we were using the "orientation" value instead of the
real transform, which may contain arbitrary rotations for
instance, and in some case ended up with a final "orientation"
that looked valid, but wasn't.

this fixes a problem on devices with a h/w composer hal where
the rotation animation looked weird.

Change-Id: I4be8a2a1bde49c33456fcf5c8d87ab515c216763
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
c5953904ad6b6db1f48cf6d208ecf940f6a656d4 13-Aug-2011 Mathias Agopian <mathias@google.com> fix an orientation change drawing artifact.

a wrong orientation would be briefly shown when
rotation the screen. this happened when the window manager
set a custom transformation and the h/w composer was used.

the custom transformation was applied twice in that case.

Bug: 5037522
Change-Id: Ic1f87b63cd843f4475e4265d1624463825d775c4
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.
ad795baecccf239621cbffa0249c8e855296cae6 09-Aug-2011 Mathias Agopian <mathias@google.com> improve dumpsys SurfaceFlinger output

we now output the handle and size of all buffers of each layer.

Change-Id: I8d011ee4ae9199f4198bd07bed770ec3bcf02986
e8067a7d996105d9e03d75e6593e28b795fa9336 03-Aug-2011 Mathias Agopian <mathias@google.com> fix a crasher in surfaceflinger

this would happen if being told to draw before a buffer
was available.

Change-Id: I46d121c73e883078cdbf952063e38b0076f79038
a537c0f42e8077baafcbc65844adf1ec8397c040 03-Aug-2011 Mathias Agopian <mathias@google.com> update HWC data structures even when a layer is marked for SKIP

Change-Id: I16bcf44cd617814a14a795429bde2f39f411077d
dbe6486ca151d0eb1950be0aae347f0eb8ed3442 30-Jul-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: abandon Layer SurfaceTextures

This change makes the Layer::onRemoved method call
SurfaceTextures::abandon on the layer's SurfaceTexture. This will cause
all client-initiated operations on the SurfaceTexture to fail. In
particular, this will result in an error on the client side, rather than
a deadlock when removing a layer that used a SurfaceTexture in
synchronous mode.

Change-Id: I14014d00369f29560a21b606831edee432bb8867
Bug: 5020874
db5230f4441fa8f120f15bdd6fcfc6e75d9c27d0 28-Jul-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: fix a layer occlusion bug

This change fixes a bug where the window visibility would be computed
before any buffers were available, causing the window to be treated as
non-opaque. When the first buffer arrived, if both mCurrentOpacity and
the opacity determined by the buffer's format were 'opaque', a
recomputation of the opacity would not be done, and the window would
continue to be treated as non-opaque. SurfaceFlinger could then
unnecessarily draw fully occluded layers.

Change-Id: I2b95da2f4b50e68d50fc5afd8b772e26e62f58d6
Bug: 5057122
3fbce7c56082e4e0d23f1c1c89983d3841853ed7 26-Jul-2011 Mathias Agopian <mathias@google.com> remove dead code and member variables.

also fix some comments and improve debugging logs.

Change-Id: I83e55309f306332b59e1ec46104c4a7fffbf3c97
97c602c5af5f3ffd69009bf496d86347b71a2b4c 20-Jul-2011 Mathias Agopian <mathias@google.com> implement: "Add an ANativeWindow API for SurfaceFlinger to suggest an optimal buffer orientation"

Bug: 4487161
Change-Id: I883f34efe542c2a566d04966f873374f40c50092
933389f75814bb62e8153528f9cff2cb329b77df 19-Jul-2011 Mathias Agopian <mathias@google.com> use SurfaceTexture new scaling mode in SF

SF now obeys SurfaceTexture's scaling mode instead
of inferring it from the buffer's size

Change-Id: I4d50e9851abedd7e64bfcfc8af9eefb9fb668529
29a367bb7c14c916e991a6a0028727bd06c1e16e 12-Jul-2011 Mathias Agopian <mathias@google.com> take the state transform into account with h/w composer hal

if the state transform didn't preserve rectangles, we
would still try to use h/w composer hal using the bounds
of the transformed rect, which isn't correct.

now we correctly fall back to composition.

Change-Id: Iff78f4339ece415d4987e95a5717b04934d370ab
3d8063b02e06020c8062addcc9ec49048d3bdb9a 27-Jun-2011 Jamie Gennis <jgennis@google.com> SurfaceTexture: change onFrameAvailable behavior

This change alters the conditions under which the onFrameAvailable
callback gets called by the C++ SurfaceTexture class. The new behavior
is to call the callback whenever a frame gets queued that will be
visible to the buffer consumer. This means that buffers queued in
synchronous mode always trigger the callback, as those buffers will
remain pending until they are consumed. Buffers queued in asynchronous
mode will only trigger the callback if there was not previously an
unconsumed buffer pending.

The new behavior means that a consumer should perform a draw operation
exactly once for every onFrameAvailable call that it recieves. This
change also modifies SurfaceFlinger and the SurfaceTexture JNI to
support of the new behavior.

Change-Id: I8b2c6e00961d3d58b11c6af50b555b6e4c5f5b40
ddc31c3e2bc6ffe66695c385d23e8ccc3c6dad06 13-Jun-2011 Mathias Agopian <mathias@google.com> fix RefBase so it retains binary-compatibility with gingerbread

Bug: 4595257
Change-Id: I0d5e10f497e3f39868bff58f6ded510c38b44b12
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
342451d19f9e985912a413612ca6c1de5a13d339 20-May-2011 Mathias Agopian <mathias@google.com> Merge "Fix a race that could cause GL commands to be executed from the wrong thread."
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
3629d7ff29495aad453b08a86e9ede7e42afa786 17-May-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: unfreeze windows for fixed size buffers.

This change makes SurfaceFlinger unfreeze a window if it ever gets a
buffer that is fixed-size. Normally the window would not be frozen if
its in fixed-size mode, but if the window was frozen before entering
fixed-size mode then it should be unfrozen.

Change-Id: I6bc822d4b02ae51fa8914c1f60f5d24b2002b38d
345c6114dad73fad026fa0925cca133236091dc2 27-Apr-2011 Conley Owens <cco3@android.com> am ba5aebd1: am ac505b86: am f0556bb9: am 86d1d747: Merge "Add lock before calling initEglImage"

* commit 'ba5aebd106c61567ad6be905efd18902025735aa':
Add lock before calling initEglImage
ddc25bb92eb10ee40559424a75cac5e440b75575 27-Apr-2011 Conley Owens <cco3@android.com> am ac505b86: am f0556bb9: am 86d1d747: Merge "Add lock before calling initEglImage"

* commit 'ac505b86b45462d9883f9c36fad0ef85e0885ee4':
Add lock before calling initEglImage
0d11baf88920660cf0e30b25b7268a9459e8ffa5 15-Apr-2011 Kobi Cohen Arazi <kobic@codeaurora.org> Add lock before calling initEglImage

Without that lock, there is a chance of race condition
where while composing a specific index, requestBuf with
the same index can be executed and touch the
same data that is being used in initEglImage.
(e.g. dirty flag in texture)
3eb70b4a51979399aed9b0017a23151701d1ad0e 19-Mar-2011 Jamie Gennis <jgennis@google.com> am bd340c7b: am b368f4d8: am 38caff23: Merge "SurfaceFlinger: Fix a typo." into honeycomb-mr1

* commit 'bd340c7b492fcf7d0a6cccab8825e710c83fe76d':
SurfaceFlinger: Fix a typo.
5fd799dab602850b384d124c61096636f0988a93 19-Mar-2011 Jamie Gennis <jgennis@google.com> SurfaceFlinger: Fix a typo.

This change makes Layer skip its cleanup of its old shared memory region
when the UserClient object that owned the memory has been freed.

Bug: 3429357
Change-Id: I9e4d8eb190f6914dc043674b9bb8dd28e959901b
939fee8819ac714af6f99b1d8e0bd2ff6626a356 17-Mar-2011 Mathias Agopian <mathias@google.com> am e22aa623: am 25594e19: am f40e638e: fix [4093196] Device lock up - log spam with SharedBufferStack: waitForCondition(LockCondition) timed out

* commit 'e22aa62362a3007ee59ac62d4b5969e216987995':
fix [4093196] Device lock up - log spam with SharedBufferStack: waitForCondition(LockCondition) timed out
d0b55c011a311b677493ba72804bf1bc4df68224 17-Mar-2011 Mathias Agopian <mathias@google.com> fix [4093196] Device lock up - log spam with SharedBufferStack: waitForCondition(LockCondition) timed out

a memory corruption happned when the buffer pool was resized
(like when playing a video or using camera) and there was
no current active buffer. In this case, the faulty code
would index into an array at position -1 which corrupted
24 bytes of data.

also improved region validation code (ifdef'ed out by default)

Bug: 4093196
Change-Id: I915c581d131148959d720e00e3892e9186ab733d
5bf3abefb2745bf0c45b0814cfd44b4682060a6c 12-Mar-2011 Mathias Agopian <mathias@google.com> Fix initialization order warning.

Change-Id: I794dfaaa3a2f2645a89abc6c45de5f76e485f7d0
795f5ccf4788b791ff1042426be769ec51db6675 12-Mar-2011 Eric Hassold <hassold@google.com> Merge "Default to NONE format in Layer"
7ffe3807506da6f052535ca0c790636e41a8e310 11-Mar-2011 Eric Hassold <hassold@google.com> Default to NONE format in Layer

mFormat is not initialized with any value in Layer constructor, causing
a call to requestFormat() with no explicit format specified to fallback to
some uninitialized value. Such invalid path actually detected by valgrind.

Change-Id: Ib7faabcd61eaa26fb0ae7a9a486d9e258ba31b63
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
ab0225e3308c2cc6d399e967be16e766468437ac 23-Feb-2011 Eric Hassold <hassold@google.com> Merge "Correctly handle translucency of device-specific pixel formats"
a1f47b90ab53af978be45b8bda16c5d084ae66e6 16-Feb-2011 Mathias Agopian <mathias@google.com> fix a surface leak in SurfaceFlinger

SF kept a strong reference to ISurface until the
window manager removed the surface from the screen.
This fell appart when running standalone tests, that is
when the window manager wasn't involved.

When the window manager is around, it would clean-up surfaces
even when an application died.

with this change, SF is able to do its own cleanup without
relying on the window manager.

the change is very simple, we simply don't keep a reference
to ISurface and make sure no more than one of them can
be created.

Change-Id: I61f2d7473bf8d4aa651549a846c34cdbb0d0c85a
ac45e6bff1b41acd35c981291b37b23f8e083cee 10-Feb-2011 Eric Hassold <hassold@google.com> Correctly handle translucency of device-specific pixel formats

Check requested format for device-specific formats, and assume (as
documented in libhardware/include/hardware/hardware.h) this is opaque
layer so no blending is necessary.

Bug: 3215931
Change-Id: Ib4dff8060ac522d201ff1e74807ac340c17d3fa7
3cbe436bfd71b888ff9de97242cc976015b5b635 29-Jan-2011 Mathias Agopian <mathias@google.com> am 8d778b37: am 231da079: Merge "fix [3389263] OMX.Nvidia.h264.decode fails to shutdown" into honeycomb

* commit '8d778b375ccb4945cdcd7cc93272a6d36466ad00':
fix [3389263] OMX.Nvidia.h264.decode fails to shutdown
3cc2677efc2a4bc06297b9667ac529284f6abf9d 29-Jan-2011 Mathias Agopian <mathias@google.com> fix [3389263] OMX.Nvidia.h264.decode fails to shutdown

We were still destroying an ANativeWindow's buffer pretty soon
after it was removed from the window manager. This time
we really wait for the ISurace to go away.

Change-Id: I329273fedaeef76ee92836f6180c2c3808389330
16f0453fee84c6aad59fe0d1c7d36f061d46cffc 20-Jan-2011 Glenn Kasten <gkasten@google.com> Protected surface API

To be used by DRM framework, implemented by display HAL

Change-Id: I054a07a94f4d5dbe792f3a597e2e49a100d90eb2
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.
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
420a283c4dc2a669c93bd5c0a2180b14f3625501 15-Dec-2010 Mathias Agopian <mathias@google.com> Fix a problem where hwc and GL composition could show a different buffer

if a surface's buffers are reallocated, the current active buffer will
end-up pointing on one of these until a new buffer is retired.

we're now keeping a reference to the actual buffer until we retire a
new one.

Change-Id: Ib1703947e7a0340694d846e0962576318863b935
da9584dc295cc5e6d0b49a97c1e45159249d650b 14-Dec-2010 Mathias Agopian <mathias@google.com> fix [3223749] media server crashes when switching mode from video capture to still image capture

there was an issue were in some situation SF would call prepare() on hwc
with a NULL handle and never call prepare again.
in this situation, we onw set the SKIP flag to make sure that hwc
won't process this layer and as soon as we receive our first buffer we
trigger a recompute of the visible regions which will end-up calling
prepare() again.

Change-Id: I6b400b2df79712408b9315a9859290c7fcb1609e
dd17b3eaa99f761e265ff457e335b5a0ff83dafb 14-Dec-2010 Mathias Agopian <mathias@google.com> fix [3176642] Camera preview turns completely black for multiple toggles between camera and camcorder app

There was a leak of Surface tokens when a surface was detached from a UserClient.
We now always detach a surface from its client before attaching to the new one,
this guarantees that its token is freed.

Change-Id: Icfad0b16286ed58155bdfafdf36ab161440aa485
f345069099a13f0c2dd91f1fa92786643e4becb0 09-Dec-2010 Mathias Agopian <mathias@google.com> [3211070] camera preview image is rendered offset from the UI overlay frame

somehow this change got lost.

Change-Id: I36f6c7ef3f782918042b77e9dc91a4c811d84a40
86bdb2f918ffd238d6e0d1ae1f95af882f04d6cb 09-Dec-2010 Mathias Agopian <mathias@google.com> fix [3260137] Sometimes front-facing camera mirroring is wrong

make sure to take the buffer's orientation into account.

Change-Id: I9fef89e66368ad2dec1cb8c7b77ac2b3b4858efb
a1aa18fc267a7d2db99b3cbc39907127bcdf6ac6 08-Dec-2010 Mathias Agopian <mathias@google.com> resolved conflicts for merge of a0f011ff to master

Change-Id: I4c17021fc269ce66c98cc345353600eda332f980
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
b5a00fcb71426492f248ed49a0514a9b8d385065 08-Dec-2010 Mathias Agopian <mathias@google.com> am 48f42f8c: am 4153bf3a: Merge "[3171580] don\'t automatically log GraphicBuffer allocation failures" into gingerbread

* commit '48f42f8c3fbd33b2f46c6290ff5963dd58938cf9':
[3171580] don't automatically log GraphicBuffer allocation failures
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
733189d408e13b54fd70971b265244367efd0f51 03-Dec-2010 Mathias Agopian <mathias@google.com> [3171580] Fix two typos related to fixed-size buffers

mFixedSize was never set, this bug was introduced during some "cleanup", in
practice this could cause some issues when a fixed-size buffer was used and
the window was resized.

Layer::drawForSreenShot() had a typo that had no effect.

mFixedSize was used to determine if filtering was needed, which was a bit too
conservative and created a dependency between filtering and "fixed size" states
which should exist.

Now we enable filtering based on the size of the buffer vs. the size of the layer.

Change-Id: I32044e91b0c944c1b137efdceb3f01dfaa78119d
678bdd6349344df254cc0c3377a40fd99e216635 04-Dec-2010 Mathias Agopian <mathias@google.com> [3171580] don't automatically log GraphicBuffer allocation failures

some of these failures are not fatal and even expected in some cases
so they should not emit a dump in the log in those cases.

Change-Id: Idcfa252e3bfa9d74e27fe4ad8f8623aa01aa9c5e
040481419473cb9913b632cd8973b1d7065f9c9c 01-Dec-2010 Louis Huemiller <lhuemill@google.com> Remove const_cast to layer handle

Change-Id: Ica1e089cb56b5f9f46ab87abf735ffe7237fc926
54cc83e8a48c57307cdd40fe4b7e296020490095 02-Nov-2010 Jamie Gennis <jgennis@google.com> Implement reducing the buffer count of a Surface.

Change-Id: I7f979c60c06d654aa8265002836277434bc1a64f
Bug: 3095167
3b996c96e4cd1057cb6b9531eaf8c01f934d2b2a 10-Oct-2010 Romain Guy <romainguy@google.com> Always create OpenGL accelerated windows in RGBA 8888.

Bug #3081600

The OpenGL renderer in libhwui uses a single EGL context per process and
thus create it with an RGBA 8888 EGL configuration. To ensure that all
windows are compatible with this configuration, this change modifies
the window manager and SurfaceFlinger.

The window manager now checks the window's flags and if the window is
hardware accelerated, it forces the window's pixel format to be
translucent when creating the surface. The window itself is still
marked as opaque if we know that the window will be opaque on screen.
This keeps existing optimizations in place.

Similarly in SurfaceFlinger, a translucent Surface can now be created
with the Surface.OPAQUE flag, indicating SurfaceFlinger that the surface
does not require blending, despite its RGBA 8888 configuration.

Change-Id: Ic747b6b12564ba064412d842117880fcc199eb7c
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
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
e44d21a247aac5192b8ef397d433a4aefb6ba53e 21-Sep-2010 Mathias Agopian <mathias@google.com> fix [3018216] UI shrinks / stretches while using apps with IME

Change-Id: Ie4c5d8a434b4489355ed8c52af96eb931b4d7167
5dda7f7cf23a02fff2e35d7eb6bb7c9f0d620f95 17-Sep-2010 Jamie Gennis <jgennis@google.com> Fix a SurfaceFlinger bug.

The bug caused SurfaceFlinger to constantly trigger reallocation of buffers
that requested a fixed size.

Change-Id: Ic993a60e6474e36a344c8b48d541a0d08b8c4faf
413f750501c4392e096c7bed27af0764cbadeb94 26-Aug-2010 Mathias Agopian <mathias@google.com> am 6d4346ce: am 4cffbb47: Merge "fix [2946787] Screen flicker on low resolution setting in camcorder." into gingerbread

Merge commit '6d4346ce35a521d67f45d7c9658c450c0fc461d2'

* commit '6d4346ce35a521d67f45d7c9658c450c0fc461d2':
fix [2946787] Screen flicker on low resolution setting in camcorder.
eff062c49e858d0dd94a1e57f6115bc84dba103e 25-Aug-2010 Mathias Agopian <mathias@google.com> fix [2946787] Screen flicker on low resolution setting in camcorder.

Change-Id: I7e86f2b6d85dcae8dd212890b978fa6ac7de6893
e34a3d1a294e1d83caa410f3006e474bef787e1a 25-Aug-2010 Mathias Agopian <mathias@google.com> am 46820412: am 8eb16af2: Merge "don\'t try to lock a buffer that wasn\'t allocated with SW usage bits" into gingerbread

Merge commit '468204124e95bbf74ae8cc000318ade29e311be6'

* commit '468204124e95bbf74ae8cc000318ade29e311be6':
don't try to lock a buffer that wasn't allocated with SW usage bits
f1b38247d4d9c2ddc7315a72b609a95e0ed8050f 21-Aug-2010 Mathias Agopian <mathias@google.com> don't try to lock a buffer that wasn't allocated with SW usage bits

Change-Id: Iabbcec1bfa30dc47d45ece699dd178653f1b675b
4ad298c12c43563789fd2213428347caf2f74c64 25-Aug-2010 Mathias Agopian <mathias@google.com> am bc4389ed: am 8395b462: Merge "fix [2931513] Add support for setting the orientation of an ANativeWindow" into gingerbread

Merge commit 'bc4389edfbb5777aec1a9af7863b2ca3ade2fa64'

* commit 'bc4389edfbb5777aec1a9af7863b2ca3ade2fa64':
fix [2931513] Add support for setting the orientation of an ANativeWindow
b661d66013b9803c50dc78ca0247ac39caef443a 20-Aug-2010 Mathias Agopian <mathias@google.com> fix [2931513] Add support for setting the orientation of an ANativeWindow

Also implement support for cropping.

Change-Id: Iba5888dd242bf2feaac9e9ce26e404c1f404c280
000ca8fa9a1a92aa2f132ba41d11ece6d01cdadd 18-Aug-2010 Mathias Agopian <mathias@google.com> revert hwcomposer HAL changes. DO NOT MERGE.

This reverts commit:
a350ff98692b3a50cad5cc93f9f83221242ca86a 11-Aug-2010 Mathias Agopian <mathias@google.com> call into hwcomposer HAL when present

Change-Id: I70f31c69a9436a43860e78977442863ecba6d27b
208cb0772429b9ac800010829ecc7b854bdc2d24 28-Jul-2010 Mathias Agopian <mathias@google.com> fix [2873058] Surface::dequeueBuffer blocks on last buffer, i.e. cannot dequeue all allocated buffers at once.

this situation happened when the last buffer needed to be resized
(or allocated, the first time). the assumption was that the buffer
was in use by SF itself as the current buffer (obviously, this
assumption made no sense when the buffer had never been allocated, btw).

the system would wait until some other buffer became the "front" buffer.

we fix this problem by entirely removing the requirement that the
buffer being resized cannot be the front buffer. instead, we just
allocate a new buffer and replace the front buffer by the new one.

the downside is that this uses more memory (an extra buffer) for a
brief amount of time while the old buffer is being reallocated and
before it has actually been replaced.

Change-Id: I022e4621209474ceb1c671b23deb4188eaaa7285
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