summaryrefslogtreecommitdiff
path: root/libs/hwui/Program.cpp
AgeCommit message (Collapse)Author
2018-05-08remove obsolete Glop, Tessellators, Programs, and SkiaShaderMike Reed
Test: make Change-Id: I92f36335830dfc37be72468546637d9986f0baf1
2017-11-03Format the world (or just HWUI)John Reck
Test: No code changes, just ran through clang-format Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2015-07-14Clean up unncessary definesChris Craik
LOG_TAG and TRACE_TAG are already defined in the makefile Change-Id: I9e53e3dacbe018441edd74cb7c8c90846defee74
2015-02-12Glop Bitmap and RoundRect clipping supportChris Craik
Change-Id: I4577546a5d2e5f084cc03f39a89db9231b8111ee
2015-02-02Refactoring of Program ownership/lifecycle, and WIP Glop rendering pathChris Craik
Change-Id: I2549032790bddbc048b0bccc224ed8f386b4517c
2015-01-05Add overrides and switch to nullptr keyword for all filesChris Craik
Adds remaining missing overrides and nullptr usages, missed due to an extreme failure in tool usage. Change-Id: I56abd72975a3999ad13330003c348db40f59aebf
2014-11-19Improve logging around performance critical eventsChris Craik
bug:17702227 Add details useful to developers (such as layer size/View name), and switch away from logging implementation names/details, since they are generally not relevant to developers. Change-Id: Iee605d182f241450f7e75a6d0c283d51fa1312f5
2014-11-05Log shader source when it fails to compileRob Tsuk
So that there will be something to diagnose when such failures occur during stability tests. Bug: 18092655 Change-Id: I9a9d8d33b34273a477f2a9dbcf092887dcbc91c0
2014-07-11Abort on shader link/compile failureChris Craik
b/16207378 Change-Id: I12debb0846214a08459ad25454653a003f034402
2014-01-29Fix projection offset cachingChris Craik
Because the caching of projection matrix didn't account for changes in the offset flag, the flag could be ignored. Now we use both to verify that the cached matrix can be used. Change-Id: I193b94eaf0b98f046a6484f0866c3d25048653fd
2014-01-02Fix Clang warnings/errorsChris Craik
Fix several build warnings (struct != class, int != size_t) and errors (variable leng non-POD arrays). Change-Id: I70b4e784365514303d8954bfcb1f39d7c22c1321
2013-09-17Conservatively estimate geometry boundsChris Craik
bug:10761696 Avoids a case where a rect with top coordinate of (e.g.) 0.51f is assumed to not draw in the first row of pixels, which leads to it not being clipped. Since rounding can cause it to render in this first pixel anyway, we very slightly expand geometry bounds. Now, in ambiguous cases, the geometry bounds are expanded so clipping is more likely to happen. Change-Id: I119b7c7720de07bac1634549724ffb63935567fc
2013-06-11Avoid 9patch cache lookups when possibleRomain Guy
This optimization saves up to 0.3ms per frame on the Play Store's front page, on a Nexus 4 device. Change-Id: Iaa4ef33c6e3b37e175efd5b9eea9ef59b43f14f3
2013-05-02Pack preloaded framework assets in a texture atlasRomain Guy
When the Android runtime starts, the system preloads a series of assets in the Zygote process. These assets are shared across all processes. Unfortunately, each one of these assets is later uploaded in its own OpenGL texture, once per process. This wastes memory and generates unnecessary OpenGL state changes. This CL introduces an asset server that provides an atlas to all processes. Note: bitmaps used by skia shaders are *not* sampled from the atlas. It's an uncommon use case and would require extra texture transforms in the GL shaders. WHAT IS THE ASSETS ATLAS The "assets atlas" is a single, shareable graphic buffer that contains all the system's preloaded bitmap drawables (this includes 9-patches.) The atlas is made of two distinct objects: the graphic buffer that contains the actual pixels and the map which indicates where each preloaded bitmap can be found in the atlas (essentially a pair of x and y coordinates.) HOW IS THE ASSETS ATLAS GENERATED Because we need to support a wide variety of devices and because it is easy to change the list of preloaded drawables, the atlas is generated at runtime, during the startup phase of the system process. There are several steps that lead to the atlas generation: 1. If the device is booting for the first time, or if the device was updated, we need to find the best atlas configuration. To do so, the atlas service tries a number of width, height and algorithm variations that allows us to pack as many assets as possible while using as little memory as possible. Once a best configuration is found, it gets written to disk in /data/system/framework_atlas 2. Given a best configuration (algorithm variant, dimensions and number of bitmaps that can be packed in the atlas), the atlas service packs all the preloaded bitmaps into a single graphic buffer object. 3. The packing is done using Skia in a temporary native bitmap. The Skia bitmap is then copied into the graphic buffer using OpenGL ES to benefit from texture swizzling. HOW PROCESSES USE THE ATLAS Whenever a process' hardware renderer initializes its EGL context, it queries the atlas service for the graphic buffer and the map. It is important to remember that both the context and the map will be valid for the lifetime of the hardware renderer (if the system process goes down, all apps get killed as well.) Every time the hardware renderer needs to render a bitmap, it first checks whether the bitmap can be found in the assets atlas. When the bitmap is part of the atlas, texture coordinates are remapped appropriately before rendering. Change-Id: I8eaecf53e7f6a33d90da3d0047c5ceec89ea3af0
2013-02-15Adjust offset for non-AA line drawingChris Craik
bug:8114304 The original .375 was chosen to make GL_LINES align with Skia drawing. The new value of .065 is chosen to be as small as possible to make triangle-based lines align with Skia, while keeping lines drawn on integer coordinates unambiguous as to which column/row they draw on. Also adds more lines in CanvasCompare test to highlight the difference Change-Id: If578684f2db320682219c3caa625cf79bc62d88f
2012-09-26Make gradients beautiful againRomain Guy
Bug #7239634 This change passes two matrices to the vertex shader instead of one. We used to compute the final MVP matrix on the CPU to minimize the number of operations in the vertex shaders. Shader compilers are however smart enough to perform this optimization for us. Since we need the MV matrix to properly compute gradients dithering, this change splits the MVP matrix into two. This has the advantage of removing one matrix multiplication per drawing operation on the CPU. The SGX 540 shader compiler produces the same number of instructions in both cases. There is no penalty hit with having two matrices instead of one. We also send so few vertices per frame that it does not matter very much. Change-Id: I17d47ac4772615418e0e1885b97493d31435a936
2012-09-18Fix GL shader bugsChet Haase
Fixing errors in emitted shader code that caused GL errors at runtime Change-Id: I267a84398a81329a6688b292505f8779bd750ad1
2012-01-08Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGESteve Block
See https://android-git.corp.google.com/g/#/c/157220 Bug: 5449033 Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2011-12-13Reduce the number of active texture changesRomain Guy
Change-Id: I94046bdfe20740c26c8183822e3002d692fde7c4
2011-12-12Optimize state changesRomain Guy
Change-Id: Iae59bc8dfd6427d0967472462cc1994987092827
2011-12-12Remove leftover debugging codeRomain Guy
Change-Id: I1589af7991da36744071d5081daa24ebae5b4dfd
2011-12-12Keep shaders to render properlyRomain Guy
I don't know who's to blame, SGX or Tegra2 but one of those two GPUs is not following the OpenGL ES 2.0 spec. Change-Id: I2624e0efbc9c57d571c55c8b440a5e43f08a54f2
2011-12-12Mark color uniform fetched after fetching itRomain Guy
Change-Id: I10e8027018608070a536eb8b51c7a4272e37006c
2011-12-09Code cleanupRomain Guy
Change-Id: If92e3addfc4d8546a60edcdea60a1fc89c27b680
2011-12-09Free up resources by deleting shaders early onRomain Guy
Change-Id: I29a39775732c0a48d3e6823f7afa3e741cae8541
2011-04-27Fix various hw-accelerated line/point bugsChet Haase
All accelerated lines are now rendered as quads. Hairlines used to be rendered as GL_LINES, but these lines don't render the same as our non-accelerated lines, so we're using quads for everything. Also, fixed a bug in the way that we were offsetting quads (and not offseting points) to ensure that our lines/points actuall start on the same pixels as Skia's. Change-Id: I51b923cc08a9858444c430ba07bc8aa0c83cbe6a
2010-12-07Correctly release the OpenGL Canvas on EGL error.Romain Guy
Change-Id: Ib31fd8445f7ce5f7aa7e0205de0e7db80d024fc2
2010-11-02Optimize FBO drawing with regions.Romain Guy
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
2010-10-11Optimize GLSL shaders.Romain Guy
Change-Id: I9a5e01bced63d8da0c61330a543a2b805388a59d
2010-09-17Correctly free memory.Romain Guy
Change-Id: I08fcbfa7d27ae413e0a8e8ca6ea305c8530a72c1
2010-08-11Delete shaders after a compile error. Also disable extra logging.Romain Guy
Change-Id: I9b1558b0feac3d9b2cca926feeaf73921664cc73
2010-07-29Moved all the rendering code to the new shader generator.Romain Guy
The generator supports features that are not yet implement in the renderer: color matrix, lighting, porterduff color blending and composite shaders. This change also adds support for repeated/mirrored non-power of 2 bitmap shaders. Change-Id: I903a11a070c0eb9cc8850a60ef305751e5b47234
2010-07-27Generate shaders to cover all possible cases.Romain Guy
With this change, all the vertex and fragment shaders used by the GL renderer are now generated based on a program description supplied by the caller. This allows the renderer to generate a large number of shaders without having to write all the possible combinations by hand. The generated shaders are stored in a program cache. Change-Id: If54d286e77ae021c724d42090da476df12a18ebb
2010-07-21Add text rendering.Romain Guy
Change-Id: Ibe5a9fa844d531b31b55e43de403a98d49f659b9
2010-07-19Add support for linear gradients.Romain Guy
Change-Id: Id15329da065045b3f06fdaed615f33cd57608496
2010-07-16Add program for linear gradient.Romain Guy
This change adds a new DrawLinearGradientProgram class to enable the drawing of linear gradients. Two new vertex and fragment shaders are introduced, based on DrawTextureProgram's shaders. Change-Id: I885afc076bb6cef8cd3962ae21a086fa6a03bf96
2010-07-12Correctly support pre-multiplied alpha, optimizations, more stuff.Romain Guy
Add support for the following drawing functions: - drawBitmap(int[]...) - drawPaint() Optimizes shader state changes by enabling/disabling attribute arrays only when needed. Adds quick rejects when drawing trivial shapes to avoid unnecessary OpenGL operations. Change-Id: Ic2c6c2ed1523d08a63a8c95601a1ec40b6c7fbc9
2010-07-12Optimize shader binding changes.Romain Guy
This change also cleans up the internal API a little bit by using mat4 everywhere instead of float[16] (for the ortho matrix for instance.) Change-Id: I35924c7dc17bad17f30307118d5ed437c2ed37e0
2010-07-09Remove math from the vertex shader.Romain Guy
Change-Id: I02847a60a8734bf8b3d29ec12e76297795095e38
2010-07-09Fix alpha blending and improve fragment shaders performance.Romain Guy
Change-Id: Ib74f6941d25ca6f6a41708e541174eaa7e8d9bc2
2010-06-27Reduced the complexity of layers composition.Romain Guy
This change also refactors the code base a bit by moving classes out of OpenGLRenderer into separate headers/implementations. This makes the code more manageable. This change also adds documentation for implementation methods. The undocumented methods are simply Skia's Canvas methods. Change-Id: I54c68b443580a0129251dddc1a7ac95813d5289e