Skip to content

Commit 40c21eb

Browse files
committed
core: Rename Color::argb to Color::rgba to reflect internal representation
1 parent d9b70fb commit 40c21eb

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

core/src/avm2/globals/flash/display3D/textures/texture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn do_copy<'gc>(
4747
.chunks_exact(4)
4848
.map(|chunk| {
4949
// The ByteArray is in BGRA format. FIXME - should this be premultiplied?
50-
Color::argb(chunk[3], chunk[2], chunk[1], chunk[0])
50+
Color::rgba(chunk[2], chunk[1], chunk[0], chunk[3])
5151
})
5252
.collect();
5353

core/src/bitmap/bitmap_data.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub enum BitmapDataDrawError {
5959

6060
impl Color {
6161
#[must_use]
62-
pub fn argb(a: u8, r: u8, g: u8, b: u8) -> Self {
62+
pub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self {
6363
Self { r, g, b, a }
6464
}
6565

@@ -100,7 +100,7 @@ impl Color {
100100
let g = ((self.green() as u32 * a + 127) / 255) as u8;
101101
let b = ((self.blue() as u32 * a + 127) / 255) as u8;
102102

103-
Self::argb(old_alpha, r, g, b)
103+
Self::rgba(r, g, b, old_alpha)
104104
}
105105

106106
#[must_use]
@@ -143,12 +143,12 @@ impl Color {
143143
let g = unmultiply(self.green());
144144
let b = unmultiply(self.blue());
145145

146-
Self::argb(self.alpha(), r, g, b)
146+
Self::rgba(r, g, b, self.alpha())
147147
}
148148

149149
#[must_use]
150150
pub fn with_alpha(&self, alpha: u8) -> Self {
151-
Self::argb(alpha, self.red(), self.green(), self.blue())
151+
Self::rgba(self.red(), self.green(), self.blue(), alpha)
152152
}
153153

154154
/// # Arguments
@@ -163,7 +163,7 @@ impl Color {
163163
let g = source.green() + ((self.green() as u16 * (255 - sa as u16)) / 255) as u8;
164164
let b = source.blue() + ((self.blue() as u16 * (255 - sa as u16)) / 255) as u8;
165165
let a = source.alpha() + ((self.alpha() as u16 * (255 - sa as u16)) / 255) as u8;
166-
Self::argb(a, r, g, b)
166+
Self::rgba(r, g, b, a)
167167
}
168168

169169
fn slice_as_rgba(slice: &[Self]) -> &[u8] {
@@ -191,7 +191,7 @@ impl From<u32> for Color {
191191

192192
impl From<swf::Color> for Color {
193193
fn from(c: swf::Color) -> Self {
194-
Self::argb(c.a, c.r, c.g, c.b)
194+
Self::rgba(c.r, c.g, c.b, c.a)
195195
}
196196
}
197197

@@ -837,7 +837,7 @@ fn copy_pixels_to_bitmapdata(
837837
255
838838
};
839839

840-
let nc = Color::argb(a, r, g, b);
840+
let nc = Color::rgba(r, g, b, a);
841841

842842
// Ignore the original color entirely - the blending (including alpha)
843843
// was done by the renderer when it wrote over the previous texture contents.

core/src/bitmap/operations.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub fn noise<'gc>(
218218
255
219219
};
220220

221-
Color::argb(alpha, gray, gray, gray)
221+
Color::rgba(gray, gray, gray, alpha)
222222
} else {
223223
let r = if channel_options.contains(ChannelOptions::RED) {
224224
rng.random_range(low..high)
@@ -244,7 +244,7 @@ pub fn noise<'gc>(
244244
255
245245
};
246246

247-
Color::argb(a, r, g, b)
247+
Color::rgba(r, g, b, a)
248248
};
249249

250250
write.set_pixel32_raw(x, y, pixel_color);
@@ -364,7 +364,7 @@ pub fn perlin_noise<'gc>(
364364
color[3] = 255;
365365
}
366366

367-
write.set_pixel32_raw(x, y, Color::argb(color[3], color[0], color[1], color[2]));
367+
write.set_pixel32_raw(x, y, Color::rgba(color[0], color[1], color[2], color[3]));
368368
}
369369
}
370370
let region = PixelRegion::for_whole_size(write.width(), write.height());
@@ -773,19 +773,19 @@ pub fn compare<'gc>(
773773
let bitmap_pixel = bitmap_pixel.to_un_multiplied_alpha();
774774
let other_pixel = other_pixel.to_un_multiplied_alpha();
775775
if bitmap_pixel == other_pixel {
776-
Color::argb(0, 0, 0, 0)
776+
Color::rgba(0, 0, 0, 0)
777777
} else if bitmap_pixel.with_alpha(0) != other_pixel.with_alpha(0) {
778778
different = true;
779-
Color::argb(
780-
0xff,
779+
Color::rgba(
781780
bitmap_pixel.red().wrapping_sub(other_pixel.red()),
782781
bitmap_pixel.green().wrapping_sub(other_pixel.green()),
783782
bitmap_pixel.blue().wrapping_sub(other_pixel.blue()),
783+
0xff,
784784
)
785785
} else {
786786
different = true;
787787
let alpha = bitmap_pixel.alpha().wrapping_sub(other_pixel.alpha());
788-
Color::argb(alpha, alpha, alpha, alpha)
788+
Color::rgba(alpha, alpha, alpha, alpha)
789789
}
790790
})
791791
.collect();
@@ -1021,7 +1021,7 @@ pub fn merge<'gc>(
10211021
+ dest_color.alpha() as u16 * (256 - alpha_mult))
10221022
/ 256;
10231023

1024-
let mix_color = Color::argb(alpha as u8, red as u8, green as u8, blue as u8);
1024+
let mix_color = Color::rgba(red as u8, green as u8, blue as u8, alpha as u8);
10251025

10261026
write.set_pixel32_raw(
10271027
dest_x,
@@ -1186,7 +1186,7 @@ pub fn copy_pixels_with_alpha_source<'gc>(
11861186
let r = (source_color.red() as f64 / a).round() as u8;
11871187
let g = (source_color.green() as f64 / a).round() as u8;
11881188
let b = (source_color.blue() as f64 / a).round() as u8;
1189-
let intermediate_color = Color::argb(source_color.alpha(), r, g, b)
1189+
let intermediate_color = Color::rgba(r, g, b, source_color.alpha())
11901190
.with_alpha(final_alpha)
11911191
.to_premultiplied_alpha(true);
11921192

0 commit comments

Comments
 (0)