History log of /frameworks/native/services/surfaceflinger/Layer.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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
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
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
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
830f5004da53a83e23b4102ba9b72e4cb366cb34 25-Mar-2016 Pablo Ceballos <pceballos@google.com> Merge "SF: Add FenceTracker" into nyc-dev
acbe67888f0bd65d5400400f0115bae6bd6199dc 04-Mar-2016 Pablo Ceballos <pceballos@google.com> Add final crop implementation

Bug 26559810

Change-Id: Idaccd13cd625c92d18665ddecebdbb266ea365f3
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
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
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
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
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
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
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
dc13c5b85b099050c73297a19f1ef89308f7620b 12-May-2015 Dan Stoza <stoza@google.com> libgui: Hook up onFrameReplaced

This completes the plumbing from ConsumerListener::onFrameReplaced into
SurfaceFlinger (and other consumers that may care).

Change-Id: I376e78ace95d6748e8662e6b4d47c0dfa697a300
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
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
0ea1cb91954ac1ad0973a6b9482dcb2fee2449f5 23-Sep-2014 chenhg <chenhg@marvell.com> surfaceflinger: Check sideband stream changed to trigger sideband Layer update.

BUG: 17382907
Change-Id: I65fd037bd25238ae68a3976468ae7fd7ce49c562
a02e9484be6894f8a4db7049d432f534a4e0a676 31-Jul-2014 Eric Penner <epenner@google.com> Merge "SurfaceFlinger: Prevent deadlock by updating an atomic layer set." into lmp-dev
51c59cd1e73be3787eb75bebd87fc41739c65adb 29-Jul-2014 Eric Penner <epenner@google.com> SurfaceFlinger: Prevent deadlock by updating an atomic layer set.

Bug: 12934849

Change-Id: I9dede7316f1e967de4140bd731ac810115ea302f
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
4df87bd1f6f68126e5e9081fc1365ae500e375db 22-Apr-2014 Andy McFadden <fadden@android.com> Update HWC dump format

Shortens a few fields. Displays the format as a string.

Change-Id: Ib471f05603763e250bad165db610f8e173e8423a
d85084b2b65828442eafaff9b811e9b6c9ca9fad 20-Mar-2014 Svetoslav <svetoslavganov@google.com> Adding render stats APIs to UiAutomation (framework native).


Change-Id: Ibb1c07f7d89e11281e5c1f27f412a29ac6f9c4ab
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
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
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
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
6547ff4327aa320fbc9635668d3fc66db7dd78f6 17-Jul-2013 Jamie Gennis <jgennis@google.com> surfaceflinger: add frame duration logging

Change-Id: Ib414a45e7e191f23a2726cbbbeb606e9ce68a3b5
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
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
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
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
2f73af9212487c81d31d07227fa8a2f4abc77638 06-Mar-2013 Mathias Agopian <mathias@google.com> Make LayerDim a regular Layer instead of a LayerBase

this is in preparation to get rid of LayerBase entirely

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

Change-Id: Ic745136522df59c42f0885fd969e75ea55d09f01
306f18c5fb15ac05db09ece7241af02b9713a23d 05-Mar-2013 Mathias Agopian <mathias@google.com> Merge "rework screenshot API and implementation" into jb-mr2-dev
2a9fc493dfdba67108e4335bb1fe931bc1e2a025 01-Mar-2013 Mathias Agopian <mathias@google.com> rework screenshot API and implementation

- SurfaceFlinger now supports to take a screenshot
directly into an IGraphicBufferProducer

- reimplement the IMemoryHeap screenshot on top
of the above

- reimplement LayerScreenshot such that its
BufferQueue is directly used as the destination
of the screenshot. LayerScreenshot is now a thin
wrapper around Layer

Bug: 6940974

Change-Id: I69a2096b44b91acbb99eba16f83a9c78d94e0d10
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
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
882e3a39ed770b335a203e233b57127fde1c839e 09-Jan-2013 Andy McFadden <fadden@android.com> Add some comments.

Also, minor tweak to SurfaceTextureLayer.

Change-Id: If616d5ee4e8226dd0e16c5dbb0e0f80db553110e
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
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
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
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
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
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
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
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
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
b267579ba8dfe3f47d2a481c5a3c2254e3d565a1 23-Feb-2012 Daniel Lam <dalam@google.com> SurfaceTexture: Fully refactored from BufferQueue

SurfaceTexture and BufferQueue are separate objects.

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

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

Change-Id: I7d350bc05d1596655baddff3deaebaba58c9bcc0
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
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
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
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
fb4d5d5726c172adbe62341d99a2148685a98379 21-Sep-2011 Mathias Agopian <mathias@google.com> improve hwc dumpsys

we now log the buffer's format

Change-Id: I9d3ad8018e884240a153de3baefb6331cb014d0f
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
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
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.
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
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
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
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
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
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
a1aa18fc267a7d2db99b3cbc39907127bcdf6ac6 08-Dec-2010 Mathias Agopian <mathias@google.com> resolved conflicts for merge of a0f011ff to master

Change-Id: I4c17021fc269ce66c98cc345353600eda332f980
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
54cc83e8a48c57307cdd40fe4b7e296020490095 02-Nov-2010 Jamie Gennis <jgennis@google.com> Implement reducing the buffer count of a Surface.

Change-Id: I7f979c60c06d654aa8265002836277434bc1a64f
Bug: 3095167
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
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
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