Commit Graph

74 Commits

Author SHA1 Message Date
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
Mathias Agopian
dea20b1f34 Fix a race in SurfaceFlinger that could cause layers to be leaked forever.
The transaction flags were atomically read-and-cleared to determine if
a transaction was needed, in the later case, mStateLock was taken to
keep the current state still during the transaction. This left a small
window open, where a layer could be removed after the transaction flags
were checked but before the transaction was started holding the lock.
In that situation eTraversalNeeded would be set but only seen during the
next transaction cycle; however, because we're handling this transaction
(because of another flag) it will be commited, "loosing" the information
about the layer being removed -- so when the next transaction cycle due
to eTraversalNeeded starts, it won't notice that layers have been removed
and won't populated the ditchedLayers array.

Change-Id: Iedea9e25fee8dd98a0c5bd5ad41a20fcadf75b47
2011-05-03 20:44:51 -07:00
Mathias Agopian
4f11374018 Fix a race-condtion in SurfaceFlinger that could lead to a crash.
Client::mLayers could be accessed from different threads.
On one side from Client::attachLayer() which is currently
called from a binder thread; on the other side from
Client::detachLayer() which is always called from the main
thread.

This could lead to a corruption of Client::mLayers.

We fix this issue by adding an internal lock to Client.

Change-Id: Ib1317d7750ed5030e6f577efe34b69fc10198bd3
2011-05-03 16:21:41 -07:00
Mathias Agopian
0ef4e15a6c Get rid of the "pid" parameter from createSurface
Change-Id: I28635e3f803e6abe965d79998e305f54a202465d
2011-04-20 14:26:11 -07:00
Mathias Agopian
4cb18881b5 Fix a GraphicBuffer leak in SurfaceTexture
This leak was intentional, it was there to deal with the fact that
some gralloc implementations don't track buffer handles with
file-descriptors so buffers needed to stay alive until there were
registered, which is not guaranteed by binder transactions.

In this new implementation, we use a small BBinder holding a
reference to the buffer, which with tuck into the parcel. This forces
the reference to stay alive until the parcel is destroyed, which
is guaranteed (by construction) to happen after the buffer is
registered.

this allows the public facing API to not expose the previous hack.

Change-Id: I1dd6cd83679a2b7457ad628169e2851acc027143
2011-04-08 19:28:04 -07:00
Mathias Agopian
1bbafb9610 Fix some const-ness and comments
mDrawingState doesn't need to be accessed by the
mStateLock, because by definition it's only accessed
from the main thread.

Similarily, the list of layers in the drawing state
cannot change (ie: is const).

Change-Id: I2e5da7f4d8caee7af7802b432cd45cc81c7c08b0
2011-03-11 17:01:40 -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
Jamie Gennis
134f042286 ANativeWindow: add queues-to-window-composer check.
This change adds a new 'method' to the ANativeWindow interface to check
whether buffers queued to the window will be sent directly to the system
window compositor.

Change-Id: I4d4b199e328c110b68b250029aea650f03c8724d
Bug: 3495535
2011-03-08 16:49:51 -08:00
Mathias Agopian
1c71a47a6d remove some logs
Change-Id: Ia476184048ee419e19330a56dc8e6553189f6a24
2011-03-02 18:45:50 -08:00
Jamie Gennis
d1ad86f66b am e630e5f4: am 919853ce: Merge "Prevent SurfaceFlinger from using layer token 31." into gingerbread
* commit 'e630e5f49ba15005172dceeda7299569b2d2351f':
  Prevent SurfaceFlinger from using layer token 31.
2011-02-27 15:55:21 -08:00
Jamie Gennis
8a08392833 Prevent SurfaceFlinger from using layer token 31.
Bug: 2964479
Change-Id: I81e948924bff35b8b300d409f2c09f3779bcdeec
2011-02-10 16:18:36 -08:00
Mathias Agopian
bce26daaaf [3418265] apply layer transformations to the DimLayer.
with this change DimLayers will behave just like any other layer,
in particular they'll respect the layer transformations.

Change-Id: Icb4a1275e8bca9e3deb5f57c9f9219aaa69f9877
2011-02-02 16:05:39 -08:00
Mathias Agopian
0d1561275e fix [3385504] Surface flinger hang when adding dim surface
Change-Id: I8e0cda414bcad5854d2ca5dde8370bfd8b2e5ea4
2011-01-25 20:52:46 -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
53a67e1663 partially fix [3306150] HTML5 video with H/W acceleration blackout (DO NOT MERGE)
We used to guarantee that a layer in SurfaceFlinger would never be
destroyed before all references (to its ISurface) on the client
side would be released. At some point, this guarantee got
relaxed to allow to free gralloc resources sooner. This last
change was incorrect, because:
- in implementations with reference-counting the gralloc resources
wouldn't be released anyways, until all the mapping were gone
- in implementations without ref counting, the client side
would most likely crash or do something bad
- it also caused the SharedBufferStack slot to be reallocated
to another surface, which could be problematic if the client
continued to use the surface after the window manager destroyed it.

So, we essentially reinstate the guarantee that layers won't be
destroyed until after all references to their ISurface are
released.

NOTE: This doesn't entirely fix 3306150 because there is another
problem there where the Browser continues to use a surface after it
has been destroyed.

also improve SurfaceFlinger 'dumpsys' log

list the purgatory, which shows windows that have been closed,
but for which the client still has references.
2011-01-25 14:19:13 -08:00
Mathias Agopian
cfb676f1ae fix a small bug that caused screenshot to show garbage in some cases (DO NOT MERGE)
we were not clearing the screen entirely, which caused garbage when
the screen wasn't entirely covered by windows.

Change-Id: Ia7aa13c36a8a314e0e8427d419b16b9aa2165ddf
2011-01-25 14:18:58 -08:00
Mathias Agopian
5dc7e7da92 workaround [3201922] display not on: log full of gralloc errors (DO NOT MERGE)
we make sure to call compositionComplete after everytime we do
composition with the GPU (even for the screenshot case), which is
where the buffer locks are released.

Change-Id: I450430d1e4d1ee9ce1023970642378c42cdcfa4c
2011-01-25 14:18:29 -08:00
Mathias Agopian
0c2648ab64 tone down the log spew regarding taking screenshots.
Change-Id: I673806bda23eba6aab25f7505b7e0170afc9920b
2011-01-24 18:13:54 -08:00
Mathias Agopian
a9f54a77cd Merge "fix [3369743] SurfaceFlinger reads hardware composer hints before calling hwc.prepare()" into honeycomb 2011-01-20 12:25:33 -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
48b888aab9 improve SurfaceFlinger 'dumpsys' log
list the purgatory, which shows windows that have been closed,
but for which the client still has references.

Change-Id: I5168bb88cb328d5d77d71d0871deb9190f493126
2011-01-19 16:15:53 -08:00
Mathias Agopian
f20a32415d fix [3369743] SurfaceFlinger reads hardware composer hints before calling hwc.prepare()
Change-Id: If3277c7b9d4cb8ef20d1706155fac7b87e64fb20
2011-01-19 15:24:23 -08:00
Mathias Agopian
c1d1b0d9b7 Add logs when taking a screenshot to help tracking issue 3361121
Change-Id: I61d1e072ebe7061ee1d7255f6121b684e2923d1b
2011-01-16 17:25:26 -08:00
Mathias Agopian
0d3dcc4aab Merge "partially fix [3306150] HTML5 video with H/W acceleration blackout" into honeycomb 2011-01-14 19:27:38 -08:00
Mathias Agopian
76cd4ddc6a partially fix [3306150] HTML5 video with H/W acceleration blackout
We used to guarantee that a layer in SurfaceFlinger would never be
destroyed before all references (to its ISurface) on the client
side would be released. At some point, this guarantee got
relaxed to allow to free gralloc resources sooner. This last
change was incorrect, because:
- in implementations with reference-counting the gralloc resources
wouldn't be released anyways, until all the mapping were gone
- in implementations without ref counting, the client side
would most likely crash or do something bad
- it also caused the SharedBufferStack slot to be reallocated
to another surface, which could be problematic if the client
continued to use the surface after the window manager destroyed it.

So, we essentially reinstate the guarantee that layers won't be
destroyed until after all references to their ISurface are
released.

NOTE: This doesn't entirely fix 3306150 because there is another
problem there where the Browser continues to use a surface after it
has been destroyed.

Change-Id: I305c830dd722b30a6d53cbf3a9c714fd3cf7eb06
2011-01-14 18:19:02 -08:00
Mathias Agopian
a49576f06b Merge "fix [3312683] Camera mirroring problem after switching from back to front camera" into honeycomb 2011-01-14 10:54:47 -08:00
Mathias Agopian
ad456f9878 fix [3312683] Camera mirroring problem after switching from back to front camera
the crop as well as buffer orientation can change at every frame, when that happens
we need to reset the hwc HAL (ie: set the GEOMETRY_CHANGED flag).
currently we achieve this by taking the same code path than an actual geometry change
which is a bit more heavy than necessary.

Change-Id: I751f9ed1eeec0c27db7df2e77d5d17c6bcc17a24
2011-01-13 17:53:01 -08:00
Jamie Gennis
9a78c90cd4 Fix remote GraphicBuffer allocation in SurfaceFlinger.
This change fixes a horrible hack that I did to allow application
processes to create GraphicBuffer objects by making a binder call to
SurfaceFlinger.  This change introduces a new binder interface
specifically for doing this, and does it in such a way that
SurfaceFlinger will maintain a reference to the buffers until the app is
done with them.

Change-Id: Icb240397c6c206d7f69124c1497a829f051cb49b
2011-01-13 12:19:04 -08:00
Jamie Gennis
4956334065 Add the ISurfaceComposer::createGraphicBuffer IPC.
This change adds a new binder method to the ISurfaceComposer interface.
This IPC is intended to allow SurfaceFlinger clients to allocate gralloc
buffers using SurfaceFlinger as a proxy to gralloc.

Change-Id: Ide9fc283aec5da6268ba62cfed0c3319a50b640d
2011-01-06 13:12:35 -08:00
Mathias Agopian
f653b897a4 fix a small bug that caused screenshot to show garbage in some cases
we were not clearing the screen entirely, which caused garbage when
the screen wasn't entirely covered by windows.

Change-Id: Ie9ab9b94eabfa6cafddf45bb14bc733bdc8d35c0
2010-12-16 18:47:29 -08:00
Mathias Agopian
e6f0984361 workaround [3201922] display not on: log full of gralloc errors
while we're waiting for the real fix in the gralloc/gpu driver,
this workaround should resolve the issue.

we make sure to call compositionComplete after everytime we do
composition with the GPU (even for the screenshot case), which is
where the buffer locks are released.

Change-Id: I3cb5ad67d48c81a23100172bab77e86a70e29152
2010-12-15 15:54:57 -08:00
Mathias Agopian
ebeb709596 fix debug.sf.showbackground
Change-Id: Ie4eeca006ad6d8030900d8cb0029e4d1c22474fb
2010-12-14 18:38:36 -08:00
Mathias Agopian
bf2c6a6c8f [3258939] Need snapshot to limit which layers are included
Change-Id: Id7351a0e3f53dde99b291cffba553d89fd4d7ca9
2010-12-10 16:22:31 -08:00
Mathias Agopian
1293a8eb56 More clean-up. Get rid off the "blur" effect in SurfaceFlinger
For multiple reason, this effect is not maintainable and was never
used due to its abysmal performance. it'll be resurected when it can be
implemented efficiently.

Change-Id: Id4222c9b86c629275cdec18873ef07be8723b6d2
2010-12-08 17:13:19 -08:00
Mathias Agopian
a5529c8778 remove support for PUSH_BUFFER surfaces and overlays
the same functionality is now supported through
the h/w composer HAL, and YUV support in the GPU.

Change-Id: I8146605449954b8e8fd7f78810b7d873c2d8f5bf
2010-12-08 16:13:59 -08:00
Erik Gilling
1d21a9cafc surfaceflinger: add support for gralloc dump hooks
Change-Id: Ib6f539ed0132b70d040d653c03d52cc04249ac3c
2010-12-08 15:40:11 -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
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
Jamie Gennis
37b126a3b2 Remove a problematic empty update optimization.
This change removes an optimization from SurfaceFlinger that skipped
composition when it got window updates that had an empty dirty region.
This optimization caused problems because it would skip the hwcomposer
set call, which could leave the window's previous frame buffer bound to
an overlay plane.  When the application subsequently dequeued and tried
to lock its next buffer (which would be the buffer currently bound to
the overlay), the lock call would block until the next hwcomposer set
call (which may never happen).

Change-Id: I563b626a1d52c1f30eb82489eae0ceb4edc79936
Bug: 3138752
2010-11-10 15:09:09 -08:00
Mathias Agopian
0a96e3c31f am 9f6d18ca: am 04358138: Merge "[3095807] screen takes a long time to turn on" into gingerbread
Merge commit '9f6d18cadf9ac50062063f5f5ff5de7f6895696a'

* commit '9f6d18cadf9ac50062063f5f5ff5de7f6895696a':
  [3095807] screen takes a long time to turn on
2010-10-16 08:58:35 -07:00
Mathias Agopian
fb3051b15e am 7e9a54d4: am d4e03f37: addresses parts of 3096779 and 3097475
Merge commit '7e9a54d460030a871a4f05e61e943c6a694e9ef8'

* commit '7e9a54d460030a871a4f05e61e943c6a694e9ef8':
  addresses parts of 3096779 and 3097475
2010-10-16 08:52:30 -07:00
Mathias Agopian
1cc53746aa am a8faf91f: am 6d71f6a0: Merge "fix [3095607] Gingerbread screen turn-on animation does not show the last frame" into gingerbread
Merge commit 'a8faf91fa558be1235d508e776eb24be4429585c'

* commit 'a8faf91fa558be1235d508e776eb24be4429585c':
  fix [3095607] Gingerbread screen turn-on animation does not show the last frame
2010-10-16 08:52:12 -07:00
Mathias Agopian
c9ce8cbe3b am 3d4a9774: am b0e020ab: Merge "may fix 3097381 and 3097482. don\'t abort on/off if the animation fails" into gingerbread
Merge commit '3d4a9774ced0c704da455c5bd9989127e90ba133'

* commit '3d4a9774ced0c704da455c5bd9989127e90ba133':
  may fix 3097381 and 3097482. don't abort on/off if the animation fails
2010-10-15 14:28:07 -07:00
Mathias Agopian
e33a35f025 am 5bfa3a34: am 011b5bcc: Merge "implement part of [3094280] New animation for screen on and screen off add support for screen on animation" into gingerbread
Merge commit '5bfa3a34eaef759c3ec4def76f646eb1c0bf997f'

* commit '5bfa3a34eaef759c3ec4def76f646eb1c0bf997f':
  implement part of [3094280] New animation for screen on and screen off
2010-10-15 08:33:43 -07:00
Mathias Agopian
a6546e5af4 [3095807] screen takes a long time to turn on
turn on animation is now ~200 ms (12 frames).

Change-Id: I49ca9e8d0afa566349d360b3b6c88f0d55aa6e75
2010-10-14 15:39:21 -07:00
Mathias Agopian
abd671a08a addresses parts of 3096779 and 3097475
3097475: Animation setting should control the screen on animation
3096779: CRT power-on animation can briefly show the top app instead of lockscreen

There is now a parameter that controls wether the ON and/or OFF animation are
performed. we also always clear the screen to black on power off, to make
sure it won't briefly appear on power on.
HOWEVER, 3096779 is not 100% fixed in the case where we're doing the animation
because there is a race, where SF doesn't wait (b/c it doesn't know) for the
framework to have redrawn the lockscreen.

Change-Id: Ie0f02c9225fcdf24b1e8907e268eb7da2c5b0a03
2010-10-14 14:57:34 -07:00
Mathias Agopian
a7f0373533 fix [3095607] Gingerbread screen turn-on animation does not show the last frame
always redraw the screen entirely after the power-on animation, because:
- the animation may not run (ie: on the emu)
- the animation may not contain the video planes
- the interpolation may not be perfect and not land exactly on the last frame

Change-Id: I9ba40f537b1e94464f8a3ed6f81e7c2f552df51d
2010-10-14 12:46:24 -07:00
Mathias Agopian
015fb3fb41 may fix 3097381 and 3097482. don't abort on/off if the animation fails
now that sf handles more of the screen on/off state, we don't want to abort
because/if the animation fails for some reason (which will be the case on the
emulator).

Change-Id: I239e0a39cf8aff3074647e82db92de4a0bf0e494
2010-10-14 12:24:54 -07:00
Joe Onorato
503d2d4a08 am 9a12a3c8: am ba799098: Merge changes I76513387,I335fb671 into gingerbread
Merge commit '9a12a3c8d4bb20042cf69e07d268e3a04ac71f96'

* commit '9a12a3c8d4bb20042cf69e07d268e3a04ac71f96':
  Remove dead code, and make the animation a setting.
  turn off the electron beam
2010-10-13 23:34:21 -07:00
Mathias Agopian
9daa5c9b9d implement part of [3094280] New animation for screen on and screen off
add support for screen on animation

Change-Id: If50cf52ae04b95b42da7d74cf7fa96d5cb54d238
2010-10-13 14:28:26 -07:00