Commit Graph

37 Commits

Author SHA1 Message Date
Dan Stoza a4650a50a0 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
2015-05-12 13:10:17 -07:00
Dan Stoza dc13c5b85b libgui: Hook up onFrameReplaced
This completes the plumbing from ConsumerListener::onFrameReplaced into
SurfaceFlinger (and other consumers that may care).

Change-Id: I376e78ace95d6748e8662e6b4d47c0dfa697a300
2015-05-11 15:33:01 -07:00
Dan Stoza 634f5ee6a7 libgui: Plumb detachBuffer through ConsumerBase
Exposes IGraphicBufferConsumer::detachBuffer as a ConsumerBase
method. attachBuffer is not currently exposed, because all current
clients will be recycling buffers through the allocator.

Bug: 19628705
Change-Id: I3e519767fa43d5d880c1d5695e31b60f6ad588af
2015-04-07 15:05:40 -07:00
Dan Stoza 1c87e474d8 DO NOT MERGE libgui: Remove IGBC::BufferItem
Removes IGraphicBufferConsumer::BufferItem. Depends on the
following changes:
    I187b3a7d05196b6289596afac8fb9a9d4aebff76
    I0ddd38df37500cfd6b21d1e768ed14e39c5cd9fc

Cherry-pick of Id1fa56d092188f2cb712768d5d2fc6a9027fb73c

Change-Id: I3edf0db8fba656fd78e18a5a7f1137f0fb6b237d
2015-03-20 12:29:04 -07:00
Dan Stoza cf3834db10 DO NOT MERGE libgui: Prepare for IGBC::BufferItem removal
Currently, there are two instances of BufferItem: one inside of
IGraphicBufferConsumer, and a standalone one inside of libgui. They
only differ in the name of one of the fields, and we want to remove
the IGBC version. This changes things so that client code may be
incrementally switched over to the libgui version.

This is a squashed commit containing the following changes:
    I64f495105f56cbf5803cea4aa6b072ea29b70cf5
    I1394e693314429ada93427889f10b7b01c948053
    I9c3bc8037fa9438d4d9080b8afb694219ef2f71f
    I699ed0a6837076867ca756b28d1ffb2238f7a0d9
    Iac8425e1241774304a131da2fb9dec6e82922f13

Change-Id: Ic4d51f5df6dbc70b376d13fceba2335b9bae4f3d
2015-03-19 13:58:07 -07:00
Dan Stoza 3be1c6b60a 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
2015-03-18 15:57:27 -07:00
Dan Stoza 8e624d4cad am 98d20f82: Merge "Add a BufferItem parameter to onFrameAvailable" into lmp-mr1-dev
* commit '98d20f82ca8979b30c81df9639f54ab11e1951f9':
  Add a BufferItem parameter to onFrameAvailable
2014-11-07 20:03:42 +00:00
Dan Stoza 8dc55396fc 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
2014-11-07 10:39:13 -08:00
Dan Albert 5273a97833 resolved conflicts for merge of 86aeb9ef to lmp-dev-plus-aosp
Change-Id: I82fe2b385156d9bdb9e7183e308d7b2a4167b6ce
2014-09-08 22:15:20 -07:00
Dan Albert 8b49125f10 Make string literal concatenation play nice with C++11.
In C++11 mode, "foo"MACRO_THAT_EXPANDS_TO_STRING gets lexed as a user
defined literal. Add space around the macro.

Change-Id: I2741f5be9c0b1562e0f413d1309ef9d687e89b41
2014-09-08 18:53:39 -07:00
Mark Salyzyn 55fc54970b am 72676e7d: am 0e1313cd: Merge "libgui: 64-bit compile issues"
* commit '72676e7d0db89d477495245aa15f1a128b5c35bc':
  libgui: 64-bit compile issues
2014-06-11 17:44:52 +00:00
Mark Salyzyn 911004506d libgui: 64-bit compile issues
Change-Id: I29961c1567b8431518a7d032ea43385e23b7bb37
2014-06-09 14:27:45 -07:00
Dan Stoza febd4f4f46 BufferQueue: Increase max slots from 32 to 64
Increases NUM_BUFFER_SLOTS from 32 to 64 and changes the mask
returned by IGBC::getReleasedBuffers from 32 to 64 bits.

Bug: 13174352
Change-Id: Ie8ef0853916cfb91f83881c7241886bb1950f01a
2014-04-18 11:40:14 -07:00
Jesse Hall 399184a4cd 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
2014-03-11 12:23:14 -07:00
Igor Murashkin 7d2d160cdc gui: Update header docs for IGraphicBufferConsumer/Producer/BufferQueue
Also fix compiler warnings for libgui

Change-Id: I0ee38d9ad5eaa82d55bf812d291da8c433581cef
2013-11-13 17:34:03 -08:00
Mathias Agopian db89edc94b 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
2013-08-06 20:05:36 +00:00
Mathias Agopian a4e19521ac Binderize the consumer side of BufferQueue
While currently untested, this should allow to move the
BuffereQueue in the consumer process and have everything
work as usual.

Bug: 9265647

Change-Id: I9ca8f099f7c65b9a27b7e7a3643b46d1b58eacfc
2013-08-01 17:20:08 -07:00
Mathias Agopian 595264f1af BufferQueue improvements and APIs changes
this is the first step of a series of improvements to
BufferQueue. A few things happen in this change:

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

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

Change-Id: I691f9507d6e2e158287e3039f2a79a4d4434211d
2013-07-18 22:28:18 -07:00
Andy McFadden 1585c4d9fb Pay attention to buffer timestamps
When acquiring a buffer, SurfaceFlinger now computes the expected
presentation time and passes it to the BufferQueue acquireBuffer()
method.  If it's not yet time to display the buffer, acquireBuffer()
returns PRESENT_LATER instead of a buffer.

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

Bug 7900302

Change-Id: If9345611c5983a11a811935aaf27d6388a5036f1
2013-07-10 15:38:40 -07:00
Lajos Molnar c5d7b7d323 BufferQueue: track buffer-queue by instance vs. by reference
Instead of representing the buffer-queue as a vector of buffer
indices, represent them as a vector of BufferItems (copies).
This allows modifying the buffer slots independent of the queued
buffers.

As part of this change, BufferSlot properties that are only
been relevant in the buffer-queue have been removed.

Also, invalid scalingMode in queueBuffer now returns an error.

ConsumerBase has also changed to allow reuse of the same
buffer slots by different buffers.

Change-Id: If2a698fa142b67c69ad41b8eaca6e127eb3ef75b
Signed-off-by: Lajos Molnar <lajos@google.com>
Related-to-bug: 7093648
2013-05-23 22:17:54 +00:00
Mathias Agopian 74d211ae26 clean-up/simplify all dump() APIs
remove the scratch buffer parameter and use
String8::appendFormat() instead.

Change-Id: Ib96c91617c8e7292de87433d15cf6232b7d591b0
2013-04-22 21:51:28 +02:00
Jamie Gennis ad669b04f4 libgui: fix an EGLImage leak
This moves the call to ConsumerBase::abandon from the ConsumerBase dtor to
ConsumerBase::onLastStrongRef.  The abandon call relies on virtual methods to
perform the clean-up, so calling it from the ConsumerBase dtor after the
derived classes dtors ran was skipping some of the clean-up.  The
onLastStrongRef method should get called just before the most derived class's
dtor gets called.

Bug: 8349135
Change-Id: I836946826927cc1ed69c049049f525f92b17a269
2013-04-08 14:42:22 -07:00
Mathias Agopian ca08833d5e don't use compile-time configuration of libgui as much as possible
We now detect at runtime which sync features to use, which
allows us to remove a lot of the compile-time configuration
options. There  is still one option though, to disable
KHR_fence_sync on some devices (which are more efficient
without it).

- added a backdoor to get the vendor's EGL strings

the new logic is:
- use always ANDROID_native_fence_sync if available
- fallback to KHR_fence_sync if available and not disabled
  by the compile-time option
- use KHR_wait_sync if available and either of the above is
  enabled

Change-Id: I9c4b49d9ff1151faf902cc93bd53ea5f205aaabf
2013-03-29 15:33:47 -07:00
Jamie Gennis 1df8c34585 libgui: disallow NULL Fence pointers
This change eliminates the uses of a NULL sp<Fence> indicating that no waiting
is required.  Instead we use a non-NULL but invalid Fence object for which the
wait methods will return immediately.

Bug: 7892871
Change-Id: I5360aebe3090422ef6920d56c99fc4eedc642e48
2013-02-12 18:15:38 -08:00
Andy McFadden 2adaf04fab Rename ISurfaceTexture and SurfaceTexture
The C++ class names don't match what the classes do, so rename
ISurfaceTexture to IGraphicBufferProducer, and SurfaceTexture to
GLConsumer.

Bug 7736700

Change-Id: Ia03e468888025b5cae3c0ee1995434515dbea387
2012-12-18 13:10:48 -08:00
Jamie Gennis a436799668 am 50f8d285: am d4e70620: am 72c3f7d8: Revert "ConsumerBase: free buffers outside the lock"
* commit '50f8d2856b6644059b31684687842bf9c1f2e814':
  Revert "ConsumerBase: free buffers outside the lock"
2012-12-07 11:09:12 -08:00
Jamie Gennis 72c3f7d881 Revert "ConsumerBase: free buffers outside the lock"
This reverts commit b21a4e3b5f.
2012-12-07 10:33:07 -08:00
Jamie Gennis b5fe96b813 am 05989772: am 3ed2736c: am b21a4e3b: ConsumerBase: free buffers outside the lock
* commit '05989772d5b46cd5328e88d546f04deef39cc3c8':
  ConsumerBase: free buffers outside the lock
2012-12-06 23:24:25 -08:00
Jamie Gennis b21a4e3b5f ConsumerBase: free buffers outside the lock
This change makes ConsumerBase::onBuffersReleased hold a reference to all its
gralloc buffers until after the mutex is unlocked.  This prevents slow
gralloc::free calls from causing lock contention with rendering threads.

Bug: 7675940
Change-Id: I0ec805d1b612afeeecfffec03f982371d27d93be
2012-12-06 18:17:35 -08:00
Igor Murashkin a4a3149a36 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
2012-11-05 13:39:02 -08:00
Jesse Hall 9504eb915c Fix race condition in ConsumerBase::addReleaseFence()
This needs the ConsumerBase mutex locked, but wasn't locking it. Two
of the four places that called it already held the lock so were fine.
Now addReleaseFence() takes the lock itself, and I added
addReleaseFenceLocked() for the two already-locked callers, since in
one of them dropping the lock would be inconvenient.

Bug: 7289269
Change-Id: I7a5628adb516f8eec782aa6c14128202f96d7b0a
2012-10-05 14:40:50 -07:00
Jamie Gennis 7aff4a5de4 ConsumerBase: make fence names meaningful
Change-Id: I3580120cb63c027c327e80ec70e68650b75395de
2012-09-24 12:25:53 -07:00
Jamie Gennis b272541546 libgui: move fence handling into ConsumerBase
This change moves some common fence handling code into the base class for
BufferQueue consumer classes.  It also makes the ConsumerBase class initialize
a buffer slot's fence with the acquire fence every time a buffer is acquired.

Change-Id: I0bd88bc269e919653b659bfb3ebfb04dd61692a0
2012-09-06 17:54:53 -07:00
Jamie Gennis 9fea3421ff SurfaceTexture: inherit from ConsumerBase (try 2)
This change makes SurfaceTexture inherit from ConsumerBase.  It removes all of
the functionality from SurfaceTexture that is now provided by the base class.
This includes fixes for two bugs that were found after checking this change in
the first time and then reverting it.

Change-Id: Ie2d9f4f27cfef26fdac341de3152e842b01a58d2
2012-08-21 16:41:03 -07:00
Jamie Gennis ce7a6c0fc9 Revert "SurfaceTexture: inherit from ConsumerBase"
This reverts commit ed059a8d75

Change-Id: I72542c2595771a40c2c88251e0d6eb54e305b99b
2012-08-20 14:28:53 -07:00
Jamie Gennis ed059a8d75 SurfaceTexture: inherit from ConsumerBase
This change makes SurfaceTexture inherit from ConsumerBase.  It removes all of
the functionality from SurfaceTexture that is now provided by the base class.

Change-Id: I4a881df42810a14ee32d4ef7c8772a8f2510f4c7
2012-08-16 18:11:02 -07:00
Jamie Gennis 1a4d883dcc surfaceflinger: refactor FrambufferSurface
This change refactors the FramebufferSurface class to inherit from the new
ConsumerBase class.

Bug: 6620200
Change-Id: I46ec942ddb019658e3c5e79465548b171b2261f2
2012-08-06 18:55:01 -07:00