Bug 1418315 - Update webrender to commit 81cfbcf0763205f25329adb9b2ff75d1cd56e3f1. r=nical

MozReview-Commit-ID: 8eGY2WPahzB

--HG--
extra : rebase_source : d22c8a51ef7b55d99e7213c218cecb407ede11c8
This commit is contained in:
Kartikaya Gupta 2017-11-21 10:40:43 -05:00
parent 29bdc0b0dc
commit 7b9d5f0d04
26 changed files with 633 additions and 546 deletions

View File

@ -175,4 +175,4 @@ Troubleshooting tips:
-------------------------------------------------------------------------------
The version of WebRender currently in the tree is:
d490a74c438d987122c600afca6bb2247ab38637
81cfbcf0763205f25329adb9b2ff75d1cd56e3f1

View File

@ -1,6 +1,6 @@
[package]
name = "webrender"
version = "0.53.2"
version = "0.54.0"
authors = ["Glenn Watson <gw@intuitionlibrary.com>"]
license = "MPL-2.0"
repository = "https://github.com/servo/webrender"
@ -18,7 +18,7 @@ bincode = "0.9"
byteorder = "1.0"
euclid = "0.15.5"
fxhash = "0.2.1"
gleam = "0.4.8"
gleam = "0.4.14"
lazy_static = "0.2"
log = "0.3"
num-traits = "0.1.32"
@ -37,7 +37,7 @@ serde_derive = { optional = true, version = "1.0" }
angle = {git = "https://github.com/servo/angle", branch = "servo"}
env_logger = "0.4"
rand = "0.3" # for the benchmarks
servo-glutin = "0.12" # for the example apps
servo-glutin = "0.13" # for the example apps
[target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
freetype = { version = "0.3", default-features = false }
@ -47,5 +47,5 @@ dwrote = "0.4"
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.4"
core-graphics = "0.9"
core-text = { version = "7.0", default-features = false }
core-graphics = "0.12.2"
core-text = { version = "8.0", default-features = false }

View File

@ -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
);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -206,22 +206,60 @@ Layer fetch_layer(int clip_node_id, int scroll_node_id) {
return layer;
}
struct RenderTaskCommonData {
RectWithSize task_rect;
float texture_layer_index;
};
struct RenderTaskData {
vec4 data0;
vec4 data1;
RenderTaskCommonData common_data;
vec3 data1;
vec4 data2;
};
RenderTaskData fetch_render_task(int index) {
RenderTaskData task;
RenderTaskData fetch_render_task_data(int index) {
ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
task.data0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
task.data1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
task.data2 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(2, 0));
vec4 texel0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
vec4 texel1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
vec4 texel2 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(2, 0));
return task;
RectWithSize task_rect = RectWithSize(
texel0.xy,
texel0.zw
);
RenderTaskCommonData common_data = RenderTaskCommonData(
task_rect,
texel1.x
);
RenderTaskData data = RenderTaskData(
common_data,
texel1.yzw,
texel2
);
return data;
}
RenderTaskCommonData fetch_render_task_common_data(int index) {
ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
vec4 texel0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
vec4 texel1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
RectWithSize task_rect = RectWithSize(
texel0.xy,
texel0.zw
);
RenderTaskCommonData data = RenderTaskCommonData(
task_rect,
texel1.x
);
return data;
}
/*
@ -230,24 +268,19 @@ RenderTaskData fetch_render_task(int index) {
the transform mode of primitives on this picture, among other things.
*/
struct PictureTask {
RectWithSize target_rect;
float render_target_layer_index;
RenderTaskCommonData common_data;
vec2 content_origin;
float rasterization_mode;
vec4 color;
};
PictureTask fetch_picture_task(int address) {
RenderTaskData task_data = fetch_render_task(address);
RectWithSize target_rect = RectWithSize(
task_data.data0.xy,
task_data.data0.zw
);
RenderTaskData task_data = fetch_render_task_data(address);
PictureTask task = PictureTask(
target_rect,
task_data.data1.x,
task_data.data1.yz,
task_data.common_data,
task_data.data1.xy,
task_data.data1.z,
task_data.data2
);
@ -255,47 +288,28 @@ PictureTask fetch_picture_task(int address) {
}
struct BlurTask {
RectWithSize target_rect;
float render_target_layer_index;
RenderTaskCommonData common_data;
float blur_radius;
float scale_factor;
vec4 color;
};
BlurTask fetch_blur_task(int address) {
RenderTaskData task_data = fetch_render_task(address);
RenderTaskData task_data = fetch_render_task_data(address);
return BlurTask(
RectWithSize(task_data.data0.xy, task_data.data0.zw),
BlurTask task = BlurTask(
task_data.common_data,
task_data.data1.x,
task_data.data1.y,
task_data.data1.z,
task_data.data2
);
}
struct AlphaBatchTask {
vec2 screen_space_origin;
vec2 render_target_origin;
vec2 size;
float render_target_layer_index;
};
AlphaBatchTask fetch_alpha_batch_task(int index) {
RenderTaskData data = fetch_render_task(index);
AlphaBatchTask task;
task.render_target_origin = data.data0.xy;
task.size = data.data0.zw;
task.screen_space_origin = data.data1.xy;
task.render_target_layer_index = data.data1.z;
return task;
}
struct ClipArea {
vec4 task_bounds;
vec4 screen_origin_target_index;
RenderTaskCommonData common_data;
vec2 screen_origin;
vec4 inner_rect;
};
@ -303,14 +317,18 @@ ClipArea fetch_clip_area(int index) {
ClipArea area;
if (index == 0x7FFFFFFF) { //special sentinel task index
area.task_bounds = vec4(0.0, 0.0, 0.0, 0.0);
area.screen_origin_target_index = vec4(0.0, 0.0, 0.0, 0.0);
area.common_data = RenderTaskCommonData(
RectWithSize(vec2(0.0), vec2(0.0)),
0.0
);
area.screen_origin = vec2(0.0);
area.inner_rect = vec4(0.0);
} else {
RenderTaskData task = fetch_render_task(index);
area.task_bounds = task.data0;
area.screen_origin_target_index = task.data1;
area.inner_rect = task.data2;
RenderTaskData task_data = fetch_render_task_data(index);
area.common_data = task_data.common_data;
area.screen_origin = task_data.data1.xy;
area.inner_rect = task_data.data2;
}
return area;
@ -445,11 +463,7 @@ CompositeInstance fetch_composite_instance() {
struct Primitive {
Layer layer;
ClipArea clip_area;
#ifdef PRIMITIVE_HAS_PICTURE_TASK
PictureTask task;
#else
AlphaBatchTask task;
#endif
RectWithSize local_rect;
RectWithSize local_clip_rect;
int specific_prim_address;
@ -477,11 +491,7 @@ Primitive load_primitive() {
prim.layer = fetch_layer(pi.clip_node_id, pi.scroll_node_id);
prim.clip_area = fetch_clip_area(pi.clip_task_index);
#ifdef PRIMITIVE_HAS_PICTURE_TASK
prim.task = fetch_picture_task(pi.render_task_index);
#else
prim.task = fetch_alpha_batch_task(pi.render_task_index);
#endif
PrimitiveGeometry geom = fetch_primitive_geometry(pi.prim_address);
prim.local_rect = geom.local_rect;
@ -577,7 +587,7 @@ VertexInfo write_vertex(RectWithSize instance_rect,
RectWithSize local_clip_rect,
float z,
Layer layer,
AlphaBatchTask task,
PictureTask task,
RectWithSize snap_rect) {
// Select the corner of the local rect that we are processing.
@ -597,8 +607,8 @@ VertexInfo write_vertex(RectWithSize instance_rect,
// Apply offsets for the render task to get correct screen location.
vec2 final_pos = device_pos + snap_offset -
task.screen_space_origin +
task.render_target_origin;
task.content_origin +
task.common_data.task_rect.p0;
gl_Position = uTransform * vec4(final_pos, z, 1.0);
@ -637,7 +647,7 @@ TransformVertexInfo write_transform_vertex(RectWithSize instance_rect,
vec4 clip_edge_mask,
float z,
Layer layer,
AlphaBatchTask task) {
PictureTask task) {
RectWithEndpoint local_rect = to_rect_with_endpoint(instance_rect);
RectWithSize clip_rect;
clip_rect.p0 = clamp_rect(local_clip_rect.p0, layer.local_clip_rect);
@ -707,8 +717,8 @@ TransformVertexInfo write_transform_vertex(RectWithSize instance_rect,
// Apply offsets for the render task to get correct screen location.
vec2 final_pos = device_pos - //Note: `snap_rect` is not used
task.screen_space_origin +
task.render_target_origin;
task.content_origin +
task.common_data.task_rect.p0;
gl_Position = uTransform * vec4(final_pos, z, 1.0);
@ -797,9 +807,14 @@ Image fetch_image(int address) {
}
void write_clip(vec2 global_pos, ClipArea area) {
vec2 uv = global_pos + area.task_bounds.xy - area.screen_origin_target_index.xy;
vClipMaskUvBounds = area.task_bounds;
vClipMaskUv = vec3(uv, area.screen_origin_target_index.z);
vec2 uv = global_pos +
area.common_data.task_rect.p0 -
area.screen_origin;
vClipMaskUvBounds = vec4(
area.common_data.task_rect.p0,
area.common_data.task_rect.p0 + area.common_data.task_rect.size
);
vClipMaskUv = vec3(uv, area.common_data.texture_layer_index);
}
#endif //WR_VERTEX_SHADER

View File

@ -13,23 +13,23 @@ flat varying mat4 vColorMat;
#ifdef WR_VERTEX_SHADER
void main(void) {
CompositeInstance ci = fetch_composite_instance();
AlphaBatchTask dest_task = fetch_alpha_batch_task(ci.render_task_index);
AlphaBatchTask src_task = fetch_alpha_batch_task(ci.src_task_index);
PictureTask dest_task = fetch_picture_task(ci.render_task_index);
PictureTask src_task = fetch_picture_task(ci.src_task_index);
vec2 dest_origin = dest_task.render_target_origin -
dest_task.screen_space_origin +
src_task.screen_space_origin;
vec2 dest_origin = dest_task.common_data.task_rect.p0 -
dest_task.content_origin +
src_task.content_origin;
vec2 local_pos = mix(dest_origin,
dest_origin + src_task.size,
dest_origin + src_task.common_data.task_rect.size,
aPosition.xy);
vec2 texture_size = vec2(textureSize(sCacheRGBA8, 0));
vec2 st0 = src_task.render_target_origin;
vec2 st1 = src_task.render_target_origin + src_task.size;
vec2 st0 = src_task.common_data.task_rect.p0;
vec2 st1 = src_task.common_data.task_rect.p0 + src_task.common_data.task_rect.size;
vec2 uv = src_task.render_target_origin + aPosition.xy * src_task.size;
vUv = vec3(uv / texture_size, src_task.render_target_layer_index);
vec2 uv = src_task.common_data.task_rect.p0 + aPosition.xy * src_task.common_data.task_rect.size;
vUv = vec3(uv / texture_size, src_task.common_data.texture_layer_index);
vUvBounds = vec4(st0 + 0.5, st1 - 0.5) / texture_size.xyxy;
vOp = ci.user_data0;

View File

@ -9,46 +9,29 @@ varying vec3 vUv1;
flat varying int vOp;
#ifdef WR_VERTEX_SHADER
struct ReadbackTask {
vec2 render_target_origin;
vec2 size;
float render_target_layer_index;
};
ReadbackTask fetch_readback_task(int index) {
RenderTaskData data = fetch_render_task(index);
ReadbackTask task;
task.render_target_origin = data.data0.xy;
task.size = data.data0.zw;
task.render_target_layer_index = data.data1.x;
return task;
}
void main(void) {
CompositeInstance ci = fetch_composite_instance();
AlphaBatchTask dest_task = fetch_alpha_batch_task(ci.render_task_index);
ReadbackTask backdrop_task = fetch_readback_task(ci.backdrop_task_index);
AlphaBatchTask src_task = fetch_alpha_batch_task(ci.src_task_index);
PictureTask dest_task = fetch_picture_task(ci.render_task_index);
RenderTaskCommonData backdrop_task = fetch_render_task_common_data(ci.backdrop_task_index);
PictureTask src_task = fetch_picture_task(ci.src_task_index);
vec2 dest_origin = dest_task.render_target_origin -
dest_task.screen_space_origin +
src_task.screen_space_origin;
vec2 dest_origin = dest_task.common_data.task_rect.p0 -
dest_task.content_origin +
src_task.content_origin;
vec2 local_pos = mix(dest_origin,
dest_origin + src_task.size,
dest_origin + src_task.common_data.task_rect.size,
aPosition.xy);
vec2 texture_size = vec2(textureSize(sCacheRGBA8, 0));
vec2 st0 = backdrop_task.render_target_origin / texture_size;
vec2 st1 = (backdrop_task.render_target_origin + backdrop_task.size) / texture_size;
vUv0 = vec3(mix(st0, st1, aPosition.xy), backdrop_task.render_target_layer_index);
vec2 st0 = backdrop_task.task_rect.p0 / texture_size;
vec2 st1 = (backdrop_task.task_rect.p0 + backdrop_task.task_rect.size) / texture_size;
vUv0 = vec3(mix(st0, st1, aPosition.xy), backdrop_task.texture_layer_index);
st0 = src_task.render_target_origin / texture_size;
st1 = (src_task.render_target_origin + src_task.size) / texture_size;
vUv1 = vec3(mix(st0, st1, aPosition.xy), src_task.render_target_layer_index);
st0 = src_task.common_data.task_rect.p0 / texture_size;
st1 = (src_task.common_data.task_rect.p0 + src_task.common_data.task_rect.size) / texture_size;
vUv1 = vec3(mix(st0, st1, aPosition.xy), src_task.common_data.texture_layer_index);
vOp = ci.user_data0;

View File

@ -10,11 +10,11 @@ flat varying vec4 vUvBounds;
#ifdef WR_VERTEX_SHADER
void main(void) {
CompositeInstance ci = fetch_composite_instance();
AlphaBatchTask dest_task = fetch_alpha_batch_task(ci.render_task_index);
AlphaBatchTask src_task = fetch_alpha_batch_task(ci.src_task_index);
PictureTask dest_task = fetch_picture_task(ci.render_task_index);
PictureTask src_task = fetch_picture_task(ci.src_task_index);
vec2 dest_origin = dest_task.render_target_origin -
dest_task.screen_space_origin +
vec2 dest_origin = dest_task.common_data.task_rect.p0 -
dest_task.content_origin +
vec2(ci.user_data0, ci.user_data1);
vec2 local_pos = mix(dest_origin,
@ -22,9 +22,9 @@ void main(void) {
aPosition.xy);
vec2 texture_size = vec2(textureSize(sCacheRGBA8, 0));
vec2 st0 = src_task.render_target_origin;
vec2 st1 = src_task.render_target_origin + src_task.size;
vUv = vec3(mix(st0, st1, aPosition.xy) / texture_size, src_task.render_target_layer_index);
vec2 st0 = src_task.common_data.task_rect.p0;
vec2 st1 = src_task.common_data.task_rect.p0 + src_task.common_data.task_rect.size;
vUv = vec3(mix(st0, st1, aPosition.xy) / texture_size, src_task.common_data.texture_layer_index);
vUvBounds = vec4(st0 + 0.5, st1 - 0.5) / texture_size.xyxy;
gl_Position = uTransform * vec4(local_pos, ci.z, 1.0);

View File

@ -2,10 +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/. */
#ifdef WR_FEATURE_CACHE
#define PRIMITIVE_HAS_PICTURE_TASK
#endif
#include shared,prim_shared
varying vec4 vColor;
@ -99,7 +95,7 @@ void main(void) {
}
#ifdef WR_FEATURE_CACHE
vec2 device_origin = prim.task.target_rect.p0 +
vec2 device_origin = prim.task.common_data.task_rect.p0 +
uDevicePixelRatio * (prim.local_rect.p0 - prim.task.content_origin);
vec2 device_size = uDevicePixelRatio * prim.local_rect.size;

View File

@ -37,11 +37,11 @@ vec3 bilerp(vec3 a, vec3 b, vec3 c, vec3 d, float s, float t) {
void main(void) {
CompositeInstance ci = fetch_composite_instance();
SplitGeometry geometry = fetch_split_geometry(ci.user_data0);
AlphaBatchTask src_task = fetch_alpha_batch_task(ci.src_task_index);
AlphaBatchTask dest_task = fetch_alpha_batch_task(ci.render_task_index);
PictureTask src_task = fetch_picture_task(ci.src_task_index);
PictureTask dest_task = fetch_picture_task(ci.render_task_index);
vec2 dest_origin = dest_task.render_target_origin -
dest_task.screen_space_origin;
vec2 dest_origin = dest_task.common_data.task_rect.p0 -
dest_task.content_origin;
vec3 world_pos = bilerp(geometry.points[0], geometry.points[1],
geometry.points[3], geometry.points[2],
@ -50,12 +50,12 @@ void main(void) {
gl_Position = uTransform * final_pos;
vec2 uv_origin = src_task.render_target_origin;
vec2 uv_pos = uv_origin + world_pos.xy - src_task.screen_space_origin;
vec2 uv_origin = src_task.common_data.task_rect.p0;
vec2 uv_pos = uv_origin + world_pos.xy - src_task.content_origin;
vec2 texture_size = vec2(textureSize(sCacheRGBA8, 0));
vUv = vec3(uv_pos / texture_size, src_task.render_target_layer_index);
vUvTaskBounds = vec4(uv_origin, uv_origin + src_task.size) / texture_size.xyxy;
vUvSampleBounds = vec4(uv_origin + 0.5, uv_origin + src_task.size - 0.5) / texture_size.xyxy;
vUv = vec3(uv_pos / texture_size, src_task.common_data.texture_layer_index);
vUvTaskBounds = vec4(uv_origin, uv_origin + src_task.common_data.task_rect.size) / texture_size.xyxy;
vUvSampleBounds = vec4(uv_origin + 0.5, uv_origin + src_task.common_data.task_rect.size - 0.5) / texture_size.xyxy;
}
#endif

View File

@ -8,6 +8,7 @@ use api::{DeviceIntRect, DeviceUintSize};
use euclid::Transform3D;
use gleam::gl;
use internal_types::RenderTargetMode;
use internal_types::FastHashMap;
use std::fs::File;
use std::io::Read;
use std::iter::repeat;
@ -485,6 +486,61 @@ pub struct VBOId(gl::GLuint);
#[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)]
struct IBOId(gl::GLuint);
#[derive(PartialEq, Eq, Hash, Debug)]
struct ProgramSources {
renderer_name: String,
vs_source: String,
fs_source: String,
}
impl ProgramSources {
fn new(renderer_name: String, vs_source: String, fs_source: String) -> Self {
ProgramSources {
renderer_name,
vs_source,
fs_source,
}
}
}
struct ProgramBinary {
binary: Vec<u8>,
format: gl::GLenum,
}
impl ProgramBinary {
fn new(binary: Vec<u8>, format: gl::GLenum) -> Self {
ProgramBinary {
binary,
format
}
}
}
pub struct ProgramCache {
binaries: FastHashMap<ProgramSources, ProgramBinary>,
}
impl ProgramCache {
pub fn new() -> Self {
ProgramCache {
binaries: FastHashMap::default(),
}
}
fn get(&self, sources: &ProgramSources) -> Option<&ProgramBinary> {
self.binaries.get(&sources)
}
fn contains(&self, sources: &ProgramSources) -> bool {
self.binaries.contains_key(&sources)
}
fn insert(&mut self, sources: ProgramSources, binary: ProgramBinary) {
self.binaries.insert(sources, binary);
}
}
#[derive(Debug, Copy, Clone)]
pub enum VertexUsageHint {
Static,
@ -521,7 +577,7 @@ pub enum ShaderError {
Link(String, String), // name, error message
}
pub struct Device {
pub struct Device<'a> {
gl: Rc<gl::Gl>,
// device state
bound_textures: [gl::GLuint; 16],
@ -544,19 +600,23 @@ pub struct Device {
resource_override_path: Option<PathBuf>,
max_texture_size: u32,
renderer_name: String,
cached_programs: Option<&'a mut ProgramCache>,
// Frame counter. This is used to map between CPU
// frames and GPU frames.
frame_id: FrameId,
}
impl Device {
impl<'a> Device<'a> {
pub fn new(
gl: Rc<gl::Gl>,
resource_override_path: Option<PathBuf>,
_file_changed_handler: Box<FileWatcherHandler>,
cached_programs: Option<&mut ProgramCache>,
) -> Device {
let max_texture_size = gl.get_integer_v(gl::MAX_TEXTURE_SIZE) as u32;
let renderer_name = gl.get_string(gl::RENDERER);
Device {
gl,
@ -580,6 +640,8 @@ impl Device {
default_draw_fbo: 0,
max_texture_size,
renderer_name,
cached_programs,
frame_id: FrameId(0),
}
}
@ -592,6 +654,10 @@ impl Device {
&self.gl
}
pub fn update_program_cache(&mut self, cached_programs: &'a mut ProgramCache) {
self.cached_programs = Some(cached_programs);
}
pub fn max_texture_size(&self) -> u32 {
self.max_texture_size
}
@ -612,7 +678,7 @@ impl Device {
gl: &gl::Gl,
name: &str,
shader_type: gl::GLenum,
source: String,
source: &String,
) -> Result<gl::GLuint, ShaderError> {
debug!("compile {:?}", name);
let id = gl.create_shader(shader_type);
@ -1086,59 +1152,99 @@ impl Device {
&self.resource_override_path,
);
// Compile the vertex shader
let vs_id =
match Device::compile_shader(&*self.gl, base_filename, gl::VERTEX_SHADER, vs_source) {
Ok(vs_id) => vs_id,
Err(err) => return Err(err),
};
let sources = ProgramSources::new(self.renderer_name.clone(), vs_source, fs_source);
// Compiler the fragment shader
let fs_id =
match Device::compile_shader(&*self.gl, base_filename, gl::FRAGMENT_SHADER, fs_source) {
Ok(fs_id) => fs_id,
Err(err) => {
self.gl.delete_shader(vs_id);
return Err(err);
}
};
// Create program and attach shaders
// Create program
let pid = self.gl.create_program();
self.gl.attach_shader(pid, vs_id);
self.gl.attach_shader(pid, fs_id);
// Bind vertex attributes
for (i, attr) in descriptor
.vertex_attributes
.iter()
.chain(descriptor.instance_attributes.iter())
.enumerate()
{
self.gl
.bind_attrib_location(pid, i as gl::GLuint, attr.name);
let mut loaded = false;
if let Some(ref cached_programs) = self.cached_programs {
if let Some(binary) = cached_programs.get(&sources)
{
self.gl.program_binary(pid, binary.format, &binary.binary);
if self.gl.get_program_iv(pid, gl::LINK_STATUS) == (0 as gl::GLint) {
let error_log = self.gl.get_program_info_log(pid);
println!(
"Failed to load a program object with a program binary: {:?} renderer {}\n{}",
base_filename,
self.renderer_name,
error_log
);
} else {
loaded = true;
}
}
}
// Link!
self.gl.link_program(pid);
if loaded == false {
// Compile the vertex shader
let vs_id =
match Device::compile_shader(&*self.gl, base_filename, gl::VERTEX_SHADER, &sources.vs_source) {
Ok(vs_id) => vs_id,
Err(err) => return Err(err),
};
// GL recommends detaching and deleting shaders once the link
// is complete (whether successful or not). This allows the driver
// to free any memory associated with the parsing and compilation.
self.gl.detach_shader(pid, vs_id);
self.gl.detach_shader(pid, fs_id);
self.gl.delete_shader(vs_id);
self.gl.delete_shader(fs_id);
// Compiler the fragment shader
let fs_id =
match Device::compile_shader(&*self.gl, base_filename, gl::FRAGMENT_SHADER, &sources.fs_source) {
Ok(fs_id) => fs_id,
Err(err) => {
self.gl.delete_shader(vs_id);
return Err(err);
}
};
if self.gl.get_program_iv(pid, gl::LINK_STATUS) == (0 as gl::GLint) {
let error_log = self.gl.get_program_info_log(pid);
println!(
"Failed to link shader program: {:?}\n{}",
base_filename,
error_log
);
self.gl.delete_program(pid);
return Err(ShaderError::Link(base_filename.to_string(), error_log));
// Attach shaders
self.gl.attach_shader(pid, vs_id);
self.gl.attach_shader(pid, fs_id);
// Bind vertex attributes
for (i, attr) in descriptor
.vertex_attributes
.iter()
.chain(descriptor.instance_attributes.iter())
.enumerate()
{
self.gl
.bind_attrib_location(pid, i as gl::GLuint, attr.name);
}
if self.cached_programs.is_some() {
self.gl.program_parameter_i(pid, gl::PROGRAM_BINARY_RETRIEVABLE_HINT, gl::TRUE as gl::GLint);
}
// Link!
self.gl.link_program(pid);
// GL recommends detaching and deleting shaders once the link
// is complete (whether successful or not). This allows the driver
// to free any memory associated with the parsing and compilation.
self.gl.detach_shader(pid, vs_id);
self.gl.detach_shader(pid, fs_id);
self.gl.delete_shader(vs_id);
self.gl.delete_shader(fs_id);
if self.gl.get_program_iv(pid, gl::LINK_STATUS) == (0 as gl::GLint) {
let error_log = self.gl.get_program_info_log(pid);
println!(
"Failed to link shader program: {:?}\n{}",
base_filename,
error_log
);
self.gl.delete_program(pid);
return Err(ShaderError::Link(base_filename.to_string(), error_log));
}
}
if let Some(ref mut cached_programs) = self.cached_programs {
if !cached_programs.contains(&sources) {
let (buffer, format) = self.gl.get_program_binary(pid);
if buffer.len() > 0 {
cached_programs.insert(sources, ProgramBinary::new(buffer, format));
}
}
}
let u_transform = self.gl.get_uniform_location(pid, "uTransform");

View File

@ -11,7 +11,7 @@ use api::{ImageKey, ImageRendering, ItemRange, ItemTag, LayerPoint, LayerPrimiti
use api::{LayerSize, LayerToScrollTransform, LayerVector2D, LayoutVector2D, LineOrientation};
use api::{LineStyle, LocalClip, PipelineId, RepeatMode};
use api::{ScrollSensitivity, Shadow, TileOffset, TransformStyle};
use api::{WorldPoint, YuvColorSpace, YuvData};
use api::{PremultipliedColorF, WorldPoint, YuvColorSpace, YuvData};
use app_units::Au;
use border::ImageBorderSegment;
use clip::{ClipRegion, ClipSource, ClipSources, ClipStore, Contains, MAX_CLIP};
@ -22,20 +22,19 @@ use frame::FrameId;
use glyph_rasterizer::FontInstance;
use gpu_cache::GpuCache;
use internal_types::{FastHashMap, FastHashSet};
use picture::{PictureCompositeMode, PictureKind, PicturePrimitive};
use picture::{PictureCompositeMode, PictureKind, PicturePrimitive, RasterizationSpace};
use prim_store::{TexelRect, YuvImagePrimitiveCpu};
use prim_store::{GradientPrimitiveCpu, ImagePrimitiveCpu, LinePrimitive, PrimitiveKind};
use prim_store::{PrimitiveContainer, PrimitiveIndex};
use prim_store::{PrimitiveStore, RadialGradientPrimitiveCpu};
use prim_store::{RectangleContent, RectanglePrimitive, TextRunPrimitiveCpu};
use profiler::{FrameProfileCounters, GpuCacheProfileCounters, TextureCacheProfileCounters};
use render_task::{RenderTask, RenderTaskLocation};
use render_task::RenderTaskTree;
use render_task::{ClearMode, RenderTask, RenderTaskTree};
use resource_cache::ResourceCache;
use scene::{ScenePipeline, SceneProperties};
use std::{mem, usize, f32, i32};
use tiling::{CompositeOps, Frame};
use tiling::{RenderPass};
use tiling::{RenderPass, RenderTargetKind};
use tiling::{RenderTargetContext, ScrollbarPrimitive};
use util::{self, pack_as_float, RectHelpers, recycle_vec};
@ -1579,11 +1578,15 @@ impl FrameBuilder {
let pic = &mut self.prim_store.cpu_pictures[0];
pic.runs = prim_run_cmds;
let root_render_task = RenderTask::new_alpha_batch(
DeviceIntPoint::zero(),
RenderTaskLocation::Fixed,
PrimitiveIndex(0),
let root_render_task = RenderTask::new_picture(
None,
PrimitiveIndex(0),
RenderTargetKind::Color,
0.0,
0.0,
PremultipliedColorF::TRANSPARENT,
ClearMode::Transparent,
RasterizationSpace::Screen,
child_tasks,
);

View File

@ -139,11 +139,6 @@ impl From<CompositePrimitiveInstance> for PrimitiveInstance {
}
}
// Whether this brush is being drawn on a Picture
// task (new) or an alpha batch task (legacy).
// Can be removed once everything uses pictures.
pub const BRUSH_FLAG_USES_PICTURE: i32 = (1 << 0);
// TODO(gw): While we are comverting things over, we
// need to have the instance be the same
// size as an old PrimitiveInstance. In the

View File

@ -150,7 +150,7 @@ extern crate ws;
pub extern crate webrender_api;
#[doc(hidden)]
pub use device::build_shader_strings;
pub use device::{build_shader_strings, ProgramCache};
pub use renderer::{CpuProfile, DebugFlags, GpuProfile, OutputImageHandler, RendererKind};
pub use renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource};
pub use renderer::{GraphicsApi, GraphicsApiInfo, ReadPixelsFormat, Renderer, RendererOptions};

View File

@ -37,6 +37,15 @@ pub enum PictureCompositeMode {
Blit,
}
/// Configure whether the primitives on this picture
/// should be rasterized in screen space or local space.
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub enum RasterizationSpace {
Local = 0,
Screen = 1,
}
#[derive(Debug)]
pub enum PictureKind {
TextShadow {
@ -95,9 +104,9 @@ pub struct PicturePrimitive {
// unconditionally draw them.
pub cull_children: bool,
// TODO(gw): Add a mode that specifies if this
// picture should be rasterized in
// screen-space or local-space.
/// Configure whether the primitives on this picture
/// should be rasterized in screen space or local space.
pub rasterization_kind: RasterizationSpace,
}
impl PicturePrimitive {
@ -113,6 +122,7 @@ impl PicturePrimitive {
},
pipeline_id,
cull_children: false,
rasterization_kind: RasterizationSpace::Local,
}
}
@ -158,6 +168,7 @@ impl PicturePrimitive {
},
pipeline_id,
cull_children: false,
rasterization_kind: RasterizationSpace::Local,
}
}
@ -181,6 +192,9 @@ impl PicturePrimitive {
},
pipeline_id,
cull_children: true,
// TODO(gw): Make this configurable based on an
// exposed API parameter in StackingContext.
rasterization_kind: RasterizationSpace::Screen,
}
}
@ -281,7 +295,7 @@ impl PicturePrimitive {
prim_index: PrimitiveIndex,
prim_context: &PrimitiveContext,
render_tasks: &mut RenderTaskTree,
screen_rect: &DeviceIntRect,
prim_screen_rect: &DeviceIntRect,
child_tasks: Vec<RenderTaskId>,
parent_tasks: &mut Vec<RenderTaskId>,
) {
@ -289,15 +303,19 @@ impl PicturePrimitive {
PictureKind::Image {
ref mut readback_render_task_id,
composite_mode,
frame_output_pipeline_id,
..
} => {
match composite_mode {
Some(PictureCompositeMode::Filter(FilterOp::Blur(blur_radius))) => {
let picture_task = RenderTask::new_dynamic_alpha_batch(
screen_rect,
let picture_task = RenderTask::new_picture(
Some(prim_screen_rect.size),
prim_index,
None,
RenderTargetKind::Color,
prim_screen_rect.origin.x as f32,
prim_screen_rect.origin.y as f32,
PremultipliedColorF::TRANSPARENT,
ClearMode::Transparent,
self.rasterization_kind,
child_tasks,
);
@ -319,14 +337,19 @@ impl PicturePrimitive {
self.render_task_id = Some(blur_render_task_id);
}
Some(PictureCompositeMode::MixBlend(..)) => {
let picture_task = RenderTask::new_dynamic_alpha_batch(
screen_rect,
let picture_task = RenderTask::new_picture(
Some(prim_screen_rect.size),
prim_index,
None,
RenderTargetKind::Color,
prim_screen_rect.origin.x as f32,
prim_screen_rect.origin.y as f32,
PremultipliedColorF::TRANSPARENT,
ClearMode::Transparent,
self.rasterization_kind,
child_tasks,
);
let readback_task_id = render_tasks.add(RenderTask::new_readback(*screen_rect));
let readback_task_id = render_tasks.add(RenderTask::new_readback(*prim_screen_rect));
*readback_render_task_id = Some(readback_task_id);
parent_tasks.push(readback_task_id);
@ -334,10 +357,15 @@ impl PicturePrimitive {
self.render_task_id = Some(render_tasks.add(picture_task));
}
Some(PictureCompositeMode::Filter(..)) | Some(PictureCompositeMode::Blit) => {
let picture_task = RenderTask::new_dynamic_alpha_batch(
screen_rect,
let picture_task = RenderTask::new_picture(
Some(prim_screen_rect.size),
prim_index,
frame_output_pipeline_id,
RenderTargetKind::Color,
prim_screen_rect.origin.x as f32,
prim_screen_rect.origin.y as f32,
PremultipliedColorF::TRANSPARENT,
ClearMode::Transparent,
self.rasterization_kind,
child_tasks,
);
@ -374,12 +402,15 @@ impl PicturePrimitive {
let blur_std_deviation = blur_radius.0 as f32 * 0.5;
let picture_task = RenderTask::new_picture(
cache_size,
Some(cache_size),
prim_index,
RenderTargetKind::Color,
content_rect.origin,
content_rect.origin.x,
content_rect.origin.y,
color.premultiplied(),
ClearMode::Transparent,
self.rasterization_kind,
Vec::new(),
);
let picture_task_id = render_tasks.add(picture_task);
@ -425,12 +456,15 @@ impl PicturePrimitive {
};
let picture_task = RenderTask::new_picture(
cache_size,
Some(cache_size),
prim_index,
RenderTargetKind::Alpha,
content_rect.origin,
content_rect.origin.x,
content_rect.origin.y,
color.premultiplied(),
ClearMode::Zero,
self.rasterization_kind,
Vec::new(),
);
let picture_task_id = render_tasks.add(picture_task);

View File

@ -16,7 +16,7 @@ use core_graphics::base::kCGBitmapByteOrder32Little;
use core_graphics::color_space::CGColorSpace;
use core_graphics::context::{CGContext, CGTextDrawingMode};
use core_graphics::data_provider::CGDataProvider;
use core_graphics::font::{CGFont, CGFontRef, CGGlyph};
use core_graphics::font::{CGFont, CGGlyph};
use core_graphics::geometry::{CGPoint, CGRect, CGSize};
use core_text;
use core_text::font::{CTFont, CTFontRef};
@ -148,8 +148,6 @@ extern {
static kCTFontVariationAxisDefaultValueKey: CFStringRef;
fn CTFontCopyVariationAxes(font: CTFontRef) -> CFArrayRef;
fn CGFontCreateCopyWithVariations(font: CGFontRef, vars: CFDictionaryRef) -> CGFontRef;
}
fn new_ct_font_with_variations(cg_font: &CGFont, size: Au, variations: &[FontVariation]) -> CTFont {
@ -244,8 +242,7 @@ fn new_ct_font_with_variations(cg_font: &CGFont, size: Au, variations: &[FontVar
return ct_font;
}
let vals_dict = CFDictionary::from_CFType_pairs(&vals);
let cg_var_font_ref = CGFontCreateCopyWithVariations(cg_font.as_concrete_TypeRef(), vals_dict.as_concrete_TypeRef());
let cg_var_font: CGFont = TCFType::wrap_under_create_rule(cg_var_font_ref);
let cg_var_font = cg_font.create_copy_from_variations(&vals_dict).unwrap();
core_text::font::new_from_CGFont(&cg_var_font, size.to_f64_px())
}
}
@ -275,7 +272,7 @@ impl FontContext {
}
assert_eq!(index, 0);
let data_provider = CGDataProvider::from_buffer(&**bytes);
let data_provider = CGDataProvider::from_buffer(bytes);
let cg_font = match CGFont::from_data_provider(data_provider) {
Err(_) => return,
Ok(cg_font) => cg_font,

View File

@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{ClipId, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
use api::{LayerPoint, LayerRect};
use api::{PipelineId, PremultipliedColorF};
use api::{LayerPoint, LayerRect, PremultipliedColorF};
use clip::{ClipSource, ClipSourcesWeakHandle, ClipStore};
use clip_scroll_tree::CoordinateSystemId;
use gpu_types::{ClipScrollNodeIndex};
use picture::RasterizationSpace;
use prim_store::{PrimitiveIndex};
use std::{cmp, usize, f32, i32};
use std::rc::Rc;
@ -150,15 +150,6 @@ pub enum RenderTaskLocation {
Dynamic(Option<(DeviceIntPoint, RenderTargetIndex)>, DeviceIntSize),
}
#[derive(Debug)]
pub struct AlphaRenderTask {
pub screen_origin: DeviceIntPoint,
pub prim_index: PrimitiveIndex,
// If this render task is a registered frame output, this
// contains the pipeline ID it maps to.
pub frame_output_pipeline_id: Option<PipelineId>,
}
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub enum MaskSegment {
@ -240,6 +231,7 @@ pub struct PictureTask {
pub target_kind: RenderTargetKind,
pub content_origin: LayerPoint,
pub color: PremultipliedColorF,
pub rasterization_kind: RasterizationSpace,
}
#[derive(Debug)]
@ -258,7 +250,6 @@ pub struct RenderTaskData {
#[derive(Debug)]
pub enum RenderTaskKind {
Alpha(AlphaRenderTask),
Picture(PictureTask),
CacheMask(CacheMaskTask),
VerticalBlur(BlurTask),
@ -288,62 +279,32 @@ pub struct RenderTask {
}
impl RenderTask {
// TODO(gw): In the future we'll remove this
// completely and convert everything
// that is an alpha task to a Picture.
pub fn new_alpha_batch(
screen_origin: DeviceIntPoint,
location: RenderTaskLocation,
prim_index: PrimitiveIndex,
frame_output_pipeline_id: Option<PipelineId>,
children: Vec<RenderTaskId>,
) -> Self {
RenderTask {
cache_key: None,
children,
location,
kind: RenderTaskKind::Alpha(AlphaRenderTask {
screen_origin,
prim_index,
frame_output_pipeline_id,
}),
clear_mode: ClearMode::Transparent,
}
}
pub fn new_dynamic_alpha_batch(
rect: &DeviceIntRect,
prim_index: PrimitiveIndex,
frame_output_pipeline_id: Option<PipelineId>,
children: Vec<RenderTaskId>,
) -> Self {
let location = RenderTaskLocation::Dynamic(None, rect.size);
Self::new_alpha_batch(
rect.origin,
location,
prim_index,
frame_output_pipeline_id,
children,
)
}
pub fn new_picture(
size: DeviceIntSize,
size: Option<DeviceIntSize>,
prim_index: PrimitiveIndex,
target_kind: RenderTargetKind,
content_origin: LayerPoint,
content_origin_x: f32,
content_origin_y: f32,
color: PremultipliedColorF,
clear_mode: ClearMode,
rasterization_kind: RasterizationSpace,
children: Vec<RenderTaskId>,
) -> Self {
let location = match size {
Some(size) => RenderTaskLocation::Dynamic(None, size),
None => RenderTaskLocation::Fixed,
};
RenderTask {
cache_key: None,
children: Vec::new(),
location: RenderTaskLocation::Dynamic(None, size),
children,
location,
kind: RenderTaskKind::Picture(PictureTask {
prim_index,
target_kind,
content_origin,
content_origin: LayerPoint::new(content_origin_x, content_origin_y),
color,
rasterization_kind,
}),
clear_mode,
}
@ -542,19 +503,6 @@ impl RenderTask {
}
}
pub fn as_alpha_batch<'a>(&'a self) -> &'a AlphaRenderTask {
match self.kind {
RenderTaskKind::Alpha(ref task) => task,
RenderTaskKind::Picture(..) |
RenderTaskKind::CacheMask(..) |
RenderTaskKind::VerticalBlur(..) |
RenderTaskKind::Readback(..) |
RenderTaskKind::HorizontalBlur(..) |
RenderTaskKind::Alias(..) |
RenderTaskKind::Scaling(..) => unreachable!(),
}
}
// Write (up to) 8 floats of data specific to the type
// of render task that is provided to the GPU shaders
// via a vertex texture.
@ -567,105 +515,70 @@ impl RenderTask {
// more type-safe. Although, it will always need
// to be kept in sync with the GLSL code anyway.
match self.kind {
RenderTaskKind::Alpha(ref task) => {
let (target_rect, target_index) = self.get_target_rect();
RenderTaskData {
data: [
target_rect.origin.x as f32,
target_rect.origin.y as f32,
target_rect.size.width as f32,
target_rect.size.height as f32,
task.screen_origin.x as f32,
task.screen_origin.y as f32,
target_index.0 as f32,
0.0,
0.0,
0.0,
0.0,
0.0,
],
}
}
let (data1, data2) = match self.kind {
RenderTaskKind::Picture(ref task) => {
let (target_rect, target_index) = self.get_target_rect();
RenderTaskData {
data: [
target_rect.origin.x as f32,
target_rect.origin.y as f32,
target_rect.size.width as f32,
target_rect.size.height as f32,
target_index.0 as f32,
(
[
task.content_origin.x,
task.content_origin.y,
0.0,
task.color.r,
task.color.g,
task.color.b,
task.color.a,
task.rasterization_kind as u32 as f32,
],
}
task.color.to_array()
)
}
RenderTaskKind::CacheMask(ref task) => {
let (target_rect, target_index) = self.get_target_rect();
RenderTaskData {
data: [
target_rect.origin.x as f32,
target_rect.origin.y as f32,
(target_rect.origin.x + target_rect.size.width) as f32,
(target_rect.origin.y + target_rect.size.height) as f32,
(
[
task.actual_rect.origin.x as f32,
task.actual_rect.origin.y as f32,
target_index.0 as f32,
0.0,
],
[
task.inner_rect.origin.x as f32,
task.inner_rect.origin.y as f32,
(task.inner_rect.origin.x + task.inner_rect.size.width) as f32,
(task.inner_rect.origin.y + task.inner_rect.size.height) as f32,
],
}
)
}
RenderTaskKind::VerticalBlur(ref task) |
RenderTaskKind::HorizontalBlur(ref task) => {
let (target_rect, target_index) = self.get_target_rect();
RenderTaskData {
data: [
target_rect.origin.x as f32,
target_rect.origin.y as f32,
target_rect.size.width as f32,
target_rect.size.height as f32,
target_index.0 as f32,
(
[
task.blur_std_deviation,
task.scale_factor,
0.0,
task.color.r,
task.color.g,
task.color.b,
task.color.a,
],
}
task.color.to_array()
)
}
RenderTaskKind::Readback(..) |
RenderTaskKind::Scaling(..) => {
let (target_rect, target_index) = self.get_target_rect();
RenderTaskData {
data: [
target_rect.origin.x as f32,
target_rect.origin.y as f32,
target_rect.size.width as f32,
target_rect.size.height as f32,
target_index.0 as f32,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
],
}
RenderTaskKind::Scaling(..) |
RenderTaskKind::Alias(..) => {
(
[0.0; 3],
[0.0; 4],
)
}
RenderTaskKind::Alias(..) => RenderTaskData { data: [0.0; 12] },
};
let (target_rect, target_index) = self.get_target_rect();
RenderTaskData {
data: [
target_rect.origin.x as f32,
target_rect.origin.y as f32,
target_rect.size.width as f32,
target_rect.size.height as f32,
target_index.0 as f32,
data1[0],
data1[1],
data1[2],
data2[0],
data2[1],
data2[2],
data2[3],
]
}
}
@ -706,7 +619,6 @@ impl RenderTask {
pub fn target_kind(&self) -> RenderTargetKind {
match self.kind {
RenderTaskKind::Alpha(..) |
RenderTaskKind::Readback(..) => RenderTargetKind::Color,
RenderTaskKind::CacheMask(..) => {
@ -740,7 +652,6 @@ impl RenderTask {
// if we decide that is useful.
pub fn is_shared(&self) -> bool {
match self.kind {
RenderTaskKind::Alpha(..) |
RenderTaskKind::Picture(..) |
RenderTaskKind::VerticalBlur(..) |
RenderTaskKind::Readback(..) |

View File

@ -30,6 +30,7 @@ use device::{get_gl_format_bgra, ExternalTexture, FBOId, TextureSlot, VertexAttr
VertexAttributeKind};
use device::{FileWatcherHandler, ShaderError, TextureFilter, TextureTarget,
VertexUsageHint, VAO};
use device::ProgramCache;
use euclid::{rect, Transform3D};
use frame_builder::FrameBuilderConfig;
use gleam::gl;
@ -46,7 +47,7 @@ use rayon::Configuration as ThreadPoolConfig;
use rayon::ThreadPool;
use record::ApiRecordingReceiver;
use render_backend::RenderBackend;
use render_task::RenderTaskTree;
use render_task::{RenderTaskKind, RenderTaskTree};
#[cfg(feature = "debugger")]
use serde_json;
use std;
@ -171,36 +172,65 @@ const GPU_SAMPLER_TAG_TRANSPARENT: GpuProfileTag = GpuProfileTag {
color: debug_colors::BLACK,
};
#[cfg(feature = "debugger")]
impl TransformBatchKind {
#[cfg(feature = "debugger")]
fn debug_name(&self) -> &'static str {
match *self {
TransformBatchKind::Rectangle(..) => "Rectangle",
TransformBatchKind::TextRun(..) => "TextRun",
TransformBatchKind::Image(image_buffer_kind, ..) => match image_buffer_kind {
ImageBufferKind::Texture2D => "Image (2D)",
ImageBufferKind::TextureRect => "Image (Rect)",
ImageBufferKind::TextureExternal => "Image (External)",
ImageBufferKind::Texture2DArray => "Image (Array)",
},
TransformBatchKind::YuvImage(..) => "YuvImage",
TransformBatchKind::AlignedGradient => "AlignedGradient",
TransformBatchKind::AngleGradient => "AngleGradient",
TransformBatchKind::RadialGradient => "RadialGradient",
TransformBatchKind::BorderCorner => "BorderCorner",
TransformBatchKind::BorderEdge => "BorderEdge",
TransformBatchKind::Line => "Line",
}
}
fn gpu_sampler_tag(&self) -> GpuProfileTag {
match *self {
TransformBatchKind::Rectangle(_) => GPU_TAG_PRIM_RECT,
TransformBatchKind::Line => GPU_TAG_PRIM_LINE,
TransformBatchKind::TextRun(..) => GPU_TAG_PRIM_TEXT_RUN,
TransformBatchKind::Image(..) => GPU_TAG_PRIM_IMAGE,
TransformBatchKind::YuvImage(..) => GPU_TAG_PRIM_YUV_IMAGE,
TransformBatchKind::BorderCorner => GPU_TAG_PRIM_BORDER_CORNER,
TransformBatchKind::BorderEdge => GPU_TAG_PRIM_BORDER_EDGE,
TransformBatchKind::AlignedGradient => GPU_TAG_PRIM_GRADIENT,
TransformBatchKind::AngleGradient => GPU_TAG_PRIM_ANGLE_GRADIENT,
TransformBatchKind::RadialGradient => GPU_TAG_PRIM_RADIAL_GRADIENT,
}
}
}
impl BatchKind {
#[cfg(feature = "debugger")]
fn debug_name(&self) -> &'static str {
match *self {
BatchKind::Composite { .. } => "Composite",
BatchKind::HardwareComposite => "HardwareComposite",
BatchKind::SplitComposite => "SplitComposite",
BatchKind::Blend => "Blend",
BatchKind::Brush(kind) => {
match kind {
BrushBatchKind::Image(..) => "Brush (Image)",
}
}
BatchKind::Transformable(_, kind) => match kind {
TransformBatchKind::Rectangle(..) => "Rectangle",
TransformBatchKind::TextRun(..) => "TextRun",
TransformBatchKind::Image(image_buffer_kind, ..) => match image_buffer_kind {
ImageBufferKind::Texture2D => "Image (2D)",
ImageBufferKind::TextureRect => "Image (Rect)",
ImageBufferKind::TextureExternal => "Image (External)",
ImageBufferKind::Texture2DArray => "Image (Array)",
},
TransformBatchKind::YuvImage(..) => "YuvImage",
TransformBatchKind::AlignedGradient => "AlignedGradient",
TransformBatchKind::AngleGradient => "AngleGradient",
TransformBatchKind::RadialGradient => "RadialGradient",
TransformBatchKind::BorderCorner => "BorderCorner",
TransformBatchKind::BorderEdge => "BorderEdge",
TransformBatchKind::Line => "Line",
},
BatchKind::Brush(BrushBatchKind::Image(..)) => "Brush (Image)",
BatchKind::Transformable(_, batch_kind) => batch_kind.debug_name(),
}
}
fn gpu_sampler_tag(&self) -> GpuProfileTag {
match *self {
BatchKind::Composite { .. } => GPU_TAG_PRIM_COMPOSITE,
BatchKind::HardwareComposite => GPU_TAG_PRIM_HW_COMPOSITE,
BatchKind::SplitComposite => GPU_TAG_PRIM_SPLIT_COMPOSITE,
BatchKind::Blend => GPU_TAG_PRIM_BLEND,
BatchKind::Brush(BrushBatchKind::Image(_)) => GPU_TAG_BRUSH_IMAGE,
BatchKind::Transformable(_, batch_kind) => batch_kind.gpu_sampler_tag(),
}
}
}
@ -1175,10 +1205,10 @@ struct FrameOutput {
/// The renderer is responsible for submitting to the GPU the work prepared by the
/// RenderBackend.
pub struct Renderer {
pub struct Renderer<'a> {
result_rx: Receiver<ResultMsg>,
debug_server: DebugServer,
device: Device,
device: Device<'a>,
pending_texture_updates: Vec<TextureUpdateList>,
pending_gpu_cache_updates: Vec<GpuCacheUpdateList>,
pending_shader_updates: Vec<PathBuf>,
@ -1305,7 +1335,7 @@ impl From<std::io::Error> for RendererError {
}
}
impl Renderer {
impl<'a> Renderer<'a> {
/// Initializes webrender and creates a `Renderer` and `RenderApiSender`.
///
/// # Examples
@ -1344,6 +1374,7 @@ impl Renderer {
gl,
options.resource_override_path.clone(),
Box::new(file_watch_handler),
options.cached_programs,
);
let device_max_size = device.max_texture_size();
@ -1940,6 +1971,12 @@ impl Renderer {
mem::replace(&mut self.pipeline_epoch_map, FastHashMap::default())
}
// update the program cache with new binaries, e.g. when some of the lazy loaded
// shader programs got activated in the mean time
pub fn update_program_cache(&mut self, cached_programs: &'a mut ProgramCache) {
self.device.update_program_cache(cached_programs);
}
/// Processes the result queue.
///
/// Should be called before `render()`, as texture cache updates are done here.
@ -2477,16 +2514,13 @@ impl Renderer {
render_target: Option<(&Texture, i32)>,
target_dimensions: DeviceUintSize,
) {
let marker = match key.kind {
match key.kind {
BatchKind::Composite { .. } => {
self.ps_composite
.bind(&mut self.device, projection, 0, &mut self.renderer_errors);
GPU_TAG_PRIM_COMPOSITE
self.ps_composite.bind(&mut self.device, projection, 0, &mut self.renderer_errors);
}
BatchKind::HardwareComposite => {
self.ps_hw_composite
.bind(&mut self.device, projection, 0, &mut self.renderer_errors);
GPU_TAG_PRIM_HW_COMPOSITE
}
BatchKind::SplitComposite => {
self.ps_split_composite.bind(
@ -2495,12 +2529,9 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_SPLIT_COMPOSITE
}
BatchKind::Blend => {
self.ps_blend
.bind(&mut self.device, projection, 0, &mut self.renderer_errors);
GPU_TAG_PRIM_BLEND
self.ps_blend.bind(&mut self.device, projection, 0, &mut self.renderer_errors);
}
BatchKind::Brush(brush_kind) => {
match brush_kind {
@ -2516,7 +2547,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_BRUSH_IMAGE
}
}
}
@ -2550,7 +2580,6 @@ impl Renderer {
&mut self.renderer_errors,
);
}
GPU_TAG_PRIM_RECT
}
TransformBatchKind::Line => {
self.ps_line.bind(
@ -2560,7 +2589,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_LINE
}
TransformBatchKind::TextRun(..) => {
unreachable!("bug: text batches are special cased");
@ -2576,7 +2604,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_IMAGE
}
TransformBatchKind::YuvImage(image_buffer_kind, format, color_space) => {
let shader_index =
@ -2591,7 +2618,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_YUV_IMAGE
}
TransformBatchKind::BorderCorner => {
self.ps_border_corner.bind(
@ -2601,7 +2627,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_BORDER_CORNER
}
TransformBatchKind::BorderEdge => {
self.ps_border_edge.bind(
@ -2611,7 +2636,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_BORDER_EDGE
}
TransformBatchKind::AlignedGradient => {
self.ps_gradient.bind(
@ -2621,7 +2645,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_GRADIENT
}
TransformBatchKind::AngleGradient => {
self.ps_angle_gradient.bind(
@ -2631,7 +2654,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_ANGLE_GRADIENT
}
TransformBatchKind::RadialGradient => {
self.ps_radial_gradient.bind(
@ -2641,7 +2663,6 @@ impl Renderer {
0,
&mut self.renderer_errors,
);
GPU_TAG_PRIM_RADIAL_GRADIENT
}
},
};
@ -2671,8 +2692,14 @@ impl Renderer {
let (readback_rect, readback_layer) = readback.get_target_rect();
let (backdrop_rect, _) = backdrop.get_target_rect();
let backdrop_screen_origin = backdrop.as_alpha_batch().screen_origin;
let source_screen_origin = source.as_alpha_batch().screen_origin;
let backdrop_screen_origin = match backdrop.kind {
RenderTaskKind::Picture(ref task_info) => task_info.content_origin,
_ => panic!("bug: composite on non-picture?"),
};
let source_screen_origin = match source.kind {
RenderTaskKind::Picture(ref task_info) => task_info.content_origin,
_ => panic!("bug: composite on non-picture?"),
};
// Bind the FBO to blit the backdrop to.
// Called per-instance in case the layer (and therefore FBO)
@ -2682,10 +2709,12 @@ impl Renderer {
self.device
.bind_draw_target(Some(cache_draw_target), Some(cache_texture_dimensions));
let src_x =
backdrop_rect.origin.x - backdrop_screen_origin.x + source_screen_origin.x;
let src_y =
backdrop_rect.origin.y - backdrop_screen_origin.y + source_screen_origin.y;
let src_x = backdrop_rect.origin.x -
backdrop_screen_origin.x as i32 +
source_screen_origin.x as i32;
let src_y = backdrop_rect.origin.y -
backdrop_screen_origin.y as i32 +
source_screen_origin.y as i32;
let dest_x = readback_rect.origin.x;
let dest_y = readback_rect.origin.y;
@ -2720,7 +2749,7 @@ impl Renderer {
_ => {}
}
let _timer = self.gpu_profile.start_timer(marker);
let _timer = self.gpu_profile.start_timer(key.kind.gpu_sampler_tag());
self.draw_instanced_batch(instances, VertexArrayKind::Primitive, &key.textures);
}
@ -3600,7 +3629,7 @@ impl Renderer {
self.unlock_external_images();
}
pub fn debug_renderer<'a>(&'a mut self) -> &'a mut DebugRenderer {
pub fn debug_renderer<'b>(&'b mut self) -> &'b mut DebugRenderer {
&mut self.debug
}
@ -3859,7 +3888,7 @@ pub trait ThreadListener {
fn thread_stopped(&self, thread_name: &str);
}
pub struct RendererOptions {
pub struct RendererOptions<'a> {
pub device_pixel_ratio: f32,
pub resource_override_path: Option<PathBuf>,
pub enable_aa: bool,
@ -3880,12 +3909,13 @@ pub struct RendererOptions {
pub recorder: Option<Box<ApiRecordingReceiver>>,
pub thread_listener: Option<Box<ThreadListener + Send + Sync>>,
pub enable_render_on_scroll: bool,
pub cached_programs: Option<&'a mut ProgramCache>,
pub debug_flags: DebugFlags,
pub renderer_id: Option<u64>,
}
impl Default for RendererOptions {
fn default() -> RendererOptions {
impl<'a> Default for RendererOptions<'a> {
fn default() -> RendererOptions<'a> {
RendererOptions {
device_pixel_ratio: 1.0,
resource_override_path: None,
@ -3909,6 +3939,7 @@ impl Default for RendererOptions {
thread_listener: None,
enable_render_on_scroll: true,
renderer_id: None,
cached_programs: None,
}
}
}

View File

@ -17,7 +17,7 @@ use glyph_rasterizer::GlyphFormat;
use gpu_cache::{GpuCache, GpuCacheAddress, GpuCacheHandle, GpuCacheUpdateList};
use gpu_types::{BlurDirection, BlurInstance, BrushInstance, BrushImageKind, ClipMaskInstance};
use gpu_types::{CompositePrimitiveInstance, PrimitiveInstance, SimplePrimitiveInstance};
use gpu_types::{BRUSH_FLAG_USES_PICTURE, ClipScrollNodeIndex, ClipScrollNodeData};
use gpu_types::{ClipScrollNodeIndex, ClipScrollNodeData};
use internal_types::{FastHashMap, SourceTexture};
use internal_types::BatchTextures;
use picture::{PictureCompositeMode, PictureKind, PicturePrimitive};
@ -1021,17 +1021,25 @@ impl AlphaBatcher {
) {
for task_id in &self.tasks {
let task_id = *task_id;
let task = render_tasks.get(task_id).as_alpha_batch();
let pic = &ctx.prim_store.cpu_pictures[ctx.prim_store.cpu_metadata[task.prim_index.0].cpu_prim_index.0];
pic.add_to_batch(
task_id,
ctx,
gpu_cache,
render_tasks,
deferred_resolves,
&mut self.batch_list,
&mut self.glyph_fetch_buffer
);
let task = render_tasks.get(task_id);
match task.kind {
RenderTaskKind::Picture(ref pic_task) => {
let pic_index = ctx.prim_store.cpu_metadata[pic_task.prim_index.0].cpu_prim_index;
let pic = &ctx.prim_store.cpu_pictures[pic_index.0];
pic.add_to_batch(
task_id,
ctx,
gpu_cache,
render_tasks,
deferred_resolves,
&mut self.batch_list,
&mut self.glyph_fetch_buffer
);
}
_ => {
unreachable!();
}
}
}
self.batch_list.finalize();
@ -1413,18 +1421,6 @@ impl RenderTarget for ColorRenderTarget {
RenderTaskKind::Alias(..) => {
panic!("BUG: add_task() called on invalidated task");
}
RenderTaskKind::Alpha(ref info) => {
self.alpha_batcher.add_task(task_id);
// If this pipeline is registered as a frame output
// store the information necessary to do the copy.
if let Some(pipeline_id) = info.frame_output_pipeline_id {
self.outputs.push(FrameOutput {
pipeline_id,
task_id,
});
}
}
RenderTaskKind::VerticalBlur(ref info) => {
info.add_instances(
&mut self.vertical_blurs,
@ -1449,61 +1445,78 @@ impl RenderTarget for ColorRenderTarget {
PrimitiveKind::Picture => {
let prim = &ctx.prim_store.cpu_pictures[prim_metadata.cpu_prim_index.0];
let task_index = render_tasks.get_task_address(task_id);
match prim.kind {
PictureKind::Image { frame_output_pipeline_id, .. } => {
self.alpha_batcher.add_task(task_id);
for run in &prim.runs {
for i in 0 .. run.count {
let sub_prim_index = PrimitiveIndex(run.base_prim_index.0 + i);
// If this pipeline is registered as a frame output
// store the information necessary to do the copy.
if let Some(pipeline_id) = frame_output_pipeline_id {
self.outputs.push(FrameOutput {
pipeline_id,
task_id,
});
}
}
PictureKind::TextShadow { .. } |
PictureKind::BoxShadow { .. } => {
let task_index = render_tasks.get_task_address(task_id);
let sub_metadata = ctx.prim_store.get_metadata(sub_prim_index);
let sub_prim_address =
gpu_cache.get_address(&sub_metadata.gpu_location);
let instance = SimplePrimitiveInstance::new(
sub_prim_address,
task_index,
RenderTaskAddress(0),
ClipScrollNodeIndex(0),
ClipScrollNodeIndex(0),
0,
); // z is disabled for rendering cache primitives
for run in &prim.runs {
for i in 0 .. run.count {
let sub_prim_index = PrimitiveIndex(run.base_prim_index.0 + i);
match sub_metadata.prim_kind {
PrimitiveKind::TextRun => {
// Add instances that reference the text run GPU location. Also supply
// the parent shadow prim address as a user data field, allowing
// the shader to fetch the shadow parameters.
let text = &ctx.prim_store.cpu_text_runs
[sub_metadata.cpu_prim_index.0];
let text_run_cache_prims = &mut self.text_run_cache_prims;
let sub_metadata = ctx.prim_store.get_metadata(sub_prim_index);
let sub_prim_address =
gpu_cache.get_address(&sub_metadata.gpu_location);
let instance = SimplePrimitiveInstance::new(
sub_prim_address,
task_index,
RenderTaskAddress(0),
ClipScrollNodeIndex(0),
ClipScrollNodeIndex(0),
0,
); // z is disabled for rendering cache primitives
let font = text.get_font(ctx.device_pixel_ratio);
match sub_metadata.prim_kind {
PrimitiveKind::TextRun => {
// Add instances that reference the text run GPU location. Also supply
// the parent shadow prim address as a user data field, allowing
// the shader to fetch the shadow parameters.
let text = &ctx.prim_store.cpu_text_runs
[sub_metadata.cpu_prim_index.0];
let text_run_cache_prims = &mut self.text_run_cache_prims;
ctx.resource_cache.fetch_glyphs(
font,
&text.glyph_keys,
&mut self.glyph_fetch_buffer,
gpu_cache,
|texture_id, _glyph_format, glyphs| {
let batch = text_run_cache_prims
.entry(texture_id)
.or_insert(Vec::new());
let font = text.get_font(ctx.device_pixel_ratio);
for glyph in glyphs {
batch.push(instance.build(
glyph.index_in_text_run,
glyph.uv_rect_address.as_int(),
0
));
}
},
);
}
PrimitiveKind::Line => {
self.line_cache_prims
.push(instance.build(0, 0, 0));
}
_ => {
unreachable!("Unexpected sub primitive type");
ctx.resource_cache.fetch_glyphs(
font,
&text.glyph_keys,
&mut self.glyph_fetch_buffer,
gpu_cache,
|texture_id, _glyph_format, glyphs| {
let batch = text_run_cache_prims
.entry(texture_id)
.or_insert(Vec::new());
for glyph in glyphs {
batch.push(instance.build(
glyph.index_in_text_run,
glyph.uv_rect_address.as_int(),
0
));
}
},
);
}
PrimitiveKind::Line => {
self.line_cache_prims
.push(instance.build(0, 0, 0));
}
_ => {
unreachable!("Unexpected sub primitive type");
}
}
}
}
}
@ -1592,7 +1605,6 @@ impl RenderTarget for AlphaRenderTarget {
RenderTaskKind::Alias(..) => {
panic!("BUG: add_task() called on invalidated task");
}
RenderTaskKind::Alpha(..) |
RenderTaskKind::Readback(..) => {
panic!("Should not be added to alpha target!");
}
@ -1645,7 +1657,7 @@ impl RenderTarget for AlphaRenderTarget {
scroll_id: ClipScrollNodeIndex(0),
clip_task_address: RenderTaskAddress(0),
z: 0,
flags: BRUSH_FLAG_USES_PICTURE,
flags: 0,
user_data0: 0,
user_data1: 0,
};

View File

@ -1,6 +1,6 @@
[package]
name = "webrender_api"
version = "0.53.2"
version = "0.54.0"
authors = ["Glenn Watson <gw@intuitionlibrary.com>"]
license = "MPL-2.0"
repository = "https://github.com/servo/webrender"
@ -21,7 +21,7 @@ time = "0.1"
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.4"
core-graphics = "0.9"
core-graphics = "0.12.2"
[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.4"

View File

@ -26,6 +26,10 @@ impl PremultipliedColorF {
pub const BLACK: Self = PremultipliedColorF { r: 0.0, g: 0.0, b: 0.0, a: 1.0 };
///
pub const TRANSPARENT: Self = PremultipliedColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 };
pub fn to_array(&self) -> [f32; 4] {
[self.r, self.g, self.b, self.a]
}
}
/// Represents RGBA screen colors with floating point numbers.

View File

@ -5,17 +5,17 @@ authors = ["The Mozilla Project Developers"]
license = "MPL-2.0"
[dependencies]
webrender_api = {path = "../webrender_api", version = "0.53.2"}
webrender_api = {path = "../webrender_api", version = "0.54.0"}
rayon = "0.8"
thread_profiler = "0.1.1"
euclid = "0.15"
app_units = "0.5.6"
gleam = "0.4"
gleam = "0.4.14"
log = "0.3"
[dependencies.webrender]
path = "../webrender"
version = "0.53.2"
version = "0.54.0"
default-features = false
[target.'cfg(target_os = "windows")'.dependencies]
@ -23,5 +23,5 @@ dwrote = "0.4"
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.4"
core-graphics = "0.9"
core-graphics = "0.12.2"