mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
Bug 1528881 - Part 3: gfx: Move FAST_DIVIDE_BY_255 macro definition to nsColor.cpp. r=jrmuizel
FAST_DIVIDE_BY_255 was defined in nsColor.h but only used in nsColor.cpp. Differential Revision: https://phabricator.services.mozilla.com/D20262 --HG-- extra : source : f41b6d89c97e28400d18226ac47d97f4d8772f6b extra : intermediate-source : 6cc308158076ae86b6e7c5356ee71189ea9b883b extra : histedit_source : b4de73d30ec2e86dbed261d6eb7c6d71473a78b1
This commit is contained in:
parent
fe045e7d23
commit
1455d32b61
@ -206,6 +206,18 @@ bool NS_ColorNameToRGB(const nsAString& aColorName, nscolor* aResult) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fast approximate division by 255. It has the property that
|
||||
// for all 0 <= n <= 255*255, FAST_DIVIDE_BY_255(n) == n/255.
|
||||
// But it only uses two adds and two shifts instead of an
|
||||
// integer division (which is expensive on many processors).
|
||||
//
|
||||
// equivalent to target=v/255
|
||||
#define FAST_DIVIDE_BY_255(target, v) \
|
||||
PR_BEGIN_MACRO \
|
||||
unsigned tmp_ = v; \
|
||||
target = ((tmp_ << 8) + tmp_ + 255) >> 16; \
|
||||
PR_END_MACRO
|
||||
|
||||
// Macro to blend two colors
|
||||
//
|
||||
// equivalent to target = (bg*(255-fgalpha) + fg*fgalpha)/255
|
||||
|
@ -48,18 +48,6 @@ inline uint8_t ClampColor(T aColor) {
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
// Fast approximate division by 255. It has the property that
|
||||
// for all 0 <= n <= 255*255, FAST_DIVIDE_BY_255(n) == n/255.
|
||||
// But it only uses two adds and two shifts instead of an
|
||||
// integer division (which is expensive on many processors).
|
||||
//
|
||||
// equivalent to target=v/255
|
||||
#define FAST_DIVIDE_BY_255(target, v) \
|
||||
PR_BEGIN_MACRO \
|
||||
unsigned tmp_ = v; \
|
||||
target = ((tmp_ << 8) + tmp_ + 255) >> 16; \
|
||||
PR_END_MACRO
|
||||
|
||||
enum class nsHexColorType : uint8_t {
|
||||
NoAlpha, // 3 or 6 digit hex colors only
|
||||
AllowAlpha, // 3, 4, 6, or 8 digit hex colors
|
||||
|
Loading…
Reference in New Issue
Block a user