diff options
author | Chris Craik <ccraik@google.com> | 2014-04-15 16:18:08 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2014-04-23 16:15:11 -0700 |
commit | 3f085429fd47ebd32ac2463b3eae2a5a6c17be25 (patch) | |
tree | 2930b7ee50ce98092fde97546a3d546c817038f1 /libs/hwui/SkiaShader.cpp | |
parent | fbb54b8363b66e0b22d519ee20d1a50e8b5340ee (diff) | |
download | frameworks_base-3f085429fd47ebd32ac2463b3eae2a5a6c17be25.zip frameworks_base-3f085429fd47ebd32ac2463b3eae2a5a6c17be25.tar.gz frameworks_base-3f085429fd47ebd32ac2463b3eae2a5a6c17be25.tar.bz2 |
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
Diffstat (limited to 'libs/hwui/SkiaShader.cpp')
-rw-r--r-- | libs/hwui/SkiaShader.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp index 4f2a432..6a4a0c8 100644 --- a/libs/hwui/SkiaShader.cpp +++ b/libs/hwui/SkiaShader.cpp @@ -73,7 +73,7 @@ SkiaShader::SkiaShader(): mCaches(NULL) { } SkiaShader::SkiaShader(Type type, SkShader* key, SkShader::TileMode tileX, - SkShader::TileMode tileY, SkMatrix* matrix, bool blend): + SkShader::TileMode tileY, const SkMatrix* matrix, bool blend): mType(type), mKey(key), mTileX(tileX), mTileY(tileY), mBlend(blend), mCaches(NULL) { setMatrix(matrix); @@ -101,6 +101,49 @@ void SkiaShader::computeScreenSpaceMatrix(mat4& screenSpace, const mat4& modelVi } /////////////////////////////////////////////////////////////////////////////// +// Layer shader +/////////////////////////////////////////////////////////////////////////////// + +SkiaLayerShader::SkiaLayerShader(Layer* layer, const SkMatrix* matrix): + SkiaShader(kBitmap, NULL, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, + matrix, layer->isBlend()), mLayer(layer) { + updateLocalMatrix(matrix); +} + +SkiaShader* SkiaLayerShader::copy() { + SkiaLayerShader* copy = new SkiaLayerShader(); + copy->copyFrom(*this); + copy->mLayer = mLayer; + return copy; +} + +void SkiaLayerShader::describe(ProgramDescription& description, const Extensions& extensions) { + description.hasBitmap = true; +} + +void SkiaLayerShader::setupProgram(Program* program, const mat4& modelView, + const Snapshot& snapshot, GLuint* textureUnit) { + GLuint textureSlot = (*textureUnit)++; + Caches::getInstance().activeTexture(textureSlot); + + const float width = mLayer->getWidth(); + const float height = mLayer->getHeight(); + + mat4 textureTransform; + computeScreenSpaceMatrix(textureTransform, modelView); + + // Uniforms + mLayer->bindTexture(); + mLayer->setWrap(GL_CLAMP_TO_EDGE); + mLayer->setFilter(GL_LINEAR); + + glUniform1i(program->getUniform("bitmapSampler"), textureSlot); + glUniformMatrix4fv(program->getUniform("textureTransform"), 1, + GL_FALSE, &textureTransform.data[0]); + glUniform2f(program->getUniform("textureDimension"), 1.0f / width, 1.0f / height); +} + +/////////////////////////////////////////////////////////////////////////////// // Bitmap shader /////////////////////////////////////////////////////////////////////////////// |