Extended Color: Streamline SimpleColor premulitply/unpremultiply code
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jun 2020 21:05:09 +0000 (21:05 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jun 2020 21:05:09 +0000 (21:05 +0000)
commita8e0f0db49d48427d2f2e0433b5775a4d6fd6e58
tree368f0da8afd32401d48eac64d99673efa8f6e06c
parent900c1a9377ed51dedda09f50bee058f523d444f7
Extended Color: Streamline SimpleColor premulitply/unpremultiply code
https://bugs.webkit.org/show_bug.cgi?id=212945

Reviewed by Darin Adler.

Simplify / streamline the premulitply/unpremultiply code by:
- Removing the overloads that didn't take individual components, keeping
  only the ones taking a SimpleColor.
- Replacing the "ceiling" bool in makePremultipliedSimpleColor and converting
  it into two functions.
- Simplifying the names from makePremultipliedSimpleColor/makeUnpremultipliedSimpleColor
  to premultiplyFlooring/premultiplyCeiling/unpremultiply.
- Where component order is important, use valueAsARGB() explicitly to
  show what the resulting value's format will be.

* platform/graphics/Color.cpp:
(WebCore::blend):
Update to call premultiplyCeiling/unpremultiply.

* platform/graphics/ImageBackingStore.h:
(WebCore::ImageBackingStore::blendPixel):
(WebCore::ImageBackingStore::pixelValue const):
Update to call premultiplyFlooring/unpremultiply and valueAsARGB().

* platform/graphics/SimpleColor.h:
* platform/graphics/SimpleColor.cpp:
(WebCore::premultiplyFlooring):
(WebCore::premultiplyCeiling):
(WebCore::unpremultiplyChannel):
(WebCore::unpremultiply):
(WebCore::premultipliedChannel): Deleted.
(WebCore::unpremultipliedChannel): Deleted.
(WebCore::makePremultipliedSimpleColor): Deleted.
(WebCore::makeUnpremultipliedSimpleColor): Deleted.
Simplify premulitply/unpremultiply interfaces. Use structured bindings to make
the code a bit easier to follow as well.

* platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp:
(WebCore::ImageBufferCairoImageSurfaceBackend::platformTransformColorSpace):
Update to call premultiplyFlooring/unpremultiply and valueAsARGB().

* platform/graphics/cairo/NativeImageCairo.cpp:
(WebCore::nativeImageSinglePixelSolidColor):
Update to call premultiplyFlooring/unpremultiply and valueAsARGB(). Also removes
reinterpret cast to SimpleColor, instead following the model in ImageBufferCairoImageSurfaceBackend
and casting to unsigned, and building the SimpleColor from that. This will allow
SimpleColor to change its underlying representation in the future without breaking things.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/ImageBackingStore.h
Source/WebCore/platform/graphics/SimpleColor.cpp
Source/WebCore/platform/graphics/SimpleColor.h
Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp
Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp