System/Libraries/Graphics2D: Add member 'opacity' to Context2D
This is meant to be used for alpha blending in the Compositor, unrelated to the context's own alpha channel.
This commit is contained in:
parent
f2800ba2d6
commit
a9c623685d
1 changed files with 7 additions and 1 deletions
|
@ -5,6 +5,7 @@ class @context2d
|
||||||
I64 width;
|
I64 width;
|
||||||
I64 height;
|
I64 height;
|
||||||
U32* fb;
|
U32* fb;
|
||||||
|
I64 opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
class @callable_context2d : @context2d
|
class @callable_context2d : @context2d
|
||||||
|
@ -811,12 +812,17 @@ U0 Blot2D(Context2D* dst, I64 x, I64 y, Context2D* src)
|
||||||
I64 xx, yy;
|
I64 xx, yy;
|
||||||
I64 src_col, dst_col;
|
I64 src_col, dst_col;
|
||||||
F64 alpha;
|
F64 alpha;
|
||||||
|
I64 plot_col;
|
||||||
for (yy = 0; yy < src->height; yy++) {
|
for (yy = 0; yy < src->height; yy++) {
|
||||||
for (xx = 0; xx < src->width; xx++) {
|
for (xx = 0; xx < src->width; xx++) {
|
||||||
src_col = Peek2D(src, xx, yy);
|
src_col = Peek2D(src, xx, yy);
|
||||||
dst_col = Peek2D(dst, x + xx, y + yy);
|
dst_col = Peek2D(dst, x + xx, y + yy);
|
||||||
alpha = src_col.u8[3] / 128; // FIXME: Alpha blending not working correctly.
|
alpha = src_col.u8[3] / 128; // FIXME: Alpha blending not working correctly.
|
||||||
Plot2D(dst, x + xx, y + yy, Blend2D(alpha, dst_col, src_col));
|
plot_col = Blend2D(alpha, dst_col, src_col);
|
||||||
|
if (src->opacity) {
|
||||||
|
plot_col.u8[3] = src->opacity;
|
||||||
|
}
|
||||||
|
Plot2D(dst, x + xx, y + yy, plot_col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue