Commit Graph

70 Commits

Author SHA1 Message Date
Dan Stoza c5fe5044f4 libgui: Check slot received from IGBP in Surface
Checks that the slot number received from mGraphicBufferProducer in
Surface::dequeueBuffer is on the interval [0, NUM_BUFFER_SLOTS) to
protect against a malicious BnGraphicBufferProducer.

Bug: 36991414
AOSP-Change-Id: I1a76fd1bcce1c558f1c0c30f03638278288ed4fa
(cherry picked from commit 90ce2a9c1d3af422c66b4061805831cb208263d8)

CVE-2017-0665

Change-Id: If0fd4864b9fc4ea5a1c83d10adef26cdabb0f7e8
2017-07-06 21:31:56 +02:00
Baldev Sahu a1288c979d libgui: Copyback all region except dirty region for newly allocated buffer
Inside Surface::lock if new buffer is allocated
and DirtyRegion does not cover complete buffer
bounds then copyback may not cover all remaining area
as it copyback only area covered by dirty regions
from other buffers. This will lead to left out
black area which may cause flicker.

Change-Id: I4a3f7a56fc5fbaf4af926584919577d8d34bed57
2015-10-06 03:22:27 -06:00
Omprakash Dhyade 8760f1673e fix copy back dirty region
Copyback dirty region logic does copyback,
even when its not necessary causing 2ms delay.
Fix the logic to copy back only what is necessary

CRs-fixed: 562334
Change-Id: I52de68258ac9f87d704ee5401f93417805fa6773
2015-10-06 03:22:27 -06:00
Dan Stoza db4850c01f libgui: Fix handling of rotated surface damage
Incoming surface damage was not aware that the EGL implementation was
rotating buffers in response to SurfaceFlinger's transform hint. This
didn't affect all cases because the effect was to apply a 90 degree
rotation instead of a 270 degree rotation. For full-screen updates,
things more or less worked, but in other cases this caused corruption.

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

Bug: 22068334
Change-Id: I226ecfc7a91fe2e16edd2aa6d9149f0d26b529d6
2015-06-25 16:10:18 -07:00
Dan Stoza c6f30bdee1 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
2015-06-08 09:40:49 -07:00
Dan Stoza a2ca9bf0a9 Revert "libgui: Add getConsumerName"
This reverts commit 107fbe5599.

Change-Id: I0c2b0f7c81193b05eb3dd2f5a59f83598434b744
2015-06-08 16:30:08 +00:00
Dan Stoza 107fbe5599 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
2015-06-05 15:01:58 -07:00
Dan Stoza 812ed0644f 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
2015-06-03 11:09:33 -07:00
Dan Stoza 0e65e6c283 libgui: Fix surface damage on rotated buffers
Flips the width and height when the buffer comes in with a 90 degree
rotation so that performing the Y-flip from GL works correctly.

Bug: 20761426
Change-Id: I41c9edc8549c6cbdb534277b996ff20c59034582
2015-05-26 13:22:27 -07:00
Taiju Tsuiki 4d0cd3f524 Close Fence FDs in error cases of Surface and GraphicBufferMapper
Surface::{cancel,queue}Buffer and GraphicBufferMapper::lockAsyncYCbCr take the
ownership of |fenceFd|s. Though they don't close it on error cases.

Change-Id: I49a7ce8837d5c510c4ac4ad4649f310d18610e80
(cherry picked from commit c7263fb432)
2015-04-30 14:50:17 -07:00
Dan Stoza d9c4971da2 libgui: Change detachNextBuffer to return sp<GB>
Changes Surface::detachNextBuffer to return an sp<GraphicBuffer>
instead of an ANativeWindowBuffer* to ensure that reference counting
works correctly.

Bug: 20092217
Change-Id: I3979ea6121aaf14845f0554477b778770413581e
(cherry picked from commit 8b2daa3ca29492b181fb67840640d771c4a2b3ac)
2015-04-27 11:45:58 -07:00
Dan Stoza c62acbd127 libgui: Fix CPU rendering on Surface
When the surface damage code went in, it incorrectly assumed that if
an application was doing CPU rendering, it would be using lock and
unlockAndPost instead of dequeue and queue, so it repurposed the dirty
region too aggressively. This change keeps it from clobbering the
dirty region if a CPU producer is attached.

Bug: 20431815
Change-Id: Id4dfd71378311ea822f0289f6de2d20a7bd84014
2015-04-21 16:56:52 -07:00
Dan Stoza 5065a55291 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
2015-04-15 13:19:38 -07:00
Dan Stoza 231832eb27 DO NOT MERGE libgui: Plumb attach/detach through Surface
Exposes the attachBuffer and detachNextBuffer calls from
IGraphicBufferProducer to the public Surface interface. Also moves
the version of connect that takes a producer callback from protected
to public.

Bug: 19628705
Change-Id: I9ebc3013c4d9c84c4e8ef150c00e03f8af80319e
(cherry picked from commit c14ecb9de2)
2015-04-02 13:35:45 -07:00
Eino-Ville Talvala 82c6bcc970 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
2015-03-19 13:56:00 -07:00
Dan Stoza 966b98bd86 Surface: Permit an IProducerListener on connect
This change allows clients of Surface to provide an IProducerListener
callback object to Surface::connect, which will be passed down to the
underlying IGraphicBufferProducer.

Cherry pick of I5ea5229bf3a329bf02c6bd20e7247039c75d136b

Change-Id: I6f8f52c72654e4cee649721383819bafe378f964
2015-03-18 16:01:20 -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
Andreas Gampe b93bca5d08 am a59d7a6a: Merge "GUI: Remove unused variables"
* commit 'a59d7a6a66a2b8dcb2d00dbd6371fa89ae45ab04':
  GUI: Remove unused variables
2014-12-09 20:09:18 +00:00
Andreas Gampe 7398a5af38 GUI: Remove unused variables
For build-system CFLAGS clean-up, remove unused variables.

Bug: 18632512
Change-Id: I79fdcf830683d7278f4bf114cfb76a26da1b88ff
2014-12-08 20:42:40 -08:00
Dan Stoza dd883c0b08 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.

This is a squashed commit based on an initial change with a couple of
fixes to avoid breaking certain targets. The source commits are:
  d723bd7669
  00d504c06e
  429ba89cd2

Change-Id: I034abec27bf4020d84af60d7acc1939c59986dd6
2014-12-05 14:59:29 -08:00
Jesse Hall 9f5a1b6abd Surface: cancel the dequeued buffer when requestBuffer fails
Partial fix for bug: 17477219
Change-Id: Ibf5a9e26e02c4be8854925a77a70f5c9c7dcf6f2
2014-10-02 18:16:19 +00:00
Rachad 7cb0d39016 Tunneled Video Playback support
Added native_window_set_sideband_stream() method to Surface.[h|cpp]
 Added ConfigureVideoTunnelModeParams OMX configuration structure to
 HardwareAPI.h

Bug: 16132368
Change-Id: I28fa1b9dbe858d93e353e0991098cad45c626bd9
2014-08-04 21:57:22 +00:00
Ruben Brunk 1681d95989 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
2014-07-14 22:14:32 +00:00
Dan Stoza 29a3e90879 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
2014-06-20 13:13:57 -07:00
Greg Hackmann f974bffb36 am 38c9e132: am c1ffd351: am bd20e551: Merge "Use asynchronous lock/unlock API"
* commit '38c9e1327a5b24267c3dab5293bc9d7ada6e9fc9':
  Use asynchronous lock/unlock API
2014-05-12 18:18:47 +00:00
Francis Hart 8f3960179c Use asynchronous lock/unlock API
The gralloc API now provides a way for using lock/unlock with the Android
explicit synchronisation concept. This changes updates the GraphicBuffer class
to also expose this functionality, and updates the Surface class to make use of
in line with the dequeueBuffer/queueBuffer mechanism.

This new behaviour is dependent on GRALLOC_MODULE_API_VERSION_0_3. If the local
gralloc module does not support this then the existing synchronous lock/unlock
mechanism will be used.

Change-Id: I8c3fd9592e0c5400ac9be84450f55a77cc0bbdc5
2014-05-12 09:13:03 -07:00
Greg Hackmann 2f3dca149a am 9493d492: am 9eb142e3: am a9d49f99: Merge "Revert "Use asynchronous lock/unlock API""
* commit '9493d4924a59f14b698389386337a9c07a7ea3c4':
  Revert "Use asynchronous lock/unlock API"
2014-05-09 22:00:04 +00:00
Greg Hackmann 02528cf6aa am 4b46776f: am 8a6cd189: am f60564a1: Merge "Use asynchronous lock/unlock API"
* commit '4b46776ff88c5a365700b88e8b2b04e1b2c77e6e':
  Use asynchronous lock/unlock API
2014-05-09 21:54:48 +00:00
Greg Hackmann 53ec72523a Revert "Use asynchronous lock/unlock API"
This reverts commit 378ef07760.

Change-Id: I1de5ab973b5383633e75924fe90ac3ca8216c36a
2014-05-09 21:36:48 +00:00
Francis Hart 378ef07760 Use asynchronous lock/unlock API
The gralloc API now provides a way for using lock/unlock with the Android
explicit synchronisation concept. This changes updates the GraphicBuffer class
to also expose this functionality, and updates the Surface class to make use of
in line with the dequeueBuffer/queueBuffer mechanism.

This new behaviour is dependent on GRALLOC_MODULE_API_VERSION_0_3. If the local
gralloc module does not support this then the existing synchronous lock/unlock
mechanism will be used.

Change-Id: I77daa1beb197b63b1c2f281b8414ac4ae4b5b03c
2014-05-02 13:28:14 -07:00
Dan Stoza f0eaf25e92 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
2014-03-31 14:10:07 -07:00
Wonsik Kim 0ee14ca23d Fill in sideband stream caveat
Change-Id: I20db8aea8f13acf31b42db08d90b338da8a5209c
2014-03-17 17:46:53 +09:00
Igor Murashkin 0f1889efe7 gui: Surface::dequeueBuffer no locker holds mutex while blocking in binder
- This also fixes a hang in the camera service when trying to shut down
  if the producer is infinitely blocked while trying to get a new buffer.

Bug: 13250382
Change-Id: I32ca82162bb8645b97dbe084e13e05ca05529a42
2014-03-03 11:42:27 -08: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 365857df8b Make sure do disconnect from a BQ when its client dies.
Bug: 5679534

Change-Id: If447e8673df83fe0b1d6210641e0a48522501a53
2013-09-16 16:15:21 -07:00
Eino-Ville Talvala 7895e90e29 Surface: Fix controlledByApp parameter
Bug: 10425641
Change-Id: I1a47e2ce4ecbdb8e67030a5d9ddf6604c5e2497d
2013-08-21 12:05:42 -07:00
Andy McFadden 3c25621ad7 Re-enable frame dropping for non-auto timestamps
This change adds an entire field to note whether the timestamp was
auto-generated by Surface or supplied by the application.

The value is used when deciding whether or not to drop frames based
on buffer presentation timestamps.  If a desired presentation time
was set explicitly, BufferQueue will use that value to decide if a
frame should be dropped.  If the timestamp was generated by Surface
at the time the buffer was queued, the timestamp is ignored.

Bug 10151804

Change-Id: Ibd571a7578351063b813cbdad2ddbeed70655ba5
2013-08-16 15:15:16 -07:00
Andy McFadden d9ba9707b0 Merge "Roll back recent change" 2013-08-02 22:34:13 +00:00
Andy McFadden 4b49e08385 Roll back recent change
Disable dropping of frames based on timestamp.  Resume auto-
generating timestamps in Surface.

Bug 10151804

Change-Id: I15de26158e1d7ef22a5b150e685a126dc48ae2b4
2013-08-02 15:31:45 -07:00
Andy McFadden 86cd09d388 Merge "Drop frames based on presentation timestamp" 2013-08-02 16:53:11 +00:00
Andy McFadden 14fab7dd79 Drop frames based on presentation timestamp
If there are two or more buffers pending that are ready for
immediate presentation, drop all but the last one.

Any code that didn't explicitly specify timestamps for buffers
was using the default value (auto-generated "now").  As a result,
surfaceflinger would drop frames whenever more than one buffer
was queued.  We now use zero as the auto-generated timestamp,
and we don't set the timestamp in eglBeginFrame().

Change-Id: I187f42d33de227cd3411ff0dcd3b9ce1961457eb
2013-08-01 15:58:08 -07:00
Mathias Agopian ba93b3f8e4 log an error when dequeueBuffer gets a NULL Fence
Bug: 9858745
Change-Id: If35d6a7d770bf0a42d55bc55880a9ddb721fcfd0
2013-08-01 15:48:40 -07:00
Mathias Agopian 7cdd786fa8 Make ANW.setSwapInterval(0) work again
we can now queue/dequeue a buffer in asynchrnous mode by using the
async parameter to these calls. async mode is only specified
with those calls (it is not modal anymore).

as a consequence it can only be specified when the buffer count
is not overidden, as error is returned otherwise.

Change-Id: Ic63f4f96f671cb9d65c4cecbcc192615e09a8b6b
2013-07-19 17:38:01 -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
Mathias Agopian ea74d3b78d make the warning timout of Fence::waitForever() implicit and longer
- timeout is now 3 seconds instead of 1
- simplifies the API a bit
- allows us to change/tweak this timeout globaly

Bug: 8988871

Change-Id: I8d3c6ec43a372f602fb3f29856710339f86c0ec9
2013-05-16 18:15:57 -07:00
Jesse Hall 4c00cc1114 Fix argument types in IGraphicBufferProducer methods
Bug: 8384764
Change-Id: I7a3f1e1a0584a70af04f9eafef900505389d2202
2013-03-18 14:16:02 -07:00
Mathias Agopian 35ffa6a868 Surface can now be created only from an IGraphicBufferProducer
it can't write itself to a parcel, nor can it be created from a
parcel.

Change-Id: I69165d5c54d6024b3e546e80d8b57e3dedda7893
2013-03-12 18:45:09 -07:00
Jesse Hall 006a601f22 Fix reading NULL Surfaces from Parcels
Writing a NULL Surface was being read as a non-NULL Surface with NULL
mGraphicBufferProducer. Before the SurfaceTextureClient -> Surface
refactoring, you'd get a NULL Surface, and some code relies on that.

Bug: 8291161
Change-Id: I477bfe8882693e53a5f604a3d2c9e3cfe24473b4
2013-03-02 20:06:42 -08:00
Mathias Agopian e3c697fb92 Refactoring: Rename SurfaceTextureClient to Surface
Change-Id: Ibed34175ae273608393aaa5f0a7df207dc40d709
2013-02-14 19:19:05 -08:00
Mathias Agopian ac9fa427d4 get rid of Surface identity and token
we use the IBinder instead.

Change-Id: I4aa0b58869ba43f19980013620051e5a261b062d
2013-02-13 15:27:08 -08:00