We were treating immediate mode bounds as pre translate, which is
inconsistent with using them for quickRejection.
This fixes the overdraw counter not drawing correctly (since it uses
immediate mode drawing.
Change-Id: I1c734d367a00942bd7d9b041822c0a9f284e70a8
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
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
This optimization saves up to 0.3ms per frame on the Play Store's
front page, on a Nexus 4 device.
Change-Id: Iaa4ef33c6e3b37e175efd5b9eea9ef59b43f14f3
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
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
The rendering code optimizes by rejecting drawing operations that
lie outside of the bounds of their views. This works in most
situations, but breaks down when containers have called
setClipChildren(false), because we reject drawing that is outside
of that container, but which should be drawn anyway.
Fix is to pass in the value of that flag to the DisplayList drawing
routines which take that flag into account when deciding whether
to quickReject any particular operation.
Issue #8659277 animation clipping
Change-Id: Ief568e4db01b533a97b3c5ea5ad777c03c0eea71
bug:8649215
Previously we prevented ops with non-translate transforms from
merging, but missed the case of the first op in a merging batch
containing a non-translate transform.
This fulfills the assumption of drawText's non-immediate mode that
merged ops will have pure translate transforms.
Change-Id: I6f6db341aff3f7e84e74b4c3ccf970d585a2db1a
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
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
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
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
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
The renderer used to pre-cache glyphs at record time. This then changed
to pre-caching at the beginning of every frame. This unfortunately entails
a lot of duplicate work on every frame, which amounts to 0.5 to 1ms in
some stock applications.
This change is somewhere in the middle: pre-caching happens the first
time a DrawTextOp is deferred or every time the screen-space transform
is different from the last pre-caching operation.
Change-Id: Id6d9e2599d90a5b75010b0f0a28746befbf3c205
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
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
bug:8243821
Previously this wasn't done for deferred clipping + reordering, so
non-left-aligned text would be clipped at defer time, when it wouldn't
have been at draw time (in OpenGLRenderer::quickReject())
Change-Id: Ic96949c2dca4378f284606b37d9411ed42f8d203
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
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
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
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
bug:8037003
Changes the DisplayList from using stream read/write commands to use an array of
objects manually allocated on a linear buffer.
Depends on frameworks/native change https://googleplex-android-review.googlesource.com/#/c/257695/ which adds LinearAllocator
Also changes drawRects to use float count instead of rect count, to be more like drawLines/drawPoints
Change-Id: Ia2e4a11acd8f0a757042a05cbc9e7563cb73ee47