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

Make all render task data structs contain a common base field. #2052

Merged
merged 2 commits into from Nov 20, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -11,10 +11,8 @@ void brush_vs(
ivec2 user_data
);

// Whether this brush is being drawn on a Picture
// task (new) or an alpha batch task (legacy).
// Can be removed once everything uses pictures.
#define BRUSH_FLAG_USES_PICTURE (1 << 0)
#define RASTERIZATION_MODE_LOCAL_SPACE 0.0
#define RASTERIZATION_MODE_SCREEN_SPACE 1.0

struct BrushInstance {
int picture_address;
@@ -54,20 +52,21 @@ void main(void) {
vec2 device_pos, local_pos;
RectWithSize local_rect = geom.local_rect;

if ((brush.flags & BRUSH_FLAG_USES_PICTURE) != 0) {
// Fetch the dynamic picture that we are drawing on.
PictureTask pic_task = fetch_picture_task(brush.picture_address);
// Fetch the dynamic picture that we are drawing on.
PictureTask pic_task = fetch_picture_task(brush.picture_address);

if (pic_task.rasterization_mode == RASTERIZATION_MODE_LOCAL_SPACE) {

local_pos = local_rect.p0 + aPosition.xy * local_rect.size;

// Right now - pictures only support local positions. In the future, this
// will be expanded to support transform picture types (the common kind).
device_pos = pic_task.target_rect.p0 + uDevicePixelRatio * (local_pos - pic_task.content_origin);
device_pos = pic_task.common_data.task_rect.p0 +
uDevicePixelRatio * (local_pos - pic_task.content_origin);

// Write the final position transformed by the orthographic device-pixel projection.
gl_Position = uTransform * vec4(device_pos, 0.0, 1.0);
} else {
AlphaBatchTask alpha_task = fetch_alpha_batch_task(brush.picture_address);
Layer layer = fetch_layer(brush.clip_node_id, brush.scroll_node_id);
ClipArea clip_area = fetch_clip_area(brush.clip_address);

@@ -81,7 +80,7 @@ void main(void) {
geom.local_clip_rect,
float(brush.z),
layer,
alpha_task,
pic_task,
geom.local_rect
);

@@ -31,20 +31,20 @@ void brush_vs(
// we can expand this to support items from
// the normal texture cache and unify this
// with the normal image shader.
BlurTask task = fetch_blur_task(user_data.x);
vUv.z = task.render_target_layer_index;
BlurTask blur_task = fetch_blur_task(user_data.x);
vUv.z = blur_task.common_data.texture_layer_index;
vImageKind = user_data.y;

#if defined WR_FEATURE_COLOR_TARGET
vec2 texture_size = vec2(textureSize(sColor0, 0).xy);
#else
vec2 texture_size = vec2(textureSize(sColor1, 0).xy);
vColor = task.color;
vColor = blur_task.color;
#endif

vec2 uv0 = task.target_rect.p0;
vec2 src_size = task.target_rect.size * task.scale_factor;
vec2 uv1 = uv0 + task.target_rect.size;
vec2 uv0 = blur_task.common_data.task_rect.p0;
vec2 src_size = blur_task.common_data.task_rect.size * blur_task.scale_factor;
vec2 uv1 = uv0 + blur_task.common_data.task_rect.size;

// TODO(gw): In the future we'll probably draw these as segments
// with the brush shader. When that occurs, we can
@@ -52,8 +52,8 @@ ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
Layer layer,
ClipArea area,
int segment) {
vec2 outer_p0 = area.screen_origin_target_index.xy;
vec2 outer_p1 = outer_p0 + area.task_bounds.zw - area.task_bounds.xy;
vec2 outer_p0 = area.screen_origin;
vec2 outer_p1 = outer_p0 + area.common_data.task_rect.size;
vec2 inner_p0 = area.inner_rect.xy;
vec2 inner_p1 = area.inner_rect.zw;

@@ -86,7 +86,9 @@ ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
vec4 layer_pos = get_layer_pos(actual_pos / uDevicePixelRatio, layer);

// compute the point position in side the layer, in CSS space
vec2 vertex_pos = actual_pos + area.task_bounds.xy - area.screen_origin_target_index.xy;
vec2 vertex_pos = actual_pos +
area.common_data.task_rect.p0 -
area.screen_origin;

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

@@ -23,20 +23,20 @@ in int aBlurDirection;
in vec4 aBlurRegion;

void main(void) {
RenderTaskData task = fetch_render_task(aBlurRenderTaskAddress);
RenderTaskData src_task = fetch_render_task(aBlurSourceTaskAddress);
BlurTask blur_task = fetch_blur_task(aBlurRenderTaskAddress);
RenderTaskCommonData src_task = fetch_render_task_common_data(aBlurSourceTaskAddress);

vec4 src_rect = src_task.data0;
vec4 target_rect = task.data0;
RectWithSize src_rect = src_task.task_rect;
RectWithSize target_rect = blur_task.common_data.task_rect;

#if defined WR_FEATURE_COLOR_TARGET
vec2 texture_size = vec2(textureSize(sCacheRGBA8, 0).xy);
#else
vec2 texture_size = vec2(textureSize(sCacheA8, 0).xy);
#endif
vUv.z = src_task.data1.x;
vBlurRadius = int(3.0 * task.data1.y);
vSigma = task.data1.y;
vUv.z = src_task.texture_layer_index;
vBlurRadius = int(3.0 * blur_task.blur_radius);
vSigma = blur_task.blur_radius;

switch (aBlurDirection) {
case DIR_HORIZONTAL:
@@ -47,20 +47,21 @@ void main(void) {
break;
}

vUvRect = vec4(src_rect.xy + vec2(0.5),
src_rect.xy + src_rect.zw - vec2(0.5));
vUvRect = vec4(src_rect.p0 + vec2(0.5),
src_rect.p0 + src_rect.size - vec2(0.5));
vUvRect /= texture_size.xyxy;

if (aBlurRegion.z > 0.0) {
vec4 blur_region = aBlurRegion * uDevicePixelRatio;
src_rect = vec4(src_rect.xy + blur_region.xy, blur_region.zw);
target_rect = vec4(target_rect.xy + blur_region.xy, blur_region.zw);
src_rect = RectWithSize(src_rect.p0 + blur_region.xy, blur_region.zw);
target_rect.p0 = target_rect.p0 + blur_region.xy;
target_rect.size = blur_region.zw;
}

vec2 pos = target_rect.xy + target_rect.zw * aPosition.xy;
vec2 pos = target_rect.p0 + target_rect.size * aPosition.xy;

vec2 uv0 = src_rect.xy / texture_size;
vec2 uv1 = (src_rect.xy + src_rect.zw) / texture_size;
vec2 uv0 = src_rect.p0 / texture_size;
vec2 uv1 = (src_rect.p0 + src_rect.size) / texture_size;
vUv.xy = mix(uv0, uv1, aPosition.xy);

gl_Position = uTransform * vec4(pos, 0.0, 1.0);
@@ -128,8 +128,8 @@ void main(void) {

// Position vertex within the render task area.
vec2 final_pos = device_pos -
area.screen_origin_target_index.xy +
area.task_bounds.xy;
area.screen_origin +
area.common_data.task_rect.p0;

// Calculate the local space position for this vertex.
vec4 layer_pos = get_layer_pos(world_pos.xy, layer);
@@ -2,8 +2,6 @@
* 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 PRIMITIVE_HAS_PICTURE_TASK

#include shared,prim_shared

varying vec3 vUv;
@@ -32,7 +30,7 @@ void main(void) {
// the glyph offset, relative to its primitive bounding rect.
vec2 size = (res.uv_rect.zw - res.uv_rect.xy) * res.scale;
vec2 local_pos = glyph.offset + vec2(res.offset.x, -res.offset.y) / uDevicePixelRatio;
vec2 origin = prim.task.target_rect.p0 +
vec2 origin = prim.task.common_data.task_rect.p0 +
uDevicePixelRatio * (local_pos - prim.task.content_origin);
vec4 local_rect = vec4(origin, size);

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.