mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
gpu, op, internal/ops: add affine transformations
Add support for affine transformations. The key changes are outlined below. - Painting/clipping with rectangles is handled by, for complex transforms, creating clipping paths representing the transformed rectangle and using a larger bounding box. Cover/Blit shaders updated correspondingly to correctly map texture cordinates from the new bounding boxes. - Since path splitting must happen on CPU the transforms must happen CPU side as well - offsets removed from shaders. - Complex transforms will lead to different path splitting which means that GPU arrays can no longer be cached if the transform has changed. Thus the current transform is added as a key to the cache. - Add a public API to op for setting Affine transformations. There are a number of optimizations that could be explored further but which are left out now: - Caching also of CPU operations (e.g path splitting & transforms) and not only caching the GPU arrays. - Allow for re-use of cached GPU vertices if the transformation change is a pure offset / scaling since the splitting is then the same. Signed-off-by: Viktor <viktor.ogeman@gmail.com>
This commit is contained in:
@@ -8,7 +8,8 @@ precision highp float;
|
||||
|
||||
layout(binding = 0) uniform Block {
|
||||
vec4 transform;
|
||||
vec4 uvTransform;
|
||||
vec4 uvTransformR1;
|
||||
vec4 uvTransformR2;
|
||||
float z;
|
||||
};
|
||||
|
||||
@@ -21,5 +22,5 @@ layout(location = 0) out vec2 vUV;
|
||||
void main() {
|
||||
vec2 p = pos*transform.xy + transform.zw;
|
||||
gl_Position = toClipSpace(vec4(p, z, 1));
|
||||
vUV = uv*uvTransform.xy + uvTransform.zw;
|
||||
vUV = transform3x2(m3x2(uvTransformR1.xyz, uvTransformR2.xyz), vec3(uv,1)).xy;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ precision highp float;
|
||||
layout(binding = 0) uniform Block {
|
||||
vec4 transform;
|
||||
vec4 uvCoverTransform;
|
||||
vec4 uvTransform;
|
||||
vec4 uvTransformR1;
|
||||
vec4 uvTransformR2;
|
||||
float z;
|
||||
};
|
||||
|
||||
@@ -22,7 +23,7 @@ layout(location = 1) out vec2 vUV;
|
||||
|
||||
void main() {
|
||||
gl_Position = toClipSpace(vec4(pos*transform.xy + transform.zw, z, 1));
|
||||
vUV = uv*uvTransform.xy + uvTransform.zw;
|
||||
vUV = transform3x2(m3x2(uvTransformR1.xyz, uvTransformR2.xyz), vec3(uv,1)).xy;
|
||||
vec3 uv3 = transform3x2(fboTextureTransform, vec3(uv, 1.0));
|
||||
vCoverUV = (uv3*vec3(uvCoverTransform.xy, 1.0)+vec3(uvCoverTransform.zw, 0.0)).xy;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ precision highp float;
|
||||
|
||||
layout(binding = 0) uniform Block {
|
||||
vec4 transform;
|
||||
vec2 pathOffset;
|
||||
};
|
||||
|
||||
layout(location=0) in float corner;
|
||||
@@ -23,10 +22,10 @@ void main() {
|
||||
// Add a one pixel overlap so curve quads cover their
|
||||
// entire curves. Could use conservative rasterization
|
||||
// if available.
|
||||
vec2 from = from + pathOffset;
|
||||
vec2 ctrl = ctrl + pathOffset;
|
||||
vec2 to = to + pathOffset;
|
||||
float maxy = maxy + pathOffset.y;
|
||||
vec2 from = from;
|
||||
vec2 ctrl = ctrl;
|
||||
vec2 to = to;
|
||||
float maxy = maxy;
|
||||
vec2 pos;
|
||||
float c = corner;
|
||||
if (c >= 0.375) {
|
||||
|
||||
Reference in New Issue
Block a user