Commit Graph

1990 Commits

Author SHA1 Message Date
Andy McFadden 6905205c8d 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
2012-09-16 11:39:09 -07:00
Mathias Agopian 9ca6491bb7 Region::validate() cannot be called from addRectUnchecked()
addRectUnchecked() is allowed to be in an invalid state
temporarily.

Change-Id: I6f5162b5c49f378978c070a77abba35023fe918c
2012-09-12 17:56:29 -07:00
Mathias Agopian 068d47f29d strengthen region validation
Change-Id: I75ee7bc4dd7a2f5357ac8994a23bc8b8bfb6eb44
2012-09-12 17:30:47 -07:00
Andy McFadden c272430960 Merge "Watch for SurfaceFlinger death" into jb-mr1-dev 2012-09-12 13:22:35 -07:00
Jamie Gennis 98ff0597bd SurfaceTexture: eglDestroySync after duping its fd
This change adds a call to eglDestroySync after we've dup'd the fd for the
Android fence that the EGLSyncKHR object wraps.

Change-Id: I4fa6ece863260793630d70bb9a69d6284d05d99e
2012-09-10 14:49:42 -07:00
Jamie Gennis 61e04b92bd SurfaceTexture: use eglWaitSync
This change adds a compile-option to use eglWaitSyncANDROID to ensure that
texturing operations that access the current buffer of a SurfaceTexture do not
occur until the buffer is completely written.  It also moves this
synchronization into a new SurfaceTexture method called doGLFenceWait and
changes SurfaceFlinger's Layer class to use that method rather than performing
its own wait on the fence.

Change-Id: I70afa88086ca7ff49a80e3cd03d423767db7cb88
2012-09-10 13:27:23 -07:00
Jamie Gennis 01dbf5539b SurfaceTexture: use EGL-created native fences
This change adds support for using Android fences that come from EGLSyncKHR
objects as the release fence for a buffer.

Change-Id: Ice192ce2ec001020f909a2018afdf0f17b24dec9
2012-09-09 12:58:23 -07:00
Andy McFadden 6652b3edcb Watch for SurfaceFlinger death
The ComposerService object wasn't watching for SurfaceFlinger
restarts, which doesn't usually matter because the app framework
restarts when SurfaceFlinger dies.  However, mediaserver continues
to run, which means its ComposerService object was trying to use
a dead handle, and playback of DRM movies was failing.

This adds a DeathRecipient listener and some logic to re-establish
the SurfaceFlinger connection.

Bug 6645813

Change-Id: I07581b881d3835601aa57d5358c8259d93bc4515
2012-09-06 18:54:42 -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
Mathias Agopian 00e8c7a88a display projection API now has a single function instead of 3
Change-Id: I9bf46d372b77d547486d4bbe6f1953ec8c65e98f
2012-09-04 19:30:46 -07:00
Jamie Gennis 493db47929 Merge "BufferQueue: add a setMaxAcquiredBufferCount check" into jb-mr1-dev 2012-09-04 14:58:51 -07:00
Jamie Gennis e84ec393bb Merge "libgui: add BufferQueue test infrastructure" into jb-mr1-dev 2012-09-04 14:55:59 -07:00
Jamie Gennis 374850cf16 Merge "libgui: disable CpuConsumer tests" into jb-mr1-dev 2012-09-04 14:55:38 -07:00
Jamie Gennis c68f2ecfa0 BufferQueue: add a setMaxAcquiredBufferCount check
This change adds a check to verify the validity of the value passed to
setMaxAcquiredBufferCount.

Change-Id: I39730557aa58261e678bd6e4fce11bab78e98362
2012-09-04 14:54:34 -07:00
Mathias Agopian 50f262fe56 minor SharedBuffer clean-up
Change-Id: If38b7ce85806ae628c00f2c938de4e3f75142543
2012-08-31 18:41:21 -07:00
Mathias Agopian 2401ead700 Add a way to retrieve a Region as a SharedBuffer
Change-Id: Ia53cb905fbc88f899521658545f990fb9217b1e1
2012-08-31 18:38:22 -07:00
Mathias Agopian 3ab68558fa change how we store Region data internally
We used to keep the bounds of the region as a
separate rectangle. Instead we now store it as the last
element of the Vector<> of Rects.

This has the benefit of being slightly more efficient when
copying regions and reduces the overhead of small regions,
but more importantly will allow us to export the underlaying
SharedBuffer (eventually).

Change-Id: I80790e4fb1a09a747a5616000cfef852ac4ce9e9
2012-08-31 18:38:22 -07:00
Mathias Agopian 4c0a170585 don't generate a new Region when translating by 0,0
since regions are copy-on-write, this prevents to
duplicate the region entirely and offseting by 0,0 is
fairly common.

Change-Id: I9b8c286315a2e00dda01c2456397d72b5e12006b
2012-08-31 18:38:22 -07:00
Jamie Gennis 9e75ddda93 libgui: add BufferQueue test infrastructure
This change adds some infrastructure for testing the BufferQueue class.  It
also includes a test that tests the new check in BufferQueue::acquireBuffer
that prevents the consumer from acquiring more than one buffer beyond the max
acquired buffer count that was set.

Change-Id: I38554ad3f9a53d2ddeba7ef0deee35ec2e2f9775
2012-08-31 17:02:49 -07:00
Jamie Gennis fdb6b49dfa libgui: disable CpuConsumer tests
This change disables the CpuConsumer tests because they require a Gralloc
format that is not supported on all devices.

Change-Id: Ifaa618062c1dae53d9fcb9e16ba92c480d3dbd0c
2012-08-31 15:54:21 -07:00
Dianne Hackborn 8210185fe3 No longer need "original calling uid".
Change-Id: Ifc4a89dd088609a5a8553f6ac6553174e09e8222
2012-08-31 15:40:58 -07:00
Jamie Gennis 4697528eac SurfaceTexture: fix a few tests
Change-Id: Ic74fe8791361f8fe91ad7149720fafd4cc154ac1
2012-08-30 18:38:11 -07:00
Jamie Gennis d69097f936 libgui: add some error checks
This change adds a few error checks both in the framework and in some tests.

Change-Id: I2baf2676942a0dc15866e75852a775a0091ed16d
2012-08-30 18:38:11 -07:00
Jamie Gennis 5e5efde787 BufferQueue: add a check for the max acquired bufs
This change adds an error check to ensure that consumers don't acquire more
buffers than the maximum that they set.

Change-Id: I026643564bde52732e4ee6146972b207ddbbba77
2012-08-30 18:38:11 -07:00
Jamie Gennis 72f096fb1a BufferQueue: use max acquired buffer count
This change makes BufferQueue derive the min undequeued buffer count from a max
acquired buffer count that is set by the consumer.  This value may be set at
any time that a producer is not connected to the BufferQueue rather than at
BufferQueue construction time.

Change-Id: Icf9f1d91ec612a079968ba0a4621deffe48f4e22
2012-08-30 18:26:09 -07:00
Jamie Gennis 1847f7fd79 Merge "BufferQueue: simplify max buffer count handling" into jb-mr1-dev 2012-08-30 18:23:27 -07:00
Jamie Gennis 2b97769823 Merge "BufferQueue: clean up buffer counting" into jb-mr1-dev 2012-08-30 18:21:11 -07:00
Wink Saville 94f261556c Revert "A vendor ril depends on a native screen shot code."
This reverts commit 9b5782baf0.

A new ril for toro, hack no longer needed.
2012-08-30 11:53:55 -07:00
Jamie Gennis e191e6c348 BufferQueue: simplify max buffer count handling
This change reworks how the maximum buffer count is computed.

Change-Id: I7d3745814b9bd6f6f447f86bfea8eb7729914ebf
2012-08-29 15:35:34 -07:00
Jamie Gennis 31a353da22 BufferQueue: clean up buffer counting
This change is a clean up of some of the handling of the maximum number of
buffers that are allowed at once.  It mostly renames a few member variables and
methods, but it includes a couple small refactorings.

Change-Id: I9959310f563d09583548d4291e1050a7bbc7d87d
2012-08-29 15:35:34 -07:00
Wink Saville 9b5782baf0 A vendor ril depends on a native screen shot code.
Add a temporary shim until the vendor fixes the ril.

Bug: 7073467
Change-Id: Ia95a58bd90677c03406c988d1c29ae785f8662f2
2012-08-28 16:20:50 -07:00
Jeff Brown a50b51c03a Compatibility work around for bad graphics driver dependency.
This is a compatibility shim for one product whose drivers
are depending on SurfaceComposerClient::getDisplayInfo(
int, DisplayInfo*) when it really shouldn't.

Revert this patch when the problem has been resolved.

Bug: 7065398
Change-Id: I6542691b81fd1b1e1d79500a62e82d40a3d51db7
2012-08-27 17:20:53 -07:00
Jeff Brown 380223bf1b Remove unused "layer" argument from show().
Change-Id: I8944a9f4a27c330b11e5e837c69b88c8f84145ba
2012-08-27 14:40:17 -07:00
Jeff Brown 9d4e3d2f42 Banish DisplayID from the SurfaceFlinger API.
Use only display tokens in the API to refer to new displays.

Don't require the caller to specify the display when creating
a surface (since in general a surface could be shown on
any display).

This is intended to be a minimum change just to update the API.
Note that SurfaceFlinger still uses DisplayID in a few places
internally that might cause some features not to work properly
when there are multiple displays (LayerScreenshot, for example).

Change-Id: I3d91eec2da406eefd97bcd53655d403ad865a7e6
2012-08-27 14:40:17 -07:00
Mathias Agopian 225c66a48c Revert "put back the unused virtuals in Vector<>"
This reverts commit 1648d4c13b.

Bug: 6977192

Change-Id: Idbb6b239aaed4fb1c054ce943f6ba06ede3492bb
2012-08-24 17:16:10 -07:00
Jamie Gennis 490aee0fc5 Merge "SurfaceTexture: inherit from ConsumerBase (try 2)" into jb-mr1-dev 2012-08-24 11:11:07 -07:00
Eino-Ville Talvala 0493044503 Merge "Add BufferItemConsumer, a simple BufferQueue consumer." into jb-mr1-dev 2012-08-21 16:46:05 -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
Eino-Ville Talvala e232fdca2a Add BufferItemConsumer, a simple BufferQueue consumer.
BufferItemConsumer allows for acquiring BufferQueue's BufferItems,
which contain all the data and metadata the BufferQueue has for a
given graphics buffer.

This consumer is useful when direct access to the native buffer_handles
is needed by the client.

Also includes a minor cleanup of CpuConsumer's use of 'virtual'.

Bug: 6243944
Change-Id: If7dc4192b15ac499555f1eda42a85140f2434795
2012-08-21 15:46:35 -07:00
Mathias Agopian 1648d4c13b put back the unused virtuals in Vector<>
some binaries are using these private APIs and broke
(as they should!) with this change. Temporarily restore the
virtuals to work around this.

Bug: 6977550
Change-Id: I7c37f24b16e4d586b89205c493db5169cf87e024
2012-08-20 21:23:15 -07:00
Eino-Ville Talvala 84a9a3c0ec Merge "CpuConsumer: inherit from ConsumerBase" into jb-mr1-dev 2012-08-20 16:18:11 -07:00
Eino-Ville Talvala f57e7540d4 CpuConsumer: inherit from ConsumerBase
Change-Id: I55178b1d673ffa0fbc6e63ef47642c64d4d03228
2012-08-20 15:44:40 -07:00
Jamie Gennis 729f48082e Merge "Revert "SurfaceTexture: inherit from ConsumerBase"" into jb-mr1-dev 2012-08-20 14:33:24 -07:00
Jamie Gennis f7f6345068 Merge "Revert "SurfaceTexture: call ConsumerBase::freeBufferLocked"" into jb-mr1-dev 2012-08-20 14:33:16 -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 483bccd0d9 Revert "SurfaceTexture: call ConsumerBase::freeBufferLocked"
This reverts commit f8d33c652b

Change-Id: I1ff2e1cc85824a8fac1051f573d2931db81af511
2012-08-20 14:28:21 -07:00
Jamie Gennis 220ef10c5f Merge "SurfaceTexture: call ConsumerBase::freeBufferLocked" into jb-mr1-dev 2012-08-20 12:39:38 -07:00
Jamie Gennis f8d33c652b SurfaceTexture: call ConsumerBase::freeBufferLocked
This change fixes SurfaceTexture::freeBufferLocked so that it calls the base
class implementation.

Change-Id: I45d76fb2eb02c1fa6e4e917823ead83e2086bd15
2012-08-20 11:30:44 -07:00
Jean-Baptiste Queru d3bbcaff6f resolved conflicts for merge of 21938749 to jb-mr1-dev
Change-Id: I17da10797736f3772a143e2015fe25df0bb3eb3f
2012-08-20 10:22:33 -07:00
Jamie Gennis 2c7eb92b63 Merge "SurfaceTexture: inherit from ConsumerBase" into jb-mr1-dev 2012-08-17 15:35:17 -07:00
Mathias Agopian 818b46058a display states can't share the dirty flags
Change-Id: Ifade9f2f1a0df9a36aede77a6cf5eee4be534f98
2012-08-16 20:58:57 -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
Jeff Brown f0083bf528 Merge "Add a very simple helper function to log slow functions." into jb-mr1-dev 2012-08-13 23:35:08 -07:00
Mathias Agopian 8683fca395 improve [un]marshalling of non-binder objects
this change introduces a new class LightFlattenable<> which is
a protocol to flatten simple objects that don't require
binders or file descriptors; the benefit of this protocol is that
it doesn't require the objects to have a virtual table and give us
a consitant way of doing this.

we also introduce an implementation of this protocol for
POD structures, LightFlattenablePod<>.

Parcel has been update to handle this protocol automatically.

Sensor, Rect, Point and Region now use this new protocol.

Change-Id: Icb3ce7fa1d785249eb666f39c2129f2fc143ea4a
2012-08-13 02:46:05 -07:00
Jeff Brown 6f12d57325 Add a very simple helper function to log slow functions.
Change-Id: I2e2e072206d02b572a330dd25857c161b5b563bf
2012-08-10 22:03:55 -07:00
Mathias Agopian e57f292595 make multi-display more real
- displays are represented by a binder on the client side
- c++ clients can now create and modify displays

Change-Id: I203ea5b4beae0819d742ec5171c27568f4e8354b
2012-08-10 17:32:33 -07:00
Mathias Agopian 3165cc21cf libgui includes refactoring
Change-Id: I1d24ec17f5003ec2abab5f7472daaff4cc4cc2d3
2012-08-10 13:18:24 -07:00
Mathias Agopian 69973992d5 improve Vector<> safety checks
- make errors that will always cause a memory corruption always fatal
  (for eg: KeyedVector<>::editValue{For|At}() failure)
- make other errors fatal in debug mode, those that can be caught by
  the caller.
- fix typos

Change-Id: I65cc7d81035c37ce2906fc4500c50e5d5b5c49eb
2012-08-10 13:15:00 -07:00
Jamie Gennis 3d1d09c0c1 SurfaceTexture: Fix a fence fd leak.
Bug: 6949010
Change-Id: I289992c964504b4fe5458dbd19b248a841ef043f
2012-08-08 15:39:55 -07:00
Jamie Gennis 14bd369e4b Merge changes Ic3d35a93,I46ec942d into jb-mr1-dev
* changes:
  SurfaceTexture: fix an out of bounds array access
  surfaceflinger: refactor FrambufferSurface
2012-08-06 19:15:51 -07:00
Jamie Gennis 45cb2ba1d5 SurfaceTexture: fix an out of bounds array access
Bug: 6879028
Change-Id: Ic3d35a9384c0a6dfa4000e7743a6f6859608b0bf
2012-08-06 18:55:01 -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
Mathias Agopian 53095e25d6 libutils cleanup: remove unused or seldom used code from misc.{cpp|h}
Change-Id: I72206f16619d81887e3b85603494563faab3b445
2012-08-05 12:41:16 -07:00
Mathias Agopian 72131d9ef1 remove unneeded dependencies in libhardware
Change-Id: Ibb8d698d594216d0746b0e7270cf87d7e5acab2b
2012-08-04 20:22:32 -07:00
Mathias Agopian 92efd84f37 screen-off animation won't be handled by SF anymore
Change-Id: Idc41386804ae7d7eb981c36e1bc55c270870c8d0
2012-08-03 13:22:58 -07:00
Romain Guy 4f9c284de4 Add missing break in switch statement
Change-Id: I6206cc9ca46c4e2f125d3d820256280586ad66a1
2012-08-01 19:16:59 -07:00
Jamie Gennis 12bd497f28 libgui: enable EGL_fence_sync usage for exynos5
Bug: 6876502
Change-Id: I2ec2800881dcba9e4f6ff32ffa1341a2de01f0a2
2012-07-31 17:07:53 -07:00
Mathias Agopian e21facef01 Merge "log more info on fence sync_merge error" into jb-mr1-dev 2012-07-30 15:22:00 -07:00
Mathias Agopian d83d67b5d5 log more info on fence sync_merge error
also fix a typo where the wrong value was passed to sterror.

Change-Id: I4df2abe582e14c8f816b65818f4593a6bd3c23ea
2012-07-30 15:10:35 -07:00
Ed Heyl 747c480b0e Merge remote-tracking branch 'goog/jb-dev-mako' into jb-mr1-dev
Conflicts:
	include/media/hardware/CryptoAPI.h

Change-Id: I84bf34edbef000558f088bbf1d1e5b55d6217d2e
2012-07-28 09:55:54 -07:00
Mathias Agopian c666cae2d5 get rid of the shared-memory control block
Change-Id: If814060aca1d2ff2619d4adcd57296983d207f7f
2012-07-25 21:13:10 -07:00
Mathias Agopian 8785578391 add a layerStack attribute to Layers.
this attribute can be set through a regular transaction using
SurfaceComposerClient (just like any other attribute, eg: position or size)

Change-Id: I701a47c677ea6442ca713728a93335328cd2b172
2012-07-24 21:42:27 -07:00
Mathias Agopian 8b33f03232 update SF binder protocol to support setting display attributes
no change of functionality -- the old behavior is implemented
on top of this new protocol.
this new protocol will allow, eventually, to pass informations
about displays and layer stacks.

Change-Id: Ic6c2295e61ec8ecbc8ce01ab7664e35d928202fc
2012-07-24 20:43:54 -07:00
Nick Pelly 074cd0c076 Add elapsedRealtimeNano(), and use CLOCK_BOOTTIME where possible.
Change-Id: I4231c8ca32663e6e2cb5b7c126d091f837373807
2012-07-19 16:06:21 -07:00
Jeff Brown 6501e9944d Remove freeze(), unfreeze() and setFreezeTint().
This is all dead code.

Change-Id: I646673aac793a6ec45021c370a2450f0ea4fbcce
2012-07-16 15:38:18 -07:00
Jeff Brown f9176a93a5 Remove freezeDisplay(), which is no-op.
Change-Id: I2b70249a1545636fd6d98b58057b22f9529cad21
2012-07-16 14:58:11 -07:00
Steve Critchlow 47ad361cee Fix error trap in SurfaceTexture Client
There was an issue in Surface::lock where failure to lock a surface
resulted in two bad things happening:
- success was returned to the caller (it was apparently locked).
- an uninitialised pointer was returned as the buffer.

Change-Id: I8b0df81400e0fa0542a8bb993d76923ac96b686e
2012-07-10 14:09:10 +02:00
Naseer Ahmed 0bc64be3f5 libs/ui: Add support for triple framebuffers
Change-Id: I90dd38deeeda9a3785b87286cc7d252c6f948750
2012-07-09 22:04:19 -07:00
Jesse Hall e7db724bed Fix check for fence merge success
Change-Id: I9b16526ebfe4ffabf7c4372cca9b192ce046aa21
2012-07-03 13:41:54 -07:00
Jesse Hall dc5b485f74 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
2012-06-30 21:38:51 -07:00
Jesse Hall b42b1ac158 Return fence from acquireBuffer
Change-Id: Iab22054c1dc4fd84affab3cc5bbdcd5a1e689666
2012-06-30 21:38:51 -07:00
Jesse Hall c777b0b3b9 Pass fences with buffers from SurfaceTextureClient
Change-Id: I09b49433788d01e8b2b3684bb4d0112be29538d3
2012-06-30 21:38:51 -07:00
Jesse Hall 02a7be74dd Merge "Clarify aborted updateTexImage use of fences" 2012-06-29 09:54:25 -07:00
Jesse Hall 962174da03 Merge "Return fence to client in dequeuBuffer" 2012-06-29 09:54:08 -07:00
Jesse Hall d58c304cc6 Clarify aborted updateTexImage use of fences
When updateTexImage acquires a buffer but then aborts (due to an error
or the buffer being rejected), it releases the newly-acquired buffer.
It was passing the buffer slot's fences to releaseBuffer, even though
they hadn't been created after the acquire yet. This wasn't a bug,
since the fences would be cleared just after the buffer slot was last
released, but explicitly passing null fences makes this clearer.

Change-Id: I087f2ec3fd02c40f57782c1fca24eb9567e2943d
2012-06-28 17:08:42 -07:00
Jesse Hall f9783af225 Return fence to client in dequeuBuffer
Change-Id: Ic19750793ad993f0e85391f3cabd743ba565d4c9
2012-06-28 17:08:42 -07:00
Mathias Agopian 3094df359d First prototype atttempting to support an external display
both API and implementation will change, this is just a prototype
intended to show feasability.

SurfaceFlinger is passed an ISurfaceTexture through a new
callback, it is in turn used to create an EGLSurface which
surfaceflinger will draw into in addition to the main screen.

Change-Id: Id0bbb0b854bb7bae44d57246a90b65d4567f9a21
2012-06-28 15:51:08 -07:00
John Grossman ec44ed0758 Utils: Fix a bug in the linear transformation code.
Hand merge from ics-aah

> Utils: Fix a bug in the linear transformation code.
>
> Fix a bug where an incorrect result would be computed if you used the
> linear transformation code to do a reverse transformation (from B's
> domain into A's domain) when the scaler fraction was negative.
>
> Change-Id: I8e5f109314d235a177ab41f65d3c4cd08cff78be
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: Id90e18f685c61c1a89fd91c32adcf01363b3e8f3
Signed-off-by: John Grossman <johngro@google.com>
2012-06-27 15:34:43 -07:00
Johannes Carlsson 3443b333f1 am db1597a9: Fix shutdown sequence to avoid SIGSEGV when running am command
* commit 'db1597a98958b78dc0d8eced19ae1406382b70d6':
  Fix shutdown sequence to avoid SIGSEGV when running am command
2012-06-25 14:06:56 -07:00
Johannes Carlsson db1597a989 Fix shutdown sequence to avoid SIGSEGV when running am command
When the app_process is shutting down the main thread will close the
binder fd while pool threads are executing an ioctl (in
IPCThreadState::stopProcess called by AppRuntime::onStarted in
app_main.c).

The binder driver will then return all pending calls in ioctl
without any error and with a command. One of the threads gets a
BR_SPAWN_LOOPER which will create a new thread (the other thread
gets a BR_NOOP). This new thread then calls
vm->AttachCurrentThread. Usually this results in a log entry with
"AndroidRuntime: NOTE: attach of thread 'Binder Thread #3' failed",
but sometimes it also causes a SIGSEGV. This depends on the timing
between the new thread an the main thread that calls DestroyJavaVM
(in AndroidRuntime::start).

If IPCThreadState.cpp is compiled with "#define LOG_NDEBUG 0" the
pool thread will loop and hit the
ALOG_ASSERT(mProcess->mDriverFD >= 0) in
IPCThreadState::talkWithDriver.

Crashes like this has been seen when running the am command and
other commands that use the app_process.

This fix makes sure that any command that is received when the driver
fd is closed are ignored and IPCThreadState::talkWithDriver instead
returns an error which will cause the pool thread to exit and detach
itself from the vm. A check to avoid calling ioctl to a fd with -1
was also added in IPCThreadState::threadDestructor.

Another solution might be to change the binder driver so that it
returns an error when the fd is closed (or atleast not a
BR_SPAWN_LOOPER command). It might also be possible to call exit(0)
which is done when System.exit(0) is called from java.

Change-Id: I3d1f0ff64896c44be2a5994b3a90f7a06d27f429
2012-06-25 13:58:47 -07:00
Jesse Hall f785754009 Pass fences from BufferQueue to SurfaceTextureClient
ISurfaceTexture::dequeueBuffer now returns the buffer's fence for the
client to wait on. For BufferQueue, this means passing it through
Binder so it can be returned to the SurfaceTextureClient. Now
SurfaceTextureClient is responsible for waiting on the fence in
dequeueBuffer instead of BufferQueue: one step closer to the goal.

Change-Id: I677ae758bcd23acee2d784b8cec11b32cccc196d
2012-06-21 22:21:12 -07:00
Jesse Hall ef19414bd8 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
2012-06-21 22:21:12 -07:00
Jesse Hall a74cbc0649 Move remaining bits of lockBuffer to dequeueBuffer
FramebufferNativeWindow::dequeueBuffer now waits for the next buffer
to be non-front in addition to being free.

Change-Id: I991f154958cc6b488b1241aba83d1f95a0513b3c
2012-06-21 11:56:49 -07:00
Jamie Gennis d8e812ce6f Update ANativeWindow clients for sync
This change updates the uses of ANativeWindow to use the new ANW functions that
accept and return Sync HAL fence file descriptors.

Change-Id: I3ca648b6ac33f7360e86754f924aa072f95242f6
2012-06-20 15:48:30 -07:00
Jamie Gennis f25e183a70 libui: add the Fence class
This change adds the Fence class to libui for to wrap the libsync
functionality.

Change-Id: I93a31baeee608b93c14da807a32013dabf783f84
2012-06-20 15:48:30 -07:00
Mathias Agopian 3e87601170 Implement SurfaceFlinger's ANW on top of BufferQueue
SF now has its own implementation of ANW for the
framebuffer and it uses BufferQueue. FramebufferNativeWindow
is now only used by stand-alone apps.

Change-Id: Iddeb24087df62bd92b0f78e391dda9b97ddc859c
2012-06-13 18:07:47 -07:00
Colin Cross 52cf768fc2 Merge "surfaceflinger: replace early suspend with binder call from PowerManager" 2012-06-08 14:14:18 -07:00
Magnus Strandberg bd3ad5b23f am 1ba24574: Aligning native Parcel implementation to Java.
* commit '1ba24574b2debd3ca012adbbd77f12bed4f2d266':
  Aligning native Parcel implementation to Java.
2012-06-08 08:32:28 -07:00
Magnus Strandberg 1ba24574b2 Aligning native Parcel implementation to Java.
The Java implementation of writing the RPC response header
calculates the length of the header including the 4 bytes
specifying the header length but the native implementation
excludes the 4 bytes specifying the length from the header
length.
The native implementation has been aligned to the Java impl.

Change-Id: I325bf272a63152d8fded4cf4e51a906b5a9bfe19
2012-06-08 08:29:01 -07:00
Colin Cross 8e533069e5 surfaceflinger: replace early suspend with binder call from PowerManager
SurfaceFlinger will no longer directly synchronize with early suspend.
Instead, PowerManagerService will synchronize with SurfaceFlinger to
ensure that a black frame has been drawn on the display, and then
trigger all early suspend handlers.

Change-Id: I07acdd628440d23fdb69db94319ec5d65d3f4919
2012-06-07 16:28:30 -07:00