forked from AuroraMiddleware/gtk
cssvalue: Change color transitions to run premultiplied
Previously, the unpremultiplied values from the GdkRGBA were taken. Now we premultiply the color values as specified by the CSS specs. This is only relevant when transitioning with translucent colors. An example is the halfway transition between transparent (0, 0, 0, 0) and white (1, 1, 1, 1). Previously, all 4 values where transitioned separately and the result was semi-transparent gray (0.5, 0.5, 0.5, 0.5). By depending on the alpha value, the result is now semi-transparent white (1, 1, 1, 0.5) which is what one would naively expect. New reftest: color-transition
This commit is contained in:
parent
142abce46a
commit
cd3f24d579
@ -74,9 +74,15 @@ gtk_css_value_rgba_transition (GtkCssValue *start,
|
||||
}
|
||||
else
|
||||
{
|
||||
result.red = transition (start->rgba.red, end->rgba.red, progress);
|
||||
result.green = transition (start->rgba.green, end->rgba.green, progress);
|
||||
result.blue = transition (start->rgba.blue, end->rgba.blue, progress);
|
||||
result.red = transition (start->rgba.red * start->rgba.alpha,
|
||||
end->rgba.red * end->rgba.alpha,
|
||||
progress) / result.alpha;
|
||||
result.green = transition (start->rgba.green * start->rgba.alpha,
|
||||
end->rgba.green * end->rgba.alpha,
|
||||
progress) / result.alpha;
|
||||
result.blue = transition (start->rgba.blue * start->rgba.alpha,
|
||||
end->rgba.blue * end->rgba.alpha,
|
||||
progress) / result.alpha;
|
||||
}
|
||||
|
||||
return _gtk_css_rgba_value_new_from_rgba (&result);
|
||||
|
@ -185,6 +185,9 @@ testdata = \
|
||||
cellrenderer-pixbuf-stock-rtl.css \
|
||||
cellrenderer-pixbuf-stock-rtl.ui \
|
||||
cellrenderer-pixbuf-stock-rtl.ref.ui \
|
||||
color-transition.css \
|
||||
color-transition.ref.ui \
|
||||
color-transition.ui \
|
||||
css-currentcolor-alpha.css \
|
||||
css-currentcolor-alpha.ui \
|
||||
css-currentcolor-alpha.ref.ui \
|
||||
|
18
testsuite/reftests/color-transition.css
Normal file
18
testsuite/reftests/color-transition.css
Normal file
@ -0,0 +1,18 @@
|
||||
@import "reset-to-defaults.css";
|
||||
|
||||
@keyframes foo {
|
||||
100% { background-color: blue; }
|
||||
}
|
||||
|
||||
GtkWindow {
|
||||
background-color: #7F0080;
|
||||
}
|
||||
|
||||
GtkBox {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
GtkBox GtkBox {
|
||||
background-color: transparent;
|
||||
animation: foo 100s steps(2);
|
||||
}
|
8
testsuite/reftests/color-transition.ref.ui
Normal file
8
testsuite/reftests/color-transition.ref.ui
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
</object>
|
||||
</interface>
|
25
testsuite/reftests/color-transition.ui
Normal file
25
testsuite/reftests/color-transition.ui
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
Loading…
Reference in New Issue
Block a user