Commit Graph

238 Commits

Author SHA1 Message Date
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
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
Mathias Agopian 3ee454a7be Eradicate DisplayID.
DisplayDevices are now keyed of the wp<IBinder> the client uses.
DisplayID has now become DisplayType which is just used to identify
physical displays (as opposed to virtual displays such as wifi displays).

Change-Id: I0c5968f2c902dcd699a7e0afacf833ff070c12ea
2012-08-27 17:43:43 -07:00
Mathias Agopian 3165cc21cf libgui includes refactoring
Change-Id: I1d24ec17f5003ec2abab5f7472daaff4cc4cc2d3
2012-08-10 13:18:24 -07:00
Mathias Agopian 4297734c11 turn DisplayDevice into a reference-counted object
it's safer this way because this object owns an
EGLSurface which cannot be easily reference-counted.

it also gives us the ability to sub-class it, which
we might want to do soon.

Change-Id: I07358bb052dc5a13b4f2196b2c2b6e6e94c4bb4f
2012-08-05 00:40:46 -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
Mathias Agopian 52bbb1ae23 getting closer to final main composition loop
Change-Id: Icd63782366ffd11d9ea00c925ae5783ed7440cdb
2012-08-02 22:24:12 -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
Mathias Agopian 4fec873a98 one more step towards multiple display support
- remove dependency on cached state in validateVisibility
- get rid of mVertices and mTransformedBounds
- get rid of validateVisibility
- get rid of unlockPageFlip
- handleTransaction now returns a dirty region
- computevisibileregion now uses window-manager space
2012-07-10 14:29:27 -07:00
Jesse Hall c5c5a14c06 Only set acquire fences on overlay layers
Change-Id: I08e8173f83580de5a4e43a0ba5ea03e5ec6e8782
2012-07-02 16:49:28 -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
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
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
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 0cd545f142 sometimes we would incorrectly scale the content of a surface
this would happen when a resize was pending (ie: we have received
and processed a resize transaction but have not received a buffer
with the right size) and a new transaction came in that didn't
involve a resize, for instance a translate-only transaction.

in this case, we would incorrectly update the drawing state
with the pending size, eventhough we still don't have a buffer
for it.

the solution is quite simple, we never allow the size to propagate
from current to drawing state during the regular transaction processing
(unless we are in fixed-size mode -- meaning we don't need to have
a matching size buffer), this propagation happens later once we
receive the buffer.

Bug: 6624163
Change-Id: I11a97e4b88a7f3a0571ddcfe99c86cb04ce01a4d
2012-06-07 17:12:20 -07:00
Mathias Agopian 4824d40a35 sometimes SF would not process a surface resize
this would happen when a window started with size A, was
resized to B and immediately resized to A. In this situation
the erquested and active size would be the same, and SF
would think a transaction wasn't needed.

we fix this by always comparing the requested sizes.

Also, make sure to set mRefreshPending once we're sure
we have succesfully called updateTexImage().

Bug: 6580962
Change-Id: I2c48b4df7f05fd35c9e1d2dd82095b0f3d5a0b6a
2012-06-04 18:16:30 -07:00
Mathias Agopian e31564d8eb Fix a crasher is surfaceflinger.
this bug introduced recently would happen when the very first
buffer of a surface was rejected for not having the right size

Bug: 6577035
Change-Id: I9fabf20006019f2a6c308be7c7f5c05bdcfd5014
2012-05-29 20:41:03 -07:00
Mathias Agopian 2c8207e962 add the ability to reject buffers in SurfaceTexture::updateTexImage
SurfaceFlinger is using this new feature to reject buffers that
don't have the right size.

Bug: 6498869
Change-Id: I8a7250a47db6c082a357b703feb3b9d0fc8d3443
2012-05-23 18:01:33 -07:00
Mathias Agopian 702634a4da refactoring in preparation for bug:6498869 fix
here we just shuffle a bit the code inside lockPageFlip(),
we move the code that handles the buffer size closer to the call
to updateTexImage(). no functionality change.

Change-Id: Ie3193cd86cd32cf3c89532449fd747d145ca0ab6
2012-05-23 18:01:33 -07:00
Mathias Agopian 05cec9d127 improve resize transactions
use a flag instead of pre-committing the "requested" state
to prevent propagation or "requested" to "active", which makes
things a lot clearer when reading the code.

also avoid going through the "resized" code-path when requested
size is equal to "active" size.

Bug: 6498869
Change-Id: I24f893ba0ec5ca06aac5b8da9818989ae7ce4005
2012-05-23 18:01:24 -07:00
Mathias Agopian 419e196e63 Improve debug logs and minor clean-up
Bug: 6498869
Change-Id: I14d1b4d6960b87b5a7c4d7e20b92538edd9331ff
2012-05-23 18:01:14 -07:00
Mathias Agopian b30c415539 Fix "Battery/Status/Clock status bar area flickers when dragging down"
The crop is now handled like a resize, it's latched only when we
receive a new buffer in the case we have a resize in the same
transaction.

Bug: 6498869
Change-Id: I9f3cbbe08fb19443899461ec441c714748a4fd1a
2012-05-16 18:21:32 -07:00
Mathias Agopian 93ffb86b90 minor refactoring in praparation of crop fix
Bug: 6498869
Change-Id: I12a6f9a9fdfd2ea1db3fbe5fc8cb443aeaedb328
2012-05-16 17:07:49 -07:00
Jamie Gennis cbad735d8c SurfaceFlinger: recompute visible regions less
This change removes some visible region recomputation that was needed to handle
the SCALING_MODE_FREEZE cropping.  We've changed things to use a window crop
from the WindowManager instead, so this is no longer needed.

Bug: 6299171
Change-Id: I32fbc2b689c985837126d8ba3d9a91e79613ffbf
2012-05-14 15:41:38 -07:00
Jamie Gennis f15a83f581 SurfaceFlinger: add a crop to the layer state
This change adds a crop rectangle specified in window coordinates to the layer
state.  The all window pixels outside this crop rectangle are treated as though
they were fully transparent.  This change also adds the plumbing necessary for
WindowManager to set that crop.

Change-Id: I582bc445dc8c97d4c943d4db8d582a6ef5a66081
2012-05-11 03:16:02 -07:00
Jamie Gennis 51dcd581b1 SurfaceFlinger: recompute visible regions more
This change makes a change in the crop, scaling mode, transform, or buffer
dimensions trigger a recomputation of the visible regions of a window.  With
the new cropping behavior for SCALING_MODE_FREEZE all of these can now affect
the visible region.

Bug: 6470541
Change-Id: I1904e47efbd708e28bf189f637d24dbef65cd41e
2012-05-10 15:35:56 -07:00
Jamie Gennis 161534a3c5 SurfaceFlinger: SCALING_MODE_FREEZE cropping support
This change adss support for applying a buffer crop to layers with the
SCALING_MODE_FREEZE scaling mode.  These layers do not scale the image, but
rather treat all pixels outside the crop rectangle as fully transparent.

Change-Id: I762518e56a37aef7747f9b581df2f2589b232c49
Bug: 6299171
2012-05-09 12:53:13 -07:00
Jamie Gennis cbb1a95819 SurfaceFlinger: tell SurfaceTex about filtering
This change makes SurfaceFlinger set the filtering-enable on each layer's
SurfaceTexture before querying the texture matrix to use for GLES composition.

Change-Id: I40c3defd73ebf96e3cabb3bfdb1fc97f2036753a
2012-05-09 12:53:13 -07:00
Mathias Agopian a0db308c3d remove SurfaceTexture::connect()
use BufferQueue::connect() instead

Change-Id: I04aab7cf11304bf962cde38470747f3b19ddba42
2012-04-23 20:06:02 -07:00
Mathias Agopian 7f42a9c47c triple buffering is now controled by BoardConfig and enabled by default
use TARGET_DISABLE_TRIPLE_BUFFERING := true to disable
triple buffering.

Change-Id: I9875d6ddefd23c1af9e51e7ee7dec1bacd1e6799
2012-04-23 20:00:16 -07:00
Daniel Lam b267579ba8 SurfaceTexture: Fully refactored from BufferQueue
SurfaceTexture and BufferQueue are separate objects.

Change-Id: I230bc0ae6f78d0f9b2b5df902f40ab443ed5a055
2012-03-13 14:39:07 -07:00
Mathias Agopian ed61a47c5b Merge "a window could get stuck to gpu composition" 2012-02-27 19:48:36 -08:00
Jamie Gennis 1c8e95cf86 Add tracing to various graphics components.
This change adds ATRACE call tracing to BufferQueue,
SurfaceTextureClient, SurfaceTexture, SurfaceFlinger, Layer, and EGL.

Change-Id: I9d75ed26f5a3f0d1af635da38289520134cfbbb7
2012-02-27 17:50:35 -08:00
Mathias Agopian ec923ee0d0 a window could get stuck to gpu composition
this could happen after an orientation change. basically
we need to triger a geometry-changed when the very first buffer
is received

Change-Id: I097e411fd6612c18725737cffccdbf6b2af3511c
2012-02-27 16:58:04 -08:00
Mathias Agopian 90ac799241 fix libgui header location
Change-Id: Iec71706cdd4f29c6904993648ce873e83ef9cafe
2012-02-27 13:03:08 -08:00
Mathias Agopian ff615cc7a1 deprecate L_8, LA_88 and RGB_332 in sdk
re-add support for pixelformats L_8, LA_88 and RGB_332 in libui
for backward compatibility.

This may or may not fix 6058926

Bug: 6049685
Change-Id: Ic1b8b4cc994522f7fe664da64c0ef76b98bc6d53
2012-02-24 14:58:36 -08:00
Mathias Agopian 4d143eed99 fix an issue in SF where we could miss some updates
Change-Id: I7d350bc05d1596655baddff3deaebaba58c9bcc0
2012-02-23 21:17:01 -08:00
Mathias Agopian 303d538bb0 ui freeze workaround: reenable triple buffering mode
we're seeing UI freezes when window updates and
composition are separated. for now we workaround this
by always doing a composition after window updates on
vsync. triple buffering is reenabled for performance.

Change-Id: I693d705000b7452489bb0b4918fbeadb9879315c
2012-02-05 01:49:16 -08:00
Mathias Agopian 99ce5cdeb3 separate transactions from updates
with this changes, SF transactions are handled as soon as possible
but do not trigger updates. the update is delayed until the next
vsync.

this allows us to work much better without requiring triple-buffering.

Change-Id: I1fa10794d0cf742129f0877698b7b1e1f2ec7401
2012-02-01 20:43:06 -08:00
Mathias Agopian 8aedd4737d SF now synchronizes to VSYNC
Change-Id: Ic5e4f2ea9927ce133eef9499c03161325e9d02c5
2012-01-30 15:21:23 -08:00
Mathias Agopian 25e66fc324 added a few more commands to SF's dumpsys
--latency-clear [name]
clears the latency data for the specified layer or for
all layers if none is specified

--list
prints the list of all layers regardless of their visibility

Change-Id: I7c07ae020f838c173b98ee50f3fb3e93da78acbb
2012-01-28 22:31:55 -08:00
Mathias Agopian 82d7ab6c7e improve SurfaceFlinger dumpsys
It is now possible to say:

dumpsys SurfaceFlinger --latency

to print latency information about all windows

dumpsys SurfaceFlinger --latency window-name

to print the latency stats of the specified window

for instance: dumpsys SurfaceFlinger --latency SurfaceView

The data consists of one line containing global stats, followed by
128 lines of tab separated timestamps in nanosecond.

The first line currently contains the refresh period in nanosecond.
Each 128 following line contains 3 timestamps, of respectively
the app draw time, the vsync timestamp just prior the call to set and
the timestamp of the call to set.

Change-Id: Ib6b6da1d7e2e6ba49c282bdbc0b56a7dc203343a
2012-01-24 18:22:56 -08:00
Jamie Gennis e8696a40e0 hack up frame latency measurement
Change-Id: I6d9a466a23285304f0e229a5649815636ab5d6af
2012-01-24 15:41:50 -08:00
Steve Block 9d45368352 Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
2012-01-03 22:38:27 +00:00
Xavier Ducrohet 4c4163b53e Fix software GL renderer.
Change-Id: I07ab2709fa694e41aa3fcc5b9dfc809f55853ab4
2011-10-21 16:18:48 -07:00
Dave Burke 818fb24357 am 70ac412b: Merge "Add a LayerScreenshot" into ics-mr0
* commit '70ac412b2fe7be2507189a9fdfb30c43b36d56ac':
  Add a LayerScreenshot
2011-10-18 23:00:08 -07:00
Mathias Agopian 5ba8f366bd am 23bf2505: Merge "Make sure set GL state properly" into ics-mr0
* commit '23bf250522b7dff9acd14c5900b66b1df9c76745':
  Make sure set GL state properly
2011-10-18 20:24:21 -07:00
Mathias Agopian 118d0245ee Add a LayerScreenshot
A LayerScreenshot is a special type of layer that contains a screenshot of
the screen acquired when its created. It works just like LayerDim.

Make sure to call compositionComplete() after rendering into a FBO.

Bug: 5446982, 5467587, 5466259
Change-Id: I5d8a1b4c327f9973d950cd4f4c0bca7f62825cd4
2011-10-18 20:21:47 -07:00
Mathias Agopian c492e67810 Make sure set GL state properly
when taking a screenshot, in particular, we could end up
with stale GL state when drawing LayerDim which resulted
in incortect rendering.

Bug: 5467587
Change-Id: Id9fbed2843481d31063620f3662b364c7e3ac781
2011-10-18 15:32:57 -07:00
Mathias Agopian cdec8f01aa am 840b8a67: Revert "Add a LayerScreenshot"
* commit '840b8a678537519c27ddf2f818494eaa20a135d4':
  Revert "Add a LayerScreenshot"
2011-10-17 11:32:19 -07:00
Elliott Hughes 090cb44b94 Merge branch 'master' of ssh://android-git:29418/platform/frameworks/base 2011-10-17 11:32:08 -07:00
Mathias Agopian e9800c8311 Revert "Add a LayerScreenshot"
This reverts commit d6809f40cf61203573ec5dbc437f695cd132cc18.
2011-10-16 23:54:25 -07:00
Jamie Gennis a402c4c991 SurfaceFlinger: Remove display freezing code
This change removes the dead code from SurfaceFlinger that resulted from
disabling support for freezing the display.

Change-Id: I4e5ff00c94b4c7a79af2f65c9850c135210068ed
2011-10-14 16:44:08 -07:00
Mathias Agopian f171ab6da9 Add a LayerScreenshot
A LayerScreenshot is a special type of layer that contains a screenshot of
the screen acquired when its created. It works just like LayerDim.

Bug: 5446982
Change-Id: I7814aff2380e7e146937f2b641907be2a30c76cc
2011-10-14 14:32:48 -07:00
Jamie Gennis 9575f60722 SurfaceFlinger: screenshots w/ protected buffers
This change modifies SurfaceFlinger's screenshot behavior when a layer
with a protected buffer is visible.  The previous behavior was to simply
fail the screenshot.  The new behavior is to render the screenshot using
a placeholder texture where the protected buffer would have been.

Change-Id: I5e50cb2f3b31b2ea81cfe291c9b4a42e9ee71874
2011-10-07 17:53:37 -07:00
Jamie Gennis ed984d9406 Merge changes Ib302d79e,Ib4ee085f
* changes:
  SurfaceFlinger: set layer names on SurfaceTextures
  SurfaceTexture: add name support
2011-09-27 14:24:09 -07:00
Jamie Gennis 1b5f4e61ff Merge "SurfaceFlinger: fix setting default buffer size" into ics-factoryrom 2011-09-27 12:28:59 -07:00
Jamie Gennis 2a0d5b6084 SurfaceFlinger: fix setting default buffer size
This change makes SurfaceFlinger update a SurfaceTextureLayer's default
buffer size in response to a window resize even if the Layer is in fixed
size mode.

Change-Id: I3871c8f19a045d03904d1284390cad7659be71ff
Bug: 5366426
2011-09-26 18:38:52 -07:00
Jamie Gennis 36d2c1f02c Merge "(DO NOT MERGE) SurfaceFlinger: fix isOpaque check in lockPageFlip" into ics-factoryrom 2011-09-26 15:44:41 -07:00
Jamie Gennis 8d91b42507 SurfaceFlinger: fix the transform hint
This change fixes the transform hint to use only the global display
transform rather than incorporating the transient layer-specific
transform used during animations.

Bug: 5366891
Change-Id: I5408dcd3f4771d010953e8a696a484c835bfe81e
2011-09-24 11:27:20 -07:00
Jamie Gennis a249f2d112 SurfaceFlinger: set layer names on SurfaceTextures
This change sets the SurfaceTexture name string to match that of the
layer to which it belongs.

Change-Id: Ib302d79e916a36ab1e54cb9ff477c3b857bd957b
2011-09-22 17:50:05 -07:00
Jamie Gennis 351a513b12 (DO NOT MERGE) SurfaceFlinger: fix isOpaque check in lockPageFlip
This change fixes an issue where Layer::isOpaque was being called in
lockPageFlip to get the opaqueness for the new buffer before
mActiveBuffer was updated.

Bug: 5321313
Change-Id: Ibb5d7d3f4e9a2b1448e117a484a0d9f9ca5fc9de
2011-09-16 11:51:04 -07:00
Jamie Gennis 945d291699 SurfaceFlinger: fix isOpaque check in lockPageFlip
This change fixes an issue where Layer::isOpaque was being called in
lockPageFlip to get the opaqueness for the new buffer before
mActiveBuffer was updated.

Bug: 5321313
Change-Id: Ibb5d7d3f4e9a2b1448e117a484a0d9f9ca5fc9de
2011-09-14 18:23:37 -07:00
Mathias Agopian c7f3381c3b fix display artifacts in preview screen in timelapse video mode
We were not updating the h/w composer state when the buffer size
changed.

We also didn't update the h/w composer state when the transformation
matrix changed (which is related to the above issue, since it would
probably change when the buffer size changes).

Also moved updating the crop to setGeometry(), since we decided
that the "crop" change requires the GEOMETRY_CHANGED flag (ie:
not need to do this every frame)

Bug: 5238473

Change-Id: Ia7b47e145b48581b568d89d9aa2c14ff778be862
2011-08-30 15:31:51 -07:00
Jamie Gennis 85b6f7afea Merge "SurfaceFlinger: use the HWC gralloc usage bit" 2011-08-24 15:12:04 -07:00
Mathias Agopian 45d845190d Merge changes I14e03939,I9aafe6f2
* changes:
  Fix an issue where Surface::lock() would never update the output region
  Add a debug option to turn the "transformation hint" off
2011-08-23 21:38:59 -07:00
Mathias Agopian a45836466c Add a debug option to turn the "transformation hint" off
transformation hint is disabled with:

   adb shell service call SurfaceFlinger 1009 i32 1

Change-Id: I9aafe6f280f88ce41569ed69a06dc522b10e3a88
2011-08-23 21:10:35 -07:00
Mathias Agopian f7ae69d4bd Minor cleanup
Change-Id: Ic042043c54631b5a5c74d20136addb2c08515ea9
2011-08-23 15:57:42 -07:00
Jamie Gennis 3599bf2c07 SurfaceFlinger: use the HWC gralloc usage bit
This change makes SurfaceFlinger always use the
GRALLOC_USAGE_HW_COMPOSER usage bit when allocating buffers that may be
passed to the HWComposer.

Change-Id: I70362a8ede2b359fb2046853f85149d597465817
2011-08-22 14:56:29 -07:00
Mathias Agopian d992db3827 give the proper orientation to the h/w composer HAL
we were using the "orientation" value instead of the
real transform, which may contain arbitrary rotations for
instance, and in some case ended up with a final "orientation"
that looked valid, but wasn't.

this fixes a problem on devices with a h/w composer hal where
the rotation animation looked weird.

Change-Id: I4be8a2a1bde49c33456fcf5c8d87ab515c216763
2011-08-18 18:33:44 -07:00
Jamie Gennis 582270d69d SurfaceTexture: fix queues-to-composer
This change fixes the NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER query of
Surface and SurfaceTextureClient.  Surface now uses the inherited
SurfaceTextureClient implementation of this query.  SurfaceTextureClient
now queries SurfaceFlinger to determine whether buffers that are queued
to its ISurfaceTexture will be sent to SurfaceFlinger (as opposed to
some other process).

Change-Id: Iff187e72f30d454229f07f896b438198978270a8
2011-08-17 18:19:00 -07:00
Mathias Agopian c5953904ad fix an orientation change drawing artifact.
a wrong orientation would be briefly shown when
rotation the screen. this happened when the window manager
set a custom transformation and the h/w composer was used.

the custom transformation was applied twice in that case.

Bug: 5037522
Change-Id: Ic1f87b63cd843f4475e4265d1624463825d775c4
2011-08-12 17:09:09 -07:00
Mathias Agopian 47d0812977 SurfaceFlinger doesn't rely on having a custom RefBase destructor
we just use a message to the main thread to
destroy our GLES state.
2011-08-11 22:33:02 -07:00
Mathias Agopian ad795baecc improve dumpsys SurfaceFlinger output
we now output the handle and size of all buffers of each layer.

Change-Id: I8d011ee4ae9199f4198bd07bed770ec3bcf02986
2011-08-08 16:02:13 -07:00
Mathias Agopian e8067a7d99 fix a crasher in surfaceflinger
this would happen if being told to draw before a buffer
was available.

Change-Id: I46d121c73e883078cdbf952063e38b0076f79038
2011-08-02 18:29:57 -07:00
Mathias Agopian a537c0f42e update HWC data structures even when a layer is marked for SKIP
Change-Id: I16bcf44cd617814a14a795429bde2f39f411077d
2011-08-02 15:51:37 -07:00
Jamie Gennis dbe6486ca1 SurfaceFlinger: abandon Layer SurfaceTextures
This change makes the Layer::onRemoved method call
SurfaceTextures::abandon on the layer's SurfaceTexture.  This will cause
all client-initiated operations on the SurfaceTexture to fail.  In
particular, this will result in an error on the client side, rather than
a deadlock when removing a layer that used a SurfaceTexture in
synchronous mode.

Change-Id: I14014d00369f29560a21b606831edee432bb8867
Bug: 5020874
2011-07-30 14:38:20 -07:00
Jamie Gennis db5230f444 SurfaceFlinger: fix a layer occlusion bug
This change fixes a bug where the window visibility would be computed
before any buffers were available, causing the window to be treated as
non-opaque.  When the first buffer arrived, if both mCurrentOpacity and
the opacity determined by the buffer's format were 'opaque', a
recomputation of the opacity would not be done, and the window would
continue to be treated as non-opaque.  SurfaceFlinger could then
unnecessarily draw fully occluded layers.

Change-Id: I2b95da2f4b50e68d50fc5afd8b772e26e62f58d6
Bug: 5057122
2011-07-28 16:03:28 -07:00
Mathias Agopian 3fbce7c560 remove dead code and member variables.
also fix some comments and improve debugging logs.

Change-Id: I83e55309f306332b59e1ec46104c4a7fffbf3c97
2011-07-25 20:03:43 -07:00
Mathias Agopian 97c602c5af implement: "Add an ANativeWindow API for SurfaceFlinger to suggest an optimal buffer orientation"
Bug: 4487161
Change-Id: I883f34efe542c2a566d04966f873374f40c50092
2011-07-19 15:24:46 -07:00
Mathias Agopian 933389f758 use SurfaceTexture new scaling mode in SF
SF now obeys SurfaceTexture's scaling mode instead
of inferring it from the buffer's size

Change-Id: I4d50e9851abedd7e64bfcfc8af9eefb9fb668529
2011-07-19 13:05:12 -07:00
Mathias Agopian 29a367bb7c take the state transform into account with h/w composer hal
if the state transform didn't preserve rectangles, we
would still try to use h/w composer hal using the bounds
of the transformed rect, which isn't correct.

now we correctly fall back to composition.

Change-Id: Iff78f4339ece415d4987e95a5717b04934d370ab
2011-07-12 14:51:45 -07:00
Jamie Gennis 3d8063b02e SurfaceTexture: change onFrameAvailable behavior
This change alters the conditions under which the onFrameAvailable
callback gets called by the C++ SurfaceTexture class.  The new behavior
is to call the callback whenever a frame gets queued that will be
visible to the buffer consumer.  This means that buffers queued in
synchronous mode always trigger the callback, as those buffers will
remain pending until they are consumed.  Buffers queued in asynchronous
mode will only trigger the callback if there was not previously an
unconsumed buffer pending.

The new behavior means that a consumer should perform a draw operation
exactly once for every onFrameAvailable call that it recieves.  This
change also modifies SurfaceFlinger and the SurfaceTexture JNI to
support of the new behavior.

Change-Id: I8b2c6e00961d3d58b11c6af50b555b6e4c5f5b40
2011-06-27 15:45:39 -07:00
Mathias Agopian ddc31c3e2b fix RefBase so it retains binary-compatibility with gingerbread
Bug: 4595257
Change-Id: I0d5e10f497e3f39868bff58f6ded510c38b44b12
2011-06-13 18:39:45 -07:00
Mathias Agopian a67932fe68 unify SurfaceTexture and Surface
Add the concept of synchronous dequeueBuffer in SurfaceTexture
Implement {Surface|SurfaceTextureClient}::setSwapInterval()
Add SurfaceTexture logging
fix onFrameAvailable
2011-06-13 15:51:35 -07:00
Mathias Agopian 342451d19f Merge "Fix a race that could cause GL commands to be executed from the wrong thread." 2011-05-19 19:42:20 -07:00
Mathias Agopian ca4d3602c0 Fix a race that could cause GL commands to be executed from the wrong thread.
Change-Id: Ia3d407f7bf2f5553f46cfdade70b7b0badb35beb
2011-05-19 19:40:02 -07:00
Jamie Gennis 3629d7ff29 SurfaceFlinger: unfreeze windows for fixed size buffers.
This change makes SurfaceFlinger unfreeze a window if it ever gets a
buffer that is fixed-size.  Normally the window would not be frozen if
its in fixed-size mode, but if the window was frozen before entering
fixed-size mode then it should be unfrozen.

Change-Id: I6bc822d4b02ae51fa8914c1f60f5d24b2002b38d
2011-05-16 16:59:04 -07:00
Conley Owens 345c6114da am ba5aebd1: am ac505b86: am f0556bb9: am 86d1d747: Merge "Add lock before calling initEglImage"
* commit 'ba5aebd106c61567ad6be905efd18902025735aa':
  Add lock before calling initEglImage
2011-04-27 13:54:08 -07:00
Conley Owens ddc25bb92e am ac505b86: am f0556bb9: am 86d1d747: Merge "Add lock before calling initEglImage"
* commit 'ac505b86b45462d9883f9c36fad0ef85e0885ee4':
  Add lock before calling initEglImage
2011-04-27 13:41:12 -07:00
Kobi Cohen Arazi 0d11baf889 Add lock before calling initEglImage
Without that lock, there is a chance of race condition
where while composing a specific index, requestBuf with
the same index can be executed and touch the
same data that is being used in initEglImage.
(e.g. dirty flag in texture)
2011-04-15 10:38:33 -07:00
Jamie Gennis 3eb70b4a51 am bd340c7b: am b368f4d8: am 38caff23: Merge "SurfaceFlinger: Fix a typo." into honeycomb-mr1
* commit 'bd340c7b492fcf7d0a6cccab8825e710c83fe76d':
  SurfaceFlinger: Fix a typo.
2011-03-18 17:38:37 -07:00
Jamie Gennis 5fd799dab6 SurfaceFlinger: Fix a typo.
This change makes Layer skip its cleanup of its old shared memory region
when the UserClient object that owned the memory has been freed.

Bug: 3429357
Change-Id: I9e4d8eb190f6914dc043674b9bb8dd28e959901b
2011-03-18 16:35:13 -07:00
Mathias Agopian 939fee8819 am e22aa623: am 25594e19: am f40e638e: fix [4093196] Device lock up - log spam with SharedBufferStack: waitForCondition(LockCondition) timed out
* commit 'e22aa62362a3007ee59ac62d4b5969e216987995':
  fix [4093196] Device lock up - log spam with SharedBufferStack: waitForCondition(LockCondition) timed out
2011-03-17 00:13:49 -07:00
Mathias Agopian d0b55c011a fix [4093196] Device lock up - log spam with SharedBufferStack: waitForCondition(LockCondition) timed out
a memory corruption happned when the buffer pool was resized
(like when playing a video or using camera) and there was
no current active buffer. In this case, the faulty code
would index into an array at position -1 which corrupted
24 bytes of data.

also improved region validation code (ifdef'ed out by default)

Bug: 4093196
Change-Id: I915c581d131148959d720e00e3892e9186ab733d
2011-03-17 00:04:42 -07:00
Mathias Agopian 5bf3abefb2 Fix initialization order warning.
Change-Id: I794dfaaa3a2f2645a89abc6c45de5f76e485f7d0
2011-03-11 17:01:40 -08:00
Eric Hassold 795f5ccf47 Merge "Default to NONE format in Layer" 2011-03-11 15:08:16 -08:00
Eric Hassold 7ffe380750 Default to NONE format in Layer
mFormat is not initialized with any value in Layer constructor, causing
a call to requestFormat() with no explicit format specified to fallback to
some uninitialized value. Such invalid path actually detected by valgrind.

Change-Id: Ib7faabcd61eaa26fb0ae7a9a486d9e258ba31b63
2011-03-11 12:24:23 -08:00
Jamie Gennis 7a4d0dfd43 SurfaceFlinger: Respect the PROTECTED gralloc bit.
This change makes SurfaceFlinger treat layers for which the active
buffer has the GRALLOC_USAGE_PROTECTED bit set as if they have the
'secure' flag set.

Change-Id: Ic60b6513a63e4bb92ec6ce9fd12fd39b4ba5f674
Bug: 4081304
2011-03-10 16:25:48 -08:00
Eric Hassold ab0225e330 Merge "Correctly handle translucency of device-specific pixel formats" 2011-02-23 14:10:04 -08:00
Mathias Agopian a1f47b90ab fix a surface leak in SurfaceFlinger
SF kept a strong reference to ISurface until the
window manager removed the surface from the screen.
This fell appart when running standalone tests, that is
when the window manager wasn't involved.

When the window manager is around, it would clean-up surfaces
even when an application died.

with this change, SF is able to do its own cleanup without
relying on the window manager.

the change is very simple, we simply don't keep a reference
to ISurface and make sure no more than one of them can
be created.

Change-Id: I61f2d7473bf8d4aa651549a846c34cdbb0d0c85a
2011-02-16 15:31:07 -08:00
Eric Hassold ac45e6bff1 Correctly handle translucency of device-specific pixel formats
Check requested format for device-specific formats, and assume (as
documented in libhardware/include/hardware/hardware.h) this is opaque
layer so no blending is necessary.

Bug: 3215931
Change-Id: Ib4dff8060ac522d201ff1e74807ac340c17d3fa7
2011-02-15 16:20:03 -08:00
Mathias Agopian 3cbe436bfd am 8d778b37: am 231da079: Merge "fix [3389263] OMX.Nvidia.h264.decode fails to shutdown" into honeycomb
* commit '8d778b375ccb4945cdcd7cc93272a6d36466ad00':
  fix [3389263] OMX.Nvidia.h264.decode fails to shutdown
2011-01-28 18:43:08 -08:00
Mathias Agopian 3cc2677efc fix [3389263] OMX.Nvidia.h264.decode fails to shutdown
We were still destroying an ANativeWindow's buffer pretty soon
after it was removed from the window manager. This time
we really wait for the ISurace to go away.

Change-Id: I329273fedaeef76ee92836f6180c2c3808389330
2011-01-28 18:23:24 -08:00
Glenn Kasten 16f0453fee Protected surface API
To be used by DRM framework, implemented by display HAL

Change-Id: I054a07a94f4d5dbe792f3a597e2e49a100d90eb2
2011-01-28 08:04:00 -08:00
Mathias Agopian d1a99ec6b2 fix [3361121] hang in glClear() - device unresponsive, OTA fails (DO NOT MERGE)
Generally we never want to lock a buffer for write access if it is at
the "head" on the surfaceflinger side. The only exception (1) is when
the buffer is not currently in use AND there is at least one queued
buffer -- in which case, SurfaceFlinger will never use said buffer
anymore, because on the next composition around, it will be able to
retire the first queued buffer.

The logic above relies on SurfaceFlinger always retiring
and locking a buffer before composition -- unfortunately this
didn't happen during a screenshot.

This could leave us in a situation where a buffer is locked by the
application for write, and used by SurfaceFlinger for texturing,
causing a hang.

Here, we fix this issue by never assuming the exception (1), it was
intended as an optimization allowing ANativeWindow::lockBuffer() to
return sooner and was justified when most of SF composition was
done in software. The actual buffer locking is now ensured by
gralloc. We could have handled screenshots in a similar way to
a regular composition, but it could have caused glitches on screen,
essentially, taking a screenshot could cause to skip a frame.

now that we removed the notion of a "inUse" buffer in surfaceflinger
a lot of code can be simplified / removed.

noteworthy, the whole concept of "unlockClient" wrt. "compositionComplete"
is also gone.
2011-01-25 14:19:13 -08:00
Mathias Agopian 2bd1d95efe clean-up unneeded code
now that we removed the notion of a "inUse" buffer in surfaceflinger
a lot of code can be simplified / removed.

noteworthy, the whole concept of "unlockClient" wrt. "compositionComplete"
is also gone.

Change-Id: I210413d4c8c0998dae05c8620ebfc895d3e6233d
2011-01-20 12:10:11 -08:00
Mathias Agopian 420a283c4d Fix a problem where hwc and GL composition could show a different buffer
if a surface's buffers are reallocated, the current active buffer will
end-up pointing on one of these until a new buffer is retired.

we're now keeping a reference to the actual buffer until we retire a
new one.

Change-Id: Ib1703947e7a0340694d846e0962576318863b935
2010-12-14 20:30:37 -08:00
Mathias Agopian da9584dc29 fix [3223749] media server crashes when switching mode from video capture to still image capture
there was an issue were in some situation SF would call prepare() on hwc
with a NULL handle and never call prepare again.
in this situation, we onw set the SKIP flag to make sure that hwc
won't process this layer and as soon as we receive our first buffer we
trigger a recompute of the visible regions which will end-up calling
prepare() again.

Change-Id: I6b400b2df79712408b9315a9859290c7fcb1609e
2010-12-14 15:53:39 -08:00
Mathias Agopian dd17b3eaa9 fix [3176642] Camera preview turns completely black for multiple toggles between camera and camcorder app
There was a leak of Surface tokens when a surface was detached from a UserClient.
We now always detach a surface from its client before attaching to the new one,
this guarantees that its token is freed.

Change-Id: Icfad0b16286ed58155bdfafdf36ab161440aa485
2010-12-13 16:49:05 -08:00
Mathias Agopian f345069099 [3211070] camera preview image is rendered offset from the UI overlay frame
somehow this change got lost.

Change-Id: I36f6c7ef3f782918042b77e9dc91a4c811d84a40
2010-12-08 17:40:28 -08:00
Mathias Agopian 86bdb2f918 fix [3260137] Sometimes front-facing camera mirroring is wrong
make sure to take the buffer's orientation into account.

Change-Id: I9fef89e66368ad2dec1cb8c7b77ac2b3b4858efb
2010-12-08 17:23:18 -08:00
Mathias Agopian a1aa18fc26 resolved conflicts for merge of a0f011ff to master
Change-Id: I4c17021fc269ce66c98cc345353600eda332f980
2010-12-07 22:53:40 -08:00
Mathias Agopian e24cc7a38d [317580] fix issue where the screen wouldn't be rotated properly in bypass mode
In some situations, the screen transformation would not be
applied while in bypass mode.

Change-Id: I3d6dd52e4c12b11aae97b54bf8e2322536eee37f
2010-12-07 21:16:14 -08:00
Mathias Agopian b5a00fcb71 am 48f42f8c: am 4153bf3a: Merge "[3171580] don\'t automatically log GraphicBuffer allocation failures" into gingerbread
* commit '48f42f8c3fbd33b2f46c6290ff5963dd58938cf9':
  [3171580] don't automatically log GraphicBuffer allocation failures
2010-12-07 17:24:03 -08:00
Mathias Agopian 22c67843be [3171580] SurfaceFlinger Bypass mode. (DO NOT MERGE)
This is a poor's man precursor to the h/w composer HAL.
Basically we detect when a window is full screen and in
that case we bypass surfaceflinger's composition step, which
yields to much improved performance.

Change-Id: Ie03796ae81a1c951949b771c9323044b980cb347
2010-12-03 17:35:07 -08:00
Mathias Agopian 733189d408 [3171580] Fix two typos related to fixed-size buffers
mFixedSize was never set, this bug was introduced during some "cleanup", in
practice this could cause some issues when a fixed-size buffer was used and
the window was resized.

Layer::drawForSreenShot() had a typo that had no effect.

mFixedSize was used to determine if filtering was needed, which was a bit too
conservative and created a dependency between filtering and "fixed size" states
which should exist.

Now we enable filtering based on the size of the buffer vs. the size of the layer.

Change-Id: I32044e91b0c944c1b137efdceb3f01dfaa78119d
2010-12-03 17:35:06 -08:00
Mathias Agopian 678bdd6349 [3171580] don't automatically log GraphicBuffer allocation failures
some of these failures are not fatal and even expected in some cases
so they should not emit a dump in the log in those cases.

Change-Id: Idcfa252e3bfa9d74e27fe4ad8f8623aa01aa9c5e
2010-12-03 17:33:09 -08:00
Louis Huemiller 0404814194 Remove const_cast to layer handle
Change-Id: Ica1e089cb56b5f9f46ab87abf735ffe7237fc926
2010-12-01 12:29:36 -08:00
Jamie Gennis 54cc83e8a4 Implement reducing the buffer count of a Surface.
Change-Id: I7f979c60c06d654aa8265002836277434bc1a64f
Bug: 3095167
2010-11-11 14:06:38 -08:00
Romain Guy 3b996c96e4 Always create OpenGL accelerated windows in RGBA 8888.
Bug #3081600

The OpenGL renderer in libhwui uses a single EGL context per process and
thus create it with an RGBA 8888 EGL configuration. To ensure that all
windows are compatible with this configuration, this change modifies
the window manager and SurfaceFlinger.

The window manager now checks the window's flags and if the window is
hardware accelerated, it forces the window's pixel format to be
translucent when creating the surface. The window itself is still
marked as opaque if we know that the window will be opaque on screen.
This keeps existing optimizations in place.

Similarly in SurfaceFlinger, a translucent Surface can now be created
with the Surface.OPAQUE flag, indicating SurfaceFlinger that the surface
does not require blending, despite its RGBA 8888 configuration.

Change-Id: Ic747b6b12564ba064412d842117880fcc199eb7c
2010-10-12 11:00:18 -07:00
Mathias Agopian df85c455c3 refactored screenshot code
the core screenshot function now can capture the screen at any lower resolution
performing bilinear filtering.

we also now have some client code to interface with the screenshot service.

it's now possible to request a screenshot at a lower resolution.

Change-Id: I33689bba98507ab928d0898b21596d0d2fe4b953
2010-10-04 17:36:17 -07:00
Mathias Agopian 74c40c0a27 refactored screenshot code
the core screenshot function now can capture the screen at any lower resolution
performing bilinear filtering.

we also now have some client code to interface with the screenshot service.

it's now possible to request a screenshot at a lower resolution.

Change-Id: I5a3b0e431421800e3aad601d9af8f94adffbc71f
2010-09-29 16:55:15 -07:00
Mathias Agopian e44d21a247 fix [3018216] UI shrinks / stretches while using apps with IME
Change-Id: Ie4c5d8a434b4489355ed8c52af96eb931b4d7167
2010-09-21 10:52:42 -07:00
Jamie Gennis 5dda7f7cf2 Fix a SurfaceFlinger bug.
The bug caused SurfaceFlinger to constantly trigger reallocation of buffers
that requested a fixed size.

Change-Id: Ic993a60e6474e36a344c8b48d541a0d08b8c4faf
2010-09-17 12:19:07 -07:00
Mathias Agopian 413f750501 am 6d4346ce: am 4cffbb47: Merge "fix [2946787] Screen flicker on low resolution setting in camcorder." into gingerbread
Merge commit '6d4346ce35a521d67f45d7c9658c450c0fc461d2'

* commit '6d4346ce35a521d67f45d7c9658c450c0fc461d2':
  fix [2946787] Screen flicker on low resolution setting in camcorder.
2010-08-25 16:40:28 -07:00
Mathias Agopian eff062c49e fix [2946787] Screen flicker on low resolution setting in camcorder.
Change-Id: I7e86f2b6d85dcae8dd212890b978fa6ac7de6893
2010-08-25 15:09:52 -07:00
Mathias Agopian e34a3d1a29 am 46820412: am 8eb16af2: Merge "don\'t try to lock a buffer that wasn\'t allocated with SW usage bits" into gingerbread
Merge commit '468204124e95bbf74ae8cc000318ade29e311be6'

* commit '468204124e95bbf74ae8cc000318ade29e311be6':
  don't try to lock a buffer that wasn't allocated with SW usage bits
2010-08-25 12:24:02 -07:00
Mathias Agopian f1b38247d4 don't try to lock a buffer that wasn't allocated with SW usage bits
Change-Id: Iabbcec1bfa30dc47d45ece699dd178653f1b675b
2010-08-25 12:14:27 -07:00
Mathias Agopian 4ad298c12c am bc4389ed: am 8395b462: Merge "fix [2931513] Add support for setting the orientation of an ANativeWindow" into gingerbread
Merge commit 'bc4389edfbb5777aec1a9af7863b2ca3ade2fa64'

* commit 'bc4389edfbb5777aec1a9af7863b2ca3ade2fa64':
  fix [2931513] Add support for setting the orientation of an ANativeWindow
2010-08-24 17:56:40 -07:00
Mathias Agopian b661d66013 fix [2931513] Add support for setting the orientation of an ANativeWindow
Also implement support for cropping.

Change-Id: Iba5888dd242bf2feaac9e9ce26e404c1f404c280
2010-08-24 15:40:50 -07:00
Mathias Agopian 000ca8fa9a revert hwcomposer HAL changes. DO NOT MERGE.
This reverts commit:
94364b91a2894bf037b8beb027132fbb812e1434
f8e705dea48f77f1c2532fdbadd4997dd1851af0
b59beb5ca68d0228f60dda60d85e2d0226b33215
e0d5f5bcf5a8b26f4ad75f549cbf380b2c9faf20
2010-08-17 20:22:04 -07:00
Mathias Agopian a350ff9869 call into hwcomposer HAL when present
Change-Id: I70f31c69a9436a43860e78977442863ecba6d27b
2010-08-11 16:08:45 -07:00
Mathias Agopian 208cb07724 fix [2873058] Surface::dequeueBuffer blocks on last buffer, i.e. cannot dequeue all allocated buffers at once.
this situation happened when the last buffer needed to be resized
(or allocated, the first time). the assumption was that the buffer
was in use by SF itself as the current buffer (obviously, this
assumption made no sense when the buffer had never been allocated, btw).

the system would wait until some other buffer became the "front" buffer.

we fix this problem by entirely removing the requirement that the
buffer being resized cannot be the front buffer. instead, we just
allocate a new buffer and replace the front buffer by the new one.

the downside is that this uses more memory (an extra buffer) for a
brief amount of time while the old buffer is being reallocated and
before it has actually been replaced.

Change-Id: I022e4621209474ceb1c671b23deb4188eaaa7285
2010-07-27 20:11:35 -07:00
Mathias Agopian 81bac09fa6 move native services under services/
moved surfaceflinger, audioflinger, cameraservice

all native services should now reside in this location.

Change-Id: Iee42b83dd2a94c3bf5107ab0895fe2dfcd5337a8
2010-07-14 17:59:35 -07:00