mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1084093, part 1 - Add some helpers to Moz2D Color to convert to/from packed ARGB. r=Bas
This commit is contained in:
parent
b0acb565de
commit
39e820da80
@ -232,12 +232,28 @@ public:
|
||||
return newColor;
|
||||
}
|
||||
|
||||
static Color FromARGB(uint32_t aColor)
|
||||
{
|
||||
Color newColor(((aColor >> 16) & 0xff) * (1.0f / 255.0f),
|
||||
((aColor >> 8) & 0xff) * (1.0f / 255.0f),
|
||||
((aColor >> 0) & 0xff) * (1.0f / 255.0f),
|
||||
((aColor >> 24) & 0xff) * (1.0f / 255.0f));
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
uint32_t ToABGR() const
|
||||
{
|
||||
return uint32_t(r * 255.0f) | uint32_t(g * 255.0f) << 8 |
|
||||
uint32_t(b * 255.0f) << 16 | uint32_t(a * 255.0f) << 24;
|
||||
}
|
||||
|
||||
uint32_t ToARGB() const
|
||||
{
|
||||
return uint32_t(b * 255.0f) | uint32_t(g * 255.0f) << 8 |
|
||||
uint32_t(r * 255.0f) << 16 | uint32_t(a * 255.0f) << 24;
|
||||
}
|
||||
|
||||
Float r, g, b, a;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user