mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
This updates webrender to include the webgl related changes needed for this patch. There was an additional commit in webrender before these landed, so also copy the shaders for that change across. There is an interface change to webrender push_image. For now, just pass zero, which is a no-op to this function. A follow up commit will introduce the servo specific changes to use this new interface.
32 lines
1.3 KiB
GLSL
32 lines
1.3 KiB
GLSL
#line 1
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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/. */
|
|
|
|
void main(void) {
|
|
#ifdef WR_FEATURE_TRANSFORM
|
|
float alpha = 1;
|
|
vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
|
|
|
|
// We clamp the texture coordinate calculation here to the local rectangle boundaries,
|
|
// which makes the edge of the texture stretch instead of repeat.
|
|
vec2 pos_for_texture =
|
|
clamp(pos, vLocalRect.xy, vLocalRect.xy + vLocalRect.zw) - vLocalRect.xy;
|
|
#else
|
|
float alpha = 1;
|
|
vec2 local_pos = vLocalPos;
|
|
vec2 relative_pos_in_rect = vLocalPos - vLocalRect.xy;
|
|
#endif
|
|
|
|
alpha = min(alpha, do_clip(local_pos, vClipRect, vClipRadius));
|
|
|
|
// We calculate the particular tile this fragment belongs to, taking into
|
|
// account the spacing in between tiles. We only paint if our fragment does
|
|
// not fall into that spacing.
|
|
vec2 position_in_tile = mod(relative_pos_in_rect, vStretchSize + vTileSpacing);
|
|
vec2 st = vTextureOffset + ((position_in_tile / vStretchSize) * vTextureSize);
|
|
alpha = alpha * float(all(bvec2(step(position_in_tile, vStretchSize))));
|
|
|
|
oFragColor = texture(sDiffuse, st) * vec4(1, 1, 1, alpha);
|
|
}
|