am 7808581c: Merge "Pre-multiply color components for 2-stop gradients Bug #7033344" into jb-mr1-dev
* commit '7808581ca3b462fb187aed6b0d1b86fb83a8a215': Pre-multiply color components for 2-stop gradients Bug #7033344
This commit is contained in:
@@ -17625,23 +17625,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
// use use a height of 1, and then wack the matrix each time we
|
||||
// actually use it.
|
||||
shader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP);
|
||||
|
||||
paint.setShader(shader);
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
|
||||
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void setFadeColor(int color) {
|
||||
if (color != 0 && color != mLastColor) {
|
||||
if (color != mLastColor) {
|
||||
mLastColor = color;
|
||||
color |= 0xFF000000;
|
||||
|
||||
shader = new LinearGradient(0, 0, 0, 1, color | 0xFF000000,
|
||||
color & 0x00FFFFFF, Shader.TileMode.CLAMP);
|
||||
|
||||
paint.setShader(shader);
|
||||
// Restore the default transfer mode (src_over)
|
||||
paint.setXfermode(null);
|
||||
if (color != 0) {
|
||||
shader = new LinearGradient(0, 0, 0, 1, color | 0xFF000000,
|
||||
color & 0x00FFFFFF, Shader.TileMode.CLAMP);
|
||||
paint.setShader(shader);
|
||||
// Restore the default transfer mode (src_over)
|
||||
paint.setXfermode(null);
|
||||
} else {
|
||||
shader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP);
|
||||
paint.setShader(shader);
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,10 +217,12 @@ void GradientCache::generateTexture(uint32_t* colors, float* positions,
|
||||
float amount = (pos - start) / distance;
|
||||
float oppAmount = 1.0f - amount;
|
||||
|
||||
*p++ = uint8_t(startR * oppAmount + endR * amount);
|
||||
*p++ = uint8_t(startG * oppAmount + endG * amount);
|
||||
*p++ = uint8_t(startB * oppAmount + endB * amount);
|
||||
*p++ = uint8_t(startA * oppAmount + endA * amount);
|
||||
const float alpha = startA * oppAmount + endA * amount;
|
||||
const float a = alpha / 255.0f;
|
||||
*p++ = uint8_t(a * (startR * oppAmount + endR * amount));
|
||||
*p++ = uint8_t(a * (startG * oppAmount + endG * amount));
|
||||
*p++ = uint8_t(a * (startB * oppAmount + endB * amount));
|
||||
*p++ = uint8_t(alpha);
|
||||
}
|
||||
|
||||
for (int i = 1; i < GRADIENT_TEXTURE_HEIGHT; i++) {
|
||||
|
||||
@@ -46,11 +46,12 @@ static inline bool isPowerOfTwo(unsigned int n) {
|
||||
}
|
||||
|
||||
static inline void bindUniformColor(int slot, uint32_t color) {
|
||||
const float a = ((color >> 24) & 0xff) / 255.0f;
|
||||
glUniform4f(slot,
|
||||
((color >> 16) & 0xff) / 255.0f,
|
||||
((color >> 8) & 0xff) / 255.0f,
|
||||
((color ) & 0xff) / 255.0f,
|
||||
((color >> 24) & 0xff) / 255.0f);
|
||||
a * ((color >> 16) & 0xff) / 255.0f,
|
||||
a * ((color >> 8) & 0xff) / 255.0f,
|
||||
a * ((color ) & 0xff) / 255.0f,
|
||||
a);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -154,10 +155,6 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView,
|
||||
|
||||
// Uniforms
|
||||
bindTexture(texture, mWrapS, mWrapT);
|
||||
// Assume linear here; we should really check the transform in
|
||||
// ::updateTransforms() but we don't have the texture object
|
||||
// available at that point. The optimization is not worth the
|
||||
// effort for now.
|
||||
texture->setFilter(GL_LINEAR);
|
||||
|
||||
glUniform1i(program->getUniform("bitmapSampler"), textureSlot);
|
||||
@@ -166,14 +163,6 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView,
|
||||
glUniform2f(program->getUniform("textureDimension"), 1.0f / width, 1.0f / height);
|
||||
}
|
||||
|
||||
void SkiaBitmapShader::updateTransforms(Program* program, const mat4& modelView,
|
||||
const Snapshot& snapshot) {
|
||||
mat4 textureTransform;
|
||||
computeScreenSpaceMatrix(textureTransform, modelView);
|
||||
glUniformMatrix4fv(program->getUniform("textureTransform"), 1,
|
||||
GL_FALSE, &textureTransform.data[0]);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Linear gradient shader
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -257,13 +246,6 @@ void SkiaLinearGradientShader::setupProgram(Program* program, const mat4& modelV
|
||||
glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
|
||||
}
|
||||
|
||||
void SkiaLinearGradientShader::updateTransforms(Program* program, const mat4& modelView,
|
||||
const Snapshot& snapshot) {
|
||||
mat4 screenSpace;
|
||||
computeScreenSpaceMatrix(screenSpace, modelView);
|
||||
glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Circular gradient shader
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -384,13 +366,6 @@ void SkiaSweepGradientShader::setupProgram(Program* program, const mat4& modelVi
|
||||
glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
|
||||
}
|
||||
|
||||
void SkiaSweepGradientShader::updateTransforms(Program* program, const mat4& modelView,
|
||||
const Snapshot& snapshot) {
|
||||
mat4 screenSpace;
|
||||
computeScreenSpaceMatrix(screenSpace, modelView);
|
||||
glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Compose shader
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -82,10 +82,6 @@ struct SkiaShader {
|
||||
mGradientCache = gradientCache;
|
||||
}
|
||||
|
||||
virtual void updateTransforms(Program* program, const mat4& modelView,
|
||||
const Snapshot& snapshot) {
|
||||
}
|
||||
|
||||
uint32_t getGenerationId() {
|
||||
return mGenerationId;
|
||||
}
|
||||
@@ -148,7 +144,6 @@ struct SkiaBitmapShader: public SkiaShader {
|
||||
void describe(ProgramDescription& description, const Extensions& extensions);
|
||||
void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
|
||||
GLuint* textureUnit);
|
||||
void updateTransforms(Program* program, const mat4& modelView, const Snapshot& snapshot);
|
||||
|
||||
private:
|
||||
SkiaBitmapShader() {
|
||||
@@ -172,7 +167,6 @@ struct SkiaLinearGradientShader: public SkiaShader {
|
||||
void describe(ProgramDescription& description, const Extensions& extensions);
|
||||
void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
|
||||
GLuint* textureUnit);
|
||||
void updateTransforms(Program* program, const mat4& modelView, const Snapshot& snapshot);
|
||||
|
||||
private:
|
||||
SkiaLinearGradientShader() {
|
||||
@@ -197,7 +191,6 @@ struct SkiaSweepGradientShader: public SkiaShader {
|
||||
virtual void describe(ProgramDescription& description, const Extensions& extensions);
|
||||
void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
|
||||
GLuint* textureUnit);
|
||||
void updateTransforms(Program* program, const mat4& modelView, const Snapshot& snapshot);
|
||||
|
||||
protected:
|
||||
SkiaSweepGradientShader(Type type, float x, float y, uint32_t* colors, float* positions,
|
||||
|
||||
Reference in New Issue
Block a user