Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More aggressive RectWithSize usage for local rectangles #1087

Merged
merged 4 commits into from Apr 10, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Introduced ClipVertexInfo

  • Loading branch information
kvark committed Apr 7, 2017
commit 3ffb8c9fa7ef2828a0267643649d788ec0ae0996
@@ -34,12 +34,21 @@ CacheClipInstance fetch_clip_item(int index) {
return cci;
}

struct ClipVertexInfo {
vec3 local_pos;
vec2 screen_pos;
RectWithSize clipped_local_rect;
};

// The transformed vertex function that always covers the whole clip area,
// which is the intersection of all clip instances of a given primitive
TransformVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
Layer layer,
ClipArea area,
int segment_index) {
ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
Layer layer,
ClipArea area,
int segment_index) {

RectWithSize clipped_local_rect = intersect_rect(local_clip_rect,
layer.local_clip_rect);

vec2 outer_p0 = area.screen_origin_target_index.xy;
vec2 outer_p1 = outer_p0 + area.task_bounds.zw - area.task_bounds.xy;
@@ -79,7 +88,7 @@ TransformVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,

gl_Position = uTransform * vec4(vertex_pos, 0.0, 1);

return TransformVertexInfo(layer_pos.xyw, actual_pos);
return ClipVertexInfo(layer_pos.xyw, actual_pos, clipped_local_rect);
}

#endif //WR_VERTEX_SHADER
@@ -29,12 +29,12 @@ void main(void) {
ImageMaskData mask = fetch_mask_data(cci.data_index);
RectWithSize local_rect = mask.local_rect;

TransformVertexInfo vi = write_clip_tile_vertex(local_rect,
layer,
area,
cci.segment_index);
ClipVertexInfo vi = write_clip_tile_vertex(local_rect,
layer,
area,
cci.segment_index);

vLocalRect = local_rect;
vLocalRect = vi.clipped_local_rect;
vPos = vi.local_pos;

vClipMaskUv = vec3((vPos.xy / vPos.z - local_rect.p0) / local_rect.size, 0.0);
@@ -64,11 +64,11 @@ void main(void) {
ClipData clip = fetch_clip(cci.data_index);
RectWithSize local_rect = clip.rect.rect;

TransformVertexInfo vi = write_clip_tile_vertex(local_rect,
layer,
area,
cci.segment_index);
vLocalRect = local_rect;
ClipVertexInfo vi = write_clip_tile_vertex(local_rect,
layer,
area,
cci.segment_index);
vLocalRect = vi.clipped_local_rect;
vPos = vi.local_pos;

vClipMode = clip.rect.mode.x;
@@ -472,14 +472,6 @@ struct VertexInfo {
vec2 screen_pos;
};

RectWithSize compute_clip_rect(RectWithSize local_rect,
RectWithSize local_clip_rect,
Layer layer) {
// intersect all 3 clip rectangles
return intersect_rect(layer.local_clip_rect,
intersect_rect(local_clip_rect, local_rect));
}

VertexInfo write_vertex(RectWithSize instance_rect,
RectWithSize local_clip_rect,
float z,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.