History log of /frameworks/base/libs/hwui/DisplayListRenderer.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
69e65019b0a6204f0ed9487d8fd7b3564eba6df8 21-Nov-2014 Chris Craik <ccraik@google.com> Revert "Add a way to override Xfermode DO NOT MERGE"

Feature no longer needed.


This reverts commit 4678dcc5524258908eadc5fe1e5e1874768967eb.

Change-Id: Ib0a19946e966a54857165555827b5fa7b34b6bea
4678dcc5524258908eadc5fe1e5e1874768967eb 12-Nov-2014 Rob Tsuk <robtsuk@google.com> Add a way to override Xfermode DO NOT MERGE

Add a non-public API to Canvas/GLES20Canvas to provide a way to draw
the touch ripple animation without using a save layer.

Change-Id: I6e2095adffe515194f669fb75bb67abf813bd518
4b19b7aaff1d1ff972ebe68101c2107454bbe5de 07-Nov-2014 John Reck <jreck@google.com> Merge "Fix wrong-thread issue" into lmp-mr1-dev
12f5e3433226f0a2886a98b0b8da8d5e947c5cde 07-Nov-2014 John Reck <jreck@google.com> Fix wrong-thread issue

Bug: 18259560

Change-Id: Ic63a86efba9c86f21defac0695a73db8b09ae284
a35778c799e8073a42b9e22191bde9d838327ab7 06-Nov-2014 John Reck <jreck@google.com> Yank ResourceCache out of Caches

Bug: 17947547

Pull the ResourceCache (aka, ref-counting side channel) out of
Caches so that DisplayListRenderer doesn't use Caches, avoiding
the risk of instantiating Caches on the wrong thread or
without a GL context

Change-Id: I7d63b70b3b0a0163308c5dedd6ef255eadebe8fd
0e89e2b7bcb2c035e8cee77f93120e7c5617f8d2 31-Oct-2014 John Reck <jreck@google.com> Layer changes

Bug: 17208461

* Switch Layer to be VirtualLightRefBase instead of
Caches' side-channel ref-counting
* Include active layers in gfxinfo dump
* Run gfxinfo dump on the correct thread
* Dump gfxinfo on Layer creation failure

Change-Id: I28d195699e2334518e215ab28c7a17355aee9678
072707dfad1da6f49f4d3ce58ca104f6c46a7266 15-Sep-2014 Jorim Jaggi <jjaggi@google.com> Use RenderThread for navigation bar ripples

Bug: 17506181
Change-Id: Icf3b80f8c4bc29fe85313381d4019dda3ef85ea9
4ace7305608442ab35ea9aa65a4220df152c187f 15-Sep-2014 Chris Craik <ccraik@google.com> Force isolation of clip and matrix within layer


Unclipped save layers need to isolate their clips and matrices
so that the save time readout of background content matches clip and
position with the restore/compose step.

Change-Id: I2de474cda76e960d080852f1716d6ddfa8a512d4
8afd0f245cc0c4a0366f39f41b5f78e47ee83be3 22-Aug-2014 Chris Craik <ccraik@google.com> Create z reordering boundaries around dispatchDraw


This means rendernodes with a Z will no longer be drawn at the end of
their parent's DisplayList, but at the end of the associated reorder
region (DisplayListData::Chunk).

Change-Id: Ia033fee9d9a4db567b2a8d5e90fc57a4d0a64544
947eabf42d835d0dfb0daa2fe6d869139c7000d6 19-Aug-2014 Chris Craik <ccraik@google.com> Early reject drawText calls that will not draw


Prevents high contrast text from drawing invisible text.

Also fixes stroked text bounds calculation.

Change-Id: Iaeff51ead8b7b8ef2a1a0ca8b89598564e0d443f
69e5adffb19135d51bde8e458f4907d7265f3e23 14-Aug-2014 Chris Craik <ccraik@google.com> Define shadow casting behavior within layers


Savelayers and HW layers both now support shadow casting.

For save layers, the light source should always be correct, for HW
layers, the light source position is set when the layer is created,
and updated when it is resized.

Change-Id: Ie85567dd43c2bb0a0b08fd0bd4db41efa793ac2b
b3cca876c2e11b865cb4f83abe2c48a60b95af5b 09-Aug-2014 Chris Craik <ccraik@google.com> Fix ripples projecting to scrolled view


1) Fix projectionReceiveIndex, which could in some cases point at
translate/restore ops.

2) Use background translateX / translateY for projected RenderNodes.
This makes them match background position, and thus properly account
for scroll.

Change-Id: Idbd5700858fd67c5abea0270a1012952fe09ac22
796475006f5d670e8383a2050f11719522437a43 06-Aug-2014 Chris Craik <ccraik@google.com> Move bitmap transforms out of bitmap ops


This allows us to deduplicate a lot between the two ops, and fixes the
shader coordinate space for the left,top argument drawBitmap to match

Change-Id: I53da05af9ee74c74e9e70b4ab8053190ca220b16
09d5cddf67b676018700bcc10a72242641cd7eec 24-Jul-2014 John Reck <jreck@google.com> Add kModeSync

Bug: 16526750

Change-Id: I4c087160e80432739321172fd57880846c8de6e0
cce47eb580d666ead1f6095d1e3b65233592bbaa 17-Jul-2014 Chris Craik <ccraik@google.com> Add accessibility text contrast setting


Adds a feature which draws all text (in the HW accelerated standard
path) in a high contrast mode. Text is drawn at full alpha, and either
white or black (depending on its original color) with a starkly
contrasted outline beneath it.

Change-Id: I943f624b6367de35367cced3b2a8298f2bc62377
544e524db6e4da526af1c897fe5314036ede5012 11-Jul-2014 Chris Craik <ccraik@google.com> Fix arc 360 degree sweep rendering

Change-Id: I83715968cb90f4fcf39b25fb283d241d1a1284b5
3b20251a355c88193c439f928a84ae69483fb488 23-Jun-2014 John Reck <jreck@google.com> No-fail invokeFunctor

Bug: 15513308
Bug: 15449247

Change-Id: I13a29f9c8d4975cdda6dcb33b6332c2555ff0f7c
a7090e0cfd7c719a6d4c03aae34f5db98754cbdd 21-Jun-2014 Chris Craik <ccraik@google.com> Update 'DisplayList' vs 'RenderNode' naming in several places

Change-Id: I635c6627d098b661fb9b0ba1bd42fa6d7277d287
6ac174b97246ed40fe780b29561603b61770fa17 17-Jun-2014 Chris Craik <ccraik@google.com> Clean up tessellation cache in prep for other tesselation types


Also fixes compilation warning, avoids SkPaint deep copy

Change-Id: I74334f08b1d34c6789aabf968ff62db5bacbed1b
139088228faa7f3c446af7387e017933998a5570 10-Dec-2013 Derek Sollenberger <djsollen@google.com> Update HWUI matrix API

1. more closely mirror Skia API by using const ref instead of ptrs
2. store SkMatrix in the drawOp instead of the linear allocation heap

Change-Id: I4b9f6f76b9f7d19325e29303d27b793679fd4823
d490aa426090fc358873821b47ef27ead0c97409 23-May-2014 Chris Craik <ccraik@google.com> Merge "Inspect SkShader to determine hw shader."
d1ad5e62fda248c6d185cde3cb6d9f01a223066c 05-May-2014 Leon Scroggins III <scroggo@google.com> Inspect SkShader to determine hw shader.

Instead of duplicating internal info about SkShader, inspect the
SkShader installed on the SkPaint.

Remove setupModifiers, nResetModifiers, and nSetupShader.

Remove calls to create/destroy the (previously) attached SkiaShader.

Remove native code for setupShader and resetModifiers.

Remove code keeping track of native SkiaShader.

Include Extensions.h.

Compare shaders on the paint, instead of on DrawModifiers.

Remove vector of SkiaShaders.

Access the SkShader on mPaint.
Remove SetupShaderOp and ResetShaderOp.

Remove resetShader, setupShader, refShader, and mShaderMap.

Pass SkShader to setupDrawShader and setupDrawShaderUniforms.

Add LayerShader, a class inheriting from SkShader, to mimic the
behavior of SkiaLayerShader. Unlike SkiaLayerShader, it can be set on
the SkPaint so it can be inspected later.
Set a LayerShader instead of a SkiaLayerShader.
setupDrawShader and setupDrawShaderUniforms now inspect an SkShader
passed in.
Inspect SkShader instead of mDrawModifiers.mShader.
Remove resetShader and setupShader.
setupDrawColorUniforms now takes a boolean indicating whether there is
a shader.
Add an inline function for accessing the SkShader on an SkPaint.
In setupDrawBlending(Layer*, bool), do not check the shader (which will
never be set), but do check whether the color filter may change the
alpha (newly fixed behavior).
In setupDrawBlending(SkPaint, ...), check the SkShader and whether the
color filter affects alpha (the latter is new behavior).

Remove pure virtual functions setupShader and resetShader.

Remove functions for refing/unrefing shaders.

Much of this code was redundant and has been removed.
Convert structs into class with nothing but static functions for
calling describe/setupProgram.

Use the SkPixelRef as the key to the bitmap Lru cache, since shader
inspection will provide a different SkBitmap pointer (though it will
hold the correct SkPixelRef with the correct generation ID).

Update manual test to have more shaders: radial, sweep, compose,
invalid compose.


Change-Id: Iaa7189178bda1c55f96da044d2a9fa602ba36034
797b95b26bbb7557678af78b9a2a61830158920f 21-May-2014 Chris Craik <ccraik@google.com> Define light position (using new lighting spec) in Java

Also updates the relative shadow strengths.

Change-Id: I6cac7275d38df98aea9f0dda463cd7207102986a
a64a2bef1048db5a742843f1e3bea9e80d0defc5 14-May-2014 Chris Craik <ccraik@google.com> Combine projection matrix, and viewport management

Merge management of ortho projection matrix with the viewport size,
since they should always be changed together.

Change-Id: Iccb8f30828f4fb7848999ac54852e7ed2d6f2eb1
ddc52285ca6fd147f442a21e90e0e4702a10d304 11-May-2014 Jorim Jaggi <jjaggi@google.com> Revert "Simplify projection matrix management."

This reverts commit 0efaa71d5414287ed4beac0a88cf76f7e33a1e74.
0c0ec26366045e515790a6acdab782965efc63b4 10-May-2014 Chris Craik <ccraik@google.com> Simplify projection matrix management.

Store in and use from snapshot, and remove the kFlagOrthoDirty flag,
as it's redundant with kFlagIsFboLayer.

Change-Id: I2bd380192d50117f4ce1fd2058213669a886f406
e10e827ed68b0a9487cf8dd1fc545f9a09517ae9 08-May-2014 Chris Craik <ccraik@google.com> Rename matrices for consistency

The projection matrix no longer contains viewing transformation, and
has thus been renamed.

Change-Id: I4f85ccdac97f4cb4f987bb05c389816680f1c94f
5b554f010358d8f47e31d92a42aa3edc4a71ec47 08-May-2014 Derek Sollenberger <djsollen@google.com> Merge "Avoid caching shadow properties in Java & HWUI."
c29a0a4664a4b9871fadd668b632469a0db240b9 31-Mar-2014 Derek Sollenberger <djsollen@google.com> Avoid caching shadow properties in Java & HWUI.

bug: 10650594
Change-Id: I6f57df002710bb0567ed7e53fc0bfe96cfd504b8
52244fff29042926e21fa897ef5ab11148e35299 02-May-2014 John Reck <jreck@google.com> Add CanvasProperty for drawCircle

Change-Id: Icbcc030f5033d2094e567d7c519b9d672f2aac1c
3f085429fd47ebd32ac2463b3eae2a5a6c17be25 16-Apr-2014 Chris Craik <ccraik@google.com> Clip TouchFeedbackDrawable effect to receiver Outline

Projected RenderNodes are now wrapped with a ClipRect or masked
SaveLayer, so that they are clipped to the outline of the projection
receiver surface.

Change-Id: I1d4afc1bb5d638d650bc0b1dac51a498f216773e
0664fef9e2a36025b3fad85b57b4d10617b4d66e 11-Apr-2014 Chris Craik <ccraik@google.com> Fix BitmapMesh buffer copy

Change-Id: I7c1a3651c7d91d7ff37ecbe18d974fa8cb1cf415
defb7f37fe67ef2389666f7adc5da1260df87017 09-Apr-2014 Chris Craik <ccraik@google.com> When recording a child node into a parent, read staging projection property


The other properties should not be read from the UI thread.

Change-Id: I61d13774553d46a8963623727d8e8eeeb3385cc9
087bc0c14bdccf7c258dce0cdef46a69a839b427 05-Apr-2014 John Reck <jreck@google.com> Refcount RenderNode

Change-Id: I7a86db8acc2b78ef33d987a43a119f5933d7d752
113e0824d6bddf4376240681f9cf6a2deded9498 18-Mar-2014 John Reck <jreck@google.com> Move RenderNode to own file

Change-Id: I9380d161fd3ddd7b569c262dd8e7aa0c96151b1e
e18264b079481a244b30e3f71012c53bbd861f92 12-Mar-2014 John Reck <jreck@google.com> Rename DisplayList->RenderNode

Change-Id: Id42e23c9a1a6eb6eaeafef707ced7fa6887b03d0
eea6ef9c767c734797912022113191dd255c4ae6 06-Mar-2014 Chris Craik <ccraik@google.com> Fix warnings in hwui

Change-Id: I6ad6b78531cc0426dc2ea82a32775f7b0265b5b1
44fd8d24f761f82d21e9b00932648a1b6bf91449 26-Feb-2014 John Reck <jreck@google.com> DisplayList overhaul

Change-Id: I53418d580c98f706e971545cff81b9921c12cc5f
76d3a1b8d035d27bc80b0f2fc480a903bd001514 10-Dec-2013 Derek Sollenberger <djsollen@google.com> Removing SkiaColorFilter and inspecting the native object directly.

bug: 10650594
Change-Id: I4fcf66d008765afa0e35d011f58bc792183cb74f
8852ab4357ffb653bafb36f3b9272866834f7a72 07-Feb-2014 Derek Sollenberger <djsollen@google.com> Merge "Keep the SkPaint used when creating a layer."
d44fbe55a9f434cb5bb0e34c143ba1445141990d 05-Feb-2014 Derek Sollenberger <djsollen@google.com> Keep the SkPaint used when creating a layer.

This will allow us to inspect the paint for thing other than
color and xfermode, such as SkColorFilters and SkShaders.

bug: 10650594
Change-Id: I2c3ddd07a3966e1e77af34136307e2b59b2898c1
1df26446b7eac7050767c38ca977fde03a41a033 06-Feb-2014 Chris Craik <ccraik@google.com> Rework and clean up DisplayList projection

Move the projection surface to be a property of a DisplayList,
set to true for every background drawable.

Additionally, handle a projecting view background such that it doesn't
try to project onto itself (which is undesirable).

Change-Id: Ic70b17474bd87340e80767f8518f73b233419c7a
f533e947035795a485344f4c270e16507f974901 15-Jan-2014 Chris Craik <ccraik@google.com> Support projection of DisplayLists onto ancestors.

For now, ancestor views signal the acceptance of projections with a
save(0x20)/restore pair.

During the order traversal, each view with the save(0x20) code will
collect descendent views with mProjectToContainedVolume (which still
needs to be renamed) so that they can be drawn out of order later.

- *Temporary* sample code added to HwAccelerationTest.

- Note that a projected displaylist must not be clipped.

Change-Id: I45c493e845961535b958d59c53e8aff3f8891d9f
d218a92c0afb8c0d98135b20b52ac87236e1c935 03-Jan-2014 Chris Craik <ccraik@google.com> Use const where possible for drawing parameters

They should never be modified by a Renderer, only read and copied.

Change-Id: I9d8d55dca19115ee9dfeb2bb3f092ba2fb327cd4
d6b65f67717025b1162f86f04e2caa5723566cac 01-Jan-2014 Chris Craik <ccraik@google.com> Use const access to snapshot from OpenGLRenderer

Additionally, move clipping methods to StatefulBaseRenderer

Change-Id: Iff232bf16fc1ad3b7d89493da6d8915db7bc5e4f
14e513058ed4168c94e015638d16f5f87fd8063a 31-Dec-2013 Chris Craik <ccraik@google.com> Move Snapshot management to intermediate StatefulBaseRenderer class

The eventual goal is for the StatefulBaseRenderer to serve as the
common base class between the DisplayListRenderer and OpenGLRenderer.

This will separate DisplayList recording, Snapshot stack management,
and the GL in OpenGLRenderer.

Additionally, avoid sp<> parameters, and use const parameters in
several places, with the intent of greatly reducing the surface area
where renderer subclasses can modify snapshot stack.

Next steps:
-move bulk of clipping logic into StatefulBaseRenderer
-disable direct snapshot access

Change-Id: Ibc3c6747134ec7daf8ea535866239fa73b874390
b458942bb6e6cf13c68341dda35ef5cee060f5ae 27-Dec-2013 Chris Craik <ccraik@google.com> Create abstract base class for OpenGLRenderer

This will eventually serve as a base class to allow
DisplayListRenderer to split off from OpenGLRenderer, and could
eventually support other rendering approaches, such as an

This will also be the main source of (implementation-independent)
documentation of the canvas/renderer methods.

Change-Id: I52047f338f5cf86a3b0b3002af7154bff5c3c227
f57776b2d195f0937906eb88b777bb55ccc36967 26-Oct-2013 Chris Craik <ccraik@google.com> 3d view system!

True 3d transformations are now supported by DisplayLists and the
renderer, initially with the translationZ property on view.

Renderer operations used directly by DisplayList (formerly,
clip/save/restore/saveLayer) are now more simply managed by allocating
them temporarily on the handler's allocator, which exists for a single
frame. This is much simpler than continuing to expand the pool of
pre-allocated DisplayListOps now that more operations are called
directly by DisplayList, especially with z ordered drawing.

Still TODO:
-APIs for camera positioning, shadows
-Make Z apis public, and expose through XML
-Make invalidation / input 3d aware

Change-Id: I95fe6fa03f9b6ddd34a7e0c6ec8dd9fe47c6c6eb
f0a590781b2c3e34132b2011d3956135add73ae0 20-Nov-2013 Chris Craik <ccraik@google.com> Clean up quick rejection, especially surrounding points + lines.


quickReject and quickRejectNoScissor have been renamed and refactored:
- to make the scissor side effect clear and explicit
- dangerous methods no longer public
- to make the simple quick reject check logic const
- simple quick reject is now conservative

This CL also fixes several issues with line and point quickRejection -
sub-pixel and hairline lines are much less likely to be incorrectly
rejected, especially at small canvas scale.

Additionally, alpha modulation for AA points < 1px in size is now
correct, dumplicating SW behavior (similar to lines and stroked
shapes work).

Change-Id: Ibb0710c721b9fb415d05acf54dd3d2b4d602156a
c1c5f0870282b56dafe5a4d756e4b9e6884655a7 12-Sep-2013 Chris Craik <ccraik@google.com> Move DeferredDisplayState out of ops


Instead of storing DeferredDisplayState within an op (thus forcing ops
to be tied to a single state instance), associate each op with a new
state at DeferredDisplayList insertion time.

Now, DisplayLists (and the ops within) can be reused in a single
DeferredDisplayList draw call, as ops will use different state
instances at different points in the frame.

Change-Id: I525ab2abe0c3883679f2fa00b219b293e9ec53d9
9b5a1a28c327e6113d68302b1f0eed1d1c6f6183 09-Aug-2013 Romain Guy <romainguy@google.com> Take shadow bounds into account for quick rejects
Bug #8634346

Change-Id: I995c5205c2959d8e4da638ae47fedcda92eb1b36
55b6f95ee4ace96c97508bcd14483fb4e9dbeaa0 28-Jun-2013 Romain Guy <romainguy@google.com> Track the atlas' generation ID
Bug #9589379

If the atlas is terminated/reinitialized and a view does not invalidate
in between it might end up using a stale AssetAtlas::Entry. This change
is similar to how 9patch meshes are cached in DrawPatchOp: we simply
track the generation ID of the cache to make sure we always use the
latest data.

Change-Id: Ib5abb3769d2ce0eabe9adc04e320ca27c422019e
e3b0a0117a2ab4118f868a731b238fe8f2430276 27-Jun-2013 Romain Guy <romainguy@google.com> Refcount 9-patches and properly handle GC events

This change adds refcounting of Res_png_9patch instances, the native
data structure used to represent 9-patches. The Dalvik NinePatch class
now holds a native pointer instead of a Dalvik byte[]. This pointer
is used whenever we need to draw the 9-patch (software or hardware.)

Since we are now tracking garbage collection of NinePatch objects
libhwui's PatchCache must keep a list of free blocks in the VBO
used to store the meshes.

This change also removes unnecessary instances tracking from
GLES20DisplayList. Bitmaps and 9-patches are refcounted at the
native level and do not need to be tracked by the Dalvik layer.

Change-Id: Ib8682d573a538aaf1945f8ec5a9bd5da5d16f74b
16ea8d373b03b1e115dd505af70dbee4e3a3a182 21-Jun-2013 Romain Guy <romainguy@google.com> Refcount the paint used by Canvas.drawPatch()

Prevents crashes :)

Change-Id: I62103ce97490613142321f080b82c2edaed67a95
03c00b5a135e68d22ca5bb829b899ebda6ed7e9d 21-Jun-2013 Romain Guy <romainguy@google.com> 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
41541825bc90dac740e424cdd41a8c997e15cdb7 04-May-2013 Chris Craik <ccraik@google.com> Use individual glyph positions to determine text bounds.


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
3b748a44c6bd2ea05fe16839caf73dbe50bd7ae9 18-Apr-2013 Romain Guy <romainguy@google.com> 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.


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.)


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.


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
527a3aace1dd72432c2e0472a570e030ad04bf16 04-Mar-2013 Chris Craik <ccraik@google.com> 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
ce4a7dfc516ee61301e9af91fad17ca1320efaab 28-Mar-2013 Romain Guy <romainguy@google.com> Don't crash when making a layer larger than supported dimensions
Bug #8437401

A misplaced ref count decrement was causing a crash when attempting to
resize a layer to dimensions larger than the max texture size supported
by the GPU.

This change fixes the crash and clarifies the warnings to make it more
obvious what's happening.

Change-Id: I632dc1b90aaa2605969e10523491a81c4922d3dc
4494599e5a4931426d5649e1d1c4f9db83824ae8 20-Mar-2013 Chris Craik <ccraik@google.com> Merge "Use snapshot alpha for layers" into jb-mr2-dev
c46d07a29e94807e768f8b162ce9f77a88ba6f46 16-Mar-2013 Romain Guy <romainguy@google.com> 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
a08f95cfeca7217f9c533b03663bf0dceedd259a 16-Mar-2013 Chris Craik <ccraik@google.com> 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
ff78583d8a73ca35ce65b5d2592570ff6fb9901b 08-Mar-2013 Chris Craik <ccraik@google.com> Fully deferred displaylist replay


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
0f6675332c04c74909425d1d328f02b32c0ff40e 01-Mar-2013 Romain Guy <romainguy@google.com> 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
a4adcf0239039eb8f005be252409901c41b28839 28-Feb-2013 Romain Guy <romainguy@google.com> 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
c3566d06421c8acc0aafb18f7e307e5725ce87e1 05-Feb-2013 Chris Craik <ccraik@google.com> DisplayList draw operation reordering


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:
which can be set to "true" to control the display list manipulation

Change-Id: I5e89f3cb0ea2d2afd3e15c64d7f32b8406777a32
0776a6069365bdea83855db154fa2d37f9d1d808 15-Feb-2013 Chris Craik <ccraik@google.com> Move DisplayList to its own cpp file

Change-Id: Ic9c1bbf4673ad5c756f3908b2ab7e699edd6a119
63696bfc0592a0b8808aa2b1c40bcf33c656c659 08-Feb-2013 Romain Guy <romainguy@google.com> Don't clip when drawing a layer

A layer will, by definition, clip its content already. The extra
clip added by the UI toolkit/renderer is wasteful and in some
situations very expensive. If a layered view is rotated, the clip
will be transformed into a non-rectangular region, thus forcing
the renderer to rely on the stencil buffer. The whole point of
using layers is to draw efficiently so let's avoid this case.

Change-Id: I813465f6468cc386b84a4d058c11a258fef8507a
b969a0de65730b071d846f8302e751e2637e6dbe 05-Feb-2013 Romain Guy <romainguy@google.com> Add support for non-antialiased text

Change-Id: I17c073955ab94abc9b409e5fcfbc675faa07c5ba
3dc553babe515fbf9bd042dd63a792e5de578ecd 04-Feb-2013 Chris Craik <ccraik@google.com> Simplify display list logging, removing pointers

Also fix save indents

Change-Id: Ia1add83422fbc200b85fd6688f5be60292b0f178
2af4635e4a9e448a65ff541252f8f94bc6ac48e0 27-Nov-2012 Chris Craik <ccraik@google.com> Object-based DisplayList recording


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
735738c4ddf3229caa5f6e634bf591953ac29944 03-Dec-2012 Romain Guy <romainguy@google.com> Preliminary Support for region clipping

Region clipping, using Canvas.clipPath or Canvas.clipRegion, requires
a stencil buffer to be always present. In addition, extra wiring is
required in JNI and display lists.

This change only adds the necessary JNI/C++ APIs and some extra
plumbing to start the real work on properly supporting region

A new debug define called DEBUG_CLIP_REGIONS can be used to draw
the current clip region. It is off by default, as is region

The default implementation of clipPath() and clipRegion(), now
in native, mimics the previous Dalvik implementation to prevent

Change-Id: I7903e7cfd7412b9b9b622566d4dbfce7bdcec00c
e3a9b24b5e3f9b2058486814a6d27729e51ad466 08-Jan-2013 Romain Guy <romainguy@google.com> Add plumbing for better text scaling

Fonts are now described by a transform matrix. This lead to switching
from a vector to a hashmap. This change therefore adds new comparators
and hash computations to Font.

Change-Id: I2daffa7d6287c18554c606b8bfa06640d28b4530
672433d90fab7383cd28beac9d4485b566a90940 05-Jan-2013 Romain Guy <romainguy@google.com> Add visual profiling feature

When profiling is enabled with debug.hwui.profile set to true,
setting debug.hwui.profile_visualizer to true will display the
profiling data directly on screen.

Change-Id: I3d5fe3f0347090815087b1cbfce66b8e76d9347b
3561d062ff01f3455c984e4cfcd101a64a2e902f 23-Oct-2012 Chet Haase <chet@google.com> Handle offscreen animations correctly

A bug in software rendering caused animations on views that are offscreen
to not get drawn, therefore the animation doesn't continue (since old-style
animations depend on the logic in the drawing code to keep running). Fix is
to special case the isAnimating case in ViewRoot to go ahead and schedule
a traversal even if the dirty rect does not intersect with the visible region.

Issue #7396035 Animations starting offscreen don't draw run/end/draw properly (sw rendering only)

Change-Id: Iae25b3a424ddc5a16ba431ecd68cf42d5500db3f
7c25aab491707f7324f9941b8cfa9bd2b4b97e76 19-Oct-2012 Romain Guy <romainguy@google.com> Defer layer rendering to avoid stalls
Bug #7326824

When a layer is taken out of the cache and initialized it gets cleared
to prepare it for future rendering. This triggers the following sequence
of operations:

attach texture storage to FBO

The clear forces a resolve on tilers which stalls the CPU for a little
while, thus producing jank during animations. This change moves the
clear to the next frame when we know we will have to execute a resolve

Change-Id: Ic1939c25df20ed65a4c48dc81ee549b2cd8b6ec3
6a2d17f71342f981c9df1dc5beff33e30eb3ae2b 30-Sep-2012 Chet Haase <chet@google.com> Fix texture corruption

When memory gets low on a device, activities flush everything they can.
Hardware-accelerated activites, such as Launcher, flush GL resources and destroy
the GL context. However, some resources were still hanging around, due to deferred
destruction policies (we don't delete layers until the DisplayLists they are in
are finalized, to ensure we don't deref deleted objects). This meant that we were
referring to obsolete GL data in these objects. in particular, it meant that we might
come around later, after a new GL context was created, and delete a texture object
that was incorrect. We use the layer's "texture id" to refer to the texture underlying the
layer. But if there's a new GL context, then this texture ID is no longer valid, and
we may be deleting the texture that a different object (layer, icon, whatever) is referring
to, because the driver may return that same ID under the new GL context.

The fix is to more aggressively delete things that we know will not be used again
when the GL context is destroyed. In particular, we delete all resources being used
by all DisplayLists at GL context destruction time.

Issue #7195815 Textures corruption on all devices, in many apps

Change-Id: I52d2d208173690dbb794a83402d38f14ea4c6c22
a3dc55f83ab583e0a66b893c71b849afa046770a 28-Sep-2012 Romain Guy <romainguy@google.com> Fix a couple of rendering issues
Bug #7253839

1. Make sure we don't make GL calls while recording display lists

2. Disable an early and trivial clip optimization in font renderer
when a perspective transformation is used on the Canvas

Change-Id: I3f1052164239329346854f72d0a0d401fbfecf06
034de6b1ec561797a2422314e6ef03e3cd3e08e0 28-Sep-2012 Romain Guy <romainguy@google.com> Plug memory leak that happens when reusing display lists
Bug #7195815

We did not reclaim resources when reusing an existing DisplayList to
record a new empty list of commands. This would lead to various memory
leaks: bitmaps, paints, paths, matrices, etc.

This is not a common case but some apps run into this situation,
such as Launcher.

Change-Id: I2eb14ac86a212123f8edbe42b70a7c1c51fa4145
54c1a64d5441a964890b44280e4457e11f4f924a 28-Sep-2012 Romain Guy <romainguy@google.com> Don't use the QCOM_tiled_rendering extension with functors
Bug #7247880

Change-Id: I4f6c38e37b953c58e6107097c613891a49dac766
603f6de35f21d74ae242d52d501f4f5c25ff4f4c 15-Sep-2012 Chet Haase <chet@google.com> 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
45e4c3df6c00ac98ff6144de9af574877d4fff19 12-Sep-2012 Romain Guy <romainguy@google.com> Discard framebuffer commands when we redraw the entire buffer

Change-Id: I32e3014832cbd3bdbace8c3d2206eb20a2002d64
89b3f48fa3ccaf9a05628f0e540c1f94716809f7 07-Sep-2012 Chet Haase <chet@google.com> Merge "Enable changing properties of layer paint" into jb-mr1-dev
58ecc204fbcacef34806290492384677a330d4d4 07-Sep-2012 Romain Guy <romainguy@google.com> Reduce the number of locks acquired by display lists

Change-Id: I1123aae0355de84db705bb75042c7083fc69c9f2
d15ebf25c595b855f6978d0600218e3ea5f31e92 05-Sep-2012 Chet Haase <chet@google.com> Enable changing properties of layer paint

Previously, to draw a layered view with a changed Paint object for the
drawLayer operation, you'd have to invalidate the parent view, to get the
native DisplayList to pick up the new Paint properties. This change adds
API and functionality so that the developer can call setLayerPaint(), which
does the proper invalidation (lightweight, doesn't cause redrawing the view).

Issue #6923810 Make it easy to efficiently animate a layer's Paint

Change-Id: I7fea79788d50f6d9c86dd5e5b2a4490cb95142bb
e816baea651476aca4407200d4a5e629b9ab8dfa 09-Aug-2012 Chet Haase <chet@google.com> Optimize interactions with glyph cache

There are two fixes here:
- precaching: instead of caching-then-drawing whenever there is a new
glyph, we cache at DisplayList record time. Then when we finally draw that
DisplayList, we just upload the affected texture(s) once, instead of once
per change. This is a huge savings in upload time, especially when there are
larger glyphs being used by the app.
- packing: Previously, glyphs would line up horizontally on each cache line, leaving
potentially tons of space vertically, especially when smaller glyphs got put into cache
lines intended for large glyphs (which can happen when an app uses lots of unique
glyphs, a common case with, for example, chinese/japanese/korean languages). The new
approach packs glyphs vertically as well as horizontally to use the space more efficiently
and provide space for more glyphs in these situations.

Change-Id: I84338aa25db208c7bf13f3f92b4d05ed40c33527
18edb81172daa9b98b53d226d94fc03249b1aded 04-Aug-2012 Romain Guy <romainguy@google.com> Avoid crash when dumping display lists

We recently changed the drawText implementation to accept more parameters
which were not taken into account during a dump operation.

Change-Id: Ia1dc682dc7bb2bb02a1f4a514ed5af5556f92a97
c25259519f1b74bb62a2b051b74537f073436b5c 28-Jul-2012 Romain Guy <romainguy@google.com> Rename drawGeneralText to drawText

Change-Id: I5062ea5b0605fc7af27f410fafc930d10f38e926
996e57c84368058be793897ebc355b917a59abc2 24-Jul-2012 Raph Levien <raph@google.com> Hardware implementation of glyph positioning (bug 5443796)

This implementation adds a drawGeneralText() method to the OpenGL
Renderer, which supports both a global x, y position, an array of
individual glyph positions, and also a length parameter (which enables
drawing of underline and strikethrough. It also adds the method to the
display list (with marshalling and unmarshalling).

With this change, the existing drawText() method is removed entirely, as
it's subsumed by the new method. It's easy enough to revert to the old
functionality if needed by passing in a NULL positions array.

Change-Id: I8c9e6ce4309fd51cc5511db85df99f6de8f4f6f5
95c21d0546e36ade3e0601394f5b625541836545 18-Jul-2012 Romain Guy <romainguy@google.com> Correctly pre-clip paths when recording display lists

External bug: http://code.google.com/p/android/issues/detail?id=34946

DisplayListRenderer::drawPath was not invoking quickReject() properly,
passing x,y,width,height instead of left,top,right,bottom. A path
could thus get rejected when it should be drawn instead.

While working on this change I found a similar issue with another
drawing command, drawBitmapData().

Change-Id: I56484e8c101768cde6a78625290872f7849dd5ee
8a4ac610e1aaf04931ac1af54b146a7fc8e66114 18-Jul-2012 Romain Guy <romainguy@google.com> Don't clear the dirty clip flag if it's not applied
Bug #6833979

Change-Id: I0ea78b7f31a557a335de10d910d03b0520029080
be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbee 16-Jul-2012 Romain Guy <romainguy@google.com> Don't copy paints for 9patches

Change-Id: I863100a0dc53fec1a3a1b2acbdeb76e6049ffe58
44b2fe3fc114ee5f7273c6b0fee2cc999bf244a2 07-Jun-2012 Chet Haase <chet@google.com> Track canvas clearing for swap buffers logic.

A previous fix made it necessary for a frame to render something to GL
in order to cause a call to eglSwapBuffers(). Besides the calls being
tracked as part of issuing a DisplayList, there is also a potential call
to clear the canvas (via glClear()) on non-opaque surfaces. This call is also
good to track, since a surface that gets cleared without any other drawing operations
is worth flipping to the screen (to erase old contents on that surface).

This fix tracks the status of the pre-draw operations to find out whether
glClear() was called and then sets the drawing status appropriately.

Issue #6606422 QuickContact dismissal is janky again (Tracking)

Change-Id: I5fcaccfdc9293dd46b83f2fc279730a5d2740ebf
486590963e2207d68eebd6944fec70d50d41116a 01-Jun-2012 Chet Haase <chet@google.com> Skip eglSwapBuffers() call when we do not draw to GL

The fix is to track when we issue GL drawing commands, and to skip the
call to eglSwapBuffers() when a DisplayList does not result in
any actual rendering calls to GL.

Issue #6364143 QuickMuni list items and buttons flicker instead of fade

Change-Id: I60a02c61a58c32d92481a1e814b4c8a49c6a37a3
ddf74373616c89e0880a28a2185fd7ce3db91de6 22-May-2012 Romain Guy <romainguy@google.com> Ensure we always set the proper blending mode
Bug #6527305

At the beginning of a frame, always set the blending mode that we
think GL is using just in case it was modified by another entity
(for instance a WebView functor.)

Change-Id: I0e1d0abee8a2abb2b8e7622aed28346e89562c06
49c5fc0b9e850497233e189ff9dcc71a78ebe6e7 15-May-2012 Romain Guy <romainguy@google.com> Avoid unnecessary copy when invoking drawBitmap(int[])
Bug #6483390

Change-Id: I4d2d725ef50c9401b4bd998b6160128102b40745
e651cc6239616a202f6e96ebc2ed93b4b8b3627c 15-May-2012 Romain Guy <romainguy@google.com> Remove all Dalvik allocations from Cavnas.drawBitmap(int[], ...)

Change-Id: Ie28538a2104d21154fdc78a56525e7403f08287d
d34dd71800d9a1077e58c3b7f2511c46848da417 03-May-2012 Chet Haase <chet@google.com> Fix hang/crash in native path code

An optimization for paths is to only create a texture for the original native
Path object, and have all copies of that object use that texture. This works in
most cases, but sometimes that original path object may get destroyed (when the
SDK path object is finalized) while we are still referencing and using that object
in the DisplayList code. This causes undefined errors such as crashes and hanging
as we iterate through the operations of a destroyed (and garbage-filled) path object.

The fix is to use the existing ResourceCache to refcount the original path until
we are done with it.

Issue #6414050 Analytics Dogfood App crashes reliably on Jellybean

Change-Id: I5dbec5c069f7d6a1e68c13424f454976a7d188e9
6f9ad204cc529babeb3aa7c9a57cf00ed7188471 01-May-2012 Chet Haase <chet@google.com> Fix launcher invisibility bug

There was a bug in the DisplayList code for layers where we would
set the alpha value for a layer only if the alpha were non-1. This works
most of the time (since the value is usually 1 and doesn't need to
be set at all, and if the value is non-1, it is set correctly). But when
the value has been set to a non-1 value, setting alpha back to 1 cannot happen
due to this logic. This caused launcher to have some invisible pages when
returning to Home because those pages previously had an alpha value of 0, and
setting the alpha to 1 had no effect due to this DisplayList code.

The fix is to simply remove the check for non-1 values; we should
always set the alpha value of layers to handle all cases.

Issue #6413892 alpha value is messed up after AlphaAnimation

Change-Id: Ia51acb2eaaf0609ea7189998ed449bdd9ea7e05f
1271e2cc80b01d577e9db339459ef0222bb9320d 20-Apr-2012 Chet Haase <chet@google.com> Remove USE_DISPLAY_LIST_PROPERTIES flag

This flag was still hanging around pending any need to disable
DisplayList properties. But things seem stable, so it's time to clean up
and simplify the code.

At the same time, I reduced redundance in DisplayList dimensions. We
used to call drawDisplayList() with width/height parameters that were
used to do a clip reject. This is redundant with the DisplayList properties
that set the bounds of the DisplayList; the left/right and top/bottom properties
represent the same width/height properties formerly used in drawDisplayList().
The new approach is to not pass dimensions to drawDisplayList(), but to
instead pull those dimensions directly from the DisplayList when needed.

Change-Id: I8871beff03b1d4be95f7c6e079c31a71d31e0c56
a23eed808a1ae4ec0d818c0a9238385e797fd056 13-Apr-2012 Chet Haase <chet@google.com> Fix layer blending bug

Cached layers were sometimes retaining an obsolete blending
value, causing artifacts where translucent objects were disappearing
completely. Also, added extra tracing info for DisplayLists.

Issue #6303668 Flickering views during SwipeHelper drag

Change-Id: I66ce158652c4a3ed316040585b40b1744e1fad0c
db8c9a6a4d9bf8c39f834b25611926caf21380f6 22-Mar-2012 Chet Haase <chet@google.com> Optimization of alpha with DisplayList properties

Some views (such as ImageView and TextView) handle non-opaque alpha
values directly. This was originally an optimization, but we can handle it faster
in many cases without this optimization when DisplayList properties are enabled.
Basically, if a view has non-overlapping rendering, we set the alpha value directly
on the renderer (the equivalent of setting it on the Paint object) and draw each
primitive with that alpha value. Doing it this way avoids re-creating DisplayLists
while getting the same speedup that onSetAlpha() used to get pre-DisplayList properties.

Change-Id: I0f7827f075d3b35093a882d4adbb300a1063c288
9420abd56a2af7ddbeb70562b79d61b2dca8c5a1 30-Mar-2012 Chet Haase <chet@google.com> Re-enable DisplayList properties.

Re-enabling DisplayList properties last week caused some app
errors due to the way that some transforms were being handled (specifically,
those coming from the old Animations and ViewGroup's childStaticTransformation
field). This change pushes *all* transform/alpha data from View.draw() into
the view's DisplayList, making DisplayLists more encapsulated (and correct).

Change-Id: Ia702c6aae050784bb3ed505aa87553113f8a1938
b85967b9af76e1e60f7a96603e2567a6449d2e04 26-Mar-2012 Chet Haase <chet@google.com> Re-enabling DisplayList properties

Several issues came up after DisplayList properties were enabled,
so they were disabled pending fixes. Those issues have been fixed, so
DisplayList properties are once again being enabled by default. This
CL both re-enables these properties (in View.java and DisplayListRenderer.h)
and fixes the various issues that enabling them caused the first time around.

Related issues (all currently marked as Fixed, though that was simply because
DL properties were disabled - this CL provides the real fixes now that
DL properties are enabled by default):
Issue #6198276 Text input broken
Issue #6198472 Native crash at pc 00076428 in many different apps in JRM80
Issue #6204173 Date/time picker isn't rendering all parts of UI
Issue #6203941 All Apps overscroll effect is rendered weirdly/has flickering
Issue #6200058 CAB rendering issue - not drawing items?
Issue #6198578 Front camera shows black screen after taking picture.
Issue #6232010 Layers not recreated when children change (DisplayList properties)

Change-Id: I8b5f9ec342208ecb20d3e6a60d26cf7c6112ec8b
6554943a1dd6854c0f4976900956e556767b49e1 27-Mar-2012 Romain Guy <romainguy@google.com> Use a status_t return type for GL functors

WebView needs more fine-grained control over the behavior of the
framework upon execution of the display lists. The new status_t
allows WebView to requests its functor to be re-executed directly
without causing a redraw of the entire hierarchy.

Change-Id: I97a8141dc5c6eeb6805b6024cc1e76fce07d24cc
9d1992deaeb3d60d5928f05b649a2cc654ba98a3 13-Mar-2012 Chet Haase <chet@google.com> Optimizing DisplayList properties

DisplayList properties are still disabled default (flags in View.java
and DisplayListRenderer.h). When they are enabled, and when a View has
a DisplayList, invalidations due to property changes are now optimized
to avoid causing DisplayList recreation. This eliminates the drawing step
of invalidation (due to changes in these properties), only requiring
issuing the previously-created DisplayList to the GL renderer. Invalidation
is slightly faster (less overhead as we walk up the hierarchy), getDisplayList()
is potentially much faster (going down to ~0ms), depending on the complexity
of the View being redrawn and the size of the invalidated hierarchy.

Change-Id: I57587d5b810c3595bdd72a6c52349c2a3d1bdf25
390f882f8905e8d1ac0d4b7f2e01aa04dccc3c16 14-Mar-2012 Romain Guy <romainguy@google.com> Correctly compute the number of bytes written by each op.
Bug #6157792

Previously, DisplayListRenderer would compute the number of bytes
written after a drawing op by looking at the difference between
the start pointer of the command stream and the end pointer of
the command stream. The SkWriter class used to record the commands
stream allocates blocks of storage which would cause a crash when
a command spanned two blocks.

Change-Id: I4d79d3feeb6d72d9d4e6ab05ecebd72d004be56c
491189f6bb81827a0c8e343f89420a9bcd2e62ae 13-Mar-2012 Chet Haase <chet@google.com> Fix garbage deref with DisplayList property structures

This is the real fix to issue 6158892. We currently delete
transform/camera structures at DisplayList destructor time, if these
structures are not NULL. We set the fields to NULL in an init() method
called (eventually) by the constructor. But it is possible for the object
to be destroyed before that init code is called, resulting in the deref
bug reported. The fi is to set these structures to NULL directly in the

Issue 6158892i: Device runtime restarts frequently

Change-Id: Ibfa0f9314767eed6fd51f4ec7edc0d0edd5fdd0f
3c9d9c18b41d052c76bad10a448d3acce024649b 13-Mar-2012 Romain Guy <romainguy@google.com> Merge "Follow the include style used elsewhere in the library"
d5a85fb63d91a9297e8d9a11016f3b3ed60dfbab 13-Mar-2012 Romain Guy <romainguy@google.com> Follow the include style used elsewhere in the library

Change-Id: I14aebdaeb04b6f4c611153ece4ac1f6ad9bfc15f
866ed817d0adf5b874eff277b4a4d2bcc6f61830 13-Mar-2012 Chet Haase <chet@google.com> Fix garbage deref in DisplayList structures

Issue #6158892: Device runtime restarts frequently

Change-Id: I4e6afaaf9ac66d6846caf0ed82ea67163d8b15c2
a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3 21-Feb-2012 Chet Haase <chet@google.com> Handle view properties at the native level

Basic functionality of handling View properties (transforms,
left/right/top/bottom, and alpha) at the native DisplayList level.
This logic is disabled for now (via compile-time flags in View.java and
DisplayListRenderer.h) as we continue work on it (there is no advantage
to the new approach until we optimize invalidation and rendering paths
to use the new code path).

Change-Id: I370c8d21fbd291be415f55515ab8dced6f6d51a3
3fe4eb9c60d39acaadd9f807b1a21c239d1270ef 12-Mar-2012 Romain Guy <romainguy@google.com> Turn down the number of glGetError() calls.

glGetError() was invoked every time a display list was updated. This
was unnecessary since display list updates do not execute OpenGL code.

Change-Id: Ia0a75a65ccf2a4701fb3a828848cd0c42f256c6c
bb0acdf9e1d862a7cf0e2533321fc1105c29b5e3 05-Mar-2012 Romain Guy <romainguy@google.com> Delete display list objects and resources on the UI thread
Bug #6073717
Bug #6065504
Bug #6026515
Bug #5971725

Prior to this patch, the destructor of DisplayList would always run
on the finalizer thread. This could cause a race condition if the UI
thread was busy rendering display lists at the same time leading to
various random native crashes.

Change-Id: Ie11108e3b1538d4b358a1a8b4cce1b2d33152d0c
ad1daaa87b793af30f3dd67a0f3cd5c0fd6ac0c1 02-Mar-2012 Romain Guy <romainguy@google.com> Remove stray log

Change-Id: I0c1979aab395098651c8a63d0bae0198ebc3746b
325740fb444af8fc7fb0119b2e30ce322c2ae134 25-Feb-2012 Romain Guy <romainguy@google.com> Add hooks to implement Canvas.drawTextOnPath() in GL

Change-Id: I165c9e05facf5365aa6850605688e538640c7fcc
33f6beb10f98e8ba96250e284876d607055d278d 17-Feb-2012 Romain Guy <romainguy@google.com> Record possible clip rejects when recording display lists

This optimization allows us to quickly skip operations that lie
entirely outside of the known bounds of a display list. Because
of ViewGroup.setClipChildren, we must keep the operations recorded
in the display list. setClipChildren(false) is however a very
uncommon operation and we will therefore often benefit from this
new optimization.

Change-Id: I0942c864e55298e6dccd9977d15adefbce3ba3ad
13631f3da855f200a151e7837ed9f6b079622b58 31-Jan-2012 Romain Guy <romainguy@google.com> Add debug markers to OpenGLRenderer

These markers will be used to group the GL commands by View in the
OpenGL ES debugging tool. This will help correlate individual GL
calls to higher level components like Views.

Change-Id: I73607ba2e7224a80ac32527968261ee008f049c6
5ff9df658230d49e42c43586997a02d8e4dd417e 24-Jan-2012 Romain Guy <romainguy@google.com> Add full support for Canvas.setDrawFilter()

Change-Id: I0ad35d0603c4eeda469014803be14c1dcdde918c
eb9a5367e8f0e970db8509ffb2584f5376bc62ed 18-Jan-2012 Romain Guy <romainguy@google.com> First pass at implementing Canvas.drawPosText() in GL

Change-Id: Ia3ac347e95d57eb86c63045156c8dbc0572b03cb
d4a69b4a1cb5b52035345abd8cb9595ae4cf9fa5 06-Jan-2012 Fabrice Di Meglio <fdimeglio@google.com> Merge "Fix bug #5753006 Garbled Labels in Maps"
c511bee87cda99a252d1a62487f47c8f05aee78c 05-Jan-2012 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #5753006 Garbled Labels in Maps

- it was a regression introduced into this CL: https://android-git.corp.google.com/g/#/c/154240/5
- basically needed to set the GlyphID encoding to the Skia Paint as we are now using glyphID resulting
from the Harfbuzz shaping
- also define GlyphID encoding as the default on the Paint class

Change-Id: Idb7c2c57ac67595425ce3be9421258962690fcdd
5baa3a62a97544669fba6d65a11c07f252e654dd 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
8f9a9f61ab793d9387a5942b307e74324704893b 05-Dec-2011 Romain Guy <romainguy@google.com> Clip text correctly
Bug #5706056

A newly introduced optimization relied on the display list renderer
to properly measure text to perform fast clipping. The paint used
to measure text needs to have AA and glyph id encoding set to return
the correct results. Unfortunately these properties were set by
the GL renderer and not by the display list renderer. This change
simply sets the properties in the display list renderer instead.

This change also improves the error message printed out when the
application attempts to use a bitmap larger than the max texture

Change-Id: I4d84e1c7d194aed9ad476f69434eaa2c8f3836a8
cac5fd3e09e9dc918753d4aff624bf29a367ade3 02-Dec-2011 Romain Guy <romainguy@google.com> Faster text clipping

Change-Id: I03a00c4261d81a416b1ad7b86ce2d432c71908b4
a62f172215727a1e00af0cb934904e00926a86c9 20-Oct-2011 Romain Guy <romainguy@google.com> Correctly dump DrawPatch operations in display lists

Change-Id: I8cd1c764ddc184ce45727913fa2a23a3d81b337e
04c9d8c2ffd028c35c750bac0a4a7b79e48059b5 25-Aug-2011 Romain Guy <romainguy@google.com> Optimize display lists

Remove redundant or useless operations

Change-Id: If989b4eaa9143eef4254c38b39959aeed1f2b9ab
65b345fa22b878e141b8fd8ece9c208df00fa40f 28-Jul-2011 Romain Guy <romainguy@google.com> Reclaim more memory, more often.


Change-Id: I04557ad575c307a55088549f48f0e9ad994b7275
162a0217563f4665da6eb183dfce0fef740f641f 22-Jul-2011 Jeff Brown <jeffbrown@google.com> 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
9ff3cb57ee46ac5242a7d8f08e0c66189fda2e66 28-Jun-2011 Romain Guy <romainguy@google.com> Fix parameter order evaluation issue.

This problem was affecting Android builds with gcc/x86.

Change-Id: Ibb7978413c89bd1ac09f0d1ea78f5cb4fe61f6ed
d586ad9c9fec80aa1d24d6b53cd2c8d5b47fe868 23-Jun-2011 Romain Guy <romainguy@google.com> Fix another memory leak in OpenGLRenderer

Change-Id: I23ed56891452a05cf3ca13f6919c4fef90d5ff4e
726aeba80ffc6778a9bc3e0ee957b8d644183505 01-Jun-2011 Romain Guy <romainguy@google.com> Add support to OpenGLRendere to draw BiDi text.
Bug #4350336

Change-Id: I1cf31693f7ca9653fa3a41b5b91c27ef288d680f
ed30fd8e9a2d65ee5c8520de55b0089c219f390c 23-Apr-2011 Chet Haase <chet@google.com> 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

Change-Id: Iad05f5f6cca0f8b465dccd962b501dc18fe6e053
a17de9b493123f0d6e6d0b842150bf29322b7a88 05-May-2011 Chet Haase <chet@google.com> Revert "Add ability for hierarchyviewer to output displaylist info"

This reverts commit b2a4b52e8d5e499d33e2765e8c47851bf0266299.
b2a4b52e8d5e499d33e2765e8c47851bf0266299 23-Apr-2011 Chet Haase <chet@google.com> 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

Change-Id: Id32f62569ad1ab4d533bc62987f3a7390c1bb4e6
9c1e23baf5bfbebd1aebbd6d9a18c225325567ce 24-Mar-2011 Chet Haase <chet@google.com> Add logging of graphics acceleration info to bugreports

Change-Id: I9fa4cda6ccf92df9d1c644ccdc0e7274a30106e0
1af23a32d879db330eb5a08b21090ec60b604a32 25-Mar-2011 Romain Guy <romainguy@google.com> When deleting a path, remove it from the path cache.
Bug #4170585

Change-Id: I6be4d251ceb908c89afe49c2ff85c05f36c73b70
ed6fcb034b44d9a6ac2fc72fee6030417811f234 21-Mar-2011 Romain Guy <romainguy@google.com> Add support for drawPoint() and drawPoints().

Change-Id: I01bef50c08ec3160f8d40dc060b2cf6c2e4d7639
b29cfbf768eab959b31410aafc0a99e20249e9d7 19-Mar-2011 Romain Guy <romainguy@google.com> Fix paths rendering issues.

See ApiDemos, PathEffect and PathFillTypes.

Change-Id: I9f9593c1da33d0d013b5b89c86bc5bd71128a192
7b5b6abf852c039983eded25ebe43a70fef5a4ab 15-Mar-2011 Romain Guy <romainguy@google.com> 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
cabfcc1364eb7e4de0b15b3574fba45027b45cfc 08-Mar-2011 Romain Guy <romainguy@google.com> 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
5a7e828842c26f64bb6e0ef3e0019e1949b245ee 04-Feb-2011 Chet Haase <chet@google.com> 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
d63cbd10765e8f48e39b07b15f0a4b70bf853ec8 04-Feb-2011 Chet Haase <chet@google.com> Fix leak in reused display lists

Change-Id: I32a9c41abf8f8cbcaaaa6fcc82d296800014a1b2
2fc941e4650d618ff6e122f28b616d9032ffa134 04-Feb-2011 Romain Guy <romainguy@google.com> Fixes cache misses and extra allocations.
Bug #3421454

Change-Id: If4d5c960a7e4c581a9d213073e658284b4e1c497
2b1847ea60650a9f68372abe860415f18b55081d 26-Jan-2011 Romain Guy <romainguy@google.com> Remove unused API

Change-Id: I1714fd82a64b752f0350ef4ef9179ce19e089c6a
82d41a515368236e56454bd84023bebd6306f6b7 25-Jan-2011 Romain Guy <romainguy@google.com> Fix display list support for shapes.

Change-Id: I8b4c9e9ec36266a83c0a53ba3fb6e45d61bbd6d9
7d7b5490a0b0763e831b31bc11f17d8159b5914a 25-Jan-2011 Romain Guy <romainguy@google.com> Enable partial invalidates when rendering with OpenGL.

Change-Id: Ie8be06c4776b815e8737753eb8003b4fd8936130
daf98e941e140e8739458126640183b9f296a2ab 10-Jan-2011 Chet Haase <chet@google.com> 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
a566b7c3aada08d37cf08096c972e3e641bed773 24-Jan-2011 Romain Guy <romainguy@google.com> Fix bitmap meshes to work in display lists.

Change-Id: Ie226d049840942d9ad9cf58e0c19132f49d62a75
8b2f5267f16c295f12faab810527cd6311997e34 24-Jan-2011 Romain Guy <romainguy@google.com> Add support for arcs.

Change-Id: I96c057ff4eb1b464b03f132da0b85333777bee4f
c1cd9ba335b293f11e1082447ef08e474710a05f 23-Jan-2011 Romain Guy <romainguy@google.com> Add support for ovals and stroked rectangles.

Change-Id: I1292e241386763c82e6622c8f7ed90b0f5b7bd4f
27454a42de8b3c54cdd3b2b2a12446c2c10c8cb9 23-Jan-2011 Romain Guy <romainguy@google.com> Collapse sucessive calls to restoreToCount() in display lists.

Change-Id: Icb3d3dc2c579436d375269a9cb0b821a931c5a79
4cf6e2f34994f160e1baba205a43c12784dd3e0d 23-Jan-2011 Romain Guy <romainguy@google.com> Fix potential crash in display lists.

Change-Id: I868821cbe69f7e71d93701b9cdb528a2ef796cd4
5a7b466a2b4b7ced739bd5c31e022de61650545a 21-Jan-2011 Romain Guy <romainguy@google.com> Add support for drawBitmapMesh().

Change-Id: Ic77f9c534bb90dc7b9458299544bd50b8b6ae6a5
01d58e43ede5ca98cbebdd166f9b0c545032c01b 20-Jan-2011 Romain Guy <romainguy@google.com> Add rounded rects and circles support to OpenGLRenderer.

Change-Id: I6cedf2b495d58de7c0437096809fa9e4518a1b8c
807daf7df615b60ce6fc41355aabe3aa353cebab 18-Jan-2011 Romain Guy <romainguy@google.com> Add support for skew()

Change-Id: Ia3a9a867f74fd78b61f75179e3788fdc2f0cacd0
43ccf4663c822ddd435b7683cc05221f6169c6c3 15-Jan-2011 Romain Guy <romainguy@google.com> Don't crash Launcher on config change.

Change-Id: Ibbbd7146c5ff69e9639b433f39041053654d808c
24c00216687ac87fe531dc4d4168ac0c0ca04ea6 15-Jan-2011 Romain Guy <romainguy@google.com> Copy shaders when recording them in display lists.

Change-Id: I3f22dd35f1e31c9e5102955d76548098b7b0cd8d
ffac7fc5042296a459d0f5a450dbfe20917093dc 14-Jan-2011 Romain Guy <romainguy@google.com> Add debug logs for display lists.

Change-Id: I7bae8fd96e9eccb51f29f73e4069b4d3e6bdbdd7
ada830f639591b99c3e40de22b07296c7932a33f 13-Jan-2011 Romain Guy <romainguy@google.com> 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
6c319ca1275c8db892c39b48fc54864c949f9171 11-Jan-2011 Romain Guy <romainguy@google.com> 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
5977baa1fa24125c148a72699b53e62abaf08960 06-Jan-2011 Chet Haase <chet@google.com> Reuse of native display list objects

Change-Id: Ia4553e23930ad20e56c11faa7809be788a1ad4bb
fe48f65922d4a3cc4aefe058cee5acec51504a20 12-Nov-2010 Romain Guy <romainguy@google.com> 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
9e10841c27d973b930e1b49a099c69d866659505 09-Nov-2010 Romain Guy <romainguy@google.com> Correctly remove unused paths from the cache.

Change-Id: I41d9334dcd9871634037344ab49bf69383498161
0fe478ea04720a57ef3919dbc23711bc7eba517f 08-Nov-2010 Romain Guy <romainguy@google.com> Support nested display lists.

Change-Id: I3815a2832fc0f722c668ba8f51c5f177edb77c94
5b3b35296e8b2c8d3f07d32bb645d5414db41a1d 28-Oct-2010 Romain Guy <romainguy@google.com> 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
ad93c2bb63dfc813b2eefa1043aa63afbddce655 23-Oct-2010 Chet Haase <chet@google.com> Optimizing ColorFilter in display lists

Change-Id: Ie4d5e5b0bc45e0ce47bba144049303c270762e54
d98aa2de9ab18e09c2be1997f41212740f51f6e6 26-Oct-2010 Chet Haase <chet@google.com> 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
5c13d89c1332fcc499379b9064b891187b75ca32 08-Oct-2010 Chet Haase <chet@google.com> Optimizing display lists by referencing pointers to resources instead of copying them

Change-Id: I81ad3551d74aa1e5bb64d69e33d2eb29a6c1eb6a
4bb942083a0d4db746adf95349108dd8ef842e32 13-Oct-2010 Romain Guy <romainguy@google.com> Optimize 9patch rendering.

This change detects empty quads in 9patches and removes them from
the mesh to avoid unnecessary blending.

Change-Id: I4500566fb4cb6845d64dcb59b522c0be7a0ec704
6b7bd24659fb175fe1f0e97c86c18969918b496a 07-Oct-2010 Romain Guy <romainguy@google.com> Don't clear the framebuffer when not needed.
7975fb6d12cb1eb96b75e3a563627cd4c4081bd6 02-Oct-2010 Romain Guy <romainguy@google.com> Apply bilinear filtering to text.

Change-Id: I2c81ad657ee2a11a2139e0b11ae3749db54c0749
b051e895ccb696604349c6c5efe7c4747e1d1ab6 29-Sep-2010 Romain Guy <romainguy@google.com> Add display lists caching.

Change-Id: Iac3a248a81ed8cb076a83ef9d186b8ebba685b4c
4aa90573bbf86db0d33a3a790c5dbd0d93b95cfe 27-Sep-2010 Romain Guy <romainguy@google.com> Adding display lists to the GL renderer (checkpoint.)

Change-Id: Iaa49757600a53b39369dbb23f8c3feab282518e6