History log of /frameworks/base/libs/hwui/BakedOpRenderer.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
48f9bb6254324006a4595f4576c28498a4aaf5d2 25-Mar-2017 Chris Craik <ccraik@google.com> Register functor draw correctly

Bug: 36602041
Test: existing tests still pass

Change-Id: I9f385da89e9e49e562031578a02f13a68697e0df
ec4a4b13eae2241d1613890c1c1c096bed891845 21-Oct-2016 sergeyv <sergeyv@google.com> Use Bitmap in DisplayList & RecordedOps instead of SkBitmap
Test: refactoring cl.

Change-Id: I1d8a9a6e772e2176b6c2409409a910478b45f8db
253f2c213f6ecda63b6872aee77bd30d5ec07c82 29-Sep-2016 Romain Guy <romainguy@google.com> Linear blending, step 1

NOTE: Linear blending is currently disabled in this CL as the
feature is still a work in progress

Android currently performs all blending (any kind of linear math
on colors really) on gamma-encoded colors. Since Android assumes
that the default color space is sRGB, all bitmaps and colors
are encoded with the sRGB Opto-Electronic Conversion Function
(OECF, which can be approximated with a power function). Since
the power curve is not linear, our linear math is incorrect.
The result is that we generate colors that tend to be too dark;
this affects blending but also anti-aliasing, gradients, blurs,

The solution is to convert gamma-encoded colors back to linear
space before doing any math on them, using the sRGB Electo-Optical
Conversion Function (EOCF). This is achieved in different
ways in different parts of the pipeline:

- Using hardware conversions when sampling from OpenGL textures
or writing into OpenGL frame buffers
- Using software conversion functions, to translate app-supplied
colors to and from sRGB
- Using Skia's color spaces

Any type of processing on colors must roughly ollow these steps:

[sRGB input]->EOCF->[linear data]->[processing]->OECF->[sRGB output]

For the sRGB color space, the conversion functions are defined as

OECF(linear) :=
linear <= 0.0031308 ? linear * 12.92 : (pow(linear, 1/2.4) * 1.055) - 0.055

EOCF(srgb) :=
srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4)

The EOCF is simply the reciprocal of the OECF.
While it is highly recommended to use the exact sRGB conversion
functions everywhere possible, it is sometimes useful or beneficial
to rely on approximations:

- pow(x,2.2) and pow(x,1/2.2)
- x^2 and sqrt(x)

The latter is particularly useful in fragment shaders (for instance
to apply dithering in sRGB space), especially if the sqrt() can be
replaced with an inversesqrt().

Here is a fairly exhaustive list of modifications implemented
in this CL:

- Set TARGET_ENABLE_LINEAR_BLENDING := false in BoardConfig.mk
to disable linear blending. This is only for GLES 2.0 GPUs
with no hardware sRGB support. This flag is currently assumed
to be false (see note above)
- sRGB writes are disabled when entering a functor (WebView).
This will need to be fixed at some point
- Skia bitmaps are created with the sRGB color space
- Bitmaps using a 565 config are expanded to 888
- Linear blending is disabled when entering a functor
- External textures are not properly sampled (see below)
- Gradients are interpolated in linear space
- Texture-based dithering was replaced with analytical dithering
- Dithering is done in the quantization color space, which is
why we must do EOCF(OECF(color)+dither)
- Text is now gamma corrected differently depending on the luminance
of the source pixel. The asumption is that a bright pixel will be
blended on a dark background and the other way around. The source
alpha is gamma corrected to thicken dark on bright and thin
bright on dark to match the intended design of fonts. This also
matches the behavior of popular design/drawing applications
- Removed the asset atlas. It did not contain anything useful and
could not be sampled in sRGB without a yet-to-be-defined GL
- The last column of color matrices is converted to linear space
because its value are added to linear colors

Missing features:
- Resource qualifier?
- Regeneration of goldeng images for automated tests
- Handle alpha8/grey8 properly
- Disable sRGB write for layers with external textures

Test: Manual testing while work in progress
Bug: 29940137

Change-Id: I6a07b15ab49b554377cd33a36b6d9971a15e9a0b
d4fe4d3b30aaefcaaae6a6d1b8dc4bf59e034768 10-Jun-2016 Chris Craik <ccraik@google.com> Fix framebuffer incomplete errors


Primarily fixes case where 0 dimensioned layers could be
created/updated. Additionally, adds more logging in incomplete
framebuffer cases, if they still occur.

Change-Id: Ib90dbbafd6905aca3c8f46e64064e13a308f713d
ab3f8c2e3277af88935c8fa3bb7a36470d2b0116 01-Jun-2016 sergeyv <sergeyv@google.com> HWUI: do not call glCopyTexSubImage2D on empty area.

Previous check .isEmpty() is not sufficient, because getWidth() may have
value 0.5, so technically it is not empty, but when this size is passed
to texture calls it is converted to uint_32 and it becomes zero.

Change-Id: Ia7c2bf0340466d5376f235fb5da54ad2ddfa0a03
37413289478a965336239c731ebfea37ac4dde28 13-May-2016 Chris Craik <ccraik@google.com> Fix hw layer overdraw/update visualization

Fixes: 28748255

Change-Id: I83b531cdf5e4407fd17edd72d96e6189924926fa
74af6e282f8a8f75928a071e8200039517cf5c12 05-Apr-2016 Chris Craik <ccraik@google.com> Fix OffscreenBuffer leak

Fixes: 27941148

Make OffscreenBuffer lifecycle an explicit (and tested) contract between
FrameBuilder and BakedOpRenderer, entirely separate from dispatch. This
makes it safe to reject any rendering work via overdraw content
rejection (before it gets to a BakedOpDispatcher).

Adds a couple tests around OffscreenBuffer leaks, and switches
OffscreenBuffer tests to RENDERTHREAD_TEST macro, as appropriate.

Change-Id: Id114b835d042708ae921028fb4b17e5fa485fe64
96bacd186e5381d27181cb3414003a74e2d2c3b7 18-Mar-2016 Chris Craik <ccraik@google.com> Rebuild outline when setBackground is called.


Also correctly register damage from profiling bars.

Change-Id: I9550c2742eb833350a077ca48eccf9b584083a1e
02806288d1c56475413888a934c796e6e4eb11c5 12-Mar-2016 Chris Craik <ccraik@google.com> Fix flickering when layers resize in-place

Change-Id: Ia11c93ebc1097f3735071204b6f14ca079bb9fc4
419a1e7ef53468e494d21c66ea7f63c0c522d208 09-Mar-2016 Chris Craik <ccraik@google.com> Add initial BakedOpDispatcher tests


Change-Id: If8ba33732d09b335171f87d5efc419641bafa126
1dfa0704964c17e45775b9e01f1fa0b1a10774f7 05-Mar-2016 Chris Craik <ccraik@google.com> Support GPU profiling vis in new pipeline


Change-Id: I905c1a998d9a9e2097c047dab9de87a70d7a370e
64db2bf1118db88c937e2b8c61b299bb2a80e3cb 27-Feb-2016 Chris Craik <ccraik@google.com> Clip buffer damage to viewport bounds


Change-Id: Ief3ae9c2dd92196b7d09f1b9fadf009eb228d80a
4876de16e34622634266d09522c9153c78c7c2fb 26-Feb-2016 Chris Craik <ccraik@google.com> Properly reject empty unclipped savelayers


Empty unclipped savelayers (clipped at defer time, often by dirty rect)
were resulting in invalid layer clear rectangles. Simplify by just
rejecting these unclipped savelayers entirely at defer.

Also, use repaint rect as base clip for constructed ops within

Change-Id: I5c466199e85201a2f68f5cdc60b29187c849961b
0b8d0677be2289bbc9e0b48c0878fb67d1cc0ebd 29-Jan-2016 John Reck <jreck@google.com> Fix copyLayerInto

Bug: 26763945
Change-Id: I21ffbd56cf70bad0928416963e6fc254be435af9
c52ac0b9e2dc9d060f21498ac59404ec7fd1e846 26-Jan-2016 John Reck <jreck@google.com> Merge "Add fine-grained debug layer"
975591a7af883d866d86ab819e164c6004694744 23-Jan-2016 John Reck <jreck@google.com> Add fine-grained debug layer

Full GLES error checking layer via -include
trickery. Change DEBUG_OPENGL to a level system.

HIGH = every GL call is error checked
MODERATE = checkpointing at interesting spots
LOW = only asserts there are no errors at the end of a frame
or when the FBO changes

Change-Id: Ibe81aae93d942059c4ddf1cbb11c828b7ce4c10b
25f0dc440d6c9239a873e6d1fc98b0d8e3eb7c7f 25-Jan-2016 John Reck <jreck@google.com> Validate Region.orSelf arguments

Bug: 26611248

libui.so has int overflow sanitization enable, so
validate that we have "reasonable" looking floats
before trying to orSelf the Region.

Change-Id: I135ef7be82e7abaa9aa569224c2799612847cd03
2de7771740ee08fcaff638ec6b2e460bb72fff04 20-Jan-2016 John Reck <jreck@google.com> Normalize GL_UNPACK_ALIGNMENT

Several places were setting GL_UNPACK_ALIGNMENT
unneccessarily, whereas other places were assuming an
unpack alignment of 1. Since we never actually
do explicit row-alignment, set GL_UNPACK_ALIGNMENT
to 1 at context creation time and never change it

Bug: 26584230

Also turns on aggressive glGetError checking to
better catch potential problem zones

Change-Id: I190c8f0f0494a7f046d5ed769405c75d363be59a
9372ac3621848085e77b867f220c0b5ffce4010d 19-Jan-2016 John Reck <jreck@google.com> Fix ordering of texture->upload arguments

Caught by scatter-shotting GL_CHECKPOINTS which
seem generally useful to have

Bug: 26609444

Change-Id: Ie31d9297d8dae56405126720f338b4256c8bae77
38e0c32852e3b9d8ca4a9d3791577f52536419cb 10-Nov-2015 John Reck <jreck@google.com> Track texture memory globally

Also mostly consolidates texture creation

Change-Id: Ifea01303afda531dcec99b8fe2a0f64cf2f24420
84ad6149db0e1dc98ed3778ee4fc2ab685765d9a 12-Jan-2016 Chris Craik <ccraik@google.com> Fix a couple crashes in the new reorderer

Also fixes the layer clear scissor logic in BakedOpRenderer, fixing a

Change-Id: I61106a18938ea35e31f0a0b585b5743544245773
15f046866cb650d78f55d03327cfa4a474fc9471 12-Jan-2016 Chris Craik <ccraik@google.com> Fix clip serialization crash

Can't safely rewind clip allocations, since those pointers are cached by
ClipArea. Instead add early rejection to handle most cases, and update

Change-Id: Ic32f95cf95602f427f25761a8da1583c4495f36d
7435eb148e72382126e9073183e881357bb38a8b 08-Jan-2016 Chris Craik <ccraik@google.com> Unclipped savelayer support in new renderer


Change-Id: I89dd5de8d7d008a1e298d227d767aabff5c96e27
b87eadda1818034ce03d85f30388384d1ac65916 06-Jan-2016 Chris Craik <ccraik@google.com> Partial unclipped save layer support

Not yet implemented in renderer.

Change-Id: I491ec6e7886bfa313d1db71dd5981690d45b78a9
e5b50197e870aa6d22c3893f5d25f4279f06e5c3 05-Jan-2016 Chris Craik <ccraik@google.com> Support for stencil clipping in layers


Change-Id: Ic9e8652379524ccc46d8722ce49f9190b08a2abc
e4db79de127cfe961195f52907af8451026eaa20 23-Dec-2015 Chris Craik <ccraik@google.com> Stencil support in new recorder/reorderer


Adds complex (non-rectangular) clipping support, and overdraw
visualization. Doesn't support stencil clipping in layers.

Change-Id: I8d10c7f1d2769ab5756774ca672344cc09901f87
e29ce6f51d681af7649c0a7cddee97c471e43eb5 11-Dec-2015 Chris Craik <ccraik@google.com> Add functor support to new reorderer/renderer


Change-Id: I95df7e0504f62d254e8ffbd8d65ed5d763080b9c
15c3f19a445b8df575911a16e8a6dba755a084b5 03-Dec-2015 Chris Craik <ccraik@google.com> Merged op dispatch in OpReorderer


Also switches std::functions to function pointers on OpReorderer, and
switches AssetAtlas' entry getter methods to using pixelRef pointers,
so it's clear they're the keys.

Change-Id: I3040ce5ff4e178a8364e0fd7ab0876ada7d4de05
9e7fcfda28fde747ba4e026772007cea77374e16 25-Nov-2015 Chris Craik <ccraik@google.com> Move BakedOpDispatcher to separate file

Change-Id: If7aad6db6b7e54a33eac9b9eddbe8cd844207282
a1717271caac5e8ea3808c331d4141ac01a42134 19-Nov-2015 Chris Craik <ccraik@google.com> Initial text support in new reorderer/renderer

Removes obsolete drawPosText codepath, and unifies text decoration behavior.

Change-Id: I9c563249ab688a3394445a0e7fe1b9d0661f6f7c
98787e6c9b2c10b1ab7820bdac168686025b924a 13-Nov-2015 Chris Craik <ccraik@google.com> Finish shadow support in new reorderer/renderer

Now passes alphas and light radius, and correctly transforms light
center for layers.

Also fixes begin-frame/layer clears to be damage rect aware.

Change-Id: I3b1415cd7bf1518c510145ebebdb745f494a2542
9fded232a9548a304e0145011df8849fba0dcda7 12-Nov-2015 Chris Craik <ccraik@google.com> Recycle OffscreenBuffers

Change-Id: Ia2e219026f211a5308ecf8209c5f986bb888aadd
d3daa3198e2212c985c634821682d5819346b653 06-Nov-2015 Chris Craik <ccraik@google.com> Add shadow support to new reorderer/renderer

Doesn't yet use correct lighting info (esp. in layers), or
tessellate shadows asynchronously

Change-Id: I9ccec24b28869be42138a9bb234b1af874291a44
8d2cf943d9c7292e54726399faefdec4a01c084b 02-Nov-2015 Chris Craik <ccraik@google.com> Add region-tracking to OffscreenBuffers

Change-Id: I024c7219c080b9a89888517f5a89d49dfe8065ba
0b7e8245db728d127ada698be63d78b33fc6e4da 29-Oct-2015 Chris Craik <ccraik@google.com> Initial HW layer support in new reorderer/renderer

Shares vast majority of clipped savelayer code, with only minor
differences in lifecycle.

Doesn't yet handle fill region, resize, or window transform.

Change-Id: Iabdd71811590d2b937eb11e1b01ce556ade54a5a
5854b34881b1a747ac80b5077869ef270a92b1f4 26-Oct-2015 Chris Craik <ccraik@google.com> Rework receiver/dispatcher design slightly, and replace Layer usage.

Switched from 'renderer/info' to 'dispatcher/renderer' to make their
interaction more natural. The new BakedOpRenderer is more similar in
responsibilities to the OpenGLRenderer, as it manages layer and frame
lifecycles, and performs the actual rendering.

However, it's still simpler because the BakedOpDispatcher handles
mapping Canvas drawing ops to Glops, and the OpReorderer handles almost
all canvas state operations.

Also switch BakedOpRenderer to use the new OffscreenBuffer, which
serves as a lightweight Layer replacement, with a much simpler

Change-Id: Ie0e2e248503400041d49729d813d485d28c76eb3
818c9fbf1d76d5df19253ba4eb964efa939ec9ec 23-Oct-2015 Chris Craik <ccraik@google.com> Initial version of clipped saveLayer in new pipeline

Additionally disables usage of FBO cache, so FBO destruction safely
interacts with renderstate caching.

Change-Id: I25c277cb7afec2ca33bf226445d6c8867a15a915
6fe991e5e76f9af9dab960100d5768d96d5f4daa 20-Oct-2015 Chris Craik <ccraik@google.com> Work to support saveLayer in new pipeline

clipped SaveLayers will now be pulled to the beginning of the frame,
prior to drawing FBO 0. This will remove the need for switching FBOs

Change-Id: I4d8dc1f845e84e9b49d5acdf4f4703eef4a9cb06
b565df13a9e5c7b1d7d93bdfa4a793752d66d3cc 05-Oct-2015 Chris Craik <ccraik@google.com> Initial commit of new Canvas operation recording / replay

- drawRect, drawBitmap, drawColor, drawPaint, drawRenderNode, drawRegion
- Recording with new DisplayList format
- batching & reordering
- Stateless op reorder
- Stateless op rendering
- Frame lifecycle (clear, geterror, cleanup)

Not done:
- SaveLayer (clipped and unclipped)
- HW layers
- Complex clipping
- Ripple projection
- Z reordering
- Z shadows
- onDefer prefetching (text + task kickoff)
- round rect clip
- linear allocation for std collections
- AssetAtlas support

Change-Id: Iaf98c1a3aeab5fa47cc8f9c6d964420abc0e7691