Commit Graph

298 Commits

Author SHA1 Message Date
Jesse Hall d05a17fbb3 Treat composition frames with no layers as using GLES composition
When there are no window layers for a display, SurfaceFlinger clears
the undefined region using GLES. Some of the places that check for
GLES composition weren't considering this special case, in particular:

- We were skipping the eglSwapBuffers() on these frames.
- We were putting VirtualDisplaySurface in HWC-only composition mode.

This change centralizes the logic for this special case.

Bug: 10957068
Change-Id: I2deaf2ed101e8ea76708862a6bb67751b6078794
2013-09-30 17:08:28 -07:00
Mathias Agopian ff98f3e598 am 338acd68: am 86206b41: Merge "fix initialization of framebuffer target crop rect on hwc 1.3" into klp-dev
* commit '338acd6869532f2684cbd1e4f273eaffc6d4ef6d':
  fix initialization of framebuffer target crop rect on hwc 1.3
2013-09-26 12:47:35 -07:00
Mathias Agopian 2b3d0c4079 am 0ff4b283: am 6da15f46: fix crashers with wifi/virtual displays
* commit '0ff4b28396d77a0ed2f191836895a891108a8b5b':
  fix crashers with wifi/virtual displays
2013-09-26 12:47:35 -07:00
Mathias Agopian 86206b41b2 Merge "fix initialization of framebuffer target crop rect on hwc 1.3" into klp-dev 2013-09-26 19:41:22 +00:00
Mathias Agopian 8f63c2049b fix initialization of framebuffer target crop rect on hwc 1.3
Bug: 10936771
Change-Id: If283e5e231ca34b93e0b1784bb4e8e4c7bfd75de
2013-09-25 20:44:34 -07:00
Mathias Agopian 6da15f46f5 fix crashers with wifi/virtual displays
Bug: 10647742
Change-Id: I4b8ed9da52ef95af3a3b3a04b98514a3776a674d
2013-09-25 20:40:07 -07:00
Christopher Ferris 6de9653ac8 Merge "Remove unnecessary include." 2013-09-19 23:16:10 +00:00
Christopher Ferris d142f4b787 Remove unnecessary include.
All these files are including utils/CallStack.h, but none of the code
uses any CallStack objects.

Change-Id: I38c3a346a3bd0ddbff368d0f7f8b3f3d78fc0432
2013-09-19 15:45:03 -07: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
Jesse Hall 8db92553e9 Force async behavior for the virtual display output BufferQueue
Bug: 10551087
Change-Id: I40bbb2b87d64420939a0ea309254f281437dab56
2013-08-29 16:09:11 -07:00
Mathias Agopian bef42c50eb handle several vsync signal correctly
Change-Id: I34935d2197ce8e914fef2f110896e47b44225ad2
2013-08-21 17:45:46 -07:00
Jesse Hall 028dc8f2d7 Provide HWC prepare with a valid output buffer
We weren't dequeing and setting the output buffer until just before
set(). This didn't allow HWC to make decisions in prepare() based on
the output buffer format, dimensions, etc.

Now we dequeue the output buffer at the beginning of the composition
loop and provide it to HWC in prepare. In GLES-only rendering, we may
have to cancel the buffer and acquire a new one if GLES requests a
buffer with properties different than the one we already dequeued.

Bug: 10365313
Change-Id: I96b4b0a851920e4334ef05080d58097d46467ab8
2013-08-20 16:35:32 -07:00
Jesse Hall 353ddc6e77 Fix HWComposer dumping of float source crops
Change-Id: I45a9344b5fab17ccb54bebd01382d738a03860e6
2013-08-20 16:11:50 -07:00
Andy McFadden 90f59bf9eb Merge "Re-enable frame dropping for non-auto timestamps" into klp-dev 2013-08-19 14:27:28 +00: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
Jesse Hall 9e663de4fe Use new HWC display type/count constants.
Change-Id: I774d0c68906ac6dc69268f708c30a6b0868b8816
2013-08-16 14:28:37 -07: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 ad678e18b6 single buffer mode for BufferQueue
Bug: 9891035
Change-Id: Id1ab5f911a6dc4c1d8235e65775b3d3635231ad4
2013-07-26 18:45:02 -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
Jesse Hall bce7611e8e Fix build -- update for function signature change
Change-Id: I9c2448d5853c69ec7e962847fdaba9a99906cc42
2013-07-16 13:46:20 -07:00
Jesse Hall 3bc3840888 Merge "Rewrite VirtualDisplaySurface" 2013-07-16 20:29:30 +00:00
Jesse Hall 38efe86d94 Rewrite VirtualDisplaySurface
The previous implementation assumed that the HWC could read and write
the same buffer on frames that involved both GLES and HWC composition.
It turns out some hardware can't do this. The new implementation
maintains a scratch buffer pool to use on these mixed frames, but on
GLES-only or HWC-only frames still does composition directly into the
output buffer.

Bug: 8384764
Change-Id: I7a3addb34fad9bfcbdabbb8b635083e10223df69
2013-07-15 13:59:41 -07:00
Andy McFadden c33f9a76b5 Merge "Pay attention to buffer timestamps" 2013-07-11 14:40:45 +00: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
Mathias Agopian 6b44267a3b fix SF buffer cropping
When a buffer had a crop (meaning its content is scaled to the window size)
and a window crop was defined, the resulting crop couldn't be expressed
properly because h/w composer's API was limited to integers, since
this is fixed in h/w composer 1.3, we take adventage of this to
make sure we get the correct crop.

this bug could result in the buffer being scaled by an incorrect ratio and
be slightly offset; moreover, it would produce different results from the
GL code path, which is always correct.

Change-Id: I8e20e00b6e26177d14f4ab4d2cd581e26c818892
2013-07-10 15:08:29 -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 2381033ad0 am e6eef6c1: am ea74d3b7: make the warning timout of Fence::waitForever() implicit and longer
* commit 'e6eef6c136b007f3a7e1e19884875b855c0c5f95':
  make the warning timout of Fence::waitForever() implicit and longer
2013-05-17 10:18:45 -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 c0db61966a am dda42952: am 64f3b2fd: Merge "Remove experimental HWC virtual display support" into jb-mr2-dev
* commit 'dda4295221f831560ca9d554cd9b7be1c672d0b6':
  Remove experimental HWC virtual display support
2013-05-08 15:05:15 -07:00
Jesse Hall e737c11cd8 Remove experimental HWC virtual display support
Bug: 8384764
Change-Id: I97b52ed83ad85466bd91cb9291308994048568a1
2013-05-07 11:58:47 -07: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
Jesse Hall 1df59c93fe Merge "Tell HWComposer the dimensions of virtual displays" into jb-mr2-dev 2013-04-06 03:32:19 +00:00
Jesse Hall d5e345b0cf Merge "Actually set the virtual display output buffer." into jb-mr2-dev 2013-04-06 03:31:49 +00:00
Jesse Hall 1c569c4d45 Tell HWComposer the dimensions of virtual displays
HWComposer queries the HWC for dimensions of physical displays, but
can't do that for virtual displays. The dimensions are used to set the
display frame of the framebuffer target layer passed to HWC, and
implicitly the dimensions of the virtual display.

Bug: 8316155
Change-Id: I9cbd2530d2fa878f86128a1472def520b5d694a5
2013-04-05 14:38:52 -07:00
Jesse Hall 6d5b8e600e Merge "Clean up HWC state when releasing a DisplayDevice" into jb-mr2-dev 2013-04-04 22:36:10 +00:00
Jesse Hall 2ba647e9f5 Actually set the virtual display output buffer.
Bug: 8316155
Change-Id: Ida1ac47e5a932fdaad3ec862e121cfe55d255699
2013-04-04 12:59:37 -07:00
Mathias Agopian 33ceeb3258 Fix include paths
Change-Id: If5350a3de995cc0cb1afea067e7ce168bc00d3f5
2013-04-01 16:54:58 -07:00
Jesse Hall 02d86567d9 Clean up HWC state when releasing a DisplayDevice
DisplayDevices can be released when DisplayManager removes them from
the display list, or (for virtual displays) when the surface is set to
NULL. We were only cleaning up HWC resources associated with the
display in the first case.

Bug: 8384764
Change-Id: Id3d226dd7178fbe6d0a2ac4e2660b864ee073de3
2013-03-27 14:58:09 -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 851cfe8342 Isolate knowledge that fb target == output buffer
HWComposer didn't allow the virtual display output buffer to be set
directly, instead it always used the framebuffer target buffer.
DisplayDevice was only providing the framebuffer release fence to
DisplaySurfaces after a commit.

This change fixes both of these, so both HWComposer and DisplayDevice
should continue to work if VirtualDisplaySurface changes to use
separate framebuffer and output buffers. It's also more correct since
VirtualDisplaySurface uses the correct release fence when queueing the
buffer to the sink.

Bug: 8384764
Change-Id: I95c71e8d4f67705e23f122259ec8dd5dbce70dcf
2013-03-22 15:27:57 -07:00
Jesse Hall afaf14b9fb Use descriptive aliases instead of HWC_NUM_DISPLAY_TYPES
Bug: 8384764
Change-Id: Ia2563fab19dbc6e4a95bed03445e609334841cca
2013-03-22 09:56:58 -07:00
Jesse Hall 13f01cbdbd Pass sp<Fence>s around instead of file descriptors
Change-Id: Iac70584a2207940730e8f803a543e4e9a4000c47
2013-03-22 09:56:58 -07:00
Jesse Hall 8d8c759761 Merge "Release virtual display buffer immediately after HWC set" into jb-mr2-dev 2013-03-22 16:51:32 +00:00
Mathias Agopian 70a6e88dbd initialize planeAlpha (to 0xFF) for the FB_TARGET
Bug: 8422625
Change-Id: I7b72456c2e01ed92e675cc1bfa0cfd0d2ce5064e
2013-03-21 16:25:12 -07:00
Jesse Hall 7414965606 Release virtual display buffer immediately after HWC set
Previously we only queued a virtual display buffer to the sink when
the next frame was about to be displayed. This may delay the "last"
frame of an animation indefinitely. Now we queue the buffer as soon as
HWC set() returns and gives us the release fence.

Bug: 8384764
Change-Id: I3844a188e0f6ef6ff28f3e11477cfa063a924b1a
2013-03-20 11:16:55 -07:00
Jesse Hall ef64b75a93 Don't log an error on HWC1.1+ devices with no FB HAL
Change-Id: I015e5a1a1f926181e51f82525f69beff71bd70cd
2013-03-19 11:22:57 -07:00
Jesse Hall 80e0a397a4 Add BufferQueueInterposer and use it for virtual displays
BufferQueueInterposer allows a client to tap into a
IGraphicBufferProducer-based buffer queue, and modify buffers as they
pass from producer to consumer. VirtualDisplaySurface uses this to
layer HWC composition on top of GLES composition before passing the
buffer to the virtual display consumer.

Bug: 8384764
Change-Id: I61ae54f3d90de6a35f4f02bb5e64e7cc88e1cb83
2013-03-18 14:21:45 -07: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 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
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
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
Mathias Agopian 5fe58b8ba6 only disable hwc when alpha < 1.0
Bug: 8149181
Change-Id: Ib3c7a44f04871e020adceeae16d002141ac758d4
2013-02-07 16:22:50 -08:00
Mathias Agopian 9f8386e111 Add support for plane-alpha in HWC
Change-Id: I218e7dd5f23de535aabce61e993002ab6cb46cdd
2013-02-05 14:46:32 -08:00
Jesse Hall 51d2200738 Remove unused HWCLayer::setPerFrameDefaultState()
Bug: 7977590
Change-Id: Ic49c4e38ef2ee6beaeb268c406347c882135bdf0
2013-01-14 12:17:27 -08:00
Jesse Hall 800856a7b7 am f3e9d5bd: am cbe51356: Merge "Remove support for legacy HWC version encoding"
* commit 'f3e9d5bde57a41593a7dbc15e6f1fdb1ea64ea74':
  Remove support for legacy HWC version encoding
2013-01-14 09:52:16 -08:00
Jesse Hall f3e9d5bde5 am cbe51356: Merge "Remove support for legacy HWC version encoding"
* commit 'cbe5135610cd3c919e6334fada72cc52238bb8b0':
  Remove support for legacy HWC version encoding
2013-01-14 09:47:49 -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
Jesse Hall 7296051995 Remove support for legacy HWC version encoding
Change-Id: If03ae1ebf10d15777310e1449a57473021390582
2013-01-10 18:17:13 -08:00
Mathias Agopian dd9d192287 workaround: don't reset compositionType to HWC_FRAMEBUFFER
This workaround a HWC HAL issue in Nexus 7, which causes videos and live
wallpapers to animate slowly.

Bug: 7563862
Change-Id: I87803aaad9751b1fd8392b9732304d4bccec659a
2013-01-09 15:37:21 -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
Jamie Gennis e64b38fad2 Merge "SurfaceFlinger: track the HWC retire fences" 2012-11-19 16:37:43 -08:00
Mathias Agopian 3e095b2515 workaround: don't reset compositionType to HWC_FRAMEBUFFER [DO NOT MERGE]
This workaround a HWC HAL issue in Nexus 7, which causes videos and live
wallpapers to animate slowly.

Bug: 7563862
Change-Id: I16ad85317e3e7f47f005e7397357c14186b0a13d
2012-11-19 15:07:33 -08:00
Jamie Gennis 2ec3e0748b SurfaceFlinger: track the HWC retire fences
This change adds functionality to the HWComposer class to track the retire
fences returned by each hwc set call.  It adds the HWComposer::getDisplayFence
method to allow other parts of SurfaceFlinger to get a fence that will signal
when the most recent flip takes effect on a display.

Change-Id: I676e0f98440fc58ed70908aa1a1e2ee3e7bf9eb2
2012-11-19 13:46:40 -08:00
Mathias Agopian ee932d0ad1 Reset compositionType to HWC_FRAMEBUFFER before calling prepare()
Honor the documentation. this broke in JB-MR1.

Change-Id: I841a93b409fc940374bc748c4e143d82a192669c
2012-11-14 14:41:42 -08:00
Andy McFadden 620685c2e6 Fix emulator vsync
The code that reserves display IDs was only run when a hardware
composer was present.  The eventControl() function, which handles
enabling of vsync, was ignoring the request because the primary
display didn't appear in its set of allocated IDs.  This moves
reservation of IDs for built-in displays outside the HWC-only block.

Also, added a couple of warnings in eventControl().

Bug 7376568

Change-Id: I185ccdf817a25499b5c2668f8f6d594afb8c1568
2012-10-19 12:53:46 -07:00
Jamie Gennis cdbaecb541 SurfaceFlinger: make the num FBs a board config
Bug: 7283132
Change-Id: I38116f39fc18212f2daab94bbfc3daaf89439fc4
2012-10-12 14:29:12 -07:00
Andy McFadden 9e9689c111 Fix HDMI unblank behavior
Two issues:

(1) We were announcing the hotplug event before we were ready to
handle blank/unblank events, so we were losing the initial unblank
that power manager sends us when HDMI is first plugged in.  This
left the display blank until you toggled the device power off/on.

(2) We were retaining fbTargetHandle for HDMI after the display was
disconnected.  The value didn't get updated when HDMI was reconnected
because the display was blank, so we didn't go through that code
path.  So, when HDMI was re-connected, we passed stale data into
the HWC.

Bug 7323938

Change-Id: I2335d24fd7b0f00bb23fc63aa7bcf44cb8857c73
2012-10-10 18:17:51 -07:00
Mathias Agopian cb55857bbd fix dumpsys Layer name when using multiple displays
Bug: 7288401
Change-Id: I14beeef58fac5270cef3b611e18c163060efe6c3
2012-10-08 15:57:17 -07:00
Andy McFadden 5a8f9012ee Tone down a fatal assert
The new disconnectDisplay function doesn't handle virtual displays,
but it may be called for them.  Return without doing anything.

Bug 7281786

Change-Id: I62607f2ae6073fa66b393f55932604aeb8e03566
2012-10-04 19:09:45 -07:00
Mathias Agopian 81cd5d3b94 make sure we don't call into the HWC HAL when not needed
when enabling/disabling vsync we now make sure to
not call into the HAL if the state wouldn't change.

Bug: 7274951

Change-Id: Ie24a6d68888a51b577acf9c2a973d85437cbacaf
2012-10-04 15:25:32 -07:00
Andy McFadden 27ec5739bc Fix crashes after HDMI disconnect
The display was being removed from SurfaceFlinger's list before we
had a chance to reset HWComposer's layer list, so we were passing
stale data into the hardware composer (which has its own per-display
data).  This resulted in "invalid gralloc handle" complaints.
We now clear the layer list immediately after removing the display.

The display was being removed while its EGLSurface was still
"current", resulting in "cancelBuffer: BufferQueue has been
abandoned" complaints.  We now call makeCurrent on the primary
display before removing the external display.

Bug 7274254

Change-Id: Ia59e3a61d7ec46488b96bf93ec5e4ed3488b70e4
2012-10-04 02:02:23 -07:00
Jesse Hall ba607d53c6 Add Fence::waitForever which logs a warning timeout, and use it
Bug: 7217641
Change-Id: If0c1a613ead307c4045a47824174bf40c72bc7d7
2012-10-02 16:29:46 -07:00
Jamie Gennis d30b36d1fd SurfaceFlinger: reset the FB_TGT acquire fence
This change makes SurfaceFlinger reset the acquire fence fd to -1 after each
call to HWComposer::commit.  The HWComposer implementation is resonsible for
closing the fd, so SurfaceFlinger should make sure not to pass it to HWC
multiple times.

Change-Id: I79554d9f6d6ef2b77d632d40251516c1f5b16ddb
Bug: 7258954
2012-10-01 12:24:59 -07:00
Andy McFadden c01a79d77b Pass display arg to blank/unblank
This allows us to blank and unblank displays other than the built-in
display (e.g. HDMI).

Bug: 7240511
Change-Id: I89ea13f9e497be74c3e1231d0c62fb558e93e0f8
2012-09-28 13:04:16 -07:00
Mathias Agopian 9e2463e717 add/remove displays properly on hotplug events
Bug: 7191563
Change-Id: I8f0fbf3b29658c9479443141798e6f288a1f2d52
2012-09-21 18:26:16 -07:00
Mathias Agopian b4d18ed34e fix an issue where hotplug events were not dispatched
Change-Id: I527eec77f338cd6f1a9021aa4c9d384dbddd6d2a
2012-09-21 14:20:35 -07:00
Mathias Agopian 38e623bc5c fix a typo preventing pre hwc-1.1 devices from booting
Change-Id: Icf01254689633d04967872749ac947a671e47ed8
2012-09-20 19:27:07 -07:00
Mathias Agopian f5a3392834 we now correctly set-up connected screens during boot
Change-Id: Ie8b1a3b97ad1821cc970e43abe96c8cec7135b66
2012-09-20 17:13:58 -07:00
Mathias Agopian 148994e5f3 We now report hotplug events to the framework
Change-Id: I2d6b7787d39e5929485a551e4982498c5053c211
2012-09-20 17:13:58 -07:00
Mathias Agopian 1604f777d1 one more step toward HDMI support
getDisplayInfo() now returns proper information for
HWC managed displays.

hotplug is sitll not supported; so this is not fully correct
as the information returned will be bogus if the HDMI screen
is not plugged in.

Bug: 7191563
Change-Id: If55d8e829fae0443571548155007f486cdf9bc9f
2012-09-20 17:13:58 -07:00
Mathias Agopian f33e4b6f13 GraphicBufferAlloc class was declared twice
this was confusing because the one in FramebufferSurface
wasn't in fact being used

Change-Id: Ied45aec20d804cfbe52440f9b2f2852a85c757cf
2012-09-20 17:13:58 -07:00
Mathias Agopian 6ab93290ae suppress superfluous log
Change-Id: I838f2de4cf99e885833c4f42e2a69d6e3bb8eea5
2012-09-18 13:19:46 -07:00
Jesse Hall d3d35f1834 Check that HWC exists before trying to use it
Bug: 7185810
Change-Id: I1271d6ba397f3abf0ef166b8d03b9b26b72e28d7
2012-09-18 11:39:40 -07:00
Mathias Agopian da27af9832 add support hwc 1.1
Bug: 7124069

Change-Id: I53d705105c4ad8954d3f50ee4f4c8b7ec936b871
2012-09-17 18:57:53 -07:00
Mathias Agopian cde87a3b9d refactor things a bit
- decouple GL and main display initialization
- ensure that each "supported" display has its own FramebufferSurface
- onScreenAcquired/Released now takes a display

Change-Id: If34a05f3dea40f6c79db77f4dde283a2580daac4
2012-09-17 12:37:10 -07:00
Andy McFadden ae2cfb5746 Minor tweaks
A couple of minor cleanups I stumbled over while looking at other
things.

Change-Id: I385ecfe1afefd577afbc59d7ef1d98d868073651
2012-09-13 11:21:40 -07:00
Jesse Hall db27621e22 Initialize new HWC 1.2 fields
Also rename resolution* to width/height.

Change-Id: Ia5f0c50d3f0a349160f314a3257c3b985e13ef1d
2012-09-12 15:35:44 -07:00
Andy McFadden babba18687 Fix emulator
Emulator has no HWC.

Change-Id: I7810b27034f6772823142e5bf877681db1c8ee49
2012-09-12 13:17:01 -07:00
Andy McFadden 43601a2dc3 Reduce failure uncertainty
This adds a trivial workaround for a one-shot boot time crash, plus
an explicit check and abort for a failure condition that currently
presents as a less obvious failure.

Bug: 7145521, 7147557
Change-Id: I548f6a9caa9f0bd5710aaecea0e1c6c7c8f2f281
2012-09-11 15:15:13 -07:00
Andy McFadden b0d1dd36f1 Reshuffle FramebufferSurface
FramebufferSurface no longer speaks directly to the FB HAL.  Now
everything goes through HWComposer (which may or may not be
connected to a hardware composer).

Added display index arg to some query methods.

Change-Id: Id3e157d2d4e3555d33afbb703e518b6e92e2d6d5
2012-09-11 09:31:34 -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 55882dea1b fix a problem where all hwc layers would have the SKIP flags set
the problem was that LayerBase::setPerFrameData() was always setting
this flag. in fact there was no reason to do this at that point since
the layer is initialized to a default state in setGeometry().

Bug: 7111259
Change-Id: Ib37b0dd7391a6163070e9aca025512159c1705f9
2012-09-05 16:49:04 -07:00
Jesse Hall e25d005d91 Always reset layer acquireFenceFd after commit
If SurfaceFlinger needs to refresh the screen but the dirty region is
empty, it won't set the layer acquire fences, and stale file
descriptors will be passed to HWC commit(). Now we make sure to clear
the stale file descriptors for each layer right after commit().

Bug: 7078301
Change-Id: I6953ff91fc5488f105b30b07306f9c45a4c3f780
2012-09-05 13:03:10 -07:00
Mathias Agopian c397360883 the visible region sent to HWC was garbage
we used to have a visibleRegion object per layer, but now
it's per screen; so at somepoint the code got changed to
calculate the per-screen visible region on the stack and that's
what got passed to HWC.

we're now setting the visibleRegionScreen at each frame and
freeing at after the HWC set() call. We use the underlaying
SharedBuffer so that in most cases we don't have to allocate,
free or copy memory around.

Bug: 7089478
Change-Id: I24fa556c76613a225d9fe7a6c6b727bb476144d8
2012-08-31 18:41:22 -07:00
Jesse Hall f90883d6a5 Merge "HWC 1.1: hook up hotplug event, use new display config queries" into jb-mr1-dev 2012-08-31 12:57:07 -07:00
Jesse Hall 1bd20e0f9e HWC 1.1: hook up hotplug event, use new display config queries
Change-Id: I2fd359e5fc7e1948072c6bc6b6fe47ea5e8025c1
2012-08-31 09:25:24 -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 2b97769823 Merge "BufferQueue: clean up buffer counting" into jb-mr1-dev 2012-08-30 18:21:11 -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
Jesse Hall 9eb1eb5bb5 Handle new device api version encoding
Change-Id: I3d36058bd5d31c23b3cc4a7eb5aa033b6f3c1955
2012-08-29 10:39:38 -07:00
Andy McFadden 13a082e160 Added display initialization method
The primary display device was being configured to "blank" by
default, which prevented the boot animation from appearing
(unless you got lucky with the hardware composer state).

Bug 6975688

Change-Id: I0fa52e9e719c6e997c5725a7baf15d9718461b78
2012-08-24 11:50:34 -07:00
Mathias Agopian f435863467 teach HWC about multiple displays
Change-Id: I5e72a83d419a729835cb0e1ec45557b4d3fb56b1
2012-08-23 17:41:38 -07:00
Mathias Agopian 30bcc61431 remove support for HWC < 1.0
Change-Id: If7e676a6e3524afeb9af3875125d2131d95db38b
2012-08-23 16:30:12 -07:00
Mathias Agopian e60b0687c8 HWComposer now has its own concept of display IDs
HWComposer can now create IDs representing a display
it can deal with. IDs MAIN and HDMI are reserved.
SurfaceFlinger associate HWComposer IDs with a
DisplayDevice and uses that when it talks to HWComposer.

A DisplayDevice doesn't have to have a HWComposer ID,
in that case it just can't use h/w composer composition.

Change-Id: Iec3d7ac92e0c22bf975052ae2847402f58bade71
2012-08-23 16:03:37 -07:00
Jesse Hall bbd164a3c7 Update for cleanups in hwc interface
Change-Id: I363fd8b085167a1af6c14b68012bda5c62bfe59f
2012-08-22 12:09:39 -07:00
Jesse Hall 8f971ff666 Pass the correct number of displays based on HWC version
Change-Id: I27372f5d3102ad56f6d67722d631ae18d37f8330
2012-08-22 12:08:18 -07:00
Mathias Agopian 5f20e2d446 reimplement wifi display hack with new external display SF framework
fix a few bugs with external displays

- HWComposer doesn't really handle multiple displays yet
  so there is a lot of ugliness there

- We also need to make sure that external displays are not
  blanked by default

- due to some EGL limitations surfaces being swapped need
  to be current

Change-Id: I82bff05b43bcebd8da863c7c76b4edbc3bc223a9
2012-08-16 20:58:58 -07:00
Mathias Agopian 8b736f138c xdpi / ydpi were reported as 0
Bug: 6975723
Change-Id: Ia7fa37ec11e2308804f5034959a37e508d292d31
2012-08-13 17:54:26 -07:00
Mathias Agopian 748f3df66f avoid crashing when we don't have an h/w composer
should fix the emulator

Bug: 6956162
Change-Id: I38247b59d276b8db078c4dc2caba7d3fb545912c
2012-08-10 14:36:40 -07:00
Mathias Agopian 1e26087493 Add a display parameter to HWComposer where needed
- also replace C casts with C++ casts
- only the interface is changed, HWComposer still doesn't
  fully handle multiple displays

Change-Id: I48eb89bff2edb76bf1d4d41f46802b9b2a7166a8
2012-08-10 13:18:24 -07:00
Jesse Hall b685c54283 Changes to support multi-display HWC
Change-Id: I07efff54f2980dcb013935747b03e099b8f1181b
2012-08-07 12:16:36 -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 888c822c4c remove a dependency of DisplayDevice on the refresh rate
this remove a dependency (not all) on FramebufferSurface

Change-Id: Ie07ce70760cdcedfb41b5b41bea8da45637bf474
2012-08-04 21:23:47 -07:00
Mathias Agopian d3ee231edd cleanups in preparation of bigger changes
- fix typo drawForSreenshot misspelled
- get rid of DisplayDeviceBase
- removed unused or unneeded code
- always pass a DisplayDevice to Layer methods that are called
  on a per-display basis (to make it clear that this could be
  called more than once per composition).

Change-Id: Id948b7e09fe5c06db0e42d40d6ed75dd095c7f44
2012-08-02 22:24:12 -07:00
Mathias Agopian 0f2f5ff75b rename DisplayHardware to DisplayDevice
Change-Id: I3f7250cd914e0da4f9ec2c9403587bbe12f3cc62
2012-08-02 22:24:12 -07:00
Jesse Hall 34a09ba1ef Move eglSwapBuffers out of HWComposer
Commit 8630320 moved the eglSwapBuffers fallback (for devices with no
HWC implementation) from DisplayHardware to HWComposer. But HWComposer
only knows about the framebuffer EGL display and surface handles if
there is a HWC, so it was always passing bogus handles.

This change moves the eglSwapBuffers fallback up to SurfaceFlinger,
which has access to the framebuffer EGL handles.

Bug: 6886613
Change-Id: Iad3f5ff7c90ee48d7053999e6a4548d6794b6ebd
2012-07-30 16:10:49 -07:00
Mathias Agopian 028508cad5 hopefully fixe a race condition in sf initialization
if we received a vsync event during SF init, we could crash
as not all objects were ready to go.

Change-Id: Ie11b46e3eb1b37a709dd8757843d444f93dd0189
2012-07-25 21:13:10 -07:00
Mathias Agopian 8630320433 split HWComposer out of DisplayHardware
we will only ever have a single instance of HWComposer, so
it's now an attribute of SurfaceFlinger, instead of being part
of DisplayHardware.

DisplayHardware now just represents a "display" (it should be renamed).

Change-Id: Iec191e57686868e1df6daa8b880a286c9fefde56
2012-07-24 22:49:49 -07:00
Mathias Agopian 921e6ac4b7 SurfaceFlinger cleanup
mostly refactored SurfaceFlinger.h, but also removed dead code.
cleaned-up a few includes as well.

Change-Id: Ib15f4ffe567912b61ee98aa076c6a283b72811b5
2012-07-24 00:09:35 -07:00
Mathias Agopian a49126087b factor EGL/GL and surface creation out of DisplayHardware
Change-Id: Icd85a6a4caad06f056578008af3e21666fa8b1f4
2012-07-19 14:14:58 -07:00
Colin Cross 10fbdb6059 surfaceflinger: call into hardware composer to blank screen
Call into the new HWC blank operation to blank or unblank the screen.
Legacy systems may have already blanked the screen via early suspend,
and can choose to not implement the blank operation in their hardware
composer implementation.

Change-Id: Ib403c8c0e36367a2cfef3e1d124872fcfeb9e7cb
2012-07-13 15:48:50 -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
Mathias Agopian 1b03149f35 get rid of GraphicPlane
its functionality is now folded into DisplayHardware
there will be more changes in that area.
2012-06-28 17:27:19 -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
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 549646d29f Merge "Add support for HWC_DEVICE_API_VERSION_1_0" 2012-06-19 08:55:12 -07:00
Mathias Agopian d3076aca0f Merge "Implement SurfaceFlinger's ANW on top of BufferQueue" 2012-06-15 15:34:55 -07:00
Jesse Hall 5880cc5738 Add support for HWC_DEVICE_API_VERSION_1_0
The acquire and release fences aren't yet used; this is just support
for the new version and temporary backwards compatibility for older
versions.

Change-Id: Ia5ccc05a97c86f649042b9a35e11042fa0187e84
2012-06-14 12:35:32 -07:00
Mathias Agopian 3e8b853d67 refactor HWComposer to break dependency with the HAL headers
HWComposer must abstract the HWC HAL entirely, so that the
HAL can continue to evolve (and break binary compatibility)
without breaking SurfaceFlinger. The HWC data structure had
leaked outside of HWComposer, this is now fixed.

We now have an abstract interface that provide all the
needed functionality, HWCompose provides concrete
implementations of it based on the the HWC version.

Change-Id: I40c4676dc986b682ede5520a1c60efe64037b0bb
2012-06-14 11:56:55 -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 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
Mathias Agopian 06e51a0aaf don't actuate vsync hint when not needed
Change-Id: I61c43dd76041816ab8cbe9aeaa55c11c1479ed03
2012-04-27 13:55:05 -07:00
Mathias Agopian 03e407270c set vsync power hint
Change-Id: I28c2faf9ff584df3e74392712971cbcf75eb9e98
2012-04-26 19:52:22 -07:00
Mathias Agopian a2f4e56fec get rid off preserve backbuffer optimization in SF
this optimization didn't improve performance and in fact
seemed to hurt more than anything else. it also made
things a lot more complex as it introduced edges cases
when switching to/from h/w composer.

Change-Id: Iaafc235e175f5740cd98bff914d706e02ab88bb8
2012-04-16 03:19:15 -07:00
Mathias Agopian 22ffb117b0 make sure to disable VSYNC while screen is off
Change-Id: If1894c43b0a39a2851e1280a35ae77bccd6d9abd
2012-04-11 15:31:40 -07:00
Mathias Agopian b60314a12f rework screen on/off code
Change-Id: I13f71e850592a588bbd4805b1830c503bd4decb4
2012-04-10 22:18:43 -07:00
Mathias Agopian e2c4f4ec23 Added vsync debugging information in dumpsys log
Change-Id: I20ef05a73d89caaf6a70dc9ca25ada6e6a1f6ff9
2012-04-10 21:04:12 -07:00
Mathias Agopian 3a77871383 start VSYNC thread when HWC doesn't handle it
Change-Id: I853a822ea9ec13870ae25af55a89ad9a8cc3936a
2012-04-09 14:16:47 -07:00
Mathias Agopian 2965b26022 VSYNC handling cleanup
Change-Id: I1376bf864c4e03c11fb6d1333a8b7cfdda08c9e4
2012-04-08 20:54:47 -07:00
Erik Gilling 1a3bf41b71 Fix SurfaceFlinger crash in HWC::eventControl
eventControl was not checking if there was a hwc before callingi
hwc->eventControl

Change-Id: I4d739fc9c0d47da131f4ffc5d50e274de156d012
2012-04-06 14:13:32 -07:00
Mathias Agopian 3eb38cb33e SurfaceFlinger now uses the new VSYNC HAL API.
If h/w composer doesn't support vsync (version < 0.3) we
"fake" it with a timer.

Change-Id: I1e3be79f43c9631d1293ad7d6cf52f9bfc42d65b
2012-04-04 19:01:20 -07:00
Mathias Agopian 31d2843b45 Add HWC vsync hook. Currently unused.
Change-Id: I849d56f375813a044c5e2d0b25f791476a60fa01
2012-04-03 18:30:35 -07:00
Mathias Agopian b5dd9c0fee rewrite density calculation code so it's understandable
Change-Id: I1016cd5fd75355abe4ab879d04f4849bd2dd4122
2012-03-22 12:20:06 -07:00
Dima Zavin 6fc0a9bd4b displayhardware: fix not obeying ro.sf.lcd_density when specified
Change-Id: I71efd6aebfdb0323b07327f5e448a5cb5eb0fad6
Signed-off-by: Dima Zavin <dima@android.com>
2012-03-21 23:37:46 -07:00
Dima Zavin 1b15e1e26b surfaceflinger: use display dpi if not forced with ro.sf.lcd_nensity
Change-Id: I52c4b872e0f2c088c2a6ada7a5bb15db071f0002
Signed-off-by: Dima Zavin <dima@android.com>
2012-03-14 17:15:10 -07:00