Make CompositeOperator and BlendMode encodable
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Dec 2019 06:10:25 +0000 (06:10 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Dec 2019 06:10:25 +0000 (06:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204722

Reviewed by Eric Carlson.

Source/WebCore:

Make CompositeOperator an `enum class`, and fix the fallout.
Add EnumTraits for CompositeOperator and BlendMode, so that they can be encoded.

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator CompositeOperator const):
* dom/Document.cpp:
(WebCore::Document::compositeOperatorForBackgroundColor const):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::HTMLImageElement):
(WebCore::HTMLImageElement::parseAttribute):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawTextInternal):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::State::State):
(WebCore::CanvasRenderingContext2DBase::setGlobalCompositeOperation):
(WebCore::CanvasRenderingContext2DBase::isFullCanvasCompositeMode):
(WebCore::CanvasRenderingContext2DBase::fillInternal):
(WebCore::CanvasRenderingContext2DBase::strokeInternal):
(WebCore::CanvasRenderingContext2DBase::clearRect):
(WebCore::CanvasRenderingContext2DBase::fillRect):
(WebCore::CanvasRenderingContext2DBase::strokeRect):
(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::CanvasRenderingContext2DBase::drawImageFromRect):
(WebCore::CanvasRenderingContext2DBase::fullCanvasCompositedDrawImage):
* inspector/InspectorOverlay.cpp:
(WebCore::drawOutlinedQuadWithClip):
* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::CrossfadeGeneratedImage::drawCrossfade):
* platform/graphics/GraphicsContext.h:
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::dumpProperties const):
* platform/graphics/GraphicsTypes.cpp:
(WebCore::parseCompositeAndBlendOperator):
(WebCore::compositeOperatorName):
* platform/graphics/GraphicsTypes.h:
* platform/graphics/Image.cpp:
(WebCore::Image::fillWithSolidColor):
* platform/graphics/ImagePaintingOptions.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ShadowBlur::blurAndColorShadowBuffer):
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::drawNativeImage):
* platform/graphics/cairo/CairoOperations.h:
* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::toCairoCompositeOperator):
* platform/graphics/cg/GraphicsContext3DCG.cpp:
(WebCore::GraphicsContext3D::paintToCanvas):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::selectCGBlendMode):
* platform/graphics/filters/FEBlend.cpp:
(WebCore::FEBlend::platformApplySoftware):
(WebCore::FEBlend::externalRepresentation const):
* platform/graphics/filters/FEComposite.cpp:
(WebCore::FEComposite::platformApplySoftware):
* platform/graphics/filters/FEDropShadow.cpp:
(WebCore::FEDropShadow::platformApplySoftware):
* platform/graphics/filters/SourceAlpha.cpp:
(WebCore::SourceAlpha::platformApplySoftware):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::paint):
* platform/graphics/nicosia/NicosiaPaintingEngineBasic.cpp:
(Nicosia::PaintingEngineBasic::paint):
* platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp:
(Nicosia::paintLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
* platform/graphics/win/Direct2DOperations.cpp:
(WebCore::Direct2D::State::setCompositeOperation):
* platform/graphics/win/Direct2DOperations.h:
* platform/graphics/win/ImageCGWin.cpp:
(WebCore::BitmapImage::getHBITMAPOfSize):
* platform/graphics/win/ImageCairoWin.cpp:
(WebCore::BitmapImage::getHBITMAPOfSize):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paintMask):
* rendering/InlineFlowBox.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintMaskImages):
* rendering/RenderBox.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderBoxModelObject.h:
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::paintReplaced):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintIntoRect):
* rendering/RenderLayerBacking.cpp:
(WebCore::supportsDirectlyCompositedBoxDecorations):
* rendering/RenderTreeAsText.cpp:
* rendering/RenderView.cpp:
(WebCore::RenderView::paintBoxDecorations):
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::FillLayer):
(WebCore::FillLayer::hasOpaqueImage const):
* rendering/style/FillLayer.h:
(WebCore::FillLayer::initialFillComposite):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
(WebCore::SVGImage::draw):

Source/WebKit:

* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::incorporateUpdate):
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::paint):
(WebKit::PluginProxy::update):
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::drawRect):

Source/WebKitLegacy/win:

* FullscreenVideoController.cpp:
(FullscreenVideoController::draw):
* WebView.cpp:
(WebView::paintWithDirect2D):
(WebView::paintIntoBackingStore):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252965 268f45cc-cd09-0410-ab3c-d52691b4dbfc

53 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/dom/Document.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsTypes.cpp
Source/WebCore/platform/graphics/GraphicsTypes.h
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/platform/graphics/ImagePaintingOptions.h
Source/WebCore/platform/graphics/ShadowBlur.cpp
Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
Source/WebCore/platform/graphics/cairo/CairoOperations.h
Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/filters/FEBlend.cpp
Source/WebCore/platform/graphics/filters/FEComposite.cpp
Source/WebCore/platform/graphics/filters/FEDropShadow.cpp
Source/WebCore/platform/graphics/filters/SourceAlpha.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngineBasic.cpp
Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/win/Direct2DOperations.cpp
Source/WebCore/platform/graphics/win/Direct2DOperations.h
Source/WebCore/platform/graphics/win/ImageCGWin.cpp
Source/WebCore/platform/graphics/win/ImageCairoWin.cpp
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineFlowBox.h
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/style/FillLayer.cpp
Source/WebCore/rendering/style/FillLayer.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp
Source/WebKit/WebProcess/Plugins/PluginProxy.cpp
Source/WebKit/WebProcess/WebPage/FindController.cpp
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/FullscreenVideoController.cpp
Source/WebKitLegacy/win/WebView.cpp

index 9f19875..433af03 100644 (file)
@@ -1,5 +1,113 @@
 2019-11-30  Tim Horton  <timothy_horton@apple.com>
 
+        Make CompositeOperator and BlendMode encodable
+        https://bugs.webkit.org/show_bug.cgi?id=204722
+
+        Reviewed by Eric Carlson.
+
+        Make CompositeOperator an `enum class`, and fix the fallout.
+        Add EnumTraits for CompositeOperator and BlendMode, so that they can be encoded.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator CompositeOperator const):
+        * dom/Document.cpp:
+        (WebCore::Document::compositeOperatorForBackgroundColor const):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::HTMLImageElement):
+        (WebCore::HTMLImageElement::parseAttribute):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::State::State):
+        (WebCore::CanvasRenderingContext2DBase::setGlobalCompositeOperation):
+        (WebCore::CanvasRenderingContext2DBase::isFullCanvasCompositeMode):
+        (WebCore::CanvasRenderingContext2DBase::fillInternal):
+        (WebCore::CanvasRenderingContext2DBase::strokeInternal):
+        (WebCore::CanvasRenderingContext2DBase::clearRect):
+        (WebCore::CanvasRenderingContext2DBase::fillRect):
+        (WebCore::CanvasRenderingContext2DBase::strokeRect):
+        (WebCore::CanvasRenderingContext2DBase::drawImage):
+        (WebCore::CanvasRenderingContext2DBase::drawImageFromRect):
+        (WebCore::CanvasRenderingContext2DBase::fullCanvasCompositedDrawImage):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::drawOutlinedQuadWithClip):
+        * platform/graphics/CrossfadeGeneratedImage.cpp:
+        (WebCore::CrossfadeGeneratedImage::drawCrossfade):
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::dumpProperties const):
+        * platform/graphics/GraphicsTypes.cpp:
+        (WebCore::parseCompositeAndBlendOperator):
+        (WebCore::compositeOperatorName):
+        * platform/graphics/GraphicsTypes.h:
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::fillWithSolidColor):
+        * platform/graphics/ImagePaintingOptions.h:
+        * platform/graphics/ShadowBlur.cpp:
+        (WebCore::ShadowBlur::blurAndColorShadowBuffer):
+        * platform/graphics/cairo/CairoOperations.cpp:
+        (WebCore::Cairo::drawNativeImage):
+        * platform/graphics/cairo/CairoOperations.h:
+        * platform/graphics/cairo/CairoUtilities.cpp:
+        (WebCore::toCairoCompositeOperator):
+        * platform/graphics/cg/GraphicsContext3DCG.cpp:
+        (WebCore::GraphicsContext3D::paintToCanvas):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::selectCGBlendMode):
+        * platform/graphics/filters/FEBlend.cpp:
+        (WebCore::FEBlend::platformApplySoftware):
+        (WebCore::FEBlend::externalRepresentation const):
+        * platform/graphics/filters/FEComposite.cpp:
+        (WebCore::FEComposite::platformApplySoftware):
+        * platform/graphics/filters/FEDropShadow.cpp:
+        (WebCore::FEDropShadow::platformApplySoftware):
+        * platform/graphics/filters/SourceAlpha.cpp:
+        (WebCore::SourceAlpha::platformApplySoftware):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::paint):
+        * platform/graphics/nicosia/NicosiaPaintingEngineBasic.cpp:
+        (Nicosia::PaintingEngineBasic::paint):
+        * platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp:
+        (Nicosia::paintLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        * platform/graphics/win/Direct2DOperations.cpp:
+        (WebCore::Direct2D::State::setCompositeOperation):
+        * platform/graphics/win/Direct2DOperations.h:
+        * platform/graphics/win/ImageCGWin.cpp:
+        (WebCore::BitmapImage::getHBITMAPOfSize):
+        * platform/graphics/win/ImageCairoWin.cpp:
+        (WebCore::BitmapImage::getHBITMAPOfSize):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paintMask):
+        * rendering/InlineFlowBox.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintMaskImages):
+        * rendering/RenderBox.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::paintReplaced):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::paintIntoRect):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::supportsDirectlyCompositedBoxDecorations):
+        * rendering/RenderTreeAsText.cpp:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::paintBoxDecorations):
+        * rendering/style/FillLayer.cpp:
+        (WebCore::FillLayer::FillLayer):
+        (WebCore::FillLayer::hasOpaqueImage const):
+        * rendering/style/FillLayer.h:
+        (WebCore::FillLayer::initialFillComposite):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::nativeImage):
+        (WebCore::SVGImage::draw):
+
+2019-11-30  Tim Horton  <timothy_horton@apple.com>
+
         Reimplement some PlatformCALayer methods using GraphicsContext instead of CGContextRef
         https://bugs.webkit.org/show_bug.cgi?id=204698
 
index a398d10..4361f2c 100644 (file)
@@ -334,46 +334,46 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CompositeOperator e)
 {
     setPrimitiveUnitType(CSSUnitType::CSS_VALUE_ID);
     switch (e) {
-    case CompositeClear:
+    case CompositeOperator::Clear:
         m_value.valueID = CSSValueClear;
         break;
-    case CompositeCopy:
+    case CompositeOperator::Copy:
         m_value.valueID = CSSValueCopy;
         break;
-    case CompositeSourceOver:
+    case CompositeOperator::SourceOver:
         m_value.valueID = CSSValueSourceOver;
         break;
-    case CompositeSourceIn:
+    case CompositeOperator::SourceIn:
         m_value.valueID = CSSValueSourceIn;
         break;
-    case CompositeSourceOut:
+    case CompositeOperator::SourceOut:
         m_value.valueID = CSSValueSourceOut;
         break;
-    case CompositeSourceAtop:
+    case CompositeOperator::SourceAtop:
         m_value.valueID = CSSValueSourceAtop;
         break;
-    case CompositeDestinationOver:
+    case CompositeOperator::DestinationOver:
         m_value.valueID = CSSValueDestinationOver;
         break;
-    case CompositeDestinationIn:
+    case CompositeOperator::DestinationIn:
         m_value.valueID = CSSValueDestinationIn;
         break;
-    case CompositeDestinationOut:
+    case CompositeOperator::DestinationOut:
         m_value.valueID = CSSValueDestinationOut;
         break;
-    case CompositeDestinationAtop:
+    case CompositeOperator::DestinationAtop:
         m_value.valueID = CSSValueDestinationAtop;
         break;
-    case CompositeXOR:
+    case CompositeOperator::XOR:
         m_value.valueID = CSSValueXor;
         break;
-    case CompositePlusDarker:
+    case CompositeOperator::PlusDarker:
         m_value.valueID = CSSValuePlusDarker;
         break;
-    case CompositePlusLighter:
+    case CompositeOperator::PlusLighter:
         m_value.valueID = CSSValuePlusLighter;
         break;
-    case CompositeDifference:
+    case CompositeOperator::Difference:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -385,37 +385,37 @@ template<> inline CSSPrimitiveValue::operator CompositeOperator() const
 
     switch (m_value.valueID) {
     case CSSValueClear:
-        return CompositeClear;
+        return CompositeOperator::Clear;
     case CSSValueCopy:
-        return CompositeCopy;
+        return CompositeOperator::Copy;
     case CSSValueSourceOver:
-        return CompositeSourceOver;
+        return CompositeOperator::SourceOver;
     case CSSValueSourceIn:
-        return CompositeSourceIn;
+        return CompositeOperator::SourceIn;
     case CSSValueSourceOut:
-        return CompositeSourceOut;
+        return CompositeOperator::SourceOut;
     case CSSValueSourceAtop:
-        return CompositeSourceAtop;
+        return CompositeOperator::SourceAtop;
     case CSSValueDestinationOver:
-        return CompositeDestinationOver;
+        return CompositeOperator::DestinationOver;
     case CSSValueDestinationIn:
-        return CompositeDestinationIn;
+        return CompositeOperator::DestinationIn;
     case CSSValueDestinationOut:
-        return CompositeDestinationOut;
+        return CompositeOperator::DestinationOut;
     case CSSValueDestinationAtop:
-        return CompositeDestinationAtop;
+        return CompositeOperator::DestinationAtop;
     case CSSValueXor:
-        return CompositeXOR;
+        return CompositeOperator::XOR;
     case CSSValuePlusDarker:
-        return CompositePlusDarker;
+        return CompositeOperator::PlusDarker;
     case CSSValuePlusLighter:
-        return CompositePlusLighter;
+        return CompositeOperator::PlusLighter;
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return CompositeClear;
+    return CompositeOperator::Clear;
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
index d562e93..ff0e422 100644 (file)
@@ -7119,15 +7119,15 @@ OptionSet<StyleColor::Options> Document::styleColorOptions(const RenderStyle* st
 CompositeOperator Document::compositeOperatorForBackgroundColor(const Color& color, const RenderObject& renderer) const
 {
     if (LIKELY(!settings().punchOutWhiteBackgroundsInDarkMode() || !Color::isWhiteColor(color) || !renderer.useDarkAppearance()))
-        return CompositeSourceOver;
+        return CompositeOperator::SourceOver;
 
     auto* frameView = view();
     if (!frameView)
-        return CompositeSourceOver;
+        return CompositeOperator::SourceOver;
 
     // Mail on macOS uses a transparent view, and on iOS it is an opaque view. We need to
     // use different composite modes to get the right results in this case.
-    return frameView->isTransparent() ? CompositeDestinationOut : CompositeDestinationIn;
+    return frameView->isTransparent() ? CompositeOperator::DestinationOut : CompositeOperator::DestinationIn;
 }
 
 void Document::didAssociateFormControl(Element& element)
index 9b77394..79c3425 100644 (file)
@@ -74,7 +74,7 @@ HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
     , m_imageLoader(WTF::makeUnique<HTMLImageLoader>(*this))
     , m_form(nullptr)
     , m_formSetByParser(makeWeakPtr(form))
-    , m_compositeOperator(CompositeSourceOver)
+    , m_compositeOperator(CompositeOperator::SourceOver)
     , m_imageDevicePixelRatio(1.0f)
     , m_experimentalImageMenuEnabled(false)
     , m_createdByParser(createdByParser)
@@ -252,7 +252,7 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomStrin
         // FIXME: images don't support blend modes in their compositing attribute.
         BlendMode blendOp = BlendMode::Normal;
         if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp))
-            m_compositeOperator = CompositeSourceOver;
+            m_compositeOperator = CompositeOperator::SourceOver;
 #if ENABLE(SERVICE_CONTROLS)
     } else if (name == webkitimagemenuAttr) {
         m_experimentalImageMenuEnabled = !value.isNull();
index 69ada2c..323dd4e 100644 (file)
@@ -593,7 +593,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
         fontProxy.drawBidiText(*c, textRun, location, FontCascade::UseFallbackIfFontNotReady);
         endCompositeLayer();
         didDrawEntireCanvas();
-    } else if (state().globalComposite == CompositeCopy) {
+    } else if (state().globalComposite == CompositeOperator::Copy) {
         clearCanvas();
         fontProxy.drawBidiText(*c, textRun, location, FontCascade::UseFallbackIfFontNotReady);
         didDrawEntireCanvas();
index b4a1551..9282884 100644 (file)
@@ -199,7 +199,7 @@ CanvasRenderingContext2DBase::State::State()
     , shadowBlur(0)
     , shadowColor(Color::transparent)
     , globalAlpha(1)
-    , globalComposite(CompositeSourceOver)
+    , globalComposite(CompositeOperator::SourceOver)
     , globalBlend(BlendMode::Normal)
     , hasInvertibleTransform(true)
     , lineDashOffset(0)
@@ -769,7 +769,7 @@ String CanvasRenderingContext2DBase::globalCompositeOperation() const
 
 void CanvasRenderingContext2DBase::setGlobalCompositeOperation(const String& operation)
 {
-    CompositeOperator op = CompositeSourceOver;
+    CompositeOperator op = CompositeOperator::SourceOver;
     BlendMode blendMode = BlendMode::Normal;
     if (!parseCompositeAndBlendOperator(operation, op, blendMode))
         return;
@@ -1034,9 +1034,9 @@ static bool validateRectForCanvas(float& x, float& y, float& width, float& heigh
 bool CanvasRenderingContext2DBase::isFullCanvasCompositeMode(CompositeOperator op)
 {
     // See 4.8.11.1.3 Compositing
-    // CompositeSourceAtop and CompositeDestinationOut are not listed here as the platforms already
+    // CompositeOperator::SourceAtop and CompositeOperator::DestinationOut are not listed here as the platforms already
     // implement the specification's behavior.
-    return op == CompositeSourceIn || op == CompositeSourceOut || op == CompositeDestinationIn || op == CompositeDestinationAtop;
+    return op == CompositeOperator::SourceIn || op == CompositeOperator::SourceOut || op == CompositeOperator::DestinationIn || op == CompositeOperator::DestinationAtop;
 }
 
 static WindRule toWindRule(CanvasFillRule rule)
@@ -1096,7 +1096,7 @@ void CanvasRenderingContext2DBase::fillInternal(const Path& path, CanvasFillRule
             c->fillPath(path);
             endCompositeLayer();
             didDrawEntireCanvas();
-        } else if (state().globalComposite == CompositeCopy) {
+        } else if (state().globalComposite == CompositeOperator::Copy) {
             clearCanvas();
             c->fillPath(path);
             didDrawEntireCanvas();
@@ -1128,7 +1128,7 @@ void CanvasRenderingContext2DBase::strokeInternal(const Path& path)
             c->strokePath(path);
             endCompositeLayer();
             didDrawEntireCanvas();
-        } else if (state().globalComposite == CompositeCopy) {
+        } else if (state().globalComposite == CompositeOperator::Copy) {
             clearCanvas();
             c->strokePath(path);
             didDrawEntireCanvas();
@@ -1243,12 +1243,12 @@ void CanvasRenderingContext2DBase::clearRect(float x, float y, float width, floa
         }
         context->setAlpha(1);
     }
-    if (state().globalComposite != CompositeSourceOver) {
+    if (state().globalComposite != CompositeOperator::SourceOver) {
         if (!saved) {
             context->save();
             saved = true;
         }
-        context->setCompositeOperation(CompositeSourceOver);
+        context->setCompositeOperation(CompositeOperator::SourceOver);
     }
     context->clearRect(rect);
     if (saved)
@@ -1284,7 +1284,7 @@ void CanvasRenderingContext2DBase::fillRect(float x, float y, float width, float
         c->fillRect(rect);
         endCompositeLayer();
         didDrawEntireCanvas();
-    } else if (state().globalComposite == CompositeCopy) {
+    } else if (state().globalComposite == CompositeOperator::Copy) {
         clearCanvas();
         c->fillRect(rect);
         didDrawEntireCanvas();
@@ -1318,7 +1318,7 @@ void CanvasRenderingContext2DBase::strokeRect(float x, float y, float width, flo
         c->strokeRect(rect, state().lineWidth);
         endCompositeLayer();
         didDrawEntireCanvas();
-    } else if (state().globalComposite == CompositeCopy) {
+    } else if (state().globalComposite == CompositeOperator::Copy) {
         clearCanvas();
         c->strokeRect(rect, state().lineWidth);
         didDrawEntireCanvas();
@@ -1580,7 +1580,7 @@ ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(Document& document, Ca
     } else if (isFullCanvasCompositeMode(op)) {
         fullCanvasCompositedDrawImage(*image, normalizedDstRect, normalizedSrcRect, op);
         didDrawEntireCanvas();
-    } else if (op == CompositeCopy) {
+    } else if (op == CompositeOperator::Copy) {
         clearCanvas();
         c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options);
         didDrawEntireCanvas();
@@ -1638,7 +1638,7 @@ ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(CanvasBase& sourceCanv
     } else if (isFullCanvasCompositeMode(state().globalComposite)) {
         fullCanvasCompositedDrawImage(*buffer, dstRect, srcRect, state().globalComposite);
         didDrawEntireCanvas();
-    } else if (state().globalComposite == CompositeCopy) {
+    } else if (state().globalComposite == CompositeOperator::Copy) {
         if (&sourceCanvas == &canvasBase()) {
             if (auto copy = buffer->copyRectToBuffer(srcRect, ColorSpaceSRGB, *c)) {
                 clearCanvas();
@@ -1736,7 +1736,7 @@ ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(ImageBitmap& imageBitm
     } else if (isFullCanvasCompositeMode(state().globalComposite)) {
         fullCanvasCompositedDrawImage(*buffer, dstRect, srcRect, state().globalComposite);
         didDrawEntireCanvas();
-    } else if (state().globalComposite == CompositeCopy) {
+    } else if (state().globalComposite == CompositeOperator::Copy) {
         clearCanvas();
         c->drawImageBuffer(*buffer, dstRect, srcRect, { state().globalComposite, state().globalBlend });
         didDrawEntireCanvas();
@@ -1753,7 +1753,7 @@ void CanvasRenderingContext2DBase::drawImageFromRect(HTMLImageElement& imageElem
     CompositeOperator op;
     auto blendOp = BlendMode::Normal;
     if (!parseCompositeAndBlendOperator(compositeOperation, op, blendOp) || blendOp != BlendMode::Normal)
-        op = CompositeSourceOver;
+        op = CompositeOperator::SourceOver;
     drawImage(imageElement, FloatRect { sx, sy, sw, sh }, FloatRect { dx, dy, dw, dh }, op, BlendMode::Normal);
 }
 
@@ -1866,7 +1866,7 @@ template<class T> void CanvasRenderingContext2DBase::fullCanvasCompositedDrawIma
     buffer->context().translate(-transformedAdjustedRect.location());
     buffer->context().translate(croppedOffset);
     buffer->context().concatCTM(effectiveTransform);
-    drawImageToContext(image, buffer->context(), adjustedDest, src, { CompositeSourceOver });
+    drawImageToContext(image, buffer->context(), adjustedDest, src, { CompositeOperator::SourceOver });
 
     compositeBuffer(*buffer, bufferRect, op);
 }
index 874b46b..6638655 100644 (file)
@@ -221,7 +221,7 @@ static void drawOutlinedQuadWithClip(GraphicsContext& context, const FloatQuad&
     context.setStrokeThickness(0);
     context.fillPath(quadToPath(quad, bounds));
 
-    context.setCompositeOperation(CompositeDestinationOut);
+    context.setCompositeOperation(CompositeOperator::DestinationOut);
     context.setFillColor(Color::createUnchecked(255, 0, 0));
     context.fillPath(quadToPath(clipQuad, bounds));
 }
index d4bdb5f..4b5d6c0 100644 (file)
@@ -81,8 +81,8 @@ void CrossfadeGeneratedImage::drawCrossfade(GraphicsContext& context)
     context.clip(FloatRect(FloatPoint(), m_crossfadeSize));
     context.beginTransparencyLayer(1);
 
-    drawCrossfadeSubimage(context, m_fromImage.get(), CompositeSourceOver, 1 - m_percentage, m_crossfadeSize);
-    drawCrossfadeSubimage(context, m_toImage.get(), CompositePlusLighter, m_percentage, m_crossfadeSize);
+    drawCrossfadeSubimage(context, m_fromImage.get(), CompositeOperator::SourceOver, 1 - m_percentage, m_crossfadeSize);
+    drawCrossfadeSubimage(context, m_toImage.get(), CompositeOperator::PlusLighter, m_percentage, m_crossfadeSize);
 
     context.endTransparencyLayer();
 }
index 209036f..fa9e848 100644 (file)
@@ -194,7 +194,7 @@ struct GraphicsContextState {
     WindRule fillRule { WindRule::NonZero };
 
     float alpha { 1 };
-    CompositeOperator compositeOperator { CompositeSourceOver };
+    CompositeOperator compositeOperator { CompositeOperator::SourceOver };
     BlendMode blendMode { BlendMode::Normal };
     InterpolationQuality imageInterpolationQuality { InterpolationDefault };
 
index 506b261..d4ea50d 100644 (file)
@@ -898,7 +898,7 @@ void GraphicsLayer::dumpProperties(TextStream& ts, LayerTreeAsTextBehavior behav
 
 #if ENABLE(CSS_COMPOSITING)
     if (m_blendMode != BlendMode::Normal)
-        ts << indent << "(blendMode " << compositeOperatorName(CompositeSourceOver, m_blendMode) << ")\n";
+        ts << indent << "(blendMode " << compositeOperatorName(CompositeOperator::SourceOver, m_blendMode) << ")\n";
 #endif
 
     if (type() == Type::Normal && tiledBacking())
index 39978c4..458ae72 100644 (file)
@@ -71,8 +71,8 @@ static const char* const blendOperatorNames[] = {
     "plus-darker",
     "plus-lighter"
 };
-const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames);
-const unsigned numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
+const uint8_t numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames);
+const uint8_t numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
 
 bool parseBlendMode(const String& s, BlendMode& blendMode)
 {
@@ -98,7 +98,7 @@ bool parseCompositeAndBlendOperator(const String& s, CompositeOperator& op, Blen
     
     if (parseBlendMode(s, blendOp)) {
         // For now, blending will always assume source-over. This will be fixed in the future
-        op = CompositeSourceOver;
+        op = CompositeOperator::SourceOver;
         return true;
     }
     
@@ -109,13 +109,13 @@ bool parseCompositeAndBlendOperator(const String& s, CompositeOperator& op, Blen
 // this routine needs to be updated.
 String compositeOperatorName(CompositeOperator op, BlendMode blendOp)
 {
-    ASSERT(op >= 0);
-    ASSERT(op < numCompositeOperatorNames);
+    ASSERT(op >= CompositeOperator::Clear);
+    ASSERT(static_cast<uint8_t>(op) < numCompositeOperatorNames);
     ASSERT(blendOp >= BlendMode::Normal);
-    ASSERT(static_cast<unsigned>(blendOp) <= numBlendOperatorNames);
+    ASSERT(static_cast<uint8_t>(blendOp) <= numBlendOperatorNames);
     if (blendOp > BlendMode::Normal)
         return blendOperatorNames[static_cast<unsigned>(blendOp) - static_cast<unsigned>(BlendMode::Normal)];
-    return compositeOperatorNames[op];
+    return compositeOperatorNames[static_cast<unsigned>(op)];
 }
 
 String blendModeName(BlendMode blendOp)
index 6e1afee..2ce6b0c 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "WindRule.h"
+#include <wtf/EnumTraits.h>
 #include <wtf/Forward.h>
 
 namespace WTF {
@@ -34,24 +35,24 @@ class TextStream;
 
 namespace WebCore {
 
-enum CompositeOperator {
-    CompositeClear,
-    CompositeCopy,
-    CompositeSourceOver,
-    CompositeSourceIn,
-    CompositeSourceOut,
-    CompositeSourceAtop,
-    CompositeDestinationOver,
-    CompositeDestinationIn,
-    CompositeDestinationOut,
-    CompositeDestinationAtop,
-    CompositeXOR,
-    CompositePlusDarker,
-    CompositePlusLighter,
-    CompositeDifference
+enum class CompositeOperator : uint8_t {
+    Clear,
+    Copy,
+    SourceOver,
+    SourceIn,
+    SourceOut,
+    SourceAtop,
+    DestinationOver,
+    DestinationIn,
+    DestinationOut,
+    DestinationAtop,
+    XOR,
+    PlusDarker,
+    PlusLighter,
+    Difference
 };
 
-enum class BlendMode {
+enum class BlendMode : uint8_t {
     Normal = 1, // Start with 1 to match SVG's blendmode enumeration.
     Multiply,
     Screen,
@@ -146,3 +147,50 @@ WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, AlphaPremultiplicat
 
 } // namespace WebCore
 
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::CompositeOperator> {
+    using values = EnumValues<
+    WebCore::CompositeOperator,
+    WebCore::CompositeOperator::Clear,
+    WebCore::CompositeOperator::Copy,
+    WebCore::CompositeOperator::SourceOver,
+    WebCore::CompositeOperator::SourceIn,
+    WebCore::CompositeOperator::SourceOut,
+    WebCore::CompositeOperator::SourceAtop,
+    WebCore::CompositeOperator::DestinationOver,
+    WebCore::CompositeOperator::DestinationIn,
+    WebCore::CompositeOperator::DestinationOut,
+    WebCore::CompositeOperator::DestinationAtop,
+    WebCore::CompositeOperator::XOR,
+    WebCore::CompositeOperator::PlusDarker,
+    WebCore::CompositeOperator::PlusLighter,
+    WebCore::CompositeOperator::Difference
+    >;
+};
+
+template<> struct EnumTraits<WebCore::BlendMode> {
+    using values = EnumValues<
+    WebCore::BlendMode,
+    WebCore::BlendMode::Normal,
+    WebCore::BlendMode::Multiply,
+    WebCore::BlendMode::Screen,
+    WebCore::BlendMode::Darken,
+    WebCore::BlendMode::Lighten,
+    WebCore::BlendMode::Overlay,
+    WebCore::BlendMode::ColorDodge,
+    WebCore::BlendMode::ColorBurn,
+    WebCore::BlendMode::HardLight,
+    WebCore::BlendMode::SoftLight,
+    WebCore::BlendMode::Difference,
+    WebCore::BlendMode::Exclusion,
+    WebCore::BlendMode::Hue,
+    WebCore::BlendMode::Saturation,
+    WebCore::BlendMode::Color,
+    WebCore::BlendMode::Luminosity,
+    WebCore::BlendMode::PlusDarker,
+    WebCore::BlendMode::PlusLighter
+    >;
+};
+
+} // namespace WTF
index 1533654..098f601 100644 (file)
@@ -132,7 +132,7 @@ void Image::fillWithSolidColor(GraphicsContext& ctxt, const FloatRect& dstRect,
         return;
     
     CompositeOperator previousOperator = ctxt.compositeOperation();
-    ctxt.setCompositeOperation(color.isOpaque() && op == CompositeSourceOver ? CompositeCopy : op);
+    ctxt.setCompositeOperation(color.isOpaque() && op == CompositeOperator::SourceOver ? CompositeOperator::Copy : op);
     ctxt.fillRect(dstRect, color);
     ctxt.setCompositeOperation(previousOperator);
 }
index 2f45c3f..dea7d2a 100644 (file)
@@ -69,7 +69,7 @@ private:
     void setOption(ImageOrientation::Orientation orientation) { m_orientation = orientation; }
     void setOption(InterpolationQuality interpolationQuality) { m_interpolationQuality = interpolationQuality; }
 
-    CompositeOperator m_compositeOperator { CompositeSourceOver };
+    CompositeOperator m_compositeOperator { CompositeOperator::SourceOver };
     BlendMode m_blendMode { BlendMode::Normal };
     DecodingMode m_decodingMode { DecodingMode::Synchronous };
     ImageOrientation m_orientation { ImageOrientation::None };
index eadaa18..949958e 100644 (file)
@@ -899,7 +899,7 @@ void ShadowBlur::blurAndColorShadowBuffer(ImageBuffer& layerImage, const IntSize
     // Mask the image with the shadow color.
     GraphicsContext& shadowContext = layerImage.context();
     GraphicsContextStateSaver stateSaver(shadowContext);
-    shadowContext.setCompositeOperation(CompositeSourceIn);
+    shadowContext.setCompositeOperation(CompositeOperator::SourceIn);
     shadowContext.setFillColor(m_color);
     shadowContext.fillRect(FloatRect(0, 0, templateSize.width(), templateSize.height()));
 }
index b6fa69c..7e3d744 100644 (file)
@@ -870,8 +870,8 @@ void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* sur
     platformContext.save();
 
     // Set the compositing operation.
-    if (options.compositeOperator() == CompositeSourceOver && options.blendMode() == BlendMode::Normal && !cairoSurfaceHasAlpha(surface))
-        Cairo::State::setCompositeOperation(platformContext, CompositeCopy, BlendMode::Normal);
+    if (options.compositeOperator() == CompositeOperator::SourceOver && options.blendMode() == BlendMode::Normal && !cairoSurfaceHasAlpha(surface))
+        Cairo::State::setCompositeOperation(platformContext, CompositeOperator::Copy, BlendMode::Normal);
     else
         Cairo::State::setCompositeOperation(platformContext, options.compositeOperator(), options.blendMode());
 
index 5834f43..f5200a8 100644 (file)
@@ -118,7 +118,7 @@ struct ShadowState {
     bool ignoreTransforms { false };
 
     float globalAlpha { 1.0 };
-    CompositeOperator globalCompositeOperator { CompositeSourceOver };
+    CompositeOperator globalCompositeOperator { CompositeOperator::SourceOver };
 };
 
 void setLineCap(PlatformContextCairo&, LineCap);
index 8a5e009..f90ab28 100644 (file)
@@ -128,33 +128,33 @@ void appendRegionToCairoContext(cairo_t* to, const cairo_region_t* region)
 static cairo_operator_t toCairoCompositeOperator(CompositeOperator op)
 {
     switch (op) {
-    case CompositeClear:
+    case CompositeOperator::Clear:
         return CAIRO_OPERATOR_CLEAR;
-    case CompositeCopy:
+    case CompositeOperator::Copy:
         return CAIRO_OPERATOR_SOURCE;
-    case CompositeSourceOver:
+    case CompositeOperator::SourceOver:
         return CAIRO_OPERATOR_OVER;
-    case CompositeSourceIn:
+    case CompositeOperator::SourceIn:
         return CAIRO_OPERATOR_IN;
-    case CompositeSourceOut:
+    case CompositeOperator::SourceOut:
         return CAIRO_OPERATOR_OUT;
-    case CompositeSourceAtop:
+    case CompositeOperator::SourceAtop:
         return CAIRO_OPERATOR_ATOP;
-    case CompositeDestinationOver:
+    case CompositeOperator::DestinationOver:
         return CAIRO_OPERATOR_DEST_OVER;
-    case CompositeDestinationIn:
+    case CompositeOperator::DestinationIn:
         return CAIRO_OPERATOR_DEST_IN;
-    case CompositeDestinationOut:
+    case CompositeOperator::DestinationOut:
         return CAIRO_OPERATOR_DEST_OUT;
-    case CompositeDestinationAtop:
+    case CompositeOperator::DestinationAtop:
         return CAIRO_OPERATOR_DEST_ATOP;
-    case CompositeXOR:
+    case CompositeOperator::XOR:
         return CAIRO_OPERATOR_XOR;
-    case CompositePlusDarker:
+    case CompositeOperator::PlusDarker:
         return CAIRO_OPERATOR_DARKEN;
-    case CompositePlusLighter:
+    case CompositeOperator::PlusLighter:
         return CAIRO_OPERATOR_ADD;
-    case CompositeDifference:
+    case CompositeOperator::Difference:
         return CAIRO_OPERATOR_DIFFERENCE;
     default:
         return CAIRO_OPERATOR_SOURCE;
index cd6bb73..3afaa0a 100644 (file)
@@ -539,7 +539,7 @@ void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, const In
     context.scale(FloatSize(1, -1));
     context.translate(0, -imageSize.height());
     context.setImageInterpolationQuality(InterpolationNone);
-    context.drawNativeImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), { CompositeCopy });
+    context.drawNativeImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), { CompositeOperator::Copy });
 }
 
 } // namespace WebCore
index 970fd07..2df2e54 100644 (file)
@@ -161,33 +161,33 @@ static CGBlendMode selectCGBlendMode(CompositeOperator compositeOperator, BlendM
     switch (blendMode) {
     case BlendMode::Normal:
         switch (compositeOperator) {
-        case CompositeClear:
+        case CompositeOperator::Clear:
             return kCGBlendModeClear;
-        case CompositeCopy:
+        case CompositeOperator::Copy:
             return kCGBlendModeCopy;
-        case CompositeSourceOver:
+        case CompositeOperator::SourceOver:
             return kCGBlendModeNormal;
-        case CompositeSourceIn:
+        case CompositeOperator::SourceIn:
             return kCGBlendModeSourceIn;
-        case CompositeSourceOut:
+        case CompositeOperator::SourceOut:
             return kCGBlendModeSourceOut;
-        case CompositeSourceAtop:
+        case CompositeOperator::SourceAtop:
             return kCGBlendModeSourceAtop;
-        case CompositeDestinationOver:
+        case CompositeOperator::DestinationOver:
             return kCGBlendModeDestinationOver;
-        case CompositeDestinationIn:
+        case CompositeOperator::DestinationIn:
             return kCGBlendModeDestinationIn;
-        case CompositeDestinationOut:
+        case CompositeOperator::DestinationOut:
             return kCGBlendModeDestinationOut;
-        case CompositeDestinationAtop:
+        case CompositeOperator::DestinationAtop:
             return kCGBlendModeDestinationAtop;
-        case CompositeXOR:
+        case CompositeOperator::XOR:
             return kCGBlendModeXOR;
-        case CompositePlusDarker:
+        case CompositeOperator::PlusDarker:
             return kCGBlendModePlusDarker;
-        case CompositePlusLighter:
+        case CompositeOperator::PlusLighter:
             return kCGBlendModePlusLighter;
-        case CompositeDifference:
+        case CompositeOperator::Difference:
             return kCGBlendModeDifference;
         }
         break;
index e4d7295..23d3d21 100644 (file)
@@ -70,7 +70,7 @@ void FEBlend::platformApplySoftware()
         return;
 
     filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
-    filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), { CompositeSourceOver, m_mode });
+    filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), { CompositeOperator::SourceOver, m_mode });
 }
 #endif
 
@@ -78,7 +78,7 @@ TextStream& FEBlend::externalRepresentation(TextStream& ts, RepresentationType r
 {
     ts << indent << "[feBlend";
     FilterEffect::externalRepresentation(ts, representation);
-    ts << " mode=\"" << (m_mode == BlendMode::Normal ? "normal" : compositeOperatorName(CompositeSourceOver, m_mode)) << "\"]\n";
+    ts << " mode=\"" << (m_mode == BlendMode::Normal ? "normal" : compositeOperatorName(CompositeOperator::SourceOver, m_mode)) << "\"]\n";
 
     TextStream::IndentScope indentScope(ts);
     inputEffect(0)->externalRepresentation(ts, representation);
index d56db40..a19ea05 100644 (file)
@@ -271,24 +271,24 @@ void FEComposite::platformApplySoftware()
         IntRect sourceRect = destinationRect - in->absolutePaintRect().location();
         IntRect source2Rect = destinationRect - in2->absolutePaintRect().location();
         filterContext.drawImageBuffer(*imageBuffer2, FloatRect(adjustedDestinationRect), FloatRect(source2Rect));
-        filterContext.drawImageBuffer(*imageBuffer, FloatRect(adjustedDestinationRect), FloatRect(sourceRect), { CompositeSourceIn });
+        filterContext.drawImageBuffer(*imageBuffer, FloatRect(adjustedDestinationRect), FloatRect(sourceRect), { CompositeOperator::SourceIn });
         break;
     }
     case FECOMPOSITE_OPERATOR_OUT:
         filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()));
-        filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()), IntRect(IntPoint(), imageBuffer2->logicalSize()), CompositeDestinationOut);
+        filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()), IntRect(IntPoint(), imageBuffer2->logicalSize()), CompositeOperator::DestinationOut);
         break;
     case FECOMPOSITE_OPERATOR_ATOP:
         filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
-        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeSourceAtop);
+        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeOperator::SourceAtop);
         break;
     case FECOMPOSITE_OPERATOR_XOR:
         filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
-        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeXOR);
+        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeOperator::XOR);
         break;
     case FECOMPOSITE_OPERATOR_LIGHTER:
         filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
-        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositePlusLighter);
+        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeOperator::PlusLighter);
         break;
     default:
         break;
index 889aa2d..23666a1 100644 (file)
@@ -108,9 +108,9 @@ void FEDropShadow::platformApplySoftware()
 
     resultImage->putByteArray(*srcPixelArray, AlphaPremultiplication::Premultiplied, shadowArea.size(), shadowArea, IntPoint(), ImageBuffer::BackingStoreCoordinateSystem);
 
-    resultContext.setCompositeOperation(CompositeSourceIn);
+    resultContext.setCompositeOperation(CompositeOperator::SourceIn);
     resultContext.fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), m_shadowColor);
-    resultContext.setCompositeOperation(CompositeDestinationOver);
+    resultContext.setCompositeOperation(CompositeOperator::DestinationOver);
 
     resultImage->context().drawImageBuffer(*sourceImage, drawingRegion);
 }
index 3a680a2..a0aa250 100644 (file)
@@ -60,7 +60,7 @@ void SourceAlpha::platformApplySoftware()
 
     FloatRect imageRect(FloatPoint(), absolutePaintRect().size());
     filterContext.fillRect(imageRect, Color::black);
-    filterContext.drawImageBuffer(*imageBuffer, IntPoint(), CompositeDestinationIn);
+    filterContext.drawImageBuffer(*imageBuffer, IntPoint(), CompositeOperator::DestinationIn);
 }
 
 TextStream& SourceAlpha::externalRepresentation(TextStream& ts, RepresentationType) const
index 3e70a36..f5a95f9 100644 (file)
@@ -3255,7 +3255,7 @@ void MediaPlayerPrivateGStreamer::paint(GraphicsContext& context, const FloatRec
     if (!gstImage)
         return;
 
-    context.drawImage(gstImage->image(), rect, gstImage->rect(), { CompositeCopy, m_canRenderingBeAccelerated ? m_videoSourceOrientation : ImageOrientation() });
+    context.drawImage(gstImage->image(), rect, gstImage->rect(), { CompositeOperator::Copy, m_canRenderingBeAccelerated ? m_videoSourceOrientation : ImageOrientation() });
 }
 
 #if USE(GSTREAMER_GL)
index 3a164c2..5588941 100644 (file)
@@ -55,9 +55,9 @@ bool PaintingEngineBasic::paint(GraphicsLayer& layer, Ref<Buffer>&& buffer, cons
             context.translate(targetRect.x(), targetRect.y());
 
             if (supportsAlpha) {
-                context.setCompositeOperation(CompositeCopy);
+                context.setCompositeOperation(CompositeOperator::Copy);
                 context.fillRect(IntRect(IntPoint::zero(), sourceRect.size()), Color::transparent);
-                context.setCompositeOperation(CompositeSourceOver);
+                context.setCompositeOperation(CompositeOperator::SourceOver);
             }
 
             context.translate(-sourceRect.x(), -sourceRect.y());
index 43c8af4..e35a15d 100644 (file)
@@ -46,9 +46,9 @@ static void paintLayer(GraphicsContext& context, GraphicsLayer& layer, const Int
     context.translate(targetRect.x(), targetRect.y());
 
     if (supportsAlpha) {
-        context.setCompositeOperation(CompositeCopy);
+        context.setCompositeOperation(CompositeOperator::Copy);
         context.fillRect(IntRect(IntPoint::zero(), sourceRect.size()), Color::transparent);
-        context.setCompositeOperation(CompositeSourceOver);
+        context.setCompositeOperation(CompositeOperator::SourceOver);
     }
 
     context.translate(-sourceRect.x(), -sourceRect.y());
index 2e643b5..bd690e5 100644 (file)
@@ -825,7 +825,7 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
                 [&image](GraphicsContext& context)
                 {
                     IntRect rect { { }, IntSize { image.size() } };
-                    context.drawImage(image, rect, rect, ImagePaintingOptions(CompositeCopy));
+                    context.drawImage(image, rect, rect, ImagePaintingOptions(CompositeOperator::Copy));
                 });
             layerState.nativeImageID = nativeImageID;
             layerState.update.buffer = WTFMove(buffer);
index 8658a48..18b8718 100644 (file)
@@ -189,46 +189,46 @@ void setCompositeOperation(PlatformContextDirect2D& platformContext, CompositeOp
         }
     } else {
         switch (compositeOperation) {
-        case CompositeClear:
+        case CompositeOperator::Clear:
             // FIXME: targetBlendMode = D2D1_BLEND_MODE_CLEAR;
             break;
-        case CompositeCopy:
+        case CompositeOperator::Copy:
             targetCompositeMode = D2D1_COMPOSITE_MODE_SOURCE_COPY;
             break;
-        case CompositeSourceOver:
+        case CompositeOperator::SourceOver:
             targetCompositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER;
             break;
-        case CompositeSourceIn:
+        case CompositeOperator::SourceIn:
             targetCompositeMode = D2D1_COMPOSITE_MODE_SOURCE_IN;
             break;
-        case CompositeSourceOut:
+        case CompositeOperator::SourceOut:
             targetCompositeMode = D2D1_COMPOSITE_MODE_SOURCE_OUT;
             break;
-        case CompositeSourceAtop:
+        case CompositeOperator::SourceAtop:
             targetCompositeMode = D2D1_COMPOSITE_MODE_SOURCE_ATOP;
             break;
-        case CompositeDestinationOver:
+        case CompositeOperator::DestinationOver:
             targetCompositeMode = D2D1_COMPOSITE_MODE_DESTINATION_OVER;
             break;
-        case CompositeDestinationIn:
+        case CompositeOperator::DestinationIn:
             targetCompositeMode = D2D1_COMPOSITE_MODE_DESTINATION_IN;
             break;
-        case CompositeDestinationOut:
+        case CompositeOperator::DestinationOut:
             targetCompositeMode = D2D1_COMPOSITE_MODE_DESTINATION_OUT;
             break;
-        case CompositeDestinationAtop:
+        case CompositeOperator::DestinationAtop:
             targetCompositeMode = D2D1_COMPOSITE_MODE_DESTINATION_ATOP;
             break;
-        case CompositeXOR:
+        case CompositeOperator::XOR:
             targetCompositeMode = D2D1_COMPOSITE_MODE_XOR;
             break;
-        case CompositePlusDarker:
+        case CompositeOperator::PlusDarker:
             targetBlendMode = D2D1_BLEND_MODE_DARKEN;
             break;
-        case CompositePlusLighter:
+        case CompositeOperator::PlusLighter:
             targetBlendMode = D2D1_BLEND_MODE_LIGHTEN;
             break;
-        case CompositeDifference:
+        case CompositeOperator::Difference:
             targetBlendMode = D2D1_BLEND_MODE_DIFFERENCE;
             break;
         }
index 1dd4f12..74a1036 100644 (file)
@@ -106,7 +106,7 @@ struct ShadowState {
     bool ignoreTransforms { false };
 
     float globalAlpha { 1.0 };
-    CompositeOperator globalCompositeOperator { CompositeSourceOver };
+    CompositeOperator globalCompositeOperator { CompositeOperator::SourceOver };
 };
 
 void setLineCap(PlatformContextDirect2D&, LineCap);
index 9323da7..74d36df 100644 (file)
@@ -77,9 +77,9 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, const IntSize* size)
 
     FloatSize imageSize = BitmapImage::size();
     if (size)
-        drawFrameMatchingSourceSize(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), *size, CompositeCopy);
+        drawFrameMatchingSourceSize(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), *size, CompositeOperator::Copy);
     else
-        draw(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), { CompositeCopy });
+        draw(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), { CompositeOperator::Copy });
 
     // Do cleanup
     CGContextRelease(cgContext);
index 68bf397..d4eafc5 100644 (file)
@@ -79,9 +79,9 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, const IntSize* size)
 
     FloatSize imageSize = BitmapImage::size();
     if (size)
-        drawFrameMatchingSourceSize(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), *size, CompositeCopy);
+        drawFrameMatchingSourceSize(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), *size, CompositeOperator::Copy);
     else
-        draw(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), { CompositeCopy });
+        draw(gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), { CompositeOperator::Copy });
 
     // Do cleanup
     cairo_destroy(targetRef);
index 9075774..c316494 100644 (file)
@@ -1438,16 +1438,16 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
     bool pushTransparencyLayer = false;
     bool compositedMask = renderer().hasLayer() && renderer().layer()->hasCompositedMask();
     bool flattenCompositingLayers = renderer().view().frameView().paintBehavior().contains(PaintBehavior::FlattenCompositingLayers);
-    CompositeOperator compositeOp = CompositeSourceOver;
+    CompositeOperator compositeOp = CompositeOperator::SourceOver;
     if (!compositedMask || flattenCompositingLayers) {
         if ((maskBoxImage && renderer().style().maskLayers().hasImage()) || renderer().style().maskLayers().next())
             pushTransparencyLayer = true;
         
-        compositeOp = CompositeDestinationIn;
+        compositeOp = CompositeOperator::DestinationIn;
         if (pushTransparencyLayer) {
-            paintInfo.context().setCompositeOperation(CompositeDestinationIn);
+            paintInfo.context().setCompositeOperation(CompositeOperator::DestinationIn);
             paintInfo.context().beginTransparencyLayer(1.0f);
-            compositeOp = CompositeSourceOver;
+            compositeOp = CompositeOperator::SourceOver;
         }
     }
 
index 80415d9..d36a15b 100644 (file)
@@ -115,8 +115,8 @@ public:
 
     void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
     void paintMask(PaintInfo&, const LayoutPoint&);
-    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, CompositeOperator = CompositeSourceOver);
-    void paintFillLayer(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, CompositeOperator = CompositeSourceOver);
+    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, CompositeOperator = CompositeOperator::SourceOver);
+    void paintFillLayer(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, CompositeOperator = CompositeOperator::SourceOver);
     void paintBoxShadow(const PaintInfo&, const RenderStyle&, ShadowStyle, const LayoutRect&);
     void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override;
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override;
index 87ae762..f8d3a49 100644 (file)
@@ -1589,7 +1589,7 @@ void RenderBox::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& pa
     bool pushTransparencyLayer = false;
     bool compositedMask = hasLayer() && layer()->hasCompositedMask();
     bool flattenCompositingLayers = paintInfo.paintBehavior.contains(PaintBehavior::FlattenCompositingLayers);
-    CompositeOperator compositeOp = CompositeSourceOver;
+    CompositeOperator compositeOp = CompositeOperator::SourceOver;
 
     bool allMaskImagesLoaded = true;
     
@@ -1602,9 +1602,9 @@ void RenderBox::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& pa
 
         allMaskImagesLoaded &= style().maskLayers().imagesAreLoaded();
 
-        paintInfo.context().setCompositeOperation(CompositeDestinationIn);
+        paintInfo.context().setCompositeOperation(CompositeOperator::DestinationIn);
         paintInfo.context().beginTransparencyLayer(1);
-        compositeOp = CompositeSourceOver;
+        compositeOp = CompositeOperator::SourceOver;
     }
 
     if (allMaskImagesLoaded) {
index 2bfce5f..4954814 100644 (file)
@@ -667,7 +667,7 @@ protected:
     void paintBackground(const PaintInfo&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone);
     
     void paintFillLayer(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, CompositeOperator, RenderElement* backgroundObject, BaseBackgroundColorUsage = BaseBackgroundColorUse);
-    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderElement* backgroundObject = nullptr);
+    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeOperator::SourceOver, RenderElement* backgroundObject = nullptr);
 
     void paintMaskImages(const PaintInfo&, const LayoutRect&);
 
index 75a9fe7..e5b7558 100644 (file)
@@ -926,14 +926,14 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
             if (baseColor.isVisible()) {
                 if (!baseBgColorOnly && bgColor.isVisible())
                     baseColor = baseColor.blend(bgColor);
-                context.fillRect(backgroundRectForPainting, baseColor, CompositeCopy);
+                context.fillRect(backgroundRectForPainting, baseColor, CompositeOperator::Copy);
             } else if (!baseBgColorOnly && bgColor.isVisible()) {
                 auto operation = context.compositeOperation();
                 if (shouldClearBackground) {
-                    if (op == CompositeDestinationOut) // We're punching out the background.
+                    if (op == CompositeOperator::DestinationOut) // We're punching out the background.
                         operation = op;
                     else
-                        operation = CompositeCopy;
+                        operation = CompositeOperator::Copy;
                 }
                 context.fillRect(backgroundRectForPainting, bgColor, operation);
             } else if (shouldClearBackground)
@@ -953,7 +953,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
                 downcast<BitmapImage>(*image).updateFromSettings(settings());
 
             ImagePaintingOptions options = {
-                op == CompositeSourceOver ? bgLayer.composite() : op,
+                op == CompositeOperator::SourceOver ? bgLayer.composite() : op,
                 bgLayer.blendMode(),
                 decodingModeForImageDraw(*image, paintInfo),
                 ImageOrientation::FromImage,
@@ -969,7 +969,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
     }
 
     if (maskImage && bgLayer.clip() == FillBox::Text) {
-        context.drawConsumingImageBuffer(WTFMove(maskImage), maskRect, CompositeDestinationIn);
+        context.drawConsumingImageBuffer(WTFMove(maskImage), maskRect, CompositeOperator::DestinationIn);
         context.endTransparencyLayer();
     }
 }
index b59bf0a..8af45e1 100644 (file)
@@ -203,9 +203,9 @@ public:
     virtual LayoutUnit containingBlockLogicalWidthForContent() const;
 
     void paintBorder(const PaintInfo&, const LayoutRect&, const RenderStyle&, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
-    bool paintNinePieceImage(GraphicsContext&, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
+    bool paintNinePieceImage(GraphicsContext&, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeOperator::SourceOver);
     void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle&, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
-    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = nullptr, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeSourceOver, RenderElement* backgroundObject = nullptr, BaseBackgroundColorUsage = BaseBackgroundColorUse);
+    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = nullptr, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeOperator::SourceOver, RenderElement* backgroundObject = nullptr, BaseBackgroundColorUsage = BaseBackgroundColorUse);
 
     virtual bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& absolutePaintPostion, BackgroundBleedAvoidance, InlineFlowBox* = nullptr) const;
 
index 7ac04b8..2d00dff 100644 (file)
@@ -339,7 +339,7 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
         context.setFillColor(replacementTextColor());
         context.fillEllipse(arrowRect);
 
-        context.setCompositeOperation(CompositeClear);
+        context.setCompositeOperation(CompositeOperator::Clear);
         drawReplacementArrow(context, arrowRect);
         context.endTransparencyLayer();
     }
index a1fd300..b2c49a6 100644 (file)
@@ -645,7 +645,7 @@ ImageDrawResult RenderImage::paintIntoRect(PaintInfo& paintInfo, const FloatRect
         downcast<BitmapImage>(*image).updateFromSettings(settings());
 
     ImagePaintingOptions options = {
-        imageElement ? imageElement->compositeOperator() : CompositeSourceOver,
+        imageElement ? imageElement->compositeOperator() : CompositeOperator::SourceOver,
         decodingModeForImageDraw(*image, paintInfo),
         imageOrientation(),
         image ? chooseInterpolationQuality(paintInfo.context(), *image, image, LayoutSize(rect.size())) : InterpolationDefault
index d5cc866..d0828a2 100644 (file)
@@ -2279,7 +2279,7 @@ static bool supportsDirectlyCompositedBoxDecorations(const RenderLayerModelObjec
         return false;
 
     // FIXME: we should be able to allow backgroundComposite; However since this is not a common use case it has been deferred for now.
-    if (style.backgroundComposite() != CompositeSourceOver)
+    if (style.backgroundComposite() != CompositeOperator::SourceOver)
         return false;
 
     return true;
index 313e3e5..8611279 100644 (file)
@@ -638,7 +638,7 @@ static void writeLayer(TextStream& ts, const RenderLayer& layer, const LayoutRec
     if (layer.isolatesBlending())
         ts << " isolatesBlending";
     if (layer.hasBlendMode())
-        ts << " blendMode: " << compositeOperatorName(CompositeSourceOver, layer.blendMode());
+        ts << " blendMode: " << compositeOperatorName(CompositeOperator::SourceOver, layer.blendMode());
 #endif
     
     ts << "\n";
index f648614..057b441 100644 (file)
@@ -421,7 +421,7 @@ void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
         const Color& backgroundColor = (settings().backgroundShouldExtendBeyondPage() && documentBackgroundColor.isValid()) ? documentBackgroundColor : frameView().baseBackgroundColor();
         if (backgroundColor.isVisible()) {
             CompositeOperator previousOperator = paintInfo.context().compositeOperation();
-            paintInfo.context().setCompositeOperation(CompositeCopy);
+            paintInfo.context().setCompositeOperation(CompositeOperator::Copy);
             paintInfo.context().fillRect(paintInfo.rect, backgroundColor);
             paintInfo.context().setCompositeOperation(previousOperator);
         } else
index aaac5f7..fe5c012 100644 (file)
@@ -52,7 +52,7 @@ FillLayer::FillLayer(FillLayerType type)
     , m_origin(static_cast<unsigned>(FillLayer::initialFillOrigin(type)))
     , m_repeatX(static_cast<unsigned>(FillLayer::initialFillRepeatX(type)))
     , m_repeatY(static_cast<unsigned>(FillLayer::initialFillRepeatY(type)))
-    , m_composite(FillLayer::initialFillComposite(type))
+    , m_composite(static_cast<unsigned>(FillLayer::initialFillComposite(type)))
     , m_sizeType(static_cast<unsigned>(FillSizeType::None))
     , m_blendMode(static_cast<unsigned>(FillLayer::initialFillBlendMode(type)))
     , m_maskSourceType(static_cast<unsigned>(FillLayer::initialFillMaskSourceType(type)))
@@ -354,10 +354,10 @@ bool FillLayer::hasOpaqueImage(const RenderElement& renderer) const
     if (!m_image)
         return false;
 
-    if (m_composite == CompositeClear || m_composite == CompositeCopy)
+    if (static_cast<CompositeOperator>(m_composite) == CompositeOperator::Clear || static_cast<CompositeOperator>(m_composite) == CompositeOperator::Copy)
         return true;
 
-    return static_cast<BlendMode>(m_blendMode) == BlendMode::Normal && m_composite == CompositeSourceOver && m_image->knownToBeOpaque(&renderer);
+    return static_cast<BlendMode>(m_blendMode) == BlendMode::Normal && static_cast<CompositeOperator>(m_composite) == CompositeOperator::SourceOver && m_image->knownToBeOpaque(&renderer);
 }
 
 bool FillLayer::hasRepeatXY() const
index bcd2c61..431742b 100644 (file)
@@ -163,7 +163,7 @@ public:
     static FillBox initialFillOrigin(FillLayerType type) { return type == FillLayerType::Background ? FillBox::Padding : FillBox::Border; }
     static FillRepeat initialFillRepeatX(FillLayerType) { return FillRepeat::Repeat; }
     static FillRepeat initialFillRepeatY(FillLayerType) { return FillRepeat::Repeat; }
-    static CompositeOperator initialFillComposite(FillLayerType) { return CompositeSourceOver; }
+    static CompositeOperator initialFillComposite(FillLayerType) { return CompositeOperator::SourceOver; }
     static BlendMode initialFillBlendMode(FillLayerType) { return BlendMode::Normal; }
     static FillSize initialFillSize(FillLayerType) { return { }; }
     static Length initialFillXPosition(FillLayerType) { return Length(0.0f, Percent); }
index 1df4000..c3537e3 100644 (file)
@@ -247,7 +247,7 @@ NativeImagePtr SVGImage::nativeImage(const GraphicsContext* targetContext)
     PlatformContextDirect2D platformContext(nativeImageTarget.get());
     GraphicsContext localContext(&platformContext, GraphicsContext::BitmapRenderingContextType::GPUMemory);
 
-    draw(localContext, rect(), rect(), { CompositeSourceOver, BlendMode::Normal, DecodingMode::Synchronous, ImageOrientation::None });
+    draw(localContext, rect(), rect(), { CompositeOperator::SourceOver, BlendMode::Normal, DecodingMode::Synchronous, ImageOrientation::None });
 
     COMPtr<ID2D1Bitmap> nativeImage;
     HRESULT hr = nativeImageTarget->GetBitmap(&nativeImage);
@@ -313,10 +313,10 @@ ImageDrawResult SVGImage::draw(GraphicsContext& context, const FloatRect& dstRec
     context.clip(enclosingIntRect(dstRect));
 
     float alpha = context.alpha();
-    bool compositingRequiresTransparencyLayer = options.compositeOperator() != CompositeSourceOver || options.blendMode() != BlendMode::Normal || alpha < 1;
+    bool compositingRequiresTransparencyLayer = options.compositeOperator() != CompositeOperator::SourceOver || options.blendMode() != BlendMode::Normal || alpha < 1;
     if (compositingRequiresTransparencyLayer) {
         context.beginTransparencyLayer(alpha);
-        context.setCompositeOperation(CompositeSourceOver, BlendMode::Normal);
+        context.setCompositeOperation(CompositeOperator::SourceOver, BlendMode::Normal);
     }
 
     FloatSize scale(dstRect.size() / srcRect.size());
index 1a473ac..93e2e39 100644 (file)
@@ -1,5 +1,20 @@
 2019-11-30  Tim Horton  <timothy_horton@apple.com>
 
+        Make CompositeOperator and BlendMode encodable
+        https://bugs.webkit.org/show_bug.cgi?id=204722
+
+        Reviewed by Eric Carlson.
+
+        * UIProcess/cairo/BackingStoreCairo.cpp:
+        (WebKit::BackingStore::incorporateUpdate):
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::paint):
+        (WebKit::PluginProxy::update):
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::drawRect):
+
+2019-11-30  Tim Horton  <timothy_horton@apple.com>
+
         Reimplement some PlatformCALayer methods using GraphicsContext instead of CGContextRef
         https://bugs.webkit.org/show_bug.cgi?id=204698
 
index 7bdd03d..3035f6f 100644 (file)
@@ -87,8 +87,8 @@ void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo&
     GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(cairoContext.get()));
 
     // When m_webPageProxy.drawsBackground() is false, bitmap contains transparent parts as a background of the webpage.
-    // For such case, bitmap must be drawn using CompositeCopy to overwrite the existing surface.
-    graphicsContext.setCompositeOperation(WebCore::CompositeCopy);
+    // For such case, bitmap must be drawn using CompositeOperator::Copy to overwrite the existing surface.
+    graphicsContext.setCompositeOperation(WebCore::CompositeOperator::Copy);
 
     for (const auto& updateRect : updateInfo.updateRects) {
         IntRect srcRect = updateRect;
index 9ab5837..184cf67 100644 (file)
@@ -215,7 +215,7 @@ void PluginProxy::paint(GraphicsContext& graphicsContext, const IntRect& dirtyRe
         auto graphicsContext = m_backingStore->createGraphicsContext();
         if (graphicsContext) {
             graphicsContext->applyDeviceScaleFactor(contentsScaleFactor());
-            graphicsContext->setCompositeOperation(CompositeCopy);
+            graphicsContext->setCompositeOperation(CompositeOperator::Copy);
 
             m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor(), IntPoint(), pluginBounds());
 
@@ -727,7 +727,7 @@ void PluginProxy::update(const IntRect& paintedRect)
         auto graphicsContext = m_backingStore->createGraphicsContext();
         if (graphicsContext) {
             graphicsContext->applyDeviceScaleFactor(contentsScaleFactor());
-            graphicsContext->setCompositeOperation(CompositeCopy);
+            graphicsContext->setCompositeOperation(CompositeOperator::Copy);
             m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor(), paintedRect.location(), paintedRect);
         }
     }
index ed36a8a..c97017a 100644 (file)
@@ -537,7 +537,7 @@ void FindController::drawRect(PageOverlay&, GraphicsContext& graphicsContext, co
     graphicsContext.clearShadow();
 
     // Clear out the holes.
-    graphicsContext.setCompositeOperation(CompositeClear);
+    graphicsContext.setCompositeOperation(CompositeOperator::Clear);
     for (auto& path : whiteFramePaths)
         graphicsContext.fillPath(path);
 
index e7a0b38..8726493 100644 (file)
@@ -1,3 +1,16 @@
+2019-11-30  Tim Horton  <timothy_horton@apple.com>
+
+        Make CompositeOperator and BlendMode encodable
+        https://bugs.webkit.org/show_bug.cgi?id=204722
+
+        Reviewed by Eric Carlson.
+
+        * FullscreenVideoController.cpp:
+        (FullscreenVideoController::draw):
+        * WebView.cpp:
+        (WebView::paintWithDirect2D):
+        (WebView::paintIntoBackingStore):
+
 2019-10-31  Ryosuke Niwa  <rniwa@webkit.org>
 
         Windows build fix attempt after r251798.
index 9b14674..0733ae4 100644 (file)
@@ -501,7 +501,7 @@ void FullscreenVideoController::draw()
     IntRect innerRect(borderThickness, borderThickness, windowWidth - borderThickness * 2, windowHeight - borderThickness * 2);
 
     context.fillRoundedRect(FloatRoundedRect(outerRect, outerRadius, outerRadius, outerRadius, outerRadius), Color(borderColor));
-    context.setCompositeOperation(CompositeCopy);
+    context.setCompositeOperation(CompositeOperator::Copy);
     context.fillRoundedRect(FloatRoundedRect(innerRect, innerRadius, innerRadius, innerRadius, innerRadius), Color(backgroundColor));
 
     // Draw the widgets
index 23bf4b4..36dd589 100644 (file)
@@ -1268,7 +1268,7 @@ void WebView::paintWithDirect2D()
             gc.clip(logicalDirtyRect);
             frameView->paint(gc, logicalDirtyRect);
             if (m_shouldInvertColors)
-                gc.fillRect(logicalDirtyRect, Color::white, CompositeDifference);
+                gc.fillRect(logicalDirtyRect, Color::white, CompositeOperator::Difference);
             gc.restore();
         }
     }
@@ -1420,7 +1420,7 @@ void WebView::paintIntoBackingStore(FrameView* frameView, HDC bitmapDC, const In
         gc.clip(logicalDirtyRect);
         frameView->paint(gc, logicalDirtyRect);
         if (m_shouldInvertColors)
-            gc.fillRect(logicalDirtyRect, Color::white, CompositeDifference);
+            gc.fillRect(logicalDirtyRect, Color::white, CompositeOperator::Difference);
         gc.restore();
     }
     gc.restore();