mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Update WebRender to get the latest changes
This commit is contained in:
parent
8a12c15582
commit
0a13c05479
20 changed files with 650 additions and 445 deletions
|
@ -3,42 +3,79 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#define PST_TOP_LEFT uint(0)
|
||||
#define PST_TOP_RIGHT uint(1)
|
||||
#define PST_BOTTOM_LEFT uint(2)
|
||||
#define PST_BOTTOM_RIGHT uint(3)
|
||||
#define PST_TOP uint(4)
|
||||
#define PST_LEFT uint(5)
|
||||
#define PST_BOTTOM uint(6)
|
||||
#define PST_RIGHT uint(7)
|
||||
#define PST_TOP_LEFT 0
|
||||
#define PST_TOP 1
|
||||
#define PST_TOP_RIGHT 2
|
||||
#define PST_RIGHT 3
|
||||
#define PST_BOTTOM_RIGHT 4
|
||||
#define PST_BOTTOM 5
|
||||
#define PST_BOTTOM_LEFT 6
|
||||
#define PST_LEFT 7
|
||||
|
||||
#define BORDER_LEFT 0
|
||||
#define BORDER_TOP 1
|
||||
#define BORDER_RIGHT 2
|
||||
#define BORDER_BOTTOM 3
|
||||
|
||||
#define UV_NORMALIZED uint(0)
|
||||
#define UV_PIXEL uint(1)
|
||||
|
||||
// Border styles as defined in webrender_traits/types.rs
|
||||
#define BORDER_STYLE_NONE uint(0)
|
||||
#define BORDER_STYLE_SOLID uint(1)
|
||||
#define BORDER_STYLE_DOUBLE uint(2)
|
||||
#define BORDER_STYLE_DOTTED uint(3)
|
||||
#define BORDER_STYLE_DASHED uint(4)
|
||||
#define BORDER_STYLE_HIDDEN uint(5)
|
||||
#define BORDER_STYLE_GROOVE uint(6)
|
||||
#define BORDER_STYLE_RIDGE uint(7)
|
||||
#define BORDER_STYLE_INSET uint(8)
|
||||
#define BORDER_STYLE_OUTSET uint(9)
|
||||
#define BORDER_STYLE_NONE 0
|
||||
#define BORDER_STYLE_SOLID 1
|
||||
#define BORDER_STYLE_DOUBLE 2
|
||||
#define BORDER_STYLE_DOTTED 3
|
||||
#define BORDER_STYLE_DASHED 4
|
||||
#define BORDER_STYLE_HIDDEN 5
|
||||
#define BORDER_STYLE_GROOVE 6
|
||||
#define BORDER_STYLE_RIDGE 7
|
||||
#define BORDER_STYLE_INSET 8
|
||||
#define BORDER_STYLE_OUTSET 9
|
||||
|
||||
#define MAX_STOPS_PER_ANGLE_GRADIENT 8
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
|
||||
#define VECS_PER_LAYER 13
|
||||
#define LAYERS_PER_ROW (WR_MAX_VERTEX_TEXTURE_WIDTH / VECS_PER_LAYER)
|
||||
#define VECS_PER_LAYER 13
|
||||
#define VECS_PER_TILE 2
|
||||
#define VECS_PER_PRIM_GEOM 2
|
||||
|
||||
#define VECS_PER_TILE 2
|
||||
#define TILES_PER_ROW (WR_MAX_VERTEX_TEXTURE_WIDTH / VECS_PER_TILE)
|
||||
#define GRADIENT_HORIZONTAL 0
|
||||
#define GRADIENT_VERTICAL 1
|
||||
#define GRADIENT_ROTATED 2
|
||||
|
||||
uniform sampler2D sLayers;
|
||||
uniform sampler2D sRenderTasks;
|
||||
uniform sampler2D sPrimGeometry;
|
||||
uniform sampler2D sClips;
|
||||
|
||||
uniform sampler2D sData16;
|
||||
uniform sampler2D sData32;
|
||||
uniform sampler2D sData64;
|
||||
uniform sampler2D sData128;
|
||||
|
||||
ivec2 get_fetch_uv(int index, int vecs_per_item) {
|
||||
int items_per_row = WR_MAX_VERTEX_TEXTURE_WIDTH / vecs_per_item;
|
||||
int y = index / items_per_row;
|
||||
int x = vecs_per_item * (index % items_per_row);
|
||||
return ivec2(x, y);
|
||||
}
|
||||
|
||||
ivec2 get_fetch_uv_1(int index) {
|
||||
return get_fetch_uv(index, 1);
|
||||
}
|
||||
|
||||
ivec2 get_fetch_uv_2(int index) {
|
||||
return get_fetch_uv(index, 2);
|
||||
}
|
||||
|
||||
ivec2 get_fetch_uv_4(int index) {
|
||||
return get_fetch_uv(index, 4);
|
||||
}
|
||||
|
||||
ivec2 get_fetch_uv_8(int index) {
|
||||
return get_fetch_uv(index, 8);
|
||||
}
|
||||
|
||||
struct Layer {
|
||||
mat4 transform;
|
||||
|
@ -48,7 +85,7 @@ struct Layer {
|
|||
};
|
||||
|
||||
layout(std140) uniform Data {
|
||||
vec4 data[WR_MAX_UBO_VECTORS];
|
||||
ivec4 int_data[WR_MAX_UBO_VECTORS];
|
||||
};
|
||||
|
||||
Layer fetch_layer(int index) {
|
||||
|
@ -58,11 +95,9 @@ Layer fetch_layer(int index) {
|
|||
// This is required because trying to use an offset
|
||||
// of more than 8 texels doesn't work on some versions
|
||||
// of OSX.
|
||||
int y = index / LAYERS_PER_ROW;
|
||||
int x = VECS_PER_LAYER * (index % LAYERS_PER_ROW);
|
||||
|
||||
ivec2 uv0 = ivec2(x + 0, y);
|
||||
ivec2 uv1 = ivec2(x + 8, y);
|
||||
ivec2 uv = get_fetch_uv(index, VECS_PER_LAYER);
|
||||
ivec2 uv0 = ivec2(uv.x + 0, uv.y);
|
||||
ivec2 uv1 = ivec2(uv.x + 8, uv.y);
|
||||
|
||||
layer.transform[0] = texelFetchOffset(sLayers, uv0, 0, ivec2(0, 0));
|
||||
layer.transform[1] = texelFetchOffset(sLayers, uv0, 0, ivec2(1, 0));
|
||||
|
@ -92,10 +127,7 @@ struct Tile {
|
|||
Tile fetch_tile(int index) {
|
||||
Tile tile;
|
||||
|
||||
int y = index / TILES_PER_ROW;
|
||||
int x = VECS_PER_TILE * (index % TILES_PER_ROW);
|
||||
|
||||
ivec2 uv = ivec2(x + 0, y);
|
||||
ivec2 uv = get_fetch_uv(index, VECS_PER_TILE);
|
||||
|
||||
tile.actual_rect = texelFetchOffset(sRenderTasks, uv, 0, ivec2(0, 0));
|
||||
tile.target_rect = texelFetchOffset(sRenderTasks, uv, 0, ivec2(1, 0));
|
||||
|
@ -103,20 +135,172 @@ Tile fetch_tile(int index) {
|
|||
return tile;
|
||||
}
|
||||
|
||||
struct PrimitiveInfo {
|
||||
vec4 layer_tile;
|
||||
vec4 local_clip_rect;
|
||||
vec4 local_rect;
|
||||
struct Gradient {
|
||||
vec4 start_end_point;
|
||||
vec4 kind;
|
||||
};
|
||||
|
||||
PrimitiveInfo unpack_prim_info(int offset) {
|
||||
PrimitiveInfo info;
|
||||
Gradient fetch_gradient(int index) {
|
||||
Gradient gradient;
|
||||
|
||||
info.layer_tile = data[offset + 0];
|
||||
info.local_clip_rect = data[offset + 1];
|
||||
info.local_rect = data[offset + 2];
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
return info;
|
||||
gradient.start_end_point = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
gradient.kind = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
struct GradientStop {
|
||||
vec4 color;
|
||||
vec4 offset;
|
||||
};
|
||||
|
||||
GradientStop fetch_gradient_stop(int index) {
|
||||
GradientStop stop;
|
||||
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
stop.color = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
stop.offset = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return stop;
|
||||
}
|
||||
|
||||
struct Glyph {
|
||||
vec4 offset;
|
||||
vec4 uv_rect;
|
||||
};
|
||||
|
||||
Glyph fetch_glyph(int index) {
|
||||
Glyph glyph;
|
||||
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
glyph.offset = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
glyph.uv_rect = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return glyph;
|
||||
}
|
||||
|
||||
struct Border {
|
||||
vec4 style;
|
||||
vec4 widths;
|
||||
vec4 colors[4];
|
||||
vec4 radii[2];
|
||||
};
|
||||
|
||||
Border fetch_border(int index) {
|
||||
Border border;
|
||||
|
||||
ivec2 uv = get_fetch_uv_8(index);
|
||||
|
||||
border.style = texelFetchOffset(sData128, uv, 0, ivec2(0, 0));
|
||||
border.widths = texelFetchOffset(sData128, uv, 0, ivec2(1, 0));
|
||||
border.colors[0] = texelFetchOffset(sData128, uv, 0, ivec2(2, 0));
|
||||
border.colors[1] = texelFetchOffset(sData128, uv, 0, ivec2(3, 0));
|
||||
border.colors[2] = texelFetchOffset(sData128, uv, 0, ivec2(4, 0));
|
||||
border.colors[3] = texelFetchOffset(sData128, uv, 0, ivec2(5, 0));
|
||||
border.radii[0] = texelFetchOffset(sData128, uv, 0, ivec2(6, 0));
|
||||
border.radii[1] = texelFetchOffset(sData128, uv, 0, ivec2(7, 0));
|
||||
|
||||
return border;
|
||||
}
|
||||
|
||||
vec4 fetch_instance_geometry(int index) {
|
||||
ivec2 uv = get_fetch_uv_1(index);
|
||||
|
||||
vec4 rect = texelFetchOffset(sData16, uv, 0, ivec2(0, 0));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
struct PrimitiveGeometry {
|
||||
vec4 local_rect;
|
||||
vec4 local_clip_rect;
|
||||
};
|
||||
|
||||
PrimitiveGeometry fetch_prim_geometry(int index) {
|
||||
PrimitiveGeometry pg;
|
||||
|
||||
ivec2 uv = get_fetch_uv(index, VECS_PER_PRIM_GEOM);
|
||||
|
||||
pg.local_rect = texelFetchOffset(sPrimGeometry, uv, 0, ivec2(0, 0));
|
||||
pg.local_clip_rect = texelFetchOffset(sPrimGeometry, uv, 0, ivec2(1, 0));
|
||||
|
||||
return pg;
|
||||
}
|
||||
|
||||
struct PrimitiveInstance {
|
||||
int global_prim_index;
|
||||
int specific_prim_index;
|
||||
int render_task_index;
|
||||
int layer_index;
|
||||
int clip_address;
|
||||
ivec3 user_data;
|
||||
};
|
||||
|
||||
PrimitiveInstance fetch_instance(int index) {
|
||||
PrimitiveInstance pi;
|
||||
|
||||
int offset = index * 2;
|
||||
|
||||
ivec4 data0 = int_data[offset + 0];
|
||||
ivec4 data1 = int_data[offset + 1];
|
||||
|
||||
pi.global_prim_index = data0.x;
|
||||
pi.specific_prim_index = data0.y;
|
||||
pi.render_task_index = data0.z;
|
||||
pi.layer_index = data0.w;
|
||||
pi.clip_address = data1.x;
|
||||
pi.user_data = data1.yzw;
|
||||
|
||||
return pi;
|
||||
}
|
||||
|
||||
struct Primitive {
|
||||
Layer layer;
|
||||
Tile tile;
|
||||
vec4 local_rect;
|
||||
vec4 local_clip_rect;
|
||||
int prim_index;
|
||||
int clip_index;
|
||||
ivec3 user_data;
|
||||
};
|
||||
|
||||
Primitive load_primitive(int index) {
|
||||
Primitive prim;
|
||||
|
||||
PrimitiveInstance pi = fetch_instance(index);
|
||||
|
||||
prim.layer = fetch_layer(pi.layer_index);
|
||||
prim.tile = fetch_tile(pi.render_task_index);
|
||||
|
||||
PrimitiveGeometry pg = fetch_prim_geometry(pi.global_prim_index);
|
||||
prim.local_rect = pg.local_rect;
|
||||
prim.local_clip_rect = pg.local_clip_rect;
|
||||
|
||||
prim.prim_index = pi.specific_prim_index;
|
||||
prim.user_data = pi.user_data;
|
||||
prim.clip_index = pi.clip_address;
|
||||
|
||||
return prim;
|
||||
}
|
||||
|
||||
struct ClipRect {
|
||||
vec4 rect;
|
||||
vec4 dummy;
|
||||
};
|
||||
|
||||
ClipRect fetch_clip_rect(int index) {
|
||||
ClipRect rect;
|
||||
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
rect.rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
rect.dummy = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
struct ClipCorner {
|
||||
|
@ -124,31 +308,33 @@ struct ClipCorner {
|
|||
vec4 outer_inner_radius;
|
||||
};
|
||||
|
||||
ClipCorner unpack_clip_corner(int offset) {
|
||||
ClipCorner fetch_clip_corner(int index) {
|
||||
ClipCorner corner;
|
||||
|
||||
corner.rect = data[offset + 0];
|
||||
corner.outer_inner_radius = data[offset + 1];
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
corner.rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
corner.outer_inner_radius = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return corner;
|
||||
}
|
||||
|
||||
struct Clip {
|
||||
vec4 rect;
|
||||
ClipRect rect;
|
||||
ClipCorner top_left;
|
||||
ClipCorner top_right;
|
||||
ClipCorner bottom_left;
|
||||
ClipCorner bottom_right;
|
||||
};
|
||||
|
||||
Clip unpack_clip(int offset) {
|
||||
Clip fetch_clip(int index) {
|
||||
Clip clip;
|
||||
|
||||
clip.rect = data[offset + 0];
|
||||
clip.top_left = unpack_clip_corner(offset + 1);
|
||||
clip.top_right = unpack_clip_corner(offset + 3);
|
||||
clip.bottom_left = unpack_clip_corner(offset + 5);
|
||||
clip.bottom_right = unpack_clip_corner(offset + 7);
|
||||
clip.rect = fetch_clip_rect(index + 0);
|
||||
clip.top_left = fetch_clip_corner(index + 1);
|
||||
clip.top_right = fetch_clip_corner(index + 2);
|
||||
clip.bottom_left = fetch_clip_corner(index + 3);
|
||||
clip.bottom_right = fetch_clip_corner(index + 4);
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
@ -197,17 +383,17 @@ struct VertexInfo {
|
|||
vec2 global_clamped_pos;
|
||||
};
|
||||
|
||||
VertexInfo write_vertex(PrimitiveInfo info) {
|
||||
Layer layer = fetch_layer(int(info.layer_tile.x));
|
||||
Tile tile = fetch_tile(int(info.layer_tile.y));
|
||||
|
||||
vec2 p0 = floor(0.5 + info.local_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vec2 p1 = floor(0.5 + (info.local_rect.xy + info.local_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
VertexInfo write_vertex(vec4 instance_rect,
|
||||
vec4 local_clip_rect,
|
||||
Layer layer,
|
||||
Tile tile) {
|
||||
vec2 p0 = floor(0.5 + instance_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vec2 p1 = floor(0.5 + (instance_rect.xy + instance_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
|
||||
vec2 local_pos = mix(p0, p1, aPosition.xy);
|
||||
|
||||
vec2 cp0 = floor(0.5 + info.local_clip_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vec2 cp1 = floor(0.5 + (info.local_clip_rect.xy + info.local_clip_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vec2 cp0 = floor(0.5 + local_clip_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vec2 cp1 = floor(0.5 + (local_clip_rect.xy + local_clip_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
local_pos = clamp(local_pos, cp0, cp1);
|
||||
|
||||
local_pos = clamp(local_pos,
|
||||
|
@ -239,12 +425,12 @@ struct TransformVertexInfo {
|
|||
vec4 clipped_local_rect;
|
||||
};
|
||||
|
||||
TransformVertexInfo write_transform_vertex(PrimitiveInfo info) {
|
||||
Layer layer = fetch_layer(int(info.layer_tile.x));
|
||||
Tile tile = fetch_tile(int(info.layer_tile.y));
|
||||
|
||||
vec2 lp0 = info.local_rect.xy;
|
||||
vec2 lp1 = info.local_rect.xy + info.local_rect.zw;
|
||||
TransformVertexInfo write_transform_vertex(vec4 instance_rect,
|
||||
vec4 local_clip_rect,
|
||||
Layer layer,
|
||||
Tile tile) {
|
||||
vec2 lp0 = instance_rect.xy;
|
||||
vec2 lp1 = instance_rect.xy + instance_rect.zw;
|
||||
|
||||
lp0 = clamp(lp0,
|
||||
layer.local_clip_rect.xy,
|
||||
|
@ -295,241 +481,90 @@ TransformVertexInfo write_transform_vertex(PrimitiveInfo info) {
|
|||
}
|
||||
|
||||
struct Rectangle {
|
||||
PrimitiveInfo info;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
Rectangle fetch_rectangle(int index) {
|
||||
Rectangle rect;
|
||||
|
||||
int offset = index * 4;
|
||||
ivec2 uv = get_fetch_uv_1(index);
|
||||
|
||||
rect.info = unpack_prim_info(offset);
|
||||
rect.color = data[offset + 3];
|
||||
rect.color = texelFetchOffset(sData16, uv, 0, ivec2(0, 0));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
struct RectangleClip {
|
||||
PrimitiveInfo info;
|
||||
vec4 color;
|
||||
Clip clip;
|
||||
};
|
||||
|
||||
RectangleClip fetch_rectangle_clip(int index) {
|
||||
RectangleClip rect;
|
||||
|
||||
int offset = index * 13;
|
||||
|
||||
rect.info = unpack_prim_info(offset);
|
||||
rect.color = data[offset + 3];
|
||||
rect.clip = unpack_clip(offset + 4);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
struct Glyph {
|
||||
PrimitiveInfo info;
|
||||
vec4 color;
|
||||
vec4 uv_rect;
|
||||
};
|
||||
|
||||
Glyph fetch_glyph(int index) {
|
||||
Glyph glyph;
|
||||
|
||||
int offset = index * 5;
|
||||
|
||||
glyph.info = unpack_prim_info(offset);
|
||||
glyph.color = data[offset + 3];
|
||||
glyph.uv_rect = data[offset + 4];
|
||||
|
||||
return glyph;
|
||||
}
|
||||
|
||||
struct TextRunGlyph {
|
||||
vec4 local_rect;
|
||||
vec4 uv_rect;
|
||||
};
|
||||
|
||||
struct TextRun {
|
||||
PrimitiveInfo info;
|
||||
vec4 color;
|
||||
TextRunGlyph glyphs[WR_GLYPHS_PER_TEXT_RUN];
|
||||
};
|
||||
|
||||
PrimitiveInfo fetch_text_run_glyph(int index, out vec4 color, out vec4 uv_rect) {
|
||||
int offset = 20 * (index / WR_GLYPHS_PER_TEXT_RUN);
|
||||
int glyph_index = index % WR_GLYPHS_PER_TEXT_RUN;
|
||||
int glyph_offset = offset + 4 + 2 * glyph_index;
|
||||
TextRun fetch_text_run(int index) {
|
||||
TextRun text;
|
||||
|
||||
PrimitiveInfo info;
|
||||
info.layer_tile = data[offset + 0];
|
||||
info.local_clip_rect = data[offset + 1];
|
||||
info.local_rect = data[glyph_offset + 0];
|
||||
ivec2 uv = get_fetch_uv_1(index);
|
||||
|
||||
color = data[offset + 3];
|
||||
uv_rect = data[glyph_offset + 1];
|
||||
text.color = texelFetchOffset(sData16, uv, 0, ivec2(0, 0));
|
||||
|
||||
return info;
|
||||
return text;
|
||||
}
|
||||
|
||||
struct Image {
|
||||
PrimitiveInfo info;
|
||||
vec4 st_rect; // Location of the image texture in the texture atlas.
|
||||
vec4 stretch_size_and_tile_spacing; // Size of the actual image and amount of space between
|
||||
// tiled instances of this image.
|
||||
vec4 uvkind; // Type of texture coordinates.
|
||||
bool has_pixel_coords;
|
||||
};
|
||||
|
||||
Image fetch_image(int index) {
|
||||
Image image;
|
||||
|
||||
int offset = index * 6;
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
image.info = unpack_prim_info(offset);
|
||||
image.st_rect = data[offset + 3];
|
||||
image.stretch_size_and_tile_spacing = data[offset + 4];
|
||||
image.uvkind = data[offset + 5];
|
||||
image.st_rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
image.stretch_size_and_tile_spacing = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
image.has_pixel_coords = image.st_rect.z < 0.0;
|
||||
image.st_rect.z = abs(image.st_rect.z);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
struct ImageClip {
|
||||
PrimitiveInfo info;
|
||||
vec4 st_rect; // Location of the image texture in the texture atlas.
|
||||
vec4 stretch_size_and_tile_spacing; // Size of the actual image and amount of space between
|
||||
// tiled instances of this image.
|
||||
vec4 uvkind; // Type of texture coordinates.
|
||||
Clip clip;
|
||||
};
|
||||
|
||||
ImageClip fetch_image_clip(int index) {
|
||||
ImageClip image;
|
||||
|
||||
int offset = index * 15;
|
||||
|
||||
image.info = unpack_prim_info(offset);
|
||||
image.st_rect = data[offset + 3];
|
||||
image.stretch_size_and_tile_spacing = data[offset + 4];
|
||||
image.uvkind = data[offset + 5];
|
||||
image.clip = unpack_clip(offset + 6);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
struct Border {
|
||||
PrimitiveInfo info;
|
||||
vec4 verticalColor;
|
||||
vec4 horizontalColor;
|
||||
vec4 radii;
|
||||
vec4 border_style_trbl;
|
||||
vec4 part;
|
||||
};
|
||||
|
||||
Border fetch_border(int index) {
|
||||
Border border;
|
||||
|
||||
int offset = index * 8;
|
||||
|
||||
border.info = unpack_prim_info(offset);
|
||||
border.verticalColor = data[offset + 3];
|
||||
border.horizontalColor = data[offset + 4];
|
||||
border.radii = data[offset + 5];
|
||||
border.border_style_trbl = data[offset + 6];
|
||||
border.part = data[offset + 7];
|
||||
|
||||
return border;
|
||||
}
|
||||
|
||||
struct BoxShadow {
|
||||
PrimitiveInfo info;
|
||||
vec4 src_rect;
|
||||
vec4 bs_rect;
|
||||
vec4 color;
|
||||
vec4 border_radii_blur_radius_inverted;
|
||||
vec4 bs_rect;
|
||||
vec4 src_rect;
|
||||
};
|
||||
|
||||
BoxShadow fetch_boxshadow(int index) {
|
||||
BoxShadow bs;
|
||||
|
||||
int offset = index * 7;
|
||||
ivec2 uv = get_fetch_uv_4(index);
|
||||
|
||||
bs.info = unpack_prim_info(offset);
|
||||
bs.color = data[offset + 3];
|
||||
bs.border_radii_blur_radius_inverted = data[offset + 4];
|
||||
bs.bs_rect = data[offset + 5];
|
||||
bs.src_rect = data[offset + 6];
|
||||
bs.src_rect = texelFetchOffset(sData64, uv, 0, ivec2(0, 0));
|
||||
bs.bs_rect = texelFetchOffset(sData64, uv, 0, ivec2(1, 0));
|
||||
bs.color = texelFetchOffset(sData64, uv, 0, ivec2(2, 0));
|
||||
bs.border_radii_blur_radius_inverted = texelFetchOffset(sData64, uv, 0, ivec2(3, 0));
|
||||
|
||||
return bs;
|
||||
}
|
||||
|
||||
struct AlignedGradient {
|
||||
PrimitiveInfo info;
|
||||
vec4 color0;
|
||||
vec4 color1;
|
||||
vec4 dir;
|
||||
Clip clip;
|
||||
};
|
||||
|
||||
AlignedGradient fetch_aligned_gradient(int index) {
|
||||
AlignedGradient gradient;
|
||||
|
||||
int offset = index * 15;
|
||||
|
||||
gradient.info = unpack_prim_info(offset);
|
||||
gradient.color0 = data[offset + 3];
|
||||
gradient.color1 = data[offset + 4];
|
||||
gradient.dir = data[offset + 5];
|
||||
gradient.clip = unpack_clip(offset + 6);
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
struct AngleGradient {
|
||||
PrimitiveInfo info;
|
||||
vec4 start_end_point;
|
||||
vec4 stop_count;
|
||||
vec4 colors[MAX_STOPS_PER_ANGLE_GRADIENT];
|
||||
vec4 offsets[MAX_STOPS_PER_ANGLE_GRADIENT/4];
|
||||
};
|
||||
|
||||
AngleGradient fetch_angle_gradient(int index) {
|
||||
AngleGradient gradient;
|
||||
|
||||
int offset = index * 15;
|
||||
|
||||
gradient.info = unpack_prim_info(offset);
|
||||
gradient.start_end_point = data[offset + 3];
|
||||
gradient.stop_count = data[offset + 4];
|
||||
|
||||
for (int i=0 ; i < MAX_STOPS_PER_ANGLE_GRADIENT ; ++i) {
|
||||
gradient.colors[i] = data[offset + 5 + i];
|
||||
}
|
||||
|
||||
for (int i=0 ; i < MAX_STOPS_PER_ANGLE_GRADIENT/4 ; ++i) {
|
||||
gradient.offsets[i] = data[offset + 5 + MAX_STOPS_PER_ANGLE_GRADIENT + i];
|
||||
}
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
struct Blend {
|
||||
vec4 src_id_target_id_opacity;
|
||||
ivec4 src_id_target_id_opacity;
|
||||
};
|
||||
|
||||
Blend fetch_blend(int index) {
|
||||
Blend blend;
|
||||
|
||||
int offset = index * 1;
|
||||
|
||||
blend.src_id_target_id_opacity = data[offset + 0];
|
||||
blend.src_id_target_id_opacity = int_data[offset + 0];
|
||||
|
||||
return blend;
|
||||
}
|
||||
|
||||
struct Composite {
|
||||
vec4 src0_src1_target_id;
|
||||
vec4 info_amount;
|
||||
ivec4 src0_src1_target_id;
|
||||
ivec4 info_amount;
|
||||
};
|
||||
|
||||
Composite fetch_composite(int index) {
|
||||
|
@ -537,8 +572,8 @@ Composite fetch_composite(int index) {
|
|||
|
||||
int offset = index * 2;
|
||||
|
||||
composite.src0_src1_target_id = data[offset + 0];
|
||||
composite.info_amount = data[offset + 1];
|
||||
composite.src0_src1_target_id = int_data[offset + 0];
|
||||
composite.info_amount = int_data[offset + 1];
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue