-
-
Notifications
You must be signed in to change notification settings - Fork 171
Closed
Labels
cpuSoftware render backendSoftware render backendenhancementImprove featuresImprove featuresglOpenGL/WebGL render backendOpenGL/WebGL render backendwebgpuWebGPU render backendWebGPU render backend
Milestone
Description
I'm currently trying to refactor the advanced color blending logic of the GL backend. I'm confused by some of Thorvg's behaviors on color blending.
The main problem is that I found that the behavior of blend mode is inconsistent when applied to a normal Shape or to a Scene.
For example:
//Normal
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50);
shape1->fill(0, 255, 255);
shape1->blend(tvg::BlendMethod::Normal);
canvas->push(shape1);
// direct draw shape with blend mode
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 200, 200, 50, 50);
shape->fill(255, 255, 255, 250);
shape->blend(tvg::BlendMethod::ColorDodge);
canvas->push(shape);
This code get the following result:
But if put the shape inside a scene, even if the scene only contains one shape, like this:
//Normal
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50);
shape1->fill(0, 255, 255);
shape1->blend(tvg::BlendMethod::Normal);
canvas->push(shape1);
//ColorDodge On the scene
auto scene = tvg::Scene::gen();
scene->blend(tvg::BlendMethod::ColorDodge);
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 200, 200, 50, 50);
shape->fill(255, 255, 255, 250);
scene->push(shape);
canvas->push(scene);
Some blend modes seem to draw nothing when DstColor is all zeros, and this behavior is different from skia or impeller or html & css.
I'm going to align SKIA's Blend behavior in the GL backend by following this reference : https://github.com/google/skia/blob/main/include/core/SkBlendMode.h
Metadata
Metadata
Assignees
Labels
cpuSoftware render backendSoftware render backendenhancementImprove featuresImprove featuresglOpenGL/WebGL render backendOpenGL/WebGL render backendwebgpuWebGPU render backendWebGPU render backend
Type
Projects
Status
Done 1.0