12 Commits

Author SHA1 Message Date
Chet Haase
547e66531d Don't null the reference to Bitmap pixels until we're really ready
A change in the VM triggers a native memory error more aggressively than before,
showing that there's a bug in the logic of recycling bitmaps. Since the pixel
memory is allocated on the Java heap, nulling out the reference to that memory
in the Java level Bitmap object can cause that memory to get collected at any time.
Meanwhile, we may have a reference to that memory at the native level for rendering
purposes, causing an error if/when we access that memory after it has been collected
by the VM.

The fix is to avoid setting the reference to the pixels to null unless we are
not referring to it in native code. This is determined at the time we call
recycle() - we return a boolean to indicate whether the native code is still
using the memory. if not, the Java code can null out the reference and allow the
VM to collect it. Otherwise, it will get collected later when the encompassing
Bitmap object is collected.

Issue #7339156 HTML5 tests crash the app (Vellamo)

Change-Id: I3a0d6b9a6c5dd3b86cc2b0ff7719007e774b5e3c
2012-10-22 15:25:19 -07:00
Romain Guy
97dc9172b0 Avoid deadlock when deleting layers
Bug #7217459

Change-Id: I12bfa6c30c5030bd1b23ea6a3ce64240ab1dfba3
2012-09-23 17:49:24 -07:00
Chet Haase
603f6de35f Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).

When this happens, if the memory got corrupted, it's possible to crash.

The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.

Issue #6994632 Native crash in launcher when trying to launch all apps screen

Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-17 11:21:34 -07:00
Romain Guy
58ecc204fb Reduce the number of locks acquired by display lists
Change-Id: I1123aae0355de84db705bb75042c7083fc69c9f2
2012-09-07 14:01:09 -07:00
Romain Guy
7953745dd5 Reduce the size of libhwui by 50%
This change removes unnessary symbols. All symbols are hidden by
default, public APIs with exported symbols are explicitly marked
with ANDROID_API.

Change-Id: I692fde432a86c12108de1cfd1f6504919a7d5f3f
2011-10-12 13:48:51 -07:00
Chet Haase
5a7e828842 Fix crash when Paths are GCd in hw accelerated apps
A recent change to optimize path rendering didn't account for
the destruction of native objects by the VM finalizer. We may be
done with the Java level version before we're done with the native
structure that's used by the display list. For example, a drawing
method on a View that creates a temporary path to render into the
canvas will implicitly create a native structure that is put onto
the GL display list. That temporary path may go away, but the native
version should stick around as long as the display list does.

The fix is to refcount the original native version of the path
and only delete it when the refcoutn reaches zero (which means that
it is no longer needed by any display list). This is a similar mechanism
used for bitmaps and shaders.

Change-Id: I4de1047415066d425d1c689aa60827f97729b470
2011-02-04 12:50:55 -08:00
Chet Haase
5cafc52fb1 Fix hang in native bitmap recycling due to nested mutex locks
Change-Id: Ic37d5408ddb3f68aba6520fb0c78ffde91dfbe62
2010-11-23 14:11:43 -08:00
Chet Haase
e7d2295c06 make ResourceCache for display lists thread-safe
Change-Id: I41885b4ae249d7d7c000bab17bf32340ba85ab3a
2010-11-11 16:44:46 -08:00
Romain Guy
5b3b35296e Optimize FBO drawing with regions.
This optimization is currently disabled until Launcher is
modified to take advantage of it. The optimization can be
enabled by turning on RENDER_LAYERS_AS_REGIONS in the
OpenGLRenderer.h file.

Change-Id: I2fdf59d0f4dc690a3d7f712173ab8db3848b27b1
2010-11-02 16:17:23 -07:00
Chet Haase
ad93c2bb63 Optimizing ColorFilter in display lists
Change-Id: Ie4d5e5b0bc45e0ce47bba144049303c270762e54
2010-10-26 12:52:03 -07:00
Chet Haase
d98aa2de9a DisplayList optimizations and fixes.
We now use a copy of SkPaint objects to avoid having it changed from under us.
We reuse copies that have not changed. We also copy the SkMatrix every time to
avoid the same problem.

Change-Id: If3fd80698f2d43ea16d23302063e0fd8d0549027
2010-10-26 06:54:55 -07:00
Chet Haase
5c13d89c13 Optimizing display lists by referencing pointers to resources instead of copying them
Change-Id: I81ad3551d74aa1e5bb64d69e33d2eb29a6c1eb6a
2010-10-21 12:02:42 -07:00