30 Commits

Author SHA1 Message Date
Romain Guy
b488004289 Use float textures to render gradients when possible
Float textures offer better precision for dithering.

In addition this change removes two uniforms from gradient shaders.
These uniforms were used to dither gradients but their value is
a build time constant. Instead we hardcode the value directly in
the shader source at compile time.

Change-Id: I05e9fd3eef93771843bbd91b453274452dfaefee
2013-04-05 14:17:17 -07:00
Chris Craik
096b8d96d5 Add shader program selection shortcut
Add a key manipulation that makes black text/paths use the standard
simple bitmap/patch shader, since they are the same. Previously we'd
create a separate shader for each because the keys differed, even
though the shaders were functionally equivalent.

Also fixes some issues around setting DEBUG_PROGRAM

Change-Id: I0c77c684d58da03501ee9ab8239c7d4a70fd6b5c
2013-03-01 11:11:31 -08:00
Steve Block
5baa3a62a9 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
2012-01-03 22:38:27 +00:00
Romain Guy
f3a910b423 Optimize state changes
Change-Id: Iae59bc8dfd6427d0967472462cc1994987092827
2011-12-12 20:35:21 -08:00
Romain Guy
24edca8b52 Code cleanup
Change-Id: If92e3addfc4d8546a60edcdea60a1fc89c27b680
2011-12-09 13:08:06 -08:00
Romain Guy
df0a7fbdcf Merge "Allows to render with an OpenGL context inside a TextureView." 2011-05-02 18:33:26 -07:00
Romain Guy
8f0095cd33 Allows to render with an OpenGL context inside a TextureView.
Change-Id: I59453f7fc3997f0502a1c5d325d37fed376fabc7
2011-05-02 18:32:29 -07:00
Chet Haase
99585adeb4 Line endcaps for AA lines are now antialiased.
Also fixed other minor issues with AA and line rendering.

Change-Id: Icd4638d27c70e2ee0f28b5d9a2b97d8b29e8ac4d
2011-05-02 15:08:38 -07:00
Romain Guy
aa6c24c21c New widget: TextureView
Bug #4343984

TextureView can be used to render media content (video, OpenGL,
RenderScript) inside a View.

The key difference with SurfaceView is that TextureView does
not create a new Surface. This gives the ability to seamlessly
transform, animate, fade, etc. a TextureView, which was hard
if not impossible to do with a SurfaceView.
A TextureView also interacts perfectly with ScrollView,
ListView, etc. It allows application to embed media content
in a much more flexible way than before.

For instance, to render the camera preview at 50% opacity,
all you need to do is the following:

mTextureView.setAlpha(0.5f);
Camera c = Camera.open();
c.setPreviewTexture(mTextureView.getSurfaceTexture());
c.startPreview();

TextureView uses a SurfaceTexture to get the job done. More
APIs are required to make it easy to create OpenGL contexts
for a TextureView. It can currently be done with a bit of
JNI code.

Change-Id: Iaa7953097ab5beb8437bcbbfa03b2df5b7f80cd7
2011-04-28 18:46:19 -07:00
Chet Haase
6fca9884b3 Minor cleanup in GLrenderer code
Changed the way we use bitcodes for one of the rendering
options to make the code cleaner.

Change-Id: Ifaa965f228dbdad297a40da93bfbe63373986e35
2011-04-25 14:50:04 -07:00
Chet Haase
6cfdf45380 Fix bitfield bug with vertex shader selection
Change-Id: I8bd3005f363afb52e6624806efb3e04c4a56ee18
2011-04-22 16:42:10 -07:00
Chet Haase
5b0200bd47 Enable anti-aliasing for hw-accelerated lines
Draw anti-aliased lines with OpenGL by constructing a quad with
a border that fades out (to mimic fragment coverage).

Change-Id: Ib81a3e62d663acdf1b46b401ac4aa7ee9855cc7e
2011-04-21 11:47:05 -07:00
Romain Guy
ed6fcb034b Add support for drawPoint() and drawPoints().
Change-Id: I01bef50c08ec3160f8d40dc060b2cf6c2e4d7639
2011-03-21 13:11:49 -07:00
Romain Guy
7b5b6abf85 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
2011-03-14 18:05:08 -07:00
Romain Guy
70ca14e08a Refactor OpenGLRenderer to simplify OpenGL drawing code.
This is the first step of the refactoring:
- drawColorRect
- drawTextureMesh

Remaining methods to refactor:
- setupTextureAlpha8
- drawPath
- setupShadow
- drawText
- drawLines
- composeLayerRegion

Change-Id: I0fced6a05b6b6eee10ee7cef0c3fbdaa6cefab20
2010-12-13 18:24:33 -08:00
Romain Guy
c15008e72e Move all debug flags in a single place.
This change also adds a new memory usage flag. When turned on, the
following is printed after every frame:

D/OpenGLRenderer( 3723): Current memory usage / total memory usage (bytes):
D/OpenGLRenderer( 3723):   TextureCache          3766680 / 20971520
D/OpenGLRenderer( 3723):   LayerCache            3538944 /  8388608
D/OpenGLRenderer( 3723):   GradientCache          135168 /   524288
D/OpenGLRenderer( 3723):   PathCache               41180 /  4194304
D/OpenGLRenderer( 3723):   TextDropShadowCache         0 /  2097152
D/OpenGLRenderer( 3723):   FontRenderer 0         262144 /   262144
D/OpenGLRenderer( 3723):   FontRenderer 1         262144 /   262144
D/OpenGLRenderer( 3723):   FontRenderer 2         262144 /   262144
D/OpenGLRenderer( 3723): Other:
D/OpenGLRenderer( 3723):   FboCache                    2 /       12
D/OpenGLRenderer( 3723):   PatchCache                 31 /      512
D/OpenGLRenderer( 3723): Total memory usage:
D/OpenGLRenderer( 3723):   8268404 bytes, 7.89 MB

This should help tracking possibe memory issues.

Change-Id: I83f483ca1d2dbef904829bce368e33fe5503e8d6
2010-11-10 11:59:15 -08:00
Romain Guy
5b3b35296e 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
2010-11-02 16:17:23 -07:00
Romain Guy
4afdf666fd Color filters were ignored by the program cache fast path.
Change-Id: I08f2f02d356234a674be778d088e0558fd49c849
2010-10-13 21:31:28 -07:00
Romain Guy
dbc26d2ba1 Don't draw fully transparent views/primitives.
Change-Id: Icd7d8ef1f57b51a24faf32f7004125e6300d4fdc
2010-10-11 17:58:29 -07:00
Romain Guy
707b2f78cc Optimize GLSL shaders.
Change-Id: I9a5e01bced63d8da0c61330a543a2b805388a59d
2010-10-11 16:34:59 -07:00
Romain Guy
ee916f14cb Add support for SweepGradient in the GL renderer.
Change-Id: I7aa397ed4e34655ead9ba1f5b4ce087665e0f022
2010-09-20 17:54:17 -07:00
Romain Guy
f607bdc167 Correct implementation of saveLayer().
Change-Id: I5375126636913e0a84f2d6bbd0ebe40d2e4f2763
2010-09-12 12:24:12 -07:00
Romain Guy
a5aed0d589 Add support for advanced blend modes with the framebuffer.
This adds the ability to blend with the framebuffer using Darken,
Lighten, Add, Multiply, Overlay and Screen.

Change-Id: Iae01a53797d4ad39c373cba6ff2a42293129da1a
2010-09-09 14:42:43 -07:00
Romain Guy
fb8b763f76 Use only one GL context per process, share chaches.
Change-Id: Ieabaa25338d2f4b8d4fd90e7401ad6e7452eae11
2010-08-24 17:18:14 -07:00
Romain Guy
98173a277f Delete shaders after a compile error. Also disable extra logging.
Change-Id: I9b1558b0feac3d9b2cca926feeaf73921664cc73
2010-08-11 16:40:25 -07:00
Romain Guy
48daa54d31 Add extra blending modes.
This change adds the following blending modes for shaders and color filters:
Add
Multiply
Screen
Overlay
Darken
Lighten

Change-Id: Iff22f5ce6041b43c71b1857d73013f5010ab3413
2010-08-10 21:42:40 -07:00
Romain Guy
db1938e0e6 Add support for ColorFilters.
Color filters are fully supported and can be used with shaders.

Change-Id: Id90ccf1c81cb462f2431f366f3f8f710d7971e04
2010-08-02 18:50:56 -07:00
Romain Guy
06f96e2652 Refactor Skia shaders handling.
With this change, Skia shaders can easily be applied to any mesh. This change also
supports ComposeShader. For instance, this can be used to blend a gradient and a
bitmap togehter and paint a string of text with the result.

Change-Id: I701c2f9cf7f89b2ff58005e8a1d0d80ccf4a4aea
2010-07-30 19:18:16 -07:00
Romain Guy
889f8d1403 Moved all the rendering code to the new shader generator.
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-29 14:37:42 -07:00
Romain Guy
ac670c0433 Generate shaders to cover all possible cases.
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-27 19:52:29 -07:00