224 Commits

Author SHA1 Message Date
Chris Craik
0e87f00f8c Initialize MergingDrawBatch clip with viewport bounds
This allows merged, clipped operations to behave correctly within a
savelayer, even if the base viewport has a large offset.

Additionally, disregard opaqueness when within a
complexclip/savelayer, as the coverage can't be trusted.

Change-Id: Ic908b82a4bb410bc7fac1b4295f4874ed166efc5
2013-06-21 13:16:31 -07:00
Romain Guy
03c00b5a13 Batch 9-patches in a single mesh whenever possible
This change also fixes the way batched bitmaps were handled
inside a layer. The layer is now correctly dirtied to minimize
the amount of pixels to blend.

Fix alpha, mode and opaque computations for DrawPatchOp.

Change-Id: I1b6cd581c0f0db66c1002bb4fb1a9811e55bfa78
2013-06-21 10:13:58 -07:00
Chris Craik
36d38cb904 Merge "Better handle op size edge cases" 2013-06-17 21:02:56 +00:00
Chris Craik
d72b73cea4 Better handle op size edge cases
bug:9464358

Previously, empty and unknown sized ops are assumed to fully cover
their clip. This is now corrected such that empty sized ops are
pre-rejected before defer. Additionally, unknown sized ops disable
overdraw avoidance.

Change-Id: Icf2ce24f98be5ea6299e24ffcf826790373564a1
2013-06-17 13:52:06 -07:00
Romain Guy
fb5c905097 Merge "Cancel layer update when a layer is about to be destroyed Bug #9310706" 2013-06-17 20:39:45 +00:00
Romain Guy
e93482f5ea Cancel layer update when a layer is about to be destroyed
Bug #9310706

Change-Id: I73eea6314c326f15a979617e3a05b525935f0d3f
2013-06-17 13:35:03 -07:00
Chris Craik
a02c4ed885 Fix clip merging behavior
Previously, a new op with a clipped side could be added to a
MergingDrawBatch without considering the batch's current bounds.

Change-Id: I1b873ecf821bad7cda6630c3f311edd90ac5cc8c
2013-06-14 13:43:58 -07:00
Chris Craik
39a908c1df Fix various draw ops that may incorrectly not scissor
bug:8965976

Also consolidates quickReject scissor-ing and scissor-less paths.
Renamed plain 'quickReject' method, as it has sideEffects beyond what
the java and skia canvases do.

Change-Id: I4bdf874d3c8f469d283eae1e71c5e7ea53d47016
2013-06-13 16:16:13 -07:00
Romain Guy
7112fddbe2 Merge "Restore buildLayer()'s old behavior; it's synchronous again Bug #9193833" 2013-06-13 01:19:46 +00:00
Romain Guy
405436021d Restore buildLayer()'s old behavior; it's synchronous again
Bug #9193833

Change-Id: I4ee07e65c0a8967f0b55da030ecaad6dfc46136f
2013-06-12 15:31:28 -07:00
Chris Craik
28ce94a4ff Overdraw avoidance and merging of clipped ops
bug:8951267

If an opaque op, or group of opaque ops covers the invalidate region,
skip draw operations that precede it.

Clipped operations may now be merged, but only if they share a
clipRect - this is a very case for e.g. ListView, where all background
elements may now be a part of the same MergingDrawBatch.

It is this more aggressive merging that groups together clipped
background elements in the ListView case, enabling the overdraw
avoidance skipping the window background.

Change-Id: Ib0961977e272c5ac37f59e4c67d828467422d259
2013-06-12 14:46:52 -07:00
Romain Guy
4c2547fa92 Avoid 9patch cache lookups when possible
This optimization saves up to 0.3ms per frame on the Play Store's
front page, on a Nexus 4 device.

Change-Id: Iaa4ef33c6e3b37e175efd5b9eea9ef59b43f14f3
2013-06-11 17:14:59 -07:00
Romain Guy
8aa195d708 Introduce Caches::bindTexture() to reduce glBindTexture calls
Change-Id: Ic345422567c020c0a9035ff51dcf2ae2a1fc59f4
2013-06-04 18:58:36 -07:00
Romain Guy
a404e16e49 Make sure atlas antries can correctly filter/wrap textures
The virtual textures would each have their own values for wrapping
and filtering which could lead to conflict and/or extraneous GL
commands being issued.

Change-Id: I64cb59a03e598f46bf645bd1d30fccfa63a07431
2013-05-24 16:19:19 -07:00
Romain Guy
7f77736599 Merge "Merge scaled bitmaps with translated bitmaps" 2013-05-22 00:43:48 +00:00
Romain Guy
2db5e993b6 Merge scaled bitmaps with translated bitmaps
Change-Id: I03089f48f97b69fcb4a0171984d3ff548d41c4a8
2013-05-21 17:42:43 -07:00
Chris Craik
41541825bc Use individual glyph positions to determine text bounds.
bug:8766924

Previously text bounds were calculated to be from 0 to totalAdvance in
the X, and from the font's top to bottom. These are incorrect,
especially in light of the font fallback mechanism.

Now, we calculate the bounds of the text as we layout each glyph.
Since these are much tighter bounds in the common case, this
significantly reduces the amount of clipping required (which in turn
enables more aggressive text merging).

Change-Id: I172e5466bf5975bf837af894a9964c41db538746
2013-05-21 23:04:05 +00:00
Chris Craik
6d29c8d521 Add tessellation path for points
bug:4351353
bug:8185479

Point tessellation is similar to line special case, except that we
only tessellate one point (as a circle or rect) and duplicate it
across other instances.

Additionally:

Fixes square caps for AA=false lines

Cleanup in CanvasCompare, disabling interpolation on zoomed-in
comparison view

Change-Id: I0756fcc4b20f77878fed0d8057297c80e82ed9dc
2013-05-14 14:12:55 -07:00
Romain Guy
78dd96d5af Add an on-screen overdraw counter
The counter can be enabled by setting the system property called
debug.hwui.overdraw to the string "count". If the string is set
to "show", overdraw will be highlighted on screen instead of
printing out a simple counter.

Change-Id: I9a9c970d54bffab43138bbb7682f6c04bc2c40bd
2013-05-03 17:08:20 -07:00
Romain Guy
3b748a44c6 Pack preloaded framework assets in a texture atlas
When the Android runtime starts, the system preloads a series of assets
in the Zygote process. These assets are shared across all processes.
Unfortunately, each one of these assets is later uploaded in its own
OpenGL texture, once per process. This wastes memory and generates
unnecessary OpenGL state changes.

This CL introduces an asset server that provides an atlas to all processes.

Note: bitmaps used by skia shaders are *not* sampled from the atlas.
It's an uncommon use case and would require extra texture transforms
in the GL shaders.

WHAT IS THE ASSETS ATLAS

The "assets atlas" is a single, shareable graphic buffer that contains
all the system's preloaded bitmap drawables (this includes 9-patches.)
The atlas is made of two distinct objects: the graphic buffer that
contains the actual pixels and the map which indicates where each
preloaded bitmap can be found in the atlas (essentially a pair of
x and y coordinates.)

HOW IS THE ASSETS ATLAS GENERATED

Because we need to support a wide variety of devices and because it
is easy to change the list of preloaded drawables, the atlas is
generated at runtime, during the startup phase of the system process.

There are several steps that lead to the atlas generation:

1. If the device is booting for the first time, or if the device was
updated, we need to find the best atlas configuration. To do so,
the atlas service tries a number of width, height and algorithm
variations that allows us to pack as many assets as possible while
using as little memory as possible. Once a best configuration is found,
it gets written to disk in /data/system/framework_atlas

2. Given a best configuration (algorithm variant, dimensions and
number of bitmaps that can be packed in the atlas), the atlas service
packs all the preloaded bitmaps into a single graphic buffer object.

3. The packing is done using Skia in a temporary native bitmap. The
Skia bitmap is then copied into the graphic buffer using OpenGL ES
to benefit from texture swizzling.

HOW PROCESSES USE THE ATLAS

Whenever a process' hardware renderer initializes its EGL context,
it queries the atlas service for the graphic buffer and the map.

It is important to remember that both the context and the map will
be valid for the lifetime of the hardware renderer (if the system
process goes down, all apps get killed as well.)

Every time the hardware renderer needs to render a bitmap, it first
checks whether the bitmap can be found in the assets atlas. When
the bitmap is part of the atlas, texture coordinates are remapped
appropriately before rendering.

Change-Id: I8eaecf53e7f6a33d90da3d0047c5ceec89ea3af0
2013-05-02 13:32:09 -07:00
Chris Craik
527a3aace1 Draw Operation merging
Merge simple bitmap draw operations and text operations to avoid
issuing individual gl draws for each operation. Merging other ops to
be done eventually.

The methods are different - the bitmap merging generates a single
mesh for reused, unclipped images (esp. repeated images in a listview)

The text approach queries just defers the normal font rendering until
the last drawText in the sequence that can share the same shader.

Patches are sorted and merged, but don't yet have a multiDraw
implementation. For now, the pretending-to-merge gives better sorting
behavior by keeping similar patches together.

Change-Id: Ic300cdab0a53814cf7b09c58bf54b1bf0f58ccd6
2013-04-15 13:53:02 -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
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
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
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
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
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
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
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
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
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
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
ff316ec7a7 Implement support for drawBitmapMesh's colors array
Change-Id: I3d901f6267c2918771ac30ff55c8d80c3ab5b725
2013-02-13 18:39:43 -08:00
Romain Guy
da8d8b9699 Merge "Add a RenderBuffer object to store stencil buffers. Bug #7146141" 2013-02-07 20:11:56 +00:00
Romain Guy
3bbacf27c0 Add a RenderBuffer object to store stencil buffers.
Bug #7146141

This change is needed to add a render buffer cache to avoid
creating and destroying stencil buffers on every frame.

This change also allows the renderer to use a 1 bit or 4 bit
stencil buffer whenever possible.

Finally this change fixes a bug introduced by a previous CL
which causes the stencil buffer to not be updated in certain
conditions. The fix relies on a new optional parameter in
drawColorRects() that can be used to avoid performing a
quickReject on rectangles generated by the clip region.

Change-Id: I2f55a8e807009887b276a83cde9f53fd5c01199f
2013-02-07 12:11:22 -08:00
Chris Craik
1ba0289d18 Merge "Add cap tessellation support" 2013-02-07 00:14:38 +00:00
Chris Craik
65cd612fac Add cap tessellation support
bug:7117155
bug:8114304

Currently used for lines (with and without AA) and arcs with useCenter=false

Also removes 0.375, 0.375 offset for AA lines

Change-Id: Ic8ace418739344db1e2814edf65253fe7448b0b0
2013-02-06 15:35:12 -08:00
Romain Guy
ef35927abc Tag HardwareRenderers with a name to help debugging
The name of the renderer is the same as the window it belongs to.

Change-Id: Ie9adc0a1978afa026923ea41f5540eda6ba65a92
2013-01-31 19:07:29 -08:00
Romain Guy
c3fedafc5f Fix graphical corruption on QCOM GPU
Bug #7146141

The GL_QCOM_tiled_rendering extension requires careful use of
start/endTiling when attaching a renderbuffer dynamically.

Change-Id: I20036683ed3909ffaf40cc3d57a25257e35b6fa2
2013-01-29 17:46:17 -08:00