48 Commits

Author SHA1 Message Date
Romain Guy
04c9d8c2ff Optimize display lists
Remove redundant or useless operations

Change-Id: If989b4eaa9143eef4254c38b39959aeed1f2b9ab
2011-08-25 14:01:48 -07:00
Romain Guy
65b345fa22 Reclaim more memory, more often.
Yay.

Change-Id: I04557ad575c307a55088549f48f0e9ad994b7275
2011-07-27 18:51:50 -07:00
Jeff Brown
162a021756 Decouple GLES20RecordingCanvas lifetime from GLES20DisplayList.
Bug: 5062011

Previously, each GLES20DisplayList would hold onto an instance of
GLES20RecordingCanvas.  In turn, each GLES20RecordingCanvas
held onto an SkWriter with a 16Kb buffer along with several other
objects.  With one display list per view and hundreds of views,
the overhead could add up to a few megabytes.

Ensured that the GLES20RecordingCanvas is reset as soon as
the display list has been constructed, thereby promptly freeing
the 16Kb buffer.

Changed GLES20DisplayList so that it acquires a GLES20RecordingCanvas
from a pool as needed and recycles it when done.

Removed some dead code and cruft related to the construction of
GLES20Canvas objects in general.  Some code was written with the
assumption that the underlying renderer object could change
behind the scenes or might be lazily constructed, but that isn't
actually the case so we can simplify things.

Removed an unnecessary weak reference from GLES20DisplayList
to the View.  It isn't actually used anywhere.

Fixed a bug in GLES20DisplayList where isValid() would return
true while the display list was being recorded.  This is incorrect
because the native display list might not actually exist.  Worse,
even if the native display list does exist, it is stale and
potentially refers to old Bitmaps that have been GC'd (because the
mBitmaps list was cleared when recording started).

Change-Id: Ib12d5483688cb253478edeb0156d34c476c2566b
2011-07-21 17:15:48 -07:00
Romain Guy
9ff3cb57ee Fix parameter order evaluation issue.
This problem was affecting Android builds with gcc/x86.

Change-Id: Ibb7978413c89bd1ac09f0d1ea78f5cb4fe61f6ed
2011-06-28 14:02:11 -07:00
Romain Guy
d586ad9c9f Fix another memory leak in OpenGLRenderer
Change-Id: I23ed56891452a05cf3ca13f6919c4fef90d5ff4e
2011-06-22 17:10:00 -07:00
Romain Guy
726aeba80f Add support to OpenGLRendere to draw BiDi text.
Bug #4350336

Change-Id: I1cf31693f7ca9653fa3a41b5b91c27ef288d680f
2011-06-01 14:55:42 -07:00
Chet Haase
ed30fd8e9a Add ability for hierarchyviewer to output displaylist info
Clicking on a node in hierarchyviewer1 and hierarchyviewer2 and then
clicking the new "Dump DisplayList" button will cause the display
list for the selected node (including its children) to be output into
logcat.

Change-Id: Iad05f5f6cca0f8b465dccd962b501dc18fe6e053
2011-05-05 07:35:40 -07:00
Chet Haase
a17de9b493 Revert "Add ability for hierarchyviewer to output displaylist info"
This reverts commit b2a4b52e8d5e499d33e2765e8c47851bf0266299.
2011-05-04 18:23:12 -07:00
Chet Haase
b2a4b52e8d Add ability for hierarchyviewer to output displaylist info
Clicking on a node in hierarchyviewer1 and hierarchyviewer2 and then
clicking the new "Dump DisplayList" button will cause the display
list for the selected node (including its children) to be output into
logcat.

Change-Id: Id32f62569ad1ab4d533bc62987f3a7390c1bb4e6
2011-05-04 17:18:27 -07:00
Chet Haase
9c1e23baf5 Add logging of graphics acceleration info to bugreports
Change-Id: I9fa4cda6ccf92df9d1c644ccdc0e7274a30106e0
2011-04-01 13:24:53 -07:00
Romain Guy
1af23a32d8 When deleting a path, remove it from the path cache.
Bug #4170585

Change-Id: I6be4d251ceb908c89afe49c2ff85c05f36c73b70
2011-03-24 16:03:55 -07:00
Romain Guy
ed6fcb034b Add support for drawPoint() and drawPoints().
Change-Id: I01bef50c08ec3160f8d40dc060b2cf6c2e4d7639
2011-03-21 13:11:49 -07:00
Romain Guy
b29cfbf768 Fix paths rendering issues.
See ApiDemos, PathEffect and PathFillTypes.

Change-Id: I9f9593c1da33d0d013b5b89c86bc5bd71128a192
2011-03-18 16:24:19 -07:00
Romain Guy
7b5b6abf85 Fix rendering artifact in edge fades.
Bug #4092053

The problem always existed but was made visible by partial invalidation.
When saving a layer, the renderer would try to postpone glClear()
operations until the next drawing command. This however does not work
since the clip might have changed. The fix is rather simple and
simply gets rid of this "optimization" (that turned out to be
usless anyway given how View issues saveLayer() calls.)

This change also fixes an issue with gradients (color stops where
not properly computed when using a null stops array) and optimizes
display lists rendering (quickly rejects larger portions of the
tree to avoid executing unnecessary code.)

Change-Id: I0f5b5f6e1220d41a09cc2fa84c212b0b4afd9c46
2011-03-14 18:05:08 -07:00
Romain Guy
cabfcc1364 Add support for partial invalidates in WebView
Bug #3461349

This change also fixes two bugs that prevented partial invalidates
from working with other views. Both bugs were in our EGL implementation:
they were preventing the caller from comparing the current context/surface
with another context/surface. This was causing HardwareRenderer to always
redraw the entire screen.

Change-Id: I33e096b304d4a0b7e6c8f92930f71d2ece9bebf5
2011-03-07 18:09:03 -08: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
d63cbd1076 Fix leak in reused display lists
Change-Id: I32a9c41abf8f8cbcaaaa6fcc82d296800014a1b2
2011-02-03 16:33:26 -08:00
Romain Guy
2fc941e465 Fixes cache misses and extra allocations.
Bug #3421454

Change-Id: If4d5c960a7e4c581a9d213073e658284b4e1c497
2011-02-03 16:20:08 -08:00
Romain Guy
2b1847ea60 Remove unused API
Change-Id: I1714fd82a64b752f0350ef4ef9179ce19e089c6a
2011-01-26 13:43:01 -08:00
Romain Guy
82d41a5153 Fix display list support for shapes.
Change-Id: I8b4c9e9ec36266a83c0a53ba3fb6e45d61bbd6d9
2011-01-24 21:53:42 -08:00
Romain Guy
7d7b5490a0 Enable partial invalidates when rendering with OpenGL.
Change-Id: Ie8be06c4776b815e8737753eb8003b4fd8936130
2011-01-24 18:39:56 -08:00
Chet Haase
daf98e941e Use optimized display lists for all hwaccelerated rendering
Previously, display lists were used only if hardware acceleration
was enabled for an application (hardwareAccelerated=true) *and* if
setDrawingCacheEnabled(true) was called. This change makes the framework
use display lists for all views in an application if hardware acceleration
is enabled.

In addition, display list renderering has been optimized so that
any view's recreation of its own display list (which is necessary whenever
the visuals of that view change) will not cause any other display list
in its parent hierarchy to change. Instead, when there are any visual
changes in the hierarchy, only those views which need to have new
display list content will recreate their display lists.

This optimization works by caching display list references in each
parent display list (so the container of some child will refer to its
child's display list by a reference to the child's display list). Then when
a view needs to recreate its display list, it will do so inside the same
display list object. This will cause the content to get refreshed, but not
the reference to that content. Then when the view hierarchy is redrawn,
it will automatically pick up the new content from the old reference.

This optimization will not necessarily improve performance when applications
need to update the entire view hierarchy or redraw the entire screen, but it does
show significant improvements when redrawing only a portion of the screen,
especially when the regions that are not refreshed are complex and time-
consuming to redraw.

Change-Id: I68d21cac6a224a05703070ec85253220cb001eb4
2011-01-24 08:43:20 -08:00
Romain Guy
a566b7c3aa Fix bitmap meshes to work in display lists.
Change-Id: Ie226d049840942d9ad9cf58e0c19132f49d62a75
2011-01-23 16:36:11 -08:00
Romain Guy
8b2f5267f1 Add support for arcs.
Change-Id: I96c057ff4eb1b464b03f132da0b85333777bee4f
2011-01-23 16:15:02 -08:00
Romain Guy
c1cd9ba335 Add support for ovals and stroked rectangles.
Change-Id: I1292e241386763c82e6622c8f7ed90b0f5b7bd4f
2011-01-23 14:18:41 -08:00
Romain Guy
27454a42de Collapse sucessive calls to restoreToCount() in display lists.
Change-Id: Icb3d3dc2c579436d375269a9cb0b821a931c5a79
2011-01-23 12:01:41 -08:00
Romain Guy
4cf6e2f349 Fix potential crash in display lists.
Change-Id: I868821cbe69f7e71d93701b9cdb528a2ef796cd4
2011-01-23 11:35:13 -08:00
Romain Guy
5a7b466a2b Add support for drawBitmapMesh().
Change-Id: Ic77f9c534bb90dc7b9458299544bd50b8b6ae6a5
2011-01-20 19:09:30 -08:00
Romain Guy
01d58e43ed Add rounded rects and circles support to OpenGLRenderer.
Change-Id: I6cedf2b495d58de7c0437096809fa9e4518a1b8c
2011-01-19 21:55:10 -08:00
Romain Guy
807daf7df6 Add support for skew()
Change-Id: Ia3a9a867f74fd78b61f75179e3788fdc2f0cacd0
2011-01-18 11:19:19 -08:00
Romain Guy
43ccf4663c Don't crash Launcher on config change.
Change-Id: Ibbbd7146c5ff69e9639b433f39041053654d808c
2011-01-14 18:51:01 -08:00
Romain Guy
24c0021668 Copy shaders when recording them in display lists.
Change-Id: I3f22dd35f1e31c9e5102955d76548098b7b0cd8d
2011-01-14 15:31:00 -08:00
Romain Guy
ffac7fc504 Add debug logs for display lists.
Change-Id: I7bae8fd96e9eccb51f29f73e4069b4d3e6bdbdd7
2011-01-13 17:22:58 -08:00
Romain Guy
ada830f639 Cleanup implementation of hardware layers.
The new implementation relies on OpenGLRenderer's existing layer
code instead of duplicating it. The new code is much cleaner, with
simpler and better APIs and allows tracking of drawn regions inside
layers. Region tracking is not yet enabled but this will be done
in a future CL.

Change-Id: Ie826121a2227de8252c77b992a61218defea5143
2011-01-13 12:13:20 -08:00
Romain Guy
6c319ca127 Better backend for hardware layers.
With this new backend, a hardware layer is only recreated when
its associated view is udpated. This offers fast composition
in GL and fast update of the layer in GL as well.

Change-Id: I97c43a612f5955c6bf1c192c8ca4af10fdf1d076
2011-01-11 17:53:19 -08:00
Chet Haase
5977baa1fa Reuse of native display list objects
Change-Id: Ia4553e23930ad20e56c11faa7809be788a1ad4bb
2011-01-06 12:50:30 -08:00
Romain Guy
fe48f65922 Free resources only from the GL context thread.
Bug #3179882

Resources were freed following garbage collections on a worker thread.
This worker thread had no EGL context, which would cause the renderer
to incorrectly assume that the memory was liberated.

Change-Id: Ifdb51f94ddf42641e8654522787bfac532976c7c
2010-11-11 15:36:56 -08:00
Romain Guy
9e10841c27 Correctly remove unused paths from the cache.
Change-Id: I41d9334dcd9871634037344ab49bf69383498161
2010-11-09 14:37:42 -08:00
Romain Guy
0fe478ea04 Support nested display lists.
Change-Id: I3815a2832fc0f722c668ba8f51c5f177edb77c94
2010-11-08 12:15:28 -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
Romain Guy
4bb942083a Optimize 9patch rendering.
This change detects empty quads in 9patches and removes them from
the mesh to avoid unnecessary blending.

Change-Id: I4500566fb4cb6845d64dcb59b522c0be7a0ec704
2010-10-12 15:59:26 -07:00
Romain Guy
6b7bd24659 Don't clear the framebuffer when not needed. 2010-10-06 19:49:23 -07:00
Romain Guy
7975fb6d12 Apply bilinear filtering to text.
Change-Id: I2c81ad657ee2a11a2139e0b11ae3749db54c0749
2010-10-01 16:36:14 -07:00
Romain Guy
b051e895cc Add display lists caching.
Change-Id: Iac3a248a81ed8cb076a83ef9d186b8ebba685b4c
2010-09-29 13:29:04 -07:00
Romain Guy
4aa90573bb Adding display lists to the GL renderer (checkpoint.)
Change-Id: Iaa49757600a53b39369dbb23f8c3feab282518e6
2010-09-26 18:40:37 -07:00