Commit Graph

340 Commits

Author SHA1 Message Date
Mathias Agopian 2ca79399b9 latch transparent region hint only when we get a new frame
since the transparent region hint really depends on the
content of the window containing the SurfaceView
(it's calculated by the view hierarchy based on
overlapping views), it makes sense to latch it only when
the content of the window (the app) changes.

This should help fixing drawing artifacts when changing the
layout of a window containing a SurfaceView.

Bug: 8511430
Change-Id: Ic3aa668495293cb4d82a2cd7dcf3b6a337287678
2013-04-02 18:30:32 -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
Jesse Hall ffe1f19ca9 Fix virtual displays for HWC<=1.1
If we're using a HWC that doesn't support virtual displays, or we have
more virtual displays than HWC supports concurrently, the
VirtualDisplaySurface should simply be a passthrough from source
(GLES) to sink.

This change also tries to distinguish between display types and HWC
display IDs a little better, though there's more to do here. Probably
needs a higher-level rethink; it's too error-prone now.

Bug: 8446838
Change-Id: I708d2cf262ec30177042304f174ca5b8da701df1
2013-03-22 15:27:58 -07:00
Jesse Hall 48bc05b56d Fix dump when virtual display exists
SurfaceFlinger::getLayerSortedByZForHwcDisplay only worked for builtin
displays.

Bug: 8384764
Change-Id: I989275407fb2f06d166a6e70321c3211e27e562e
2013-03-22 15:27:58 -07:00
Mathias Agopian ed98557414 make sure screenshot are in a format supported by Bitmap.java
Change-Id: I0fb9cc4088f9c1fd27e6c017b0a7c5617adb4660
2013-03-22 00:24:39 -07:00
Mathias Agopian 50210b9a8d fix a typo that broke all screenshots
Bug: 8450197

Change-Id: I5b986cc0ff9c5e689d06a51ba68ab537d03d1f3d
2013-03-21 21:14:10 -07:00
Mathias Agopian b4b1730abb only use glReadPixels() when needed when taking screenshots
some drivers don't support this yet, so we use a system
property to enable the glReadPixels "workaround" for them:

  ro.bq.gpu_to_cpu_unsupported=1

Change-Id: I74d6a3a8f0cee8d5a507b72c760cf247e39195e0
2013-03-21 14:01:53 -07:00
Mathias Agopian abe815dd69 rework how we take screenshots for a CPU consumer
We're not using IMemoryHeap as a transport anymore,
instead we're providing a CpuConsumer and use the
IGraphicBufferProducer version of the screenshot API.

However, some GPU drivers don't support properly
a GPU to CPU path, to work around this, we use a
temporary BufferQueue on the server side for the
GL rendering, and we use glReadPixels into the
CpuConsumer (we're now using a CPU to CPU path
which is always supported).

Currently this "wrapping" is always performed,
but it can be bypassed on devices that support
the GPU to CPU path.

This also addresses a DoS attack vector on
SurfaceFlinger, where an application could
consume all of SF's filedescriptors by creating
a lot of screenshots in a row.

Bug: 8390553

Change-Id: I9e81514c2a7711b9bb393f74305be7d2abe08f1c
2013-03-19 22:22:21 -07:00
Jesse Hall fae23b8757 Merge changes I61ae54f3,I57cb668e,I7a3f1e1a,Id28a2f9b into jb-mr2-dev
* changes:
  Add BufferQueueInterposer and use it for virtual displays
  Add DisplaySurface abstraction
  Fix argument types in IGraphicBufferProducer methods
  Minor cleanups/fixes before virtual display refactoring
2013-03-19 17:45:29 +00:00
Jesse Hall 99c7dbb249 Add DisplaySurface abstraction
DisplayDevice now has a DisplaySurface instead of using
FramebufferSurface directly. FramebufferSurface implements
DisplaySurface, and so does the new VirtualDisplaySurface class.
DisplayDevice now always has a surface, not just for virtual displays.

In this change VirtualDisplaySurface is just a stub; buffers still go
directly from GLES to the final consumer.

Bug: 8384764
Change-Id: I57cb668edbc6c37bfebda90b9222d435bf589f37
2013-03-18 14:21:16 -07:00
Jesse Hall 7adb0f8a9f Minor cleanups/fixes before virtual display refactoring
None of these should change behavior, except for removing some
incorrect log messages when using a virtual display.

- HWComposer::getAndResetReleaseFenceFd() checks the HWC version, so
  no need to do that in the DisplayDevice::onSwapBuffersCompleted().
  However, it should check that mFramebufferSurface is not NULL like
  it is for virtual displays.
- Comment that FramebufferSurface::dump() overrides the non-virtual
  ConsumerBase::dump(), and fix it so the right thing happens
  regardless of the static type of the pointer/reference the callee
  has. FramebufferSurface::dump() could be removed right now, but I'd
  need to bring it back in a later change.
- Use the right enum for validating display type ids.
- Don't try to send hotplug events for virtual displays.
- Mark virtual displays as connected so HWComposer::prepare() doesn't
  think something is wrong when it gets a non-NULL layer list.
- Remove unused FramebufferSurface methods.

Bug: 8384764
Change-Id: Id28a2f9be86b45f4bb7915fdf7752157035f4294
2013-03-18 14:16:02 -07:00
Mathias Agopian 041a075262 don't allow screenshots without the READ_FRAMEBUFFER permission
the recent screenshot rework allowed the older screenshot
interface to work without that permission

Change-Id: I6c4743f4591c81106e3b823d55a055f7b4907de1
2013-03-15 18:39:16 -07:00
Mathias Agopian 7670d3cb2b Merge "get rid of purgatory and fix QueuesToWindowComposer query" into jb-mr2-dev 2013-03-16 01:14:35 +00:00
Mathias Agopian a493be5825 don't capture hidden layers in screenshots
Bug: 8389956
Change-Id: I9ed836395258732c743c6fd44092bd01020dde13
2013-03-15 16:08:10 -07:00
Mathias Agopian 6710604286 get rid of purgatory and fix QueuesToWindowComposer query
the purgatory list wasn't needed anymore; in fact it had no effect as
buffer life-time management is now handled by the BufferQueue.

For QueuesToWindowComposer we keep a list of wp<> on the IBinder
for IGraphicBufferProducers we hand over to clients so we can
easily check if an IGraphicBufferProducer is ours. We clean-up the
list when our IGraphicBufferProducer are destroyed.

Bug: 8349142
Change-Id: I1aa06652ade8c72d0004a3f5e6c3d6e8a82fc2ae
2013-03-14 19:18:13 -07:00
Mathias Agopian 6a531717cd size IMemoryHeap properly for screenshots
since we're using glReadPixels(), we only need to use
the width (as opposed to the stride) of the source
screenshot.

Bug: 8374664
Change-Id: I145c80f4fff5444df7c77c4f52e70a7203caddbd
2013-03-13 15:22:11 -07:00
Mathias Agopian 4d9b822e2c get rid of ISurface
ISurface was only used to get the IGraphicBufferProducer from
a Layer. It's now replaced by a BBinder subclass / IBinder and
is only used as a handle to the surface, to both refer to it
and manage its life-time.

Also cleaned-up a bit the ISurfaceComposer interface and
"create layer" code path.

Change-Id: I68d0e02d57b862cffb31d5168c3bc10cea0906eb
2013-03-12 17:11:48 -07:00
Mathias Agopian b7a5b05b53 Fix missing recents screenshots
We were using the "visible layer list" when taking screenshots,
which doesn't work when a layer is behind other opaque layers
and therefore hidden.

We fix this by using the full layer list, filtered by the
layerstack of the display we're looking at.

Bug: 7552304
Change-Id: I4b6f77e5511aea94f8d218975b6e22738e7e5d5b
2013-03-11 20:47:24 -07:00
Mathias Agopian d577641411 make sure to call compositionComplete after taking a screenshot
older drivers which are doing implicit synchronization need this
or they could deadlock.

Bug: 8341885
Change-Id: Icd980a6be16071678d6151e34725b3c1c547d7ee
2013-03-08 13:54:46 -08:00
Mathias Agopian 2be4e8ff23 workaround to fix screenshot leak on N4
Bug: 8322020

Change-Id: Ie60af0eb431866b8d64b2674ae7bd8b5ee05f5d6
2013-03-06 20:44:16 -08:00
Mathias Agopian 438ca07b6b Merge changes I66511c08,Ia051949f,Ic7451365,I5b571a4c into jb-mr2-dev
* changes:
  Get rid of LayerBase.
  Make LayerDim a regular Layer instead of a LayerBase
  fold LayerBaseClient into LayerBase
  Remove support for ScreenshotLayer
2013-03-07 01:47:34 +00:00
Mathias Agopian 13127d8921 Get rid of LayerBase.
The functionality of LayerBase and Layer is folded
into Layer. There wasn't a need for this abstraction
anymore.

Change-Id: I66511c08cc3d89009ba4deabf47e26cd4cfeaefb
2013-03-05 19:52:30 -08:00
Mathias Agopian b79f61d41e fold LayerBaseClient into LayerBase
Change-Id: Ic745136522df59c42f0885fd969e75ea55d09f01
2013-03-05 19:52:30 -08:00
Mathias Agopian 089a15298e Remove support for ScreenshotLayer
Change-Id: I5b571a4cf3faa77d2c4aca916fa4bd00a1065bb9
2013-03-05 19:52:29 -08:00
Jeff Sharkey 175264b09c Return NO_MEMORY when glReadPixels() fails.
Change-Id: Ic66134ef457e8442ae9135e9ec50e3d02932a253
2013-03-05 18:00:01 -08:00
Mathias Agopian 306f18c5fb Merge "rework screenshot API and implementation" into jb-mr2-dev 2013-03-05 02:30:13 +00:00
Jesse Hall eabe3140f1 Merge "Init displays to null layer stack" into jb-mr2-dev 2013-03-05 01:04:54 +00:00
Mathias Agopian 2a9fc493df rework screenshot API and implementation
- SurfaceFlinger now supports to take a screenshot
  directly into an IGraphicBufferProducer

- reimplement the IMemoryHeap screenshot on top
  of the above

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

Bug: 6940974

Change-Id: I69a2096b44b91acbb99eba16f83a9c78d94e0d10
2013-03-01 22:53:39 -08:00
Jesse Hall 01e29054e6 Init displays to null layer stack
When a display is added, initialize it to use an empty layer stack, so
if it is somehow visible it will show black. It will be assigned the
real layer stack -- along with a projection and other properties -- by
window manager soon. Normally a display remains blanked until window
manager has decided what to show on it, but for HDMI connected at boot
that isn't currently the case.

Bug: 7258935
Change-Id: Ic9bb25f7a9b8d9d3772b097ab1d6fa03bc8780a1
2013-02-28 21:05:30 -08:00
Mathias Agopian 5219a06d61 set correct crop rectangle in LayerBase::setCrop
The crop always had left=top=0, because the crop position
and the layer's transform were merged together in
computeBounds() (which really used to compute the
bounds in screen space, which we usually call the
"frame" elsewhere in the code)

Note: in practice this crop value is not used by
hwc, because it's overridden in Layer::setGeometry(), which
is why this bug was never apparent.

Change-Id: I1ec6400a8fc8314408e4252708f43ea98c2fe64e
2013-02-28 18:43:04 -08:00
Jesse Hall a9a1b006e4 Initialize DisplayData fences to NO_FENCE, not NULL
Also fix another place that was checking for NULL fence rather than
Fence::isValid().

Bug 8283950

Change-Id: Ie06db327eb416828d8dac139171d96d4470b2e35
2013-02-27 16:48:41 -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
Jamie Gennis 4b0eba949c SurfaceFlinger: add win anim frame time tracking
This change makes the 'dumpsys SurfaceFlinger --latency' command with no extra
args dump the frame timestamp data for the most recent frames that
SurfaceFlinger generated that included window animation transaction changes.

Change-Id: I8bded1ea08a4cddefef0aa955401052bb9107c90
2013-02-08 13:32:21 -08:00
Andy McFadden c19c15174b Merge "Add some comments." 2013-01-11 15:05:40 -08:00
Andy McFadden 8f06a8c2c8 Reduce C++11 warnings
A few typecasts to fix "narrowing conversion" complaints.

Change-Id: Ib2118079a2ca33959c748d03d8c6f1722d62e8fe
2013-01-11 10:24:34 -08:00
Andy McFadden 882e3a39ed Add some comments.
Also, minor tweak to SurfaceTextureLayer.

Change-Id: If616d5ee4e8226dd0e16c5dbb0e0f80db553110e
2013-01-11 10:16:10 -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 392edd88cb SurfaceFlinger: Move GraphicBufferAlloc to libgui
This change moves the GraphicBufferAlloc class from SurfaceFlinger to libgui.

Change-Id: Idf31d2004efa2651b60590733f73c4a7b831e8a9
2012-12-11 17:54:29 -08:00
Mathias Agopian 9913b9941e am a7da0dda: am 98cbec81: am efd614b8: Merge "make transform hint multi-display aware" into jb-mr1.1-dev
* commit 'a7da0dda39cf1e807eea1304b48d4583e7329b72':
  make transform hint multi-display aware
2012-11-27 18:43:52 -08:00
Mathias Agopian a7da0dda39 am 98cbec81: am efd614b8: Merge "make transform hint multi-display aware" into jb-mr1.1-dev
* commit '98cbec81be1d39223e33abde9ac35e43b62918bf':
  make transform hint multi-display aware
2012-11-27 16:10:29 -08:00
Jesse Hall 6edebdf600 Create builtin display tokens on demand
For hotpluggable builtin displays (currently just HDMI), create the
display device IBinder token when the display is connected and destroy
it when the display is disconnected. Previously we created the tokens
at startup and never changed them. This made it so that when comparing
current and drawing state, we couldn't tell whether a display had been
disconnected and reconnected.

Bug: 7491120
Change-Id: I2ac82b864e10cb1cd0a308782d7e0ab9745c5d81
2012-11-27 12:30:18 -08:00
Mathias Agopian 8430095879 make transform hint multi-display aware
if a layer is not mirrored, we now use its display
as the source for the transfrom hint calculation
instead of always using the default (main) display.

this change does two thing:
1) we make updateTransformHint take a DisplayDevice
   as a parameter instead of hard-coding the
   main display.

2) each time we do a transaction that could change
   the hint, we go through all layers and
   figure out which display should be used for their
   transform hint.

Bug: 7599344
Change-Id: I9b04a95e6c372dd770bacf81d8ef6f8e31b87b83
2012-11-21 16:03:52 -08:00
Jesse Hall 692c723e84 Create builtin display tokens on demand
For hotpluggable builtin displays (currently just HDMI), create the
display device IBinder token when the display is connected and destroy
it when the display is disconnected. Previously we created the tokens
at startup and never changed them. This made it so that when comparing
current and drawing state, we couldn't tell whether a display had been
disconnected and reconnected.

Bug: 7491120
Change-Id: I23b77037dc0f548d549abf580339edd0e3c626e9
2012-11-09 11:48:25 -08:00
Mathias Agopian 2788a3526d am 731e0331: am e70fbe8b: am 02b95105: fix transitions from hwc to GLES composition
* commit '731e0331eb402ec4564b69eaeb8b605a8b800b1b':
  fix transitions from hwc to GLES composition
2012-11-05 18:19:53 -08:00
Mathias Agopian 02b9510575 fix transitions from hwc to GLES composition
If we switched from HWC to GLES but the dirty region was empty
(could happen if the dirty region is outside of the screen for instance), we
need to force a full screen composition.

In this change we ignore the dirty region for the purpose of
rejecting the whole update and we rely on the fact that it will later
be expanded to the whole screen. This was the least risky fix.

Bug: 7467760, 7452931
Change-Id: I2132f2f963b00a3ce7150adadb107b0367b3862e
2012-11-05 17:50:57 -08:00
Mathias Agopian 766dc49c17 rework a bit how we scissor the display
the scissor rect is now computed once by DisplayDevice
and is combined with the "undefined" region so that
the letter-boxed area of the screen get cleared in
drawWormhole.

Bug: 7149437
Change-Id: Id2f30516a5786f32eace7f876ff32028f954f357
2012-10-31 14:22:51 -07:00
Mathias Agopian f45c510009 partially implement external display clipping
we perform external display clipping only on the GL
side (ie: not done on the h/w composer side, which is
harder and would be too risky). in practice this means
that WFD will be clipped properly, while HDMI *may* or
may not depending on how hwc is used.

Bug: 7149437
Change-Id: I92d4d04220db72b6ffb134c7fa7a93af569723a5
2012-10-25 12:42:42 -07:00
Mathias Agopian d17e3b5f6c prevent a client from crashing surfaceflinger
a misbehaving or malicious client could cause SF to crash
by providing a "fake" IInterface. we now check the
IInterface we get is our own and local.

Bug: 7278879
Change-Id: Ia19d05902d4b2385c5a16416148378d4998833fd
2012-10-22 14:54:23 -07:00
Jamie Gennis dd3cb84cfb SurfaceFlinger: add support for secure displays
This change adds support for displays that are not allowed to display surfaces
with the eSecure flag set.  All non-virtual displays are considered secure,
while virtual displays have their secure-ness specified at creation time.

Bug: 7368436
Change-Id: I81ad535d2d1e5a7ff78269017e85b111f0098500
2012-10-22 13:41:21 -07:00