mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
gpu: eliminate gaps by ensuring consistent transformations
This is another attempt at fixing the issue described in [0], the previous attempt was reverted[1]. This change fixes the issue by tracking resolved transformations and ensure that all segments within a path share a single transformation. [0] https://github.com/linebender/piet-gpu/issues/62 [1] https://gioui.org/commit/2b21b48a7c5c4451deb642c164548a134bb9ad06 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+14
-6
@@ -20,9 +20,10 @@ struct PathFillCubic {
|
||||
vec2 p2;
|
||||
vec2 p3;
|
||||
uint path_ix;
|
||||
uint trans_ix;
|
||||
};
|
||||
|
||||
#define PathFillCubic_size 36
|
||||
#define PathFillCubic_size 40
|
||||
|
||||
PathFillCubicRef PathFillCubic_index(PathFillCubicRef ref, uint index) {
|
||||
return PathFillCubicRef(ref.offset + index * PathFillCubic_size);
|
||||
@@ -34,10 +35,11 @@ struct PathStrokeCubic {
|
||||
vec2 p2;
|
||||
vec2 p3;
|
||||
uint path_ix;
|
||||
uint trans_ix;
|
||||
vec2 stroke;
|
||||
};
|
||||
|
||||
#define PathStrokeCubic_size 44
|
||||
#define PathStrokeCubic_size 48
|
||||
|
||||
PathStrokeCubicRef PathStrokeCubic_index(PathStrokeCubicRef ref, uint index) {
|
||||
return PathStrokeCubicRef(ref.offset + index * PathStrokeCubic_size);
|
||||
@@ -46,7 +48,7 @@ PathStrokeCubicRef PathStrokeCubic_index(PathStrokeCubicRef ref, uint index) {
|
||||
#define PathSeg_Nop 0
|
||||
#define PathSeg_FillCubic 1
|
||||
#define PathSeg_StrokeCubic 2
|
||||
#define PathSeg_size 48
|
||||
#define PathSeg_size 52
|
||||
|
||||
PathSegRef PathSeg_index(PathSegRef ref, uint index) {
|
||||
return PathSegRef(ref.offset + index * PathSeg_size);
|
||||
@@ -63,12 +65,14 @@ PathFillCubic PathFillCubic_read(Alloc a, PathFillCubicRef ref) {
|
||||
uint raw6 = read_mem(a, ix + 6);
|
||||
uint raw7 = read_mem(a, ix + 7);
|
||||
uint raw8 = read_mem(a, ix + 8);
|
||||
uint raw9 = read_mem(a, ix + 9);
|
||||
PathFillCubic s;
|
||||
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
|
||||
s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
|
||||
s.path_ix = raw8;
|
||||
s.trans_ix = raw9;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -83,6 +87,7 @@ void PathFillCubic_write(Alloc a, PathFillCubicRef ref, PathFillCubic s) {
|
||||
write_mem(a, ix + 6, floatBitsToUint(s.p3.x));
|
||||
write_mem(a, ix + 7, floatBitsToUint(s.p3.y));
|
||||
write_mem(a, ix + 8, s.path_ix);
|
||||
write_mem(a, ix + 9, s.trans_ix);
|
||||
}
|
||||
|
||||
PathStrokeCubic PathStrokeCubic_read(Alloc a, PathStrokeCubicRef ref) {
|
||||
@@ -98,13 +103,15 @@ PathStrokeCubic PathStrokeCubic_read(Alloc a, PathStrokeCubicRef ref) {
|
||||
uint raw8 = read_mem(a, ix + 8);
|
||||
uint raw9 = read_mem(a, ix + 9);
|
||||
uint raw10 = read_mem(a, ix + 10);
|
||||
uint raw11 = read_mem(a, ix + 11);
|
||||
PathStrokeCubic s;
|
||||
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
|
||||
s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
|
||||
s.path_ix = raw8;
|
||||
s.stroke = vec2(uintBitsToFloat(raw9), uintBitsToFloat(raw10));
|
||||
s.trans_ix = raw9;
|
||||
s.stroke = vec2(uintBitsToFloat(raw10), uintBitsToFloat(raw11));
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -119,8 +126,9 @@ void PathStrokeCubic_write(Alloc a, PathStrokeCubicRef ref, PathStrokeCubic s) {
|
||||
write_mem(a, ix + 6, floatBitsToUint(s.p3.x));
|
||||
write_mem(a, ix + 7, floatBitsToUint(s.p3.y));
|
||||
write_mem(a, ix + 8, s.path_ix);
|
||||
write_mem(a, ix + 9, floatBitsToUint(s.stroke.x));
|
||||
write_mem(a, ix + 10, floatBitsToUint(s.stroke.y));
|
||||
write_mem(a, ix + 9, s.trans_ix);
|
||||
write_mem(a, ix + 10, floatBitsToUint(s.stroke.x));
|
||||
write_mem(a, ix + 11, floatBitsToUint(s.stroke.y));
|
||||
}
|
||||
|
||||
uint PathSeg_tag(Alloc a, PathSegRef ref) {
|
||||
|
||||
Reference in New Issue
Block a user