Skip to content

Commit 195582a

Browse files
author
bors-servo
authored
Auto merge of #3337 - sotaroikeda:rgba, r=nical
Add simple RGBA8 support Current Linux with Wayland causes crash when WebGL exists. By [Bug 1482350 Comment 15](https://bugzilla.mozilla.org/show_bug.cgi?id=1482350#c15), WebRender needs to support RGBA8. This is a simple quick fix for supporting RGBA8. See [Bug 1482350](https://bugzilla.mozilla.org/show_bug.cgi?id=1482350) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3337) <!-- Reviewable:end -->
2 parents ea8f4a9 + 102663b commit 195582a

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

webrender/src/device/gl.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,13 @@ impl Device {
26272627
pixel_type: gl::UNSIGNED_BYTE,
26282628
}
26292629
},
2630+
ImageFormat::RGBA8 => {
2631+
FormatDesc {
2632+
internal: gl::RGBA8,
2633+
external: gl::RGBA,
2634+
pixel_type: gl::UNSIGNED_BYTE,
2635+
}
2636+
},
26302637
ImageFormat::RGBAF32 => FormatDesc {
26312638
internal: gl::RGBA32F,
26322639
external: gl::RGBA,
@@ -2783,6 +2790,7 @@ impl<'a> UploadTarget<'a> {
27832790
ImageFormat::R8 => (gl::RED, 1, gl::UNSIGNED_BYTE),
27842791
ImageFormat::R16 => (gl::RED, 2, gl::UNSIGNED_SHORT),
27852792
ImageFormat::BGRA8 => (self.bgra_format, 4, gl::UNSIGNED_BYTE),
2793+
ImageFormat::RGBA8 => (gl::RGBA, 4, gl::UNSIGNED_BYTE),
27862794
ImageFormat::RG8 => (gl::RG, 2, gl::UNSIGNED_BYTE),
27872795
ImageFormat::RGBAF32 => (gl::RGBA, 16, gl::FLOAT),
27882796
ImageFormat::RGBAI32 => (gl::RGBA_INTEGER, 16, gl::INT),

webrender/src/texture_cache.rs

+6
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,12 @@ impl TextureCache {
953953
) -> bool {
954954
let mut allowed_in_shared_cache = true;
955955

956+
// TODO(sotaro): For now, anything that requests RGBA8 just fails to allocate
957+
// in a texture page, and gets a standalone texture.
958+
if descriptor.format == ImageFormat::RGBA8 {
959+
allowed_in_shared_cache = false;
960+
}
961+
956962
// TODO(gw): For now, anything that requests nearest filtering and isn't BGRA8
957963
// just fails to allocate in a texture page, and gets a standalone
958964
// texture. This is probably rare enough that it can be fixed up later.

webrender_api/src/image.rs

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ pub enum ImageFormat {
116116
RG8 = 5,
117117
/// Four channels, signed integer storage.
118118
RGBAI32 = 6,
119+
/// Four channels, byte storage.
120+
RGBA8 = 7,
119121
}
120122

121123
impl ImageFormat {
@@ -128,6 +130,7 @@ impl ImageFormat {
128130
ImageFormat::RGBAF32 => 16,
129131
ImageFormat::RG8 => 2,
130132
ImageFormat::RGBAI32 => 16,
133+
ImageFormat::RGBA8 => 4,
131134
}
132135
}
133136
}

wrench/src/yaml_frame_reader.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ fn generate_solid_color_image(
178178

179179
fn is_image_opaque(format: ImageFormat, bytes: &[u8]) -> bool {
180180
match format {
181-
ImageFormat::BGRA8 => {
181+
ImageFormat::BGRA8 |
182+
ImageFormat::RGBA8 => {
182183
let mut is_opaque = true;
183184
for i in 0 .. (bytes.len() / 4) {
184185
if bytes[i * 4 + 3] != 255 {

0 commit comments

Comments
 (0)