diff options
author | Romain Guy <romainguy@android.com> | 2010-07-16 17:10:13 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-07-16 17:10:13 -0700 |
commit | 7fac2e18339f765320d759e8d4c090f92431959e (patch) | |
tree | 1761c4f41ecd783a85220efcbcacb04d784d96cf /libs/hwui/OpenGLRenderer.cpp | |
parent | 1e79386ba34f0db38c1b35b22cdf122632534354 (diff) | |
download | frameworks_base-7fac2e18339f765320d759e8d4c090f92431959e.zip frameworks_base-7fac2e18339f765320d759e8d4c090f92431959e.tar.gz frameworks_base-7fac2e18339f765320d759e8d4c090f92431959e.tar.bz2 |
Add plumbing to support gradients in OpenGL renderer.
The LinearGradient class keeps a copy of the various parameters that
define the gradient. The copies are native arrays to avoid copying
Java arrays on every draw call. The gradient code path is implemented
until OpenGLRenderer::drawRect() (see TODO.) The actual gradient
implementation will be added in a latter change.
Change-Id: I9300d250ef5e2e9c2e097c3116ee71dfc9d752d8
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 0bf0e89..1431563 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -528,7 +528,7 @@ void OpenGLRenderer::resetShader() { void OpenGLRenderer::setupBitmapShader(SkBitmap* bitmap, SkShader::TileMode tileX, SkShader::TileMode tileY, SkMatrix* matrix, bool hasAlpha) { - mShader = kShaderBitmap; + mShader = OpenGLRenderer::kShaderBitmap; mShaderBlend = hasAlpha; mShaderBitmap = bitmap; mShaderTileX = tileX; @@ -536,6 +536,18 @@ void OpenGLRenderer::setupBitmapShader(SkBitmap* bitmap, SkShader::TileMode tile mShaderMatrix = matrix; } +void OpenGLRenderer::setupLinearGradientShader(float* bounds, uint32_t* colors, + float* positions, SkShader::TileMode tileMode, SkMatrix* matrix, bool hasAlpha) { + mShader = OpenGLRenderer::kShaderLinearGradient; + mShaderBlend = hasAlpha; + mShaderTileX = tileMode; + mShaderTileY = tileMode; + mShaderMatrix = matrix; + mShaderBounds = bounds; + mShaderColors = colors; + mShaderPositions = positions; +} + /////////////////////////////////////////////////////////////////////////////// // Drawing implementation /////////////////////////////////////////////////////////////////////////////// @@ -555,9 +567,12 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot const GLfloat b = a * ((color ) & 0xFF) / 255.0f; switch (mShader) { - case kShaderBitmap: + case OpenGLRenderer::kShaderBitmap: drawBitmapShader(left, top, right, bottom, a, mode); return; + case OpenGLRenderer::kShaderLinearGradient: + // TODO: Generate gradient texture, set appropriate shader + break; default: break; } |