Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / gfx / wr / webrender / res / render_task.glsl
blobe5d0c298cdafb9c939add004397ec446053511fc
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifdef WR_VERTEX_SHADER
7 #define VECS_PER_RENDER_TASK        2U
9 uniform HIGHP_SAMPLER_FLOAT sampler2D sRenderTasks;
11 struct RenderTaskData {
12     RectWithEndpoint task_rect;
13     vec4 user_data;
16 // See RenderTaskData in render_task.rs
17 RenderTaskData fetch_render_task_data(int index) {
18     ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
20     vec4 texel0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
21     vec4 texel1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
23     RectWithEndpoint task_rect = RectWithEndpoint(
24         texel0.xy,
25         texel0.zw
26     );
28     RenderTaskData data = RenderTaskData(
29         task_rect,
30         texel1
31     );
33     return data;
36 RectWithEndpoint fetch_render_task_rect(int index) {
37     ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
39     vec4 texel0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
40     vec4 texel1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
42     RectWithEndpoint task_rect = RectWithEndpoint(
43         texel0.xy,
44         texel0.zw
45     );
47     return task_rect;
50 #define PIC_TYPE_IMAGE          1
51 #define PIC_TYPE_TEXT_SHADOW    2
54  The dynamic picture that this brush exists on. Right now, it
55  contains minimal information. In the future, it will describe
56  the transform mode of primitives on this picture, among other things.
57  */
58 struct PictureTask {
59     RectWithEndpoint task_rect;
60     float device_pixel_scale;
61     vec2 content_origin;
64 PictureTask fetch_picture_task(int address) {
65     RenderTaskData task_data = fetch_render_task_data(address);
67     PictureTask task = PictureTask(
68         task_data.task_rect,
69         task_data.user_data.x,
70         task_data.user_data.yz
71     );
73     return task;
76 #define CLIP_TASK_EMPTY 0x7FFFFFFF
78 struct ClipArea {
79     RectWithEndpoint task_rect;
80     float device_pixel_scale;
81     vec2 screen_origin;
84 ClipArea fetch_clip_area(int index) {
85     RenderTaskData task_data;
86     if (index >= CLIP_TASK_EMPTY) {
87       // We deliberately create a dummy RenderTaskData here then convert to a
88       // ClipArea after this if-else statement, rather than initialize the
89       // ClipArea in separate branches, to avoid a miscompile in some Adreno
90       // drivers. See bug 1884791. Unfortunately the specific details of the bug
91       // are unknown, so please take extra care not to regress this when
92       // refactoring.
93       task_data = RenderTaskData(RectWithEndpoint(vec2(0.0), vec2(0.0)),
94                                  vec4(0.0));
95     } else {
96       task_data = fetch_render_task_data(index);
97     }
99     return ClipArea(task_data.task_rect, task_data.user_data.x,
100                     task_data.user_data.yz);
103 #endif //WR_VERTEX_SHADER