SvgLoader: Use non-premultipied color
authorJunsuChoi <jsuya.choi@samsung.com>
Fri, 4 Sep 2020 03:11:08 +0000 (12:11 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 4 Sep 2020 03:22:38 +0000 (12:22 +0900)
Follow color policy of tvg:Shape.

Change-Id: I282c45de62225c01547988ec019cf31146524167

src/loaders/svg/tvgSvgSceneBuilder.cpp

index ad5bdca..a642730 100644 (file)
@@ -222,20 +222,17 @@ void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float vw, floa
         }
     } else if (style->fill.paint.curColor) {
         //Apply the current style color
-        float fa = ((float)style->fill.opacity / 255.0);
-        vg->fill(((float)style->r) * fa, ((float)style->g) * fa, ((float)style->b) * fa, style->fill.opacity);
+        vg->fill(style->r, style->g, style->b, style->fill.opacity);
     } else {
         //Apply the fill color
-        float fa = ((float)style->fill.opacity / 255.0);
-        vg->fill(((float)style->fill.paint.r) * fa, ((float)style->fill.paint.g) * fa, ((float)style->fill.paint.b) * fa, style->fill.opacity);
+        vg->fill(style->fill.paint.r, style->fill.paint.g, style->fill.paint.b, style->fill.opacity);
     }
 
     //Apply node opacity
     if (style->opacity < 255) {
         uint8_t r, g, b, a;
         vg->fill(&r, &g, &b, &a);
-        float fa = ((float)style->opacity / 255.0);
-        vg->fill(((float)r) * fa, ((float)g) * fa, ((float)b) * fa, ((float)a) * fa);
+        vg->fill(r, g, b, (a * style->opacity) / 255.0);
     }
 
     if (node->type == SvgNodeType::G) return;
@@ -266,8 +263,7 @@ void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float vw, floa
     if (style->opacity < 255) {
         uint8_t r, g, b, a;
         vg->strokeColor(&r, &g, &b, &a);
-        float fa = ((float)style->opacity / 255.0);
-        vg->stroke(((float)r) * fa, ((float)g) * fa, ((float)b) * fa, ((float)a) * fa);
+        vg->stroke(r, g, b, (a * style->opacity) / 255.0);
     }
 }
 
@@ -369,4 +365,4 @@ unique_ptr<Scene> SvgSceneBuilder::build(SvgNode* node)
     viewBox.h = node->node.doc.vh;
     preserveAspect = node->node.doc.preserveAspect;
     return _sceneBuildHelper(node, viewBox.x, viewBox.y, viewBox.w, viewBox.h, 255);
-}
\ No newline at end of file
+}