Skip to content

Commit 102663b

Browse files
committed
Add simple RGBA8 support
1 parent 29dab25 commit 102663b

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

webrender/src/device/gl.rs

Lines changed: 8 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ pub enum ImageFormat {
101101
RG8 = 5,
102102
/// Four channels, signed integer storage.
103103
RGBAI32 = 6,
104+
/// Four channels, byte storage.
105+
RGBA8 = 7,
104106
}
105107

106108
impl ImageFormat {
@@ -113,6 +115,7 @@ impl ImageFormat {
113115
ImageFormat::RGBAF32 => 16,
114116
ImageFormat::RG8 => 2,
115117
ImageFormat::RGBAI32 => 16,
118+
ImageFormat::RGBA8 => 4,
116119
}
117120
}
118121
}

wrench/src/yaml_frame_reader.rs

Lines changed: 2 additions & 1 deletion
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)