547 Commits

Author SHA1 Message Date
Romain Guy
0908764b2b First OpenGL ES 3.0 based optimization
This change uses a new OpenGL ES 3.0 feature to upload less data when
the font cache needs to be update. This can result in significant
performance improvements on device with large textures or with locales
that use a lot of glyphs (CJK for instance.)

This change also fixes various unpack alignment issues. The unpack
alignment, as well as the unpack row length, is not texture specific
but a global state that affect all glTex/SubImage2D calls. Some of
them were missing the appropriate glPixelStorei() call. This could
result in corrupted textures.

Change-Id: Iefb429d4d0d0b4e0faeadf27daafee6d30a21d85
2013-04-04 12:27:54 -07:00
Chris Craik
16ecda5317 Update view's alpha and layer docs
bug:8501661

Makes the performance issues and interaction with layer type/paint
more clear.

Additionally, corrects change from 47ab7d6612e2b5b8b66fb261dafef7c91264e173
to still allow displayList alpha to override layer paint

Change-Id: Ic94d75865700820489370461cd8ac9f9077a8d90
2013-04-01 17:21:35 -07:00
Romain Guy
02b49b70ed Prevent crash when a single layer is enqueued several times for updates
Bug #8504687

Change-Id: I9b01bbc4e3f37af23dfe5e68d3d03ad3d238b94a
2013-03-29 12:37:16 -07:00
Chris Craik
7273daace9 Fix issues related to saveLayer/restore deferral
bug:8464795

Changes drawModifiers and alpha to be restored for all operations,
since saveLayer/restore use these values, not just draw operations

Also forces a renderer state restoration before a deferred restore op
is played back, in case it is associated with a saveLayer that
doesn't have the save_clip flag set

Change-Id: I9da5d44fefbfffdee164c98f4f139843dacf85df
2013-03-28 11:33:13 -07:00
Chris Craik
9cd6451215 Merge "Set ignore flag during deferred savelayer" into jb-mr2-dev 2013-03-27 19:47:59 +00:00
Chris Craik
408eb12631 Set ignore flag during deferred savelayer
bug:8471552

Additionally, add ignore check for draw functor

In deferred mode, if we don't set ignore, a 0 alpha displayList won't
be quickRejected, and not only would its contents be needlessly
deferred, but upon playback any functors would be drawn, ignoring the
state of the snapshot.

Change-Id: Ib1edb3252080f674254086edee6f965f0efcce78
2013-03-27 10:38:36 -07:00
Romain Guy
96885eb480 Avoid multiple font cache texture uploads
Bug #8378964

This change defers drawing into layers until after the renderer for FBO0
is ready to draw. At that point, all the precaching is done which means
all glyphs can be uploaded at once in the font caches.

Change-Id: Ie1f7a7ff30f76f06fb3dbc72c7d05e66207d1ecb
2013-03-26 15:25:07 -07:00
Chris Craik
5f80362355 Isolate tiling clip state from snapshot
bug:8409891

Snapshots frequently have their clip overwritten due to applying
deferred state - now, store tiling clip information in a separate
rect, outside of the snapshot so it isn't overwritten.

Change-Id: I21ca4c45dcd802eae99e8de86f11525196777ccb
2013-03-21 14:39:04 -07:00
Romain Guy
9eac52698b Merge "Optimize text GL setup" into jb-mr2-dev 2013-03-21 01:54:42 +00:00
Chris Craik
7564c716bb Merge "Use snapshot alpha in all layer drawing" into jb-mr2-dev 2013-03-21 01:17:29 +00:00
Chris Craik
e83569ca76 Use snapshot alpha in all layer drawing
Change-Id: Icc093390da2fc36b2b6693d0e5e4357b2f730bf9
2013-03-20 17:24:36 -07:00
Romain Guy
257ae3502c Optimize text GL setup
Only performs the GL setup steps when at least one glyph is drawn.
This change also skips various draw operations when the specified
paint draws with alpha = 0.

Change-Id: I9eda148b0503acffc552ee19196f5d52e958a1a2
2013-03-20 16:35:05 -07:00
Chris Craik
d90144db52 Update snapshot upon saveLayer deferral
bug:8409891

In order to defer fbo-targetting saveLayer operations, it's necessary
to update the snapshot at defer time so that deferred display state
(namely, clip and transform) are fbo relative.

Re-enables deferring, as the issues with saveLayer are fixed.

Change-Id: I74b0779bc732675c747208f0757c3ea85f6dfbed
2013-03-20 16:32:53 -07:00
Chris Craik
4494599e5a Merge "Use snapshot alpha for layers" into jb-mr2-dev 2013-03-20 22:22:44 +00:00
Romain Guy
16b7dc9c1c Merge "Merge all shapes/paths caches to PathCache" into jb-mr2-dev 2013-03-19 02:04:29 +00:00
Romain Guy
c46d07a29e Merge all shapes/paths caches to PathCache
This change will greatly simplify the multi-threading of all
shape types.

This change also uses PathTessellator to render convex paths.

Change-Id: I4e65bc95c9d24ecae2183b72204de5c2dfb6ada4
2013-03-18 18:32:17 -07:00
Chris Craik
cada41aeb1 Work around saveLayer clipping/transform deferring issues
bug:8409891

Disables deferring

Change-Id: I93498a4a45a5bfe01143faa154926c6a138db8f9
2013-03-18 17:00:18 -07:00
Chris Craik
d0afeac6df Reset draw modifiers after flushing
bug:8401910

This avoids leaving the renderer in a state with stale pointers (to,
e.g., shaders or color filters)

Change-Id: Idf8b63657041352e70e34e91ea416fe4385d4bc2
2013-03-15 18:48:41 -07:00
Chris Craik
a08f95cfec Use snapshot alpha for layers
Removes mMultipliedAlpha, using the snapshot alpha for all
non-overlapping display list alpha control.

Additionally, fixes opacity issues where children of
hasOverlappingRendering=false displaylists (both hw layer sublists and
other sublists with hasOverlappingRendering=false)

Change-Id: I6adc16da855835f9f518f8967628e5d0135c789b
2013-03-15 17:29:27 -07:00
Chris Craik
ff78583d8a Fully deferred displaylist replay
bug:8037003

A recursive drawDisplayList call is now entirely deferred before
playing back to the screen and issuing GL commands. This way, the
entire stream can be inspected, optimized, and batch work (such as
uploading textures) before issuing commands.

Additionally, this fixes an issue where operations draw could move
across restores corresponding to saveLayer(alpha). Those and other
similar cases (such as complex clipping, requiring the stencil) are
now treated as batching barriers, with the operations that change
renderer state in a way that's difficult to defer are just re-issued
at flush time.

Change-Id: Ie7348166662a5ad89fb9b1e87558334fb826b01e
2013-03-15 14:48:18 -07:00
Romain Guy
ca89e2a687 Precache paths from a worker thread
Change-Id: I3e7b53d67e0e03e403beaf55c39350ead7f1e309
2013-03-11 17:05:28 -07:00
Romain Guy
b09f147126 Don't apply scale to glyphs when a perspective is set.
Bug #8337925

Magazines uses very large scale factors that blow up font cache & CPU.

Change-Id: I1c0ed430ed91b86cc6c6f59f7e8bdcc89a464e46
2013-03-07 17:03:25 -08:00
Romain Guy
624234f69b Take only the scale params into account to rasterize text
This change extracts the scale parameters of the current transform
to pass then to the font renderer. Rotation and perspective are
applied to the generated mesh inside the vertex shader. This limits
the number of glyphs we have to create in the font cache and thus
reduces memory churn.

Change-Id: Ic5b3bae2b2b0e0250a8ee723b071a1709725c749
2013-03-05 18:12:35 -08:00
Romain Guy
3b753829ae Fix colored rects clipping and code cleanup
The drawColorRects() method was clipping individual rectangles
using the wrong parameters left, top, right and bottom instead
of l, r, t and b. It also checked for count == 0 after the loop
when it should have checked for vertexCount == 0. The quickReject
is now not part of the loop since it's a bit overkill to perform
so many matrix multiplications. What we really care about is the
final quickReject performed on the max bounds of the entire set
of rectangles.

This change also replaces all instances of mSnapshot->transform
by currentTransform() to make the code slightly more readable.

Change-Id: I6485280414499716852f7dbfba186774eb6763d4
2013-03-05 10:27:35 -08:00
Romain Guy
19d4dd8599 Take text scale/skew into account only when rendering into a layer
3D rotations can undo scale/skew transforms; since FreeType only accepts
2x2 matrices we can end up generating very large glyphs that are drawn
at a 1:1 scale on screen. For instance, if the current transform has a
scale of 2000 set on both X and Y axis and a perspective Z factor set to
Z, the actual scale factor on screen ends up being 1. We would however
generate glyphs with a scale factor of 2000 causing the font renderer
to blow up.

Change-Id: Ia5c3618d36644e817825cb9c89e2f53aece2074e
2013-03-04 13:48:43 -08:00
Romain Guy
0f6675332c Precache glyphs at final raster size
The deferred display lists model now allows us to precache glyphs
at their exact size on screen.

This change also removes debug markers when the renderer defers
and reorders display lists. It also adds a flush event marker.

Change-Id: I66ec5216dc12b93ecfdad52a7146b1cfb31fbeb4
2013-03-01 16:04:53 -08:00
Romain Guy
a4adcf0239 Support 3D rotations when drawing text
If a perspective transform is set on the Canvas, drawText() should
not attempt to rasterize glyphs in screen space. This change uses
the old behavior instead (i.e. rasterize the glyphs at the native
font size and apply the transform on the resulting mesh.)

This change also adds an optimization: empty glyphs (spaces) do
not generate vertices anymore. This saves a lot of vertices in text
heavy applications such as Gmail.

Change-Id: Ib531384163f5165b5785501612a7b1474f3ff599
2013-02-28 16:04:48 -08:00
Romain Guy
c74f45a334 Properly scale text
This change does not apply to drawPosText() and drawTextOnPath() yet.

Prior to this change, glyphs were always rasterized based on the
font size specified in the paint. All transforms were then applied
on the resulting texture. This creates rather ugly results when
text is scaled and/or rotated.

With this change, the font renderer will apply the current transform
matrix to the glyph before they are rasterized. This generates much
better looking results.

Change-Id: I0141b6ff18db35e1213e7a3ab9db1ecaf03d7a9c
2013-02-27 15:49:57 -08:00
Chris Craik
d80806b305 Merge "Fix T-junctions in layers' generated meshes" into jb-mr2-dev 2013-02-27 23:47:55 +00:00
Romain Guy
a6456d0d7e Merge "Draw text drop shadows even when the text color is transparent" into jb-mr2-dev 2013-02-27 22:16:22 +00:00
Chris Craik
6c5b9be745 Fix T-junctions in layers' generated meshes
bug:4128442

Currently we fix T-junctions for hardware layers, and for
Canvas.saveLayer if the transform isn't rectAsRect. Ideally, hardware
layers should lazily re-generate T-junction free geometry if the
transform becomes non-rectAsRect

Depends on frameworks/native change:
https://googleplex-android-review.googlesource.com/#/c/277668/
which adds Region::createTJunctionFreeRegion()

Change-Id: Ice75b4a1a4459ff835059ea81d70f7d1563fd96d
2013-02-27 14:03:19 -08:00
Romain Guy
768bffc9b8 Draw text drop shadows even when the text color is transparent
This matches Skia's behavior.

Change-Id: Ibf0a52611f5801cfa68169f66ab0ec06f256600f
2013-02-27 13:52:26 -08:00
Romain Guy
758724fd09 Don't increment the paint's generation ID when drawing bitmaps
When the renderer draws a bitmap as part of a display list with an
alpha < 1.0f, the paint is temporarily modified to alter the opacity
of the bitmap. This has the side effect of increasing the paint's
generation ID counter which can break paint caching.

Change-Id: I5055d059ad1639829fa50af3d946e296c4dab877
2013-02-27 11:53:12 -08:00
Romain Guy
3ff0bfdd14 Add new property to debug non-rectangular clip operations
This change adds a new property called "debug.hwui.show_stencil_clip"
that accepts the following values:

- "highlight", colorizes in green any drawing command that's tested
  against a non-rectangular clip region
- "region", shows the non-rectangular clip region in blue every time
  it is used
- "hide", default value, nothing is shown

Change-Id: I83c8602310edc4aaeb8b905371cdd185b17d32b5
2013-02-25 15:01:58 -08:00
Romain Guy
505d1d64ed Merge "Prettify display lists logging" 2013-02-22 21:45:57 +00:00
Romain Guy
7031ff68bb Prettify display lists logging
This change makes it a lot easier to see the tree structure.

Change-Id: I4969abd1eb010f1d529671f8d86dc4c930be24f6
2013-02-22 11:51:15 -08:00
Chris Craik
94b97b38b7 am eab51de4: Merge "Fix clipping and stencil layer issues"
* commit 'eab51de4de88219256260fe26e2018a6234ef83b':
  Fix clipping and stencil layer issues
2013-02-21 19:31:17 -08:00
Chris Craik
b98a016c67 Fix clipping and stencil layer issues
bug:8235699

Ensure rectangle clipping operations disable deferring when necessary
(i.e., when the op might create a non-rect region), including in
DisplayList::setViewProperties

Additionally, makes clipping with a kUnion always use a region, for
consistency with software rendering

Change-Id: I6730f1a80250bcf3f91cd4afde646d470a12dbc2
2013-02-21 16:12:00 -08:00
Chris Craik
c4ca87f0f4 am 8a47d8ea: Merge "Clean up clipping and deferral logic"
* commit '8a47d8eaec26d0937aee94a057f561f246748339':
  Clean up clipping and deferral logic
2013-02-20 10:42:40 -08:00
Chris Craik
8a47d8eaec Merge "Clean up clipping and deferral logic" 2013-02-20 18:40:03 +00:00
Chris Craik
5d11676414 Clean up clipping and deferral logic
bug:8037003

-Merges replay methods
-Bounds checking for DrawBitmapMesh, DrawRects and DrawDisplayList
-Use clip as bounds for otherwise unbounded draw operations

Clip-as-bounds is correct for drawColor and functor, but other draw
operations (pos text, text on path, and layers) still need true bounds
calculation

Change-Id: I5d5149d2c624f01e3fe46628bf156e835e69b9d5
2013-02-19 18:56:10 -08:00
Romain Guy
846f5f238f am e91efaba: Merge "Expose display list APIs"
* commit 'e91efabaf2c51d017bf4c5bc4e06491c3511f4e5':
  Expose display list APIs
2013-02-19 12:36:28 -08:00
Romain Guy
52036b19a5 Expose display list APIs
The exposed APIs are slightly simpler than the full APIs used internally.
Only APIs useful to applications are exposed.

Change-Id: Ie03014628d40ad5ef63dedbc52ce3def84429d54
2013-02-19 12:30:02 -08:00
Chris Craik
620cff4006 am ad82f20d: Merge "DisplayList draw operation reordering"
* commit 'ad82f20d2382396f5ac75fdf6f7db5c4da1c4c23':
  DisplayList draw operation reordering
2013-02-19 09:56:33 -08:00
Chris Craik
c3566d0642 DisplayList draw operation reordering
bug:8037003

The reordering enables similar operations to draw together, minimizing the
OpenGL state change operations that go inbetween draws. Eventually, multiple
complete canvas draw operations will be merged (into a single glDrawArrays call,
for example)

Reorders DisplayList draw operations when:

-They can move backwards in the command stream to be after similar
operations without violating draw ordering

-The OpenGLRenderer is in a simple, replayable state (no complex clip,
or filter/shadow etc)

Also adds two system properties to control the deferral/reordering:
    "debug.hwui.disable_draw_defer"
    "debug.hwui.disable_draw_reorder"
which can be set to "true" to control the display list manipulation

Change-Id: I5e89f3cb0ea2d2afd3e15c64d7f32b8406777a32
2013-02-15 13:30:09 -08:00
Romain Guy
feb6954da1 am 10c0aa24: Merge "Implement support for drawBitmapMesh\'s colors array"
# Via Android (Google) Code Review (1) and Romain Guy (1)
* commit '10c0aa246d9b2633c6cb4e5b714abb0031a4f4cd':
  Implement support for drawBitmapMesh's colors array
2013-02-14 10:54:21 -08:00
Romain Guy
10c0aa246d Merge "Implement support for drawBitmapMesh's colors array" 2013-02-14 18:51:28 +00:00
Romain Guy
ff316ec7a7 Implement support for drawBitmapMesh's colors array
Change-Id: I3d901f6267c2918771ac30ff55c8d80c3ab5b725
2013-02-13 18:39:43 -08:00
Chris Craik
c932760f66 Merge "Revert "Merge remote-tracking branch 'goog/master-chromium' into 'goog/master'" DO NOT MERGE" 2013-02-13 23:14:58 +00:00
Romain Guy
8d4aeb7111 Add a render buffer cache to reuse stencil buffers
Bug #7146141

This new cache is used in a similar way to LayerCache. It helps
reuse already allocated stencil buffers and thus avoid churning
memory on every frame.

Change-Id: I19551d72da52c40039e65904563600e492c8b193
2013-02-13 11:27:05 -08:00