History log of /frameworks/native/libs/gui/BufferQueueProducer.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2672decb92fa24ef012cbbd3690c120530fa3cd3 14-Jun-2017 Eino-Ville Talvala <etalvala@google.com> BufferQueueProducer: Call onBuffersReleased() in detachNextBuffer

Like detachBuffer(), detachNextBuffer() needs to inform the consumer,
who generally has a cache of buffer items, that a buffer is no longer
owned by the buffer queue.

Otherwise the consumer layer can leak the buffer reference until
consumer teardown/disconnect.

Test: Camera CTS is fine, using a camera app shows correct memory
behavior
Bug: 62591036

Change-Id: I14c200d13e60dbbe21261343941f84fb786db117
/frameworks/native/libs/gui/BufferQueueProducer.cpp
feec3b1a49dbf48bc792d39d004b42cf2c72b14c 25-May-2017 Chia-I Wu <olv@google.com> libgui: fix BQ buffer allocation error checking

The error path was broken since we moved away from
IGraphicBufferAlloc.

Bug: 37956614
Test: simulate buffer allocation failures
Change-Id: I1e1ec840fafd3075b84126c6dbf6194568175a42
/frameworks/native/libs/gui/BufferQueueProducer.cpp
c5cd20733795a0fe1f1ba228ec099c4c7e6dbaa7 23-Feb-2017 Jammy Yu <jammy.yu@mstarsemi.com> Fix error BufferQueue attaching flow.

Fix error BufferQueue attaching flow. Because BufferQueue attaching
buffer flow doesn't set mNeedsReallocation to false, it will case
Surface client to request buffer for attached buffer to cause unsync
buffer states with ACodec. So, for attaching buffer by Producer, we
need to set mNeedsReallocation to false in BufferQueue. And Surface
client will not request buffer again for attached buffer to cause
some missing frames.

Bug: 38238747
Issue: 34897483
Test: GTS
Change-Id: I25f9fff4b5d1f7052ab3be612cf34879fd17c27c
/frameworks/native/libs/gui/BufferQueueProducer.cpp
2041913a05b79b96c5c084f30bb8944049a976c8 22-Apr-2017 Jiwen 'Steve' Cai <jwcai@google.com> BufferQueue: plumbing mConsumerIsProtected

This replaces current logic in BufferQueue that uses
GRALLOC_USAGE_PROTECTED to indicate whether an ANativeWindow is capable
of handling hardware protected gralloc buffers. Current logic is
problematic as it enforces producer to use protected buffer no matter
whether producer side is capable of writing into a protected buffer.

This new solution, however, introduces a new NATIVE_WINDOW_* flag that
consumer can set on IGraphicBufferConsumer to indicate its capacity,
which can then be queried by producer via Surface::query (or
IGraphicBufferProducer::query).

When consumer is capable of reading protected buffer (e.g. a protected
GL context), the producer can generate either a protected or unprotected
buffer.

When consumer is not capable of reading protected buffer, the producer
should only generate unprotected buffer.

Bug: 35726763
Test: videoplayer-nodrm-protected.apk and videoplayer-drm-protected.apk
both works.

Change-Id: I1bf6814c9f1f81f9e04f0e89646b0733ff1a4758
/frameworks/native/libs/gui/BufferQueueProducer.cpp
f3ef3eab3aaae979c48ef03d27c5004f357b3d03 20-Apr-2017 Chris Forbes <chrisforbes@google.com> gui: Adjust for libui gralloc flags change

Change-Id: I9f73a1753f9e991eb3a7f0a005c3ab240f0a38b4
Bug: b/33350696
Test: Bullhead: booted to launcher, take photo, watch youtube
/frameworks/native/libs/gui/BufferQueueProducer.cpp
fc333972e92e176ea73b34c5c6c25fc5875140be 19-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Return error when trying to disconnect twice" into oc-dev
0556d79eacbf0c9978080d87aa4075120533c7ef 22-Mar-2017 Mathias Agopian <mathias@google.com> get rid of IGraphicBufferAlloc

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

Test: marlin: run full camera cts
Test: angler: take screenshot, take photo w/ and w/o HDR, video, panorama, refocus, slo-mo
Bug: 36462585
Bug: 36333314
Change-Id: Ie5222c53c3b9462e0ac7a41568718aad131eb328
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3e198b2b331c09e8d078b5cd4cb770bcf049c0d1 08-Apr-2017 Wonsik Kim <wonsik@google.com> Return error when trying to disconnect twice

Bug: 34637488
Bug: 36737364
Test: cts-tradefed run cts-dev --module Graphics
Test: libgui_test
Change-Id: I9deb1e8978e3789269ed1cf9753892b68f246e0f
/frameworks/native/libs/gui/BufferQueueProducer.cpp
4f6ce7c7b839da76c1542b41816764e05413af99 04-Apr-2017 Mathias Agopian <mathias@google.com> fix race condition that can cause a use after free

Bug: 33004354
Test: manual
Change-Id: I9b38ee644b02268c9b995a330db758aa2e568399
/frameworks/native/libs/gui/BufferQueueProducer.cpp
f8b4ca51111cd2e566d1774ac464da859db78976 16-Mar-2017 Romain Guy <romainguy@google.com> Revert "Get rid of IGraphicBufferAlloc"

This reverts commit 78491c9f694cb0767996503c629776a8eda950d7.

Change-Id: I78d5c0a30ab80265f697f681387872b6763b2d1e
/frameworks/native/libs/gui/BufferQueueProducer.cpp
78491c9f694cb0767996503c629776a8eda950d7 15-Mar-2017 Mathias Agopian <mathias@google.com> Get rid of IGraphicBufferAlloc

This reverts commit 527747dce1ab4714bd424e5c1a25ebad3506c2cb.

selinux policy allowing this change fixed.

Test: took a screenshot
Test: ran ImageReaderTest CTS
Bug: 36194109
Change-Id: I72ac17b6c252750aa2a66cd1d94bd8b4e21b5e9d
/frameworks/native/libs/gui/BufferQueueProducer.cpp
527747dce1ab4714bd424e5c1a25ebad3506c2cb 13-Mar-2017 Chia-I Wu <olv@google.com> Revert "get rid of IGraphicBufferAlloc"

This reverts commit 1da94dfed674e94edc37cdc8ef68530520edf169.

Bug: 36176799
Bug: 36175706
Change-Id: I6dd5fe8df564f0efa4392a800fb316e27a05076e
/frameworks/native/libs/gui/BufferQueueProducer.cpp
1da94dfed674e94edc37cdc8ef68530520edf169 28-Feb-2017 Mathias Agopian <mathias@google.com> get rid of IGraphicBufferAlloc

buffers can now be allocated in-process.

Test: compile & run
Bug: cleanup
Change-Id: I3d4317a9bed20a6d8be2b7ac8fbb85738efb3657
/frameworks/native/libs/gui/BufferQueueProducer.cpp
f810b29ebc8564f94ff7fb14f2d13a0f4d111703 17-Feb-2017 Brian C. Anderson <brianderson@google.com> Merge changes from topic 'GPU_replace_GL'

* changes:
Fix unexpected FrameEvents on BufferQueue reconnect
Add FrameEvents::isValidTimestamp
Change GL references to GPU for getFrameTimestamps.
Clean up FrameTimestamp log messages.
5ac51484b293cc0ad08562b03c405721b0bdbc71 17-Feb-2017 Chong Zhang <chz@google.com> Verbose logging when API_MEDIA is force-disconnected

Media is seeing intermittent failures during CTS when mediaplayer
connected to a surface successfully but subsequent dequeueBuffer
fails. We suspect that media is getting force-disconnected. Adding
a verbose log when this happens to help track down the failure.

bug: 35364355

Change-Id: I0c48e3d141648a3d08c6abeb6793f8363e9502fc
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
--gtest_filter=*GetFrameTimestamps*

Change-Id: I64f314be72ddb154b584d726ac382cd468e345bf
/frameworks/native/libs/gui/BufferQueueProducer.cpp
22f842ba04c32cef2faf855dc304eb0ab131b9ec 19-Jan-2017 Shuzhen Wang <shuzhenwang@google.com> BufferQueue: Add bufferReplaced flag in QueueBufferOutput

For async buffer queue, when queueBuffer overwrites a previously queued
buffer, because consumer won't be able to acquire the overwritten
buffer, onBufferReleased isn't triggered either.

This makes it difficult to track which buffer in the buffer queue
becomes free other than calling dequeueBuffer(). Adding a flag in
QueueBufferOutput addresses this issue.

Test: TestBufferReplacedInQueueBuffer in BufferQueue_tests
Bug: 34481539
Change-Id: Ic7f4be2d3f9691dd6b007a450240614c0c420f0d
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3d4039d7a291cd9b6f2dd4b46fcdb576f2db3356 24-Sep-2016 Brian Anderson <brianderson@google.com> Use FenceTime to share fence times and reduce open fds.

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

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

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

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

Change-Id: Ifd4301affe1b24705b2bee7608c5a2c09dfb4041
/frameworks/native/libs/gui/BufferQueueProducer.cpp
7c3ba8aa288755fad78ddbabcee0ad5a0610ac1c 25-Jul-2016 Brian Anderson <brianderson@google.com> Update producer's cache of frame events in de/queue

* Cache is only updated during queue and dequeue if
the getFrameTimestamps is enabled.
* The consumer avoids sending a copy of the acquire
fence back to the producer since the producer
already has a copy.

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

Change-Id: I6a8b965ae79441a40893b5df937f9ed004fe7359
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3890c3995c4a52439844faeb80b5503d42b977d8 25-Jul-2016 Brian Anderson <brianderson@google.com> Cache frame event history producer-side.

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

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

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

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

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

Change-Id: I868c2ef93964656d7e41848243433499e7f45fe7
/frameworks/native/libs/gui/BufferQueueProducer.cpp
e52d9e2acec131484588a2eb184d1d4b34eebeb3 15-Nov-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add layered buffer support to libui and libgui."
8c015e29b5dfae55bbb8f78f5ef88ee2744cf0cd 15-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020 am: d073eb7a3f am: 230b943c6b am: a928cc7169 am: 0517da2c5a am: b0dff427a1 am: 1852db9aa3 am: d4f7a66cf6 am: 0646227ad2 am: b4bd9606e0
am: 0bc4216678

Change-Id: Ica5b683c1c224e847db25d7ba192ba6d80ef9704
0bc421667819f0ae0928834935af1534495f45f8 15-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020 am: d073eb7a3f am: 230b943c6b am: a928cc7169 am: 0517da2c5a am: b0dff427a1 am: 1852db9aa3 am: d4f7a66cf6 am: 0646227ad2
am: b4bd9606e0

Change-Id: I738237f426b898a05cb9511dbc0a768e7cc00cdf
0646227ad2e6c1aaddc40fc871554b51a953fa29 15-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020 am: d073eb7a3f am: 230b943c6b am: a928cc7169 am: 0517da2c5a am: b0dff427a1 am: 1852db9aa3
am: d4f7a66cf6

Change-Id: I468e9387f0541fc22d71179ff6e05397f99e4dce
d4f7a66cf698f6229553980593d81cff80f02c77 15-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020 am: d073eb7a3f am: 230b943c6b am: a928cc7169 am: 0517da2c5a am: b0dff427a1
am: 1852db9aa3

Change-Id: Ief2e221eb25138131d4b9fe19b669dca26dd1726
1852db9aa3e558c0a601d6b15c45214b0c6deff1 15-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020 am: d073eb7a3f am: 230b943c6b am: a928cc7169 am: 0517da2c5a
am: b0dff427a1

Change-Id: If61fab86a971de18633549240d32f41205bc52e9
b0dff427a1dd35598085a58d48ebf83260583cbf 15-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020 am: d073eb7a3f am: 230b943c6b am: a928cc7169
am: 0517da2c5a

Change-Id: Ie25ecd20988d9aa8d3f59b07d00b80c0a18d5e3a
6ebc46a7c01b22bc19d3c00b493f8d930b15b43a 22-Oct-2016 Craig Donner <cdonner@google.com> Add layered buffer support to libui and libgui.

Bug: 31686534
Test: manual
Change-Id: Ia40270701467f4b785660324cad883e7da08989a
/frameworks/native/libs/gui/BufferQueueProducer.cpp
d073eb7a3f28fd74bfa24c8b7599465cb7de5436 09-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix SF security vulnerability: 32706020

Because of lack of mutex lock when get mConsumerName, if one thread
getConsumerName, another thread setConsumerName frequently, an UAF will
be triggered.

Change-Id: Id1bbf0d15de6d16def2f54ecade385058cda3b65
Test: Marling with poc provided in bug report.
Bug: 32706020
/frameworks/native/libs/gui/BufferQueueProducer.cpp
59ea1049746e67065864928b1350a2edd78cdc4f 07-Oct-2016 Matthew Bouyack <mbouyack@google.com> resolve merge conflicts of 3b8e6b2 to nyc-mr1-dev-plus-aosp
am: 20e9085b51

Change-Id: I5b8f075d9a42ab3de359dc9bef9767d23af493d2
20e9085b51c00b7828e3a8fdfe902adc1c89a924 07-Oct-2016 Matthew Bouyack <mbouyack@google.com> resolve merge conflicts of 3b8e6b2 to nyc-mr1-dev-plus-aosp

Change-Id: I9c02a56d63de5828453aa8926ca801d96b04a6cf
3b8e6b2f30af0564538c2a660033d6a97ab8038f 04-Oct-2016 Matthew Bouyack <mbouyack@google.com> Eliminate unnecessary calls to onBufferReleased

This change adds a callback to ProducerListener to indicate whether the
listener needs the 'onBufferReleased' notification. This allows us to
avoid making that binder call unnecessarily, saving ~170us per frame on
Android Wear.

By default the new callback returns true, so behavior for existing
clients should be unchanged. Only the DummyProducerListener returns
false.

Also note that it would be simpler to just pass NULL for the
ProducerListener if not for that fact that we still need it for death
notification.

Bug: b/31122630

Change-Id: I730834218a055d89e89f876dd77da8127eb78000
/frameworks/native/libs/gui/BufferQueueProducer.cpp
6e7e2b44efa6427cc106b20cea76d9a80dadcac9 27-Sep-2016 Colin Cross <ccross@android.com> Fix logging implicit sign conversions

The warnings were being hidden by the use of -isystem to include
frameworks/native/include.

Bug: 31752268
Test: m -j
Change-Id: I2ce11db524ee9d8f846fdf3ed6fb882d5ef57956
(cherry picked from commit 152c3b749a8ec634afc66dddef7d33130472aeb1)
/frameworks/native/libs/gui/BufferQueueProducer.cpp
152c3b749a8ec634afc66dddef7d33130472aeb1 27-Sep-2016 Colin Cross <ccross@android.com> Fix logging implicit sign conversions

The warnings were being hidden by the use of -isystem to include
frameworks/native/include.

Bug: 31752268
Test: m -j
Change-Id: I2ce11db524ee9d8f846fdf3ed6fb882d5ef57956
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3d0becdcec3f27880b345bd05f2120c1f7e668df 23-Sep-2016 Robert Carr <racarr@google.com> Surface: Add force disconnection method. am: 97b9c86338 am: 962b13b9be
am: a9d1c1099d

Change-Id: Iea981cfaddd2be6ecdfebbdfadd9d822f17d682f
97b9c86338e2d364d47ea7522c2d81a8014f0e07 08-Sep-2016 Robert Carr <racarr@google.com> Surface: Add force disconnection method.

Add a new method forceScopedDisconnect to Surface. This will
be used by the framework to force disconnection at times where
the underlying GraphicBufferProducer may be about to be reused.
This is scoped by PID to avoid conflicting with remote producers.

Bug: 30236166
Change-Id: I857216483c0b550f240b3baea41977cbc58a67ed
/frameworks/native/libs/gui/BufferQueueProducer.cpp
a1d24b45ccb6f68448f478e2a847a5544276002b 23-Aug-2016 Dan Stoza <stoza@google.com> Add requestor name to GraphicBuffer alloc metadata

Adds a requestor name (usually the BufferQueue consumer's name) to the
metadata that GraphicBufferAllocator stores on allocation so that
`dumpsys SurfaceFlinger` can attempt to attribute buffer usage to the
correct client.

Bug: 30776557
Change-Id: I6e0f346584c871bb3b9d5481f82b697b0475a916
/frameworks/native/libs/gui/BufferQueueProducer.cpp
024e9313ce69ced1f853d737de680ef9f50ed26d 24-Aug-2016 Dan Stoza <stoza@google.com> Add requestor name to GraphicBuffer alloc metadata

Adds a requestor name (usually the BufferQueue consumer's name) to the
metadata that GraphicBufferAllocator stores on allocation so that
`dumpsys SurfaceFlinger` can attempt to attribute buffer usage to the
correct client.

Bug: 30776557
Change-Id: I6e0f346584c871bb3b9d5481f82b697b0475a916
/frameworks/native/libs/gui/BufferQueueProducer.cpp
d4079aff759713e7c7dd14cecb585a7290e80772 23-Aug-2016 Dan Stoza <stoza@google.com> Add requestor name to GraphicBuffer alloc metadata

Adds a requestor name (usually the BufferQueue consumer's name) to the
metadata that GraphicBufferAllocator stores on allocation so that
`dumpsys SurfaceFlinger` can attempt to attribute buffer usage to the
correct client.

Bug: 30776557
Change-Id: I6e0f346584c871bb3b9d5481f82b697b0475a916
/frameworks/native/libs/gui/BufferQueueProducer.cpp
468051e20be19130572231266db306396a56402b 14-Jun-2016 Irvel <irvel@google.com> Integrate SurfaceInterceptor into SurfaceFlinger

Change-Id: If18d967f2b69ed219f17a9afedb61884ad5f1dc8
/frameworks/native/libs/gui/BufferQueueProducer.cpp
bd3577ef5bae7d65e54bddc04f90b619330edb89 21-Jun-2016 Pablo Ceballos <pceballos@google.com> Make sure constructors initialize all members

- Add default constructors to Parcelables that didn't have them and
make sure all members are initialized by the constructors.
- Add missing fields to BufferItem flatten/unflatten.

Change-Id: I9aa83b326dc3aee757762e63be499dc96a74df91
/frameworks/native/libs/gui/BufferQueueProducer.cpp
bc8c1928e1dbdaf6a2820f6e426c96ed61284043 01-Jul-2016 Pablo Ceballos <pceballos@google.com> BQ: Remove getNextFrameNumber Binder call

- Return the value in queueBuffer instead and cache it in Surface

Change-Id: I10ab112afb03cf0231b047d4a4569cd641827043
/frameworks/native/libs/gui/BufferQueueProducer.cpp
0ade247d4b02b81f323480b4ba043927f6b36a73 01-Jul-2016 Pablo Ceballos <pceballos@google.com> resolve merge conflicts of 8e3e92b to nyc-mr1-dev

Change-Id: Ic67f0894e68ea5276eb9187a13cd24f105d55d68
0a0680945710946f3bf01ae05f933ccec4162dc8 30-Jun-2016 Pablo Ceballos <pceballos@google.com> BQ: Handle buffer allocation failure

Return the slot to the mFreeSlots if we fail to allocate.

Bug 29873396

Change-Id: Icafc5c64c7233d47e160f7a56e5a314e4a01611d
/frameworks/native/libs/gui/BufferQueueProducer.cpp
8e3e92b906db431c4fa822f21242977d4ee99942 28-Jun-2016 Pablo Ceballos <pceballos@google.com> BQ: Add and expose a unique id

Bug 29422927

Change-Id: I80eab94f073ebc378302f00fa86a740c3643657e
/frameworks/native/libs/gui/BufferQueueProducer.cpp
e38b57e2d454b9fafc088ef9efda88ada3267dbf 18-Jun-2016 Eino-Ville Talvala <etalvala@google.com> Merge \"BufferQueueProducer: Signal consumer when a buffer is detached\" into nyc-dev
am: 51ed38bb13

Change-Id: I7f901c66dd9e2f62bdc15c8b768f27003aa46611
93dd0518a0101844ef435a3425c803c986b38d87 10-Jun-2016 Eino-Ville Talvala <etalvala@google.com> BufferQueueProducer: Signal consumer when a buffer is detached

When a buffer is detached, it should be cleared from the consumer-side
cache as well.

Not doing so can leak buffers no longer owned by the queue for extended
lengths of time, depending on the exact usage patterns of the producer
and consumer.

Bug: 28695173
Change-Id: I2c618be51f2c827d92d0e19b92a2d5befda87c38
/frameworks/native/libs/gui/BufferQueueProducer.cpp
9e8143ec78a0bf3779f12000b67f21b8fba6e2a7 09-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "Plumbing for getting FenceTracker timestamps" into nyc-mr1-dev
ce796e78a57018f186b062199c75d94545318aca 05-Feb-2016 Pablo Ceballos <pceballos@google.com> Plumbing for getting FenceTracker timestamps

Change-Id: I1ebee9e42e28658bd3a2b161fdaabb7da756d8f3
/frameworks/native/libs/gui/BufferQueueProducer.cpp
907e94d3da1215328fe3a5020cd5005e42499eba 02-Jun-2016 Pablo Ceballos <pceballos@google.com> Merge "BQ: Don\'t return fences from dequeue in shared buffer mode" into nyc-dev
am: eb6377eb13

* commit 'eb6377eb133f902e737fab370df7679430a1d8d1':
BQ: Don't return fences from dequeue in shared buffer mode

Change-Id: Ieb075d9598edcaec542ee06663aa292111968474
28c65ad1a1bc2cfd232044e9ea704197483cf250 02-Jun-2016 Pablo Ceballos <pceballos@google.com> BQ: Don't return fences from dequeue in shared buffer mode

Bug 29007505

Change-Id: I112ae6bd64ddc9a923ad9080e85a71adb96146af
/frameworks/native/libs/gui/BufferQueueProducer.cpp
e77c7669bee30b7c0099172cf0c38cef92412040 13-May-2016 Dan Stoza <stoza@google.com> BufferQueue/SF: Add OccupancyTracker

Adds an OccupancyTracker to BufferQueue. This module keeps track of
how many buffers are in the queue over time, which, in combination
with various aggregation of these statistics, allows SurfaceFlinger
to report what fraction of the time a given layer was double- or
triple-buffered.

Change-Id: Ida6e967dc5483c00a633e9fe03998e420dd88502
/frameworks/native/libs/gui/BufferQueueProducer.cpp
1a61da5e28fa16ad556a58193c8bbeb32a5f636d 28-Apr-2016 John Reck <jreck@google.com> Return the transform to apply in getLastQueuedBuffer

Bug: 28428955
Change-Id: Id48f7d3bf3f5deb074cf0a6a52a41caac875db41
/frameworks/native/libs/gui/BufferQueueProducer.cpp
87e94cd1d16281051d5241a25035aa1db0b073d8 26-Apr-2016 Christopher Ferris <cferris@google.com> Fix use of invalid iterator.

The code grabbed an iterator to a slot, but eventually does an erase
of the iterator. Unfortunately, the code then attempts to use this
invalid iterator which can introduce subtle crashes by putting a
garbage value on the free buffer list.

Bug: 28351886
Change-Id: I42a4431b182cee4de829f15fa4ddc175a3d141f7
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
72b59753f90df64b3dd86fa6a166b24c8b64b985 20-Apr-2016 Pablo Ceballos <pceballos@google.com> Merge "BQ: Avoid unnecessary calls to consumer listener" into nyc-dev
50101d02a8eae555887282a5f761fdec57bdaf30 08-Apr-2016 Dan Stoza <stoza@google.com> libgui: Add getLastQueuedBuffer to BufferQueue

Adds the ability to get the last buffer queued to a BufferQueue plus
its acquire fence.

Bug: 27708453
Change-Id: Iee39475740b40c854a5f46178b2934fd930e61b8
/frameworks/native/libs/gui/BufferQueueProducer.cpp
245cc5b57da46d5852aa820be2a96f37425b3337 19-Apr-2016 Pablo Ceballos <pceballos@google.com> BQ: Avoid unnecessary calls to consumer listener

Try to avoid unnecessary calls to the consumer listener's
onBuffersReleased() since they can potentially deadlock.

Bug 28254168

Change-Id: Ib064e5ebe1403a1028589342b3c33e6f40bb54a9
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3559fbf93801e2c0d9d8fb246fb9b867a361b464 17-Mar-2016 Pablo Ceballos <pceballos@google.com> Rename single buffer mode to shared buffer mode

Change-Id: Id43d0737d9367981644e498942ebc0077d61038c
/frameworks/native/libs/gui/BufferQueueProducer.cpp
295a9fc8aa87daa2cded5c1a279b8cd24e9a9a9f 15-Mar-2016 Pablo Ceballos <pceballos@google.com> BQ: Allow shared buffer to be the first queued buffer

- When single-buffer mode is enabled the shared buffer will now be
either the first buffer dequeued or the first buffer queued.
Whichever comes first.

Bug 24940410

Change-Id: I9f7e2630640e37fe1fb967aed41a3025567247a8
/frameworks/native/libs/gui/BufferQueueProducer.cpp
26bb2b1c0d8f7b05feb40b0e5bf1bb384e1b5f55 08-Mar-2016 Chong Zhang <chz@google.com> Fix warning when force-disconnect but there is no connected API

It's not really an error, we can return early.

bug: 27295820
Change-Id: I450ca615cf9c33b9aaef9c31eec8217c97516df5
/frameworks/native/libs/gui/BufferQueueProducer.cpp
1b3a9acb77ee12568fa19740d8eeab165a0dcd98 01-Mar-2016 Chong Zhang <chz@google.com> Add SurfaceControl::disconnect() to disconnect currently connected API

bug: 27295820
Change-Id: I6f51338bc15e018ed7899172653599ab6254c8c9
/frameworks/native/libs/gui/BufferQueueProducer.cpp
aaf51e52cfa937a8938a4429a14432a8424c66d0 20-Feb-2016 Pablo Ceballos <pceballos@google.com> Merge "Add interface for controlling single buffer auto refresh" into nyc-dev
981066c3a5be3e4775b6537ef32268f7e108c912 18-Feb-2016 Pablo Ceballos <pceballos@google.com> Partial revert of "Fix Surface slot caching"

- Partially reverts commit 789a0c82cb370d6b82f401cc130af58c85802cbf.
- Leaves the fix in Surface, but reverts all changes to the
Producer/Consumer listeners.

Bug 27246023
Bug 27229287

Change-Id: I9283f9e59e666b5ae44c0db25f99a80d05eea3ee
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3130422a1d7a7d2a5d528cd161e860fb5f66d353 16-Feb-2016 Pablo Ceballos <pceballos@google.com> Merge "Fix Surface slot caching" into nyc-dev
dce5c559712031b3cb8039067819c11c1a4e16f9 11-Feb-2016 Pablo Ceballos <pceballos@google.com> BQ: Fix iterator use

Don't use an iterator after it's been removed from the container.

Change-Id: I374b454bba95d10dcec6a600bf8f16e5636e426b
/frameworks/native/libs/gui/BufferQueueProducer.cpp
789a0c82cb370d6b82f401cc130af58c85802cbf 05-Feb-2016 Pablo Ceballos <pceballos@google.com> Fix Surface slot caching

- Now that it's possible to resize a BufferQueue while buffers are
dequeued/acquired, it's no longer correct for Surface to clear its
cache when the BufferQueue is resized since it must keep at least
the currently dequeued buffers.
- Add an onSlotsFreed callback to IProducerListener so that producers
that wish to be notified about buffers being freed can do so. Note
that this isn't currently used in Surface.
- Review and fixup all the places where the producer/consumer
listeners for freed buffers should be called.

Change-Id: I4ab0c92bc69b75a3c072ddf5d74d78f941dba4c8
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
72daab652e3481566c01ce45c6afdb9fcec6f140 08-Dec-2015 Pablo Ceballos <pceballos@google.com> BQ: Flexible resizing

- Allow the producer to call setMaxDequeuedBufferCount and the
consumer to call setMaxAcquiredBufferCount when buffers are
currently dequeued/acquired as long as the new value is not less
than the number of dequeued/acquired buffers.

Bug 22768206

Change-Id: I599a4027a6ae9cb0a1c0d5ec60cb5e65b86a345b
/frameworks/native/libs/gui/BufferQueueProducer.cpp
9e314337cdc65b1fbf52060e9a6a4ddf2215c352 12-Jan-2016 Pablo Ceballos <pceballos@google.com> BQ: Conditionally compile validateConsistencyLocked

- Only enable it on userdebug and eng builds so that it won't slow
down user builds.

Change-Id: I70933a23d54657fdf5cbc23873da4fbee84b9a26
/frameworks/native/libs/gui/BufferQueueProducer.cpp
23b4abe024ea88c45e0b94c80e1fb537a573b143 08-Jan-2016 Pablo Ceballos <pceballos@google.com> BQ: Improved buffer/slot tracking

- Explicitly track active buffers and unused slots on top of the
already existing tracking for free slots and free buffers.

Change-Id: Ife2678678e96f0eb0b3fb21571058378134bd868
/frameworks/native/libs/gui/BufferQueueProducer.cpp
05249fc2d0da542efa46acdb7b10a619a68538e1 16-Jan-2016 Craig Donner <cdonner@google.com> Adds private EGL extension to create an EGLClientBuffer from a gralloc'd buffer. This lets you create a color EGLimage backed by gralloc, which is needed to support protected textures.

Bug: 22775237
Bug: 22855417

Change-Id: I8e03061d74a74a8fdd6524ffa97a6c75a6ced89c
/frameworks/native/libs/gui/BufferQueueProducer.cpp
5ecfb68ffd63d352df0392dca6e95ef67a66c679 05-Jan-2016 Dan Stoza <stoza@google.com> libgui: Fix attaching buffers without allocation

This changes the way that BufferQueue selects slots in
waitForFreeSlotThenRelock. This method is called from both
dequeueBuffer and attachBuffer, but those two methods actually have
different preferences:

dequeueBuffer wants a slot with a buffer if possible (to avoid
unnecessary allocations), but will settle for a slot without a buffer
if no free buffers are available.

attachBuffer wants a slot without a buffer if possible (to avoid
clobbering an existing buffer), but will settle with clobbering a free
buffer if no empty slots are available.

These preferences are now respected, which has the side-effect of
fixing a bug where it was not possible to attach a buffer if allocation
is disabled (since the previous implementation assumed finding a slot
without a buffer meant that the caller intended to allocate a buffer,
which would accordingly be blocked since allocation is disabled).

Bug: 26387372
Change-Id: Iefd550fd01925d8c51d6f062d5708d1f6d517edd
/frameworks/native/libs/gui/BufferQueueProducer.cpp
127fc63e8a15366b4395f1363e8e18eb058d1709 30-Jun-2015 Dan Stoza <stoza@google.com> libgui: Add dequeue/attach timeout

Adds the ability to specify the timeout when dequeueBuffer or
attachBuffer block due to the lack of a free buffer/slot. By default,
these will block indefinitely (which is signified by a timeout of -1).

When a timeout (other than -1) is specified, non-blocking mode is
disabled and the given timeout will be used instead.

Bug: 25196773
Change-Id: I17fdbeebccb7c8d878703d758ac1209608258e61
/frameworks/native/libs/gui/BufferQueueProducer.cpp
0bd49eb442c0e6913617380cd6f520a0b488773d 08-Dec-2015 Dan Stoza <stoza@google.com> Merge "Fix the execution point of onFrameAvailable/onFrameReplaced callbacks" am: 789ede379d am: 67322258c0
am: d76538a4db

* commit 'd76538a4dbc69b4231150a8902049fb13f5140be':
Fix the execution point of onFrameAvailable/onFrameReplaced callbacks
82fbb121763e16dcf58fb2a3e65d2f93543d9078 07-Dec-2015 Christian Poetzsch <christian.potzsch@imgtec.com> Fix the execution point of onFrameAvailable/onFrameReplaced callbacks

In a4650a5 the concept of a maximum frame number allowance for the consumer was
introduced. A call to acquireBuffers will only return buffers when their frame
number is less-than-or-equal-to this maximum frame number. When SurfaceFlinger
is the consumer, this maximum frame number is calculated in the
onFrameAvailable/onFrameReplaced callbacks. These callbacks are called when a
new buffer is dequeued by the application. The problem is that these callbacks
are called _after_ the fence wait which is used to throttle the frame
production of client apps. When the previous frame needs a long time to draw,
those waits can potentially be a long time. As a result SurfaceFlinger won't do
any composition with the new frame until the wait is over.

Normally this isn't a big problem because there is a queue of buffers for
SurfaceFlinger to work with. However, this changes massively when a client app
is using a swap interval of zero. In this case, a new frame will instantly
replace the previous queued frame. However, SurfaceFlinger doesn't know this
until the onFrameReplaced callback gets called - which is delayed by the fence
wait. If the timing is bad, SurfaceFlinger never gets a chance to pick up a new
frame to do the composition with.

We see this behaviour on our TC development system (slow GPU) with legacy
on-screen benchmarks. Such apps are using a swap interval of zero and sometimes
frames don't get updated for several seconds. This behaviour can be also seen
on a Nexus5, although it isn't as obvious as on our TC.

The fix in this cl is to move the EGL throttling to the end of the queueBuffers
function. This ensures that if a frame gets replaced in the queue, all
consumers who installed the callbacks, get called in a timely fashion.

Change-Id: I36e9ecda162150f41e97d4fb7437963a3d86b371
Signed-off-by: Christian Poetzsch <christian.potzsch@imgtec.com>
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
ccdfd60d79a8b7f1ed6401d0f2e8e29166a10584 08-Oct-2015 Pablo Ceballos <pceballos@google.com> BQ: Add support for single buffer mode

- Adds a single buffer mode to BufferQueue. In this mode designate the
first dequeued buffer as the shared buffer. All calls to dequeue()
and acquire() will then return the shared buffer, allowing the
producer and consumer to share it.
- Modify the buffer slot state tracking. Add a new SHARED state for
the shared buffer in single buffer mode. Also track how many times
a buffer has been dequeued/queued/acquired as it's possible for a
shared buffer to be both dequeued and acquired at the same time, or
dequeued/acquired multiple times. This tracking is needed to know
when to drop the buffer out of the SHARED state after single buffer
mode has been disabled.
- Add plumbing for enabling/disabling single buffer mode from Surface.

Bug 24940410

Change-Id: I3fc550c74bacb5523c049a227111356257386853
/frameworks/native/libs/gui/BufferQueueProducer.cpp
7dde599bf1a0dbef7390d91c2689d506371cdbd7 22-May-2015 Dan Stoza <stoza@google.com> Support SurfaceView synchronization.

Add API for fetching the next frame number to be produced by
a given buffer producer. Add an API to SurfaceComposer to
defer execution of the current transaction until a given frame number.
Together these may be used to synchronize app drawing and surface
control updates.

Change-Id: I8e0f4993332ac0199c768c88581a453fefbaff1d
/frameworks/native/libs/gui/BufferQueueProducer.cpp
b687a2814ca9db576eb1ea33dea90ac35cd61bc1 06-Oct-2015 Pablo Ceballos <pceballos@google.com> BQ: fix Volantis test failures

The Volantis driver will dequeue a buffer in eglCreateWindowSurface.

- Remove the requirement that no buffers be dequeued when calling
setAsyncMode() on a BufferQueueProducer, since this gets called
from eglSwapInterval.
- Modify the tests to call setMaxDequeuedBufferCount before calling
eglCreateWindowSurface.

Change-Id: Icc64e9933f151771bbd57035549cd5928c0b7216
/frameworks/native/libs/gui/BufferQueueProducer.cpp
567dbbb6dd42be5013fcde0dadb3316d85f2fa0d 27-Aug-2015 Pablo Ceballos <pceballos@google.com> BQ: get rid of async in producer interface

- Get rid of the async flag in dequeueBuffer, allocateBuffers,
waitForFreeSlotThenRelock, and QueueBufferInput.
- Instead use the persistent flags mDequeueBufferCannotBlock and
mAsyncMode to determine whether to use the async behavior.

Bug 13174928

Change-Id: Ie6f7b9e46ee3844ee77b102003c84dddf1bcafdd
/frameworks/native/libs/gui/BufferQueueProducer.cpp
583b1b32191992d6ada58b3c61c71932a71c0c4b 04-Sep-2015 Pablo Ceballos <pceballos@google.com> BQ: Prevent operations on disconnected BQs

- Update unit tests to match

Bug 23763412

Change-Id: I77e59bf6b57b328433c3835450455f80a8fa454b
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
e5b755a045f4203fdd989047441259893c6fbe2d 14-Aug-2015 Pablo Ceballos <pceballos@google.com> BQ: Get rid of setBufferCount

- Remove setBufferCount from BufferQueueProducer and
IGraphicsBufferQueueProducer.
- Get rid of the unit tests for it.
- In Surface, convert setBufferCount calls into calls to
setMaxDequeuedBufferCount.
- Change mOverrideMaxBufferCount to a boolean since it can now be
derived from mMaxAcquiredBufferCount, mMaxDequeuedBufferCount, and
mAsyncMode.

Bug 13174928

Change-Id: Ia0adc737fae9e13f186df832b8428a0829041bf9
/frameworks/native/libs/gui/BufferQueueProducer.cpp
fa455354557f6283ff3a7d76979e52fd251c155f 13-Aug-2015 Pablo Ceballos <pceballos@google.com> BQ: add setMaxDequeuedBufferCount

Adds the new setMaxDequeuedBufferCount() function to
BufferQueueProducer. This will eventually replace setBufferCount.

Also add setAsyncMode.

Bug 13174928

Change-Id: Iea1adcd5d74a75f67d8e9dde06d521695628ad5a
/frameworks/native/libs/gui/BufferQueueProducer.cpp
60d6922a011fe18c111b8d30fb6ef1f655b6b15e 07-Aug-2015 Pablo Ceballos <pceballos@google.com> libsgui: Change Rect default constructor

The current Rect default constructor initializes to all zeroes. Change
it to initialize to an invalid Rect.

Modify all of the existing invocations of the default constructor to
maintain the existing behavior.

Bug 18173359

Change-Id: Ibbad076f1550a94f56d7b1cf5350071f2022e09a
/frameworks/native/libs/gui/BufferQueueProducer.cpp
4f21a4cc22a94eeb65742fcbb0a8516624474fe5 01-Jul-2015 Amith Dsouza <amithds@google.com> Revert "Revert "Modify EGL to disconnect the window when the surface gets destroyed.""

This reverts commit 6e1a2fea67006b58e83ebbcc72f7b12f18c49d15.

Driver level issues fixed by an updated graphics driver.

Bug: 21266976
Change-Id: I93339fb6c6bab988f3550adb49ef8e70cda6473e
/frameworks/native/libs/gui/BufferQueueProducer.cpp
c6f30bdee1f634eb90d68cb76efe935b6535a1e8 08-Jun-2015 Dan Stoza <stoza@google.com> libgui/SurfaceFlinger: Add getConsumerName

Adds a getConsumerName method to IGraphicBufferProducer and Surface.
Currently, the name is cached inside of IGBP and is update on connect
and dequeueBuffer, which should be good enough for most uses.

Bug: 6667401
Change-Id: I22c7881d778e495cf8276de7bbcd769e52429915
/frameworks/native/libs/gui/BufferQueueProducer.cpp
a2ca9bf0a9789e9e5e37961ebfb356347f59309e 08-Jun-2015 Dan Stoza <stoza@google.com> Revert "libgui: Add getConsumerName"

This reverts commit 107fbe5599016b0e35145a1a00c4f238b63d61e4.

Change-Id: I0c2b0f7c81193b05eb3dd2f5a59f83598434b744
/frameworks/native/libs/gui/BufferQueueProducer.cpp
107fbe5599016b0e35145a1a00c4f238b63d61e4 06-Jun-2015 Dan Stoza <stoza@google.com> libgui: Add getConsumerName

Adds a getConsumerName method to IGraphicBufferProducer and Surface.
Currently, the name is cached inside of IGBP and is updated on connect
and dequeueBuffer, which should be good enough for most uses.

Bug: 6667401
Change-Id: Ife94bd89023fe7c00bad916932b9a19233fd2290
/frameworks/native/libs/gui/BufferQueueProducer.cpp
812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2 03-Jun-2015 Dan Stoza <stoza@google.com> libgui: Add generation numbers to BufferQueue

This change allows producers to set a generation number on a
BufferQueue. This number will be embedded in any new GraphicBuffers
created in that BufferQueue, and attempts to attach buffers which have
a different generation number will fail.

It also plumbs the setGenerationNumber method through Surface, with the
additional effect that any buffers attached to the Surface after
setting a new generation number will automatically be updated with the
new number (as opposed to failing, as would happen on through IGBP).

Bug: 20923096
Change-Id: I32bf726b035f99c3e5834beaf76afb9f01adcbc2
/frameworks/native/libs/gui/BufferQueueProducer.cpp
6e1a2fea67006b58e83ebbcc72f7b12f18c49d15 29-May-2015 Michael Lentine <mlentine@google.com> Revert "Modify EGL to disconnect the window when the surface gets destroyed."

This reverts commit 00699fa64197cc72a160d69e1f0003cdd43dc136.
/frameworks/native/libs/gui/BufferQueueProducer.cpp
51c8c502f63624af8090fe42477b95791faec2c9 14-May-2015 Michael Lentine <mlentine@google.com> Merge "Modify EGL to disconnect the window when the surface gets destroyed." into mnc-dev
00699fa64197cc72a160d69e1f0003cdd43dc136 23-Jul-2014 Michael Lentine <mlentine@google.com> Modify EGL to disconnect the window when the surface gets destroyed.

Bug: 14445579

Change-Id: I1d263ff6cffcb6e448761fca7ca4b06466ad65aa
/frameworks/native/libs/gui/BufferQueueProducer.cpp
2b83cc920ac98498bee161e2b0e7befdfc82ca2b 12-May-2015 Dan Stoza <stoza@google.com> libgui: Always allow allocation on connect

This change places BufferQueue into a predictable state where
allocation is allowed whenever a producer connects. This allows clients
to disconnect and reconnect without having to worry about being locked
out of allocation.

Bug: 20554276
Change-Id: Ic0f920a3d4204f2cafdfa69e46f3bb4204571d7e
/frameworks/native/libs/gui/BufferQueueProducer.cpp
800b41ab8486b9d885124071659c774f6c1856e2 28-Apr-2015 Dan Stoza <stoza@google.com> libgui: Fix buffer age on 64-bit targets

Changes a %llu to a PRIu64 to fix compilation on 64-bit targets.

Change-Id: I8ba982662dbe8ee2e1e47c4f6ce4bbdbe2020960
/frameworks/native/libs/gui/BufferQueueProducer.cpp
4afd8b67f9be307e6c6ed89deab2e85516bb3a0e 26-Feb-2015 Dan Stoza <stoza@google.com> BufferQueue: Add NATIVE_WINDOW_BUFFER_AGE query

Adds a NATIVE_WINDOW_BUFFER_AGE query, which returns the age of the
contents of the most recently dequeued buffer as the number of frames
that have elapsed since it was last queued.

Change-Id: Ib6fd62945cb62d1e60133a65beee510363218a23
(cherry picked from commit 49f810c72df8d1d64128e376757079825c8decd4)
/frameworks/native/libs/gui/BufferQueueProducer.cpp
9de7293b0a1b01ebe6fb1ab4a498f144adc8029f 17-Apr-2015 Dan Stoza <stoza@google.com> libgui: Allow an IGBProducer to disable allocation

Adds a new method IGBP::allowAllocation, which controls whether
dequeueBuffer is permitted to allocate a new buffer. If allocation is
disallowed, dequeueBuffer will block or return an error as it
normally would (as controlled by *ControlledByApp).

If there are free buffers, but they are not of the correct dimensions,
format, or usage, they may be freed if a more suitable buffer is not
found first.

Bug: 19801715
Change-Id: I0d604958b78b2fd775c2547690301423f9a52165
/frameworks/native/libs/gui/BufferQueueProducer.cpp
0de7ea752900b5da29ad19c2799040235477f3c5 23-Apr-2015 Dan Stoza <stoza@google.com> libgui: Change BufferQueue to use free lists

BufferQueue used to choose free buffers by scanning through its array
of slots and picking one based on timestamp. This changes that
mechanism to use a pair of free lists: one with buffers attached and
one without. This makes it easier to choose either type of free slot
depending on the needs of the current operation.

Fixes an issue with the first version of this change, found in bugs
20482952, 20443314, and 20464549.

Bug: 13175420
Change-Id: I9b6e83cfe8f9b4329a976025cb8e291d51fb6d4a
/frameworks/native/libs/gui/BufferQueueProducer.cpp
1fc9cc25a487d4d9dea3cc185331e3481ead36ff 22-Apr-2015 Dan Stoza <stoza@google.com> Revert "libgui: Change BufferQueue to use free lists"

This reverts commit 8dddc990103b71137be2a6365a26b1ac36598e68.

Change-Id: I0b0fed9f1394c6f6ae812f6c562ead4473a8226e
/frameworks/native/libs/gui/BufferQueueProducer.cpp
8dddc990103b71137be2a6365a26b1ac36598e68 17-Apr-2015 Dan Stoza <stoza@google.com> libgui: Change BufferQueue to use free lists

BufferQueue used to choose free buffers by scanning through its array
of slots and picking one based on timestamp. This changes that
mechanism to use a pair of free lists: one with buffers attached and
one without. This makes it easier to choose either type of free slot
depending on the needs of the current operation.

Bug: 13175420
Change-Id: Ic8398e7511bd11a60a1c82e3ad2ee271c9822be1
/frameworks/native/libs/gui/BufferQueueProducer.cpp
5065a55291b67f584d7b0be3fa3cfc4e29a3cd1c 18-Mar-2015 Dan Stoza <stoza@google.com> libgui: Pass surface damage through BufferQueue

This change adds support for passing surface damage all of the way
down from the EGL interface through the consumer side of the
BufferQueue. Depends on system/core change
Ie645e6a52b37b5c1b3be19481e8348570d1aa62c

Bug: 11239309
Change-Id: I4457ea826e9ade4ec187f973851d855b7b93a31b
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
difference
- 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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3be1c6b60a188dc10025e2ce156c11fac050625d 18-Nov-2014 Dan Stoza <stoza@google.com> libgui: Enable -Weverything and -Werror

Enables -Weverything and -Werror, with just a few exceptions for
warnings we can't (or shouldn't need to) work around.

Cherry pick of I034abec27bf4020d84af60d7acc1939c59986dd6 plus a
couple of minor changes to CpuConsumer.cpp to make it work with a
prior change:
Uncomment CC_LOGV on line 46
Change C-style cast to static_cast on line 71

Change-Id: Iaec610477ea0122317b0578fb74caf2383d4cf08
/frameworks/native/libs/gui/BufferQueueProducer.cpp
e12cfc23b2399ded0cc4608e47c5ba864fc5ab7d 17-Nov-2014 Marco Nelissen <marcone@google.com> am 55f71bc0: Merge "Replace IInterface::asBinder() with a static"

* commit '55f71bc0800b9ec7a779c5d30d5a90e074c2526b':
Replace IInterface::asBinder() with a static
097ca275f4717a2c47a5d49f302ed2b72c8a1370 14-Nov-2014 Marco Nelissen <marcone@google.com> Replace IInterface::asBinder() with a static

so we can do NULL checks again, and update calls to IInterface::asBinder()
to use the new static version.

Change-Id: Ia7b10eb38ca55b72278bfd33d3bf647f338b4e6a
/frameworks/native/libs/gui/BufferQueueProducer.cpp
98d20f82ca8979b30c81df9639f54ab11e1951f9 07-Nov-2014 Dan Stoza <stoza@google.com> Merge "Add a BufferItem parameter to onFrameAvailable" into lmp-mr1-dev
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
de288fe2d43adfa1b2243ae534faaf832bf50491 04-Nov-2014 Jesse Hall <jessehall@google.com> Revert "bufferqueue: workaround: allow NULL fence with queueBuffer"

Underlying bug has been fixed, workaround no longer needed

This reverts commit 5b0cbcf9464dbcda9d19ae978911222806ec8bdc.

Change-Id: Ic9532b407d1291a7780a12a75aaa117ae4aa9fcb
/frameworks/native/libs/gui/BufferQueueProducer.cpp
a069e8532ba272ac5b935e332e426a3dacf827fc 20-Oct-2014 Jesse Hall <jessehall@google.com> am 649bafb7: Merge "bufferqueue: workaround: allow NULL fence with queueBuffer (DO NOT MERGE)" into lmp-dev

* commit '649bafb7ba2c3204295bc3451ff7af7e28e714ed':
bufferqueue: workaround: allow NULL fence with queueBuffer (DO NOT MERGE)
5b0cbcf9464dbcda9d19ae978911222806ec8bdc 19-Oct-2014 Jesse Hall <jessehall@google.com> bufferqueue: workaround: allow NULL fence with queueBuffer (DO NOT MERGE)

On one device there is a bug, not yet root-caused, that causes fence
fds to not make it across binder from producer to consumer in the
IGraphicBufferProducer::queueBuffer call. Rather than returning an
error, which the producer typically treats as a fatal error, this
change allows the buffer to be queued with no fence. This avoids an
application crash at the risk of (likely single-frame) visible
corruption.

Bug: 17946343
Change-Id: I9ca89f94098c455e1e90f5f58d5336c936b04a9c
/frameworks/native/libs/gui/BufferQueueProducer.cpp
99a0afbaee9eddabc2b544e3a5c432901c1d498c 30-Sep-2014 Eric Penner <epenner@google.com> BufferQueueProducer: Throttle EGL frame production.

Throttling was previously controlled by a combination of the
driver and the number of buffers in the queue. This patch makes
a more consistent trade-off, which allows two GPU frames pending
but not three. More buffering could improve throughput in the
case of varying frame times, but this also increases latency.

Bug: 17502897
Change-Id: I4ee68019ca94c635294c5959931a555a6c4ef2df
/frameworks/native/libs/gui/BufferQueueProducer.cpp
45e2fc22261cb8ecac4901b4425bcb7352c71174 08-Aug-2014 Michael Lentine <mlentine@google.com> Revert "Modify EGL to disconnect the window when the surface gets destroyed."

This reverts commit 843cbb241da60ada234918a30cfe9a01a1e04187.
/frameworks/native/libs/gui/BufferQueueProducer.cpp
cd36eb445bcc55c88e157584d9ac229280459463 30-Jul-2014 Michael Lentine <mlentine@google.com> Merge "Modify EGL to disconnect the window when the surface gets destroyed." into lmp-dev
843cbb241da60ada234918a30cfe9a01a1e04187 23-Jul-2014 Michael Lentine <mlentine@google.com> Modify EGL to disconnect the window when the surface gets destroyed.

Bug: 14445579

Change-Id: I1d263ff6cffcb6e448761fca7ca4b06466ad65aa
/frameworks/native/libs/gui/BufferQueueProducer.cpp
11f14871db607718090ae6aa2e5dee3f490b8830 26-Jul-2014 Antoine Labour <piman@google.com> BufferQueueProducer: fix which slot gets pre-allocated

Commit 78014f32da6d0ebf52fb34ebb7663863000520a0 introduced a bug that
made us pre-allocate buffers into the last available free slots instead
of the first available ones. This in turn caused more re-allocations,
and possibly triggered driver bugs.

Change-Id: Ic4a70e676b4f2bbb054bc873be62ced26e3099a0
/frameworks/native/libs/gui/BufferQueueProducer.cpp
78014f32da6d0ebf52fb34ebb7663863000520a0 16-Jul-2014 Antoine Labour <piman@google.com> BufferQueue: release mutex while allocating. DO NOT MERGE

BufferQueueProducer::allocateBuffers used to keep the BufferQueueCore
mutex while doing the buffer allocation, which would cause the consumer
(which also needs the mutex) to block if the allocation takes a long
time.
Instead, release the mutex while doing the allocation, and grab it again
before filling the slots. Keep a bool state and a condvar to prevent
other producers from trying to allocate the slots while the mutex is
released.

Bug: 11792166

Change-Id: I4ab1319995ef892be2beba892f1fdbf50ce0416d
(cherry picked from commit ea96044470a29133321c681080870b9d31f81a19)
/frameworks/native/libs/gui/BufferQueueProducer.cpp
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
29a3e90879fd96404c971e7187cd0e05927bbce0 20-Jun-2014 Dan Stoza <stoza@google.com> BufferQueue: Add allocateBuffers method

This adds an allocateBuffers method to BufferQueue, which instructs
it to allocate up to the maximum number of buffers allowed by the
current configuration. The goal is that this method can be called
ahead of render time, which will prevent dequeueBuffers from blocking
in allocation and inducing jank.

This interface is also plumbed up to the native Surface (and, in
another change, up to the Java Surface and ThreadedRenderer).

Bug: 11792166
Change-Id: I4aa96b4351ea1c95ed5db228ca3ef98303229c74
/frameworks/native/libs/gui/BufferQueueProducer.cpp
8f515ce1c57379cafac4357bc4fdb61dd346ec5f 09-Jun-2014 Mark Salyzyn <salyzyn@google.com> libgui: 64 bit compile issues (part deux)

- nsecs_t printed with PRId64
- int64_t/uint64_t print issues
- some size_t printing issues.
- missing argument to BQ_LOGV

Change-Id: I493f2b578e801dc38c44f8c536faa45266720402
/frameworks/native/libs/gui/BufferQueueProducer.cpp
4cbf3c53447215a31f69d3ac615ba0daa902f717 21-Apr-2014 Dan Stoza <stoza@google.com> Merge "BufferQueue: Guard against unbounded queue growth"
ae3c3682333f25e860fe54e2bae3599bb466cdb6 19-Apr-2014 Dan Stoza <stoza@google.com> BufferQueue: Guard against unbounded queue growth

Adds logic to dequeueBuffer that blocks if there are currently too
many buffers in the queue. This prevents unbounded growth around
times where the slots are cleared but the queue is not (e.g.,
during rapid connect/disconnect or setBufferCount activity). This
replaces the fix from ag/377958 in a more general way.

Bug: 11293214
Change-Id: Ieb7adfcd076ff7ffe3d4d369397b2c29cf5099c3
/frameworks/native/libs/gui/BufferQueueProducer.cpp
d9822a3843017444364899afc3c23fb5be6b9cb9 28-Mar-2014 Dan Stoza <stoza@google.com> BufferQueueProducer: add detachNextBuffer

Adds a new method, IGBP::detachNextBuffer, that effectively does
dequeue + request + detach in a single call, but does not need to
know anything about the dequeued buffer, and will not block on
dequeue. This is mostly for the upcoming StreamSplitter to use in
its onBufferReleased callback.

Change-Id: Ie88a69de109003acebaa486a5b44c8a455726550
/frameworks/native/libs/gui/BufferQueueProducer.cpp
fd34b65f717b84fa06d8c37f41b070f41d0ad3a3 11-Apr-2014 Dan Stoza <stoza@google.com> Merge "BufferQueue: Add producer buffer-released callback"
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
/frameworks/native/libs/gui/BufferQueueProducer.cpp
f0eaf25e9247edf4d124bedaeb863f7abdf35a3e 21-Mar-2014 Dan Stoza <stoza@google.com> BufferQueue: Add producer buffer-released callback

Add a callback to the producer side, onBufferReleased, which will be
called every time the consumer releases a buffer back to the
BufferQueue. This will enable a buffer stream splitter to work
autonomously without having to block on dequeueBuffer.

The binder object used for the callback replaces the generic IBinder
token that was passed into IGraphicBufferProducer::connect to detect
the death of the producer. If a producer does not wish to listen for
buffer release events, it can pass in an instance of the
DummyProducerListener class defined in IProducerListener.h, if it even
cares about death events (BufferQueue doesn't enforce the token being
non-NULL, though perhaps we should).

Change-Id: I23935760673524abeafea2b58dccc3583b368710
/frameworks/native/libs/gui/BufferQueueProducer.cpp
2443c7903c6910b57bcc615a4bf2e60068c15dbd 24-Mar-2014 Dan Stoza <stoza@google.com> BufferQueue: Set attached buffers as requested

When a buffer is attached to the producer side, it needs to be marked
as having been requested so that it can be queued successfully.

Change-Id: I90a88b332c415a57921bd094ae635afdf65bff99
/frameworks/native/libs/gui/BufferQueueProducer.cpp
73ed82f809a40560fd3a6d53d18e5c846362d764 13-Mar-2014 Jesse Hall <jessehall@google.com> Merge "Add sideband streams to BufferQueue and related classes"
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
BufferQueue.

Change-Id: Ib3f262eddfc520f4bbe3d9b91753ed7dd09d3a9b
/frameworks/native/libs/gui/BufferQueueProducer.cpp
9f3053de78630815d60cf48a2cf2348cc5867c45 07-Mar-2014 Dan Stoza <stoza@google.com> BufferQueue: Allow detaching/reattaching buffers

Adds detachBuffer and attachBuffer calls to both the producer and
consumer sides of BufferQueue. Buffers may be detached while dequeued
by the producer or acquired by the consumer, and when attached, enter
the dequeued and acquired states, respectively.

Bug: 13173343
Change-Id: Ic152692b0a94d99e0135b9bfa62747dab2a54220
/frameworks/native/libs/gui/BufferQueueProducer.cpp
3e96f1982fda358424b0b75f394cbf7c1794a072 03-Mar-2014 Dan Stoza <stoza@google.com> Change BufferQueue into producer/consumer wrapper

Now that BufferQueue has been split into core + producer + consumer,
rewrite BufferQueue to be a thin layer over a producer and consumer
interface. Eventually, this layer will be deprecated in favor of
only using either the producer or consumer interface, as applicable.

Change-Id: I340ae5f5b633b244fb594615ff52ba50b9e2f7e4
/frameworks/native/libs/gui/BufferQueueProducer.cpp
289ade165e60b5f71734d30e535f16eb1f4313ad 28-Feb-2014 Dan Stoza <stoza@google.com> Split BufferQueue into core + producer + consumer

Change-Id: Idc39f1e511d68ce4f02202d35425a419bc0bcd92
/frameworks/native/libs/gui/BufferQueueProducer.cpp