previously, opacity value is ignored to gradient fill.
This patch implements that case.
Change-Id: Iaaba617659e708d1484ca9b2256395397cc95a33
bool shapeGenStrokeRle(SwShape* shape, const Shape* sdata, unsigned tid, const Matrix* transform, const SwSize& clip, SwBBox& bbox);
void shapeFree(SwShape* shape);
void shapeDelStroke(SwShape* shape);
-bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix* transform, SwSurface* surface, bool ctable);
+bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix* transform, SwSurface* surface, uint32_t opacity, bool ctable);
void shapeResetFill(SwShape* shape);
void shapeDelFill(SwShape* shape);
bool imageGenOutline(SwImage* image, const Picture* pdata, unsigned tid, const Matrix* transform);
void imageFree(SwImage* image);
-bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform, SwSurface* surface, bool ctable);
+bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform, SwSurface* surface, uint32_t opacity, bool ctable);
void fillReset(SwFill* fill);
void fillFree(SwFill* fill);
void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t offset, uint32_t len);
#define FIXPT_SIZE (1<<FIXPT_BITS)
-static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surface)
+static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surface, uint32_t opacity)
{
if (!fill->ctable) {
fill->ctable = static_cast<uint32_t*>(malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
auto pColors = colors;
- if (pColors->a < 255) fill->translucent = true;
+ auto a = (pColors->a * opacity) / 255;
+ if (a < 255) fill->translucent = true;
- auto r = ALPHA_MULTIPLY(pColors->r, pColors->a);
- auto g = ALPHA_MULTIPLY(pColors->g, pColors->a);
- auto b = ALPHA_MULTIPLY(pColors->b, pColors->a);
+ auto r = ALPHA_MULTIPLY(pColors->r, a);
+ auto g = ALPHA_MULTIPLY(pColors->g, a);
+ auto b = ALPHA_MULTIPLY(pColors->b, a);
- auto rgba = surface->blender.join(r, g, b, pColors->a);
+ auto rgba = surface->blender.join(r, g, b, a);
auto inc = 1.0f / static_cast<float>(GRADIENT_STOP_SIZE);
auto pos = 1.5f * inc;
uint32_t i = 0;
auto curr = colors + j;
auto next = curr + 1;
auto delta = 1.0f / (next->offset - curr->offset);
- if (next->a < 255) fill->translucent = true;
+ a = (next->a * opacity) / 255;
+ if (!fill->translucent && a < 255) fill->translucent = true;
- auto r = ALPHA_MULTIPLY(next->r, next->a);
- auto g = ALPHA_MULTIPLY(next->g, next->a);
- auto b = ALPHA_MULTIPLY(next->b, next->a);
+ auto r = ALPHA_MULTIPLY(next->r, a);
+ auto g = ALPHA_MULTIPLY(next->g, a);
+ auto b = ALPHA_MULTIPLY(next->b, a);
- auto rgba2 = surface->blender.join(r, g, b, next->a);
+ auto rgba2 = surface->blender.join(r, g, b, a);
while (pos < next->offset && i < GRADIENT_STOP_SIZE) {
auto t = (pos - curr->offset) * delta;
}
-bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform, SwSurface* surface, bool ctable)
+bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform, SwSurface* surface, uint32_t opacity, bool ctable)
{
if (!fill) return false;
fill->spread = fdata->spread();
if (ctable) {
- if (!_updateColorTable(fill, fdata, surface)) return false;
+ if (!_updateColorTable(fill, fdata, surface, opacity)) return false;
}
if (fdata->id() == FILL_ID_LINEAR) {
}
//Fill
- if (flags & (RenderUpdateFlag::Gradient | RenderUpdateFlag::Transform)) {
+ if (flags & (RenderUpdateFlag::Gradient | RenderUpdateFlag::Transform | RenderUpdateFlag::Color)) {
auto fill = sdata->fill();
if (fill) {
auto ctable = (flags & RenderUpdateFlag::Gradient) ? true : false;
if (ctable) shapeResetFill(&shape);
- if (!shapeGenFillColors(&shape, fill, transform, surface, ctable)) goto end;
+ if (!shapeGenFillColors(&shape, fill, transform, surface, opacity, ctable)) goto end;
+ ++addStroking;
} else {
shapeDelFill(&shape);
}
}
end:
shapeDelOutline(&shape, tid);
- if (addStroking == 2 && opacity < 255) cmpStroking = true;
+ if (addStroking > 1 && opacity < 255) cmpStroking = true;
else cmpStroking = false;
}
uint8_t r, g, b, a;
if (auto fill = task->sdata->fill()) {
- //FIXME: pass opacity to apply gradient fill?
rasterGradientShape(surface, &task->shape, fill->id());
} else{
task->sdata->fillColor(&r, &g, &b, &a);
}
-bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix* transform, SwSurface* surface, bool ctable)
+bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix* transform, SwSurface* surface, uint32_t opacity, bool ctable)
{
- return fillGenColorTable(shape->fill, fill, transform, surface, ctable);
+ return fillGenColorTable(shape->fill, fill, transform, surface, opacity, ctable);
}