⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 167553 in webkit


Ignore:
Timestamp:
Apr 19, 2014, 3:26:59 PM (12 years ago)
Author:
Simon Fraser
Message:

[UI-side compositing] Implement blend modes
https://bugs.webkit.org/show_bug.cgi?id=131891
<rdar://problem/16490085>

Reviewed by Tim Horton.

Implement blend modes with UI-side compositing.

PlatformCALayer::setBlendMode() becomes pure virtual, and overridden in
PlatformCALayerMac and PlatformCALayerRemote.
PlatformCAFilters::setBlendingFiltersOnLayer() now takes a raw platform
layer, so it can be called from the UI process on a CALayer*.

Source/WebCore:
Fix an issue with GraphicsLayerCA::LayerChange flags. 1 << 31 shifts
a signed integer, so it ended up setting all the high bits in m_uncommittedChanges,
causing us to push blend modes to the UI process for every layer. Fix by shifting
an unsigned long long (1LLU << 31). This should also fix a build warning on Windows.

  • WebCore.exp.in:
  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/PlatformCAFilters.h:
  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/mac/PlatformCAFiltersMac.mm:

(PlatformCAFilters::setBlendingFiltersOnLayer):

  • platform/graphics/ca/mac/PlatformCALayerMac.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.mm:

(PlatformCALayerMac::setFilters):
(PlatformCALayerMac::setBlendMode):
(PlatformCALayer::setBlendMode): Deleted.

Source/WebKit2:
Add BlendMode to LayerProperties, and initialize, encode and decode it,
as well as adding dumping support for blend modes.

  • Shared/mac/RemoteLayerTreePropertyApplier.mm:

(WebKit::applyPropertiesToLayer):

  • Shared/mac/RemoteLayerTreeTransaction.h:
  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::RemoteLayerTreeTextStream::operator<<):
(WebKit::dumpChangedLayers):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(WebKit::PlatformCALayerRemote::setBlendMode):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:
Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167551 r167553  
     12014-04-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] Implement blend modes
     4        https://bugs.webkit.org/show_bug.cgi?id=131891
     5        <rdar://problem/16490085>
     6
     7        Reviewed by Tim Horton.
     8
     9        Implement blend modes with UI-side compositing.
     10       
     11        PlatformCALayer::setBlendMode() becomes pure virtual, and overridden in
     12        PlatformCALayerMac and PlatformCALayerRemote.
     13        PlatformCAFilters::setBlendingFiltersOnLayer() now takes a raw platform
     14        layer, so it can be called from the UI process on a CALayer*.
     15       
     16        Fix an issue with GraphicsLayerCA::LayerChange flags. 1 << 31 shifts
     17        a signed integer, so it ended up setting all the high bits in m_uncommittedChanges,
     18        causing us to push blend modes to the UI process for every layer. Fix by shifting
     19        an unsigned long long (1LLU << 31). This should also fix a build warning on Windows.
     20
     21        * WebCore.exp.in:
     22        * platform/graphics/ca/GraphicsLayerCA.h:
     23        * platform/graphics/ca/PlatformCAFilters.h:
     24        * platform/graphics/ca/PlatformCALayer.h:
     25        * platform/graphics/ca/mac/PlatformCAFiltersMac.mm:
     26        (PlatformCAFilters::setBlendingFiltersOnLayer):
     27        * platform/graphics/ca/mac/PlatformCALayerMac.h:
     28        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
     29        (PlatformCALayerMac::setFilters):
     30        (PlatformCALayerMac::setBlendMode):
     31        (PlatformCALayer::setBlendMode): Deleted.
     32
    1332014-04-19  Joseph Pecoraro  <pecoraro@apple.com>
    234
  • trunk/Source/WebCore/WebCore.exp.in

    r167535 r167553  
    737737__ZN7WebCore17PlatformCAFilters17setFiltersOnLayerEP7CALayerRKNS_16FilterOperationsE
    738738__ZN7WebCore17PlatformCAFilters23filterValueForOperationEPKNS_15FilterOperationEi
     739__ZN7WebCore17PlatformCAFilters25setBlendingFiltersOnLayerEP7CALayerNS_9BlendModeE
    739740__ZN7WebCore17SQLiteTransaction5beginEv
    740741__ZN7WebCore17SQLiteTransaction6commitEv
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r167535 r167553  
    425425    enum LayerChange {
    426426        NoChange = 0,
    427         NameChanged = 1 << 1,
    428         ChildrenChanged = 1 << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
    429         GeometryChanged = 1 << 3,
    430         TransformChanged = 1 << 4,
    431         ChildrenTransformChanged = 1 << 5,
    432         Preserves3DChanged = 1 << 6,
    433         MasksToBoundsChanged = 1 << 7,
    434         DrawsContentChanged = 1 << 8,
    435         BackgroundColorChanged = 1 << 9,
    436         ContentsOpaqueChanged = 1 << 10,
    437         BackfaceVisibilityChanged = 1 << 11,
    438         OpacityChanged = 1 << 12,
    439         AnimationChanged = 1 << 13,
    440         DirtyRectsChanged = 1 << 14,
    441         ContentsImageChanged = 1 << 15,
    442         ContentsMediaLayerChanged = 1 << 16,
    443         ContentsCanvasLayerChanged = 1 << 17,
    444         ContentsColorLayerChanged = 1 << 18,
    445         ContentsRectsChanged = 1 << 19,
    446         MaskLayerChanged = 1 << 20,
    447         ReplicatedLayerChanged = 1 << 21,
    448         ContentsNeedsDisplay = 1 << 22,
    449         AcceleratesDrawingChanged = 1 << 23,
    450         ContentsScaleChanged = 1 << 24,
    451         ContentsVisibilityChanged = 1 << 25,
    452         VisibleRectChanged = 1 << 26,
    453         FiltersChanged = 1 << 27,
    454         TilingAreaChanged = 1 << 28,
    455         TilesAdded = 1 < 29,
    456         DebugIndicatorsChanged = 1 << 30,
    457         CustomAppearanceChanged = 1 << 31,
    458         CustomBehaviorChanged = 1 << 32,
    459         BlendModeChanged = 1 << 33
     427        NameChanged = 1LLU << 1,
     428        ChildrenChanged = 1LLU << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
     429        GeometryChanged = 1LLU << 3,
     430        TransformChanged = 1LLU << 4,
     431        ChildrenTransformChanged = 1LLU << 5,
     432        Preserves3DChanged = 1LLU << 6,
     433        MasksToBoundsChanged = 1LLU << 7,
     434        DrawsContentChanged = 1LLU << 8,
     435        BackgroundColorChanged = 1LLU << 9,
     436        ContentsOpaqueChanged = 1LLU << 10,
     437        BackfaceVisibilityChanged = 1LLU << 11,
     438        OpacityChanged = 1LLU << 12,
     439        AnimationChanged = 1LLU << 13,
     440        DirtyRectsChanged = 1LLU << 14,
     441        ContentsImageChanged = 1LLU << 15,
     442        ContentsMediaLayerChanged = 1LLU << 16,
     443        ContentsCanvasLayerChanged = 1LLU << 17,
     444        ContentsColorLayerChanged = 1LLU << 18,
     445        ContentsRectsChanged = 1LLU << 19,
     446        MaskLayerChanged = 1LLU << 20,
     447        ReplicatedLayerChanged = 1LLU << 21,
     448        ContentsNeedsDisplay = 1LLU << 22,
     449        AcceleratesDrawingChanged = 1LLU << 23,
     450        ContentsScaleChanged = 1LLU << 24,
     451        ContentsVisibilityChanged = 1LLU << 25,
     452        VisibleRectChanged = 1LLU << 26,
     453        FiltersChanged = 1LLU << 27,
     454        TilingAreaChanged = 1LLU << 28,
     455        TilesAdded = 1LLU < 29,
     456        DebugIndicatorsChanged = 1LLU << 30,
     457        CustomAppearanceChanged = 1LLU << 31,
     458        CustomBehaviorChanged = 1LLU << 32,
     459        BlendModeChanged = 1LLU << 33
    460460    };
    461461    typedef uint64_t LayerChangeFlags;
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h

    r166741 r167553  
    4949public:
    5050    static void setFiltersOnLayer(PlatformLayer*, const FilterOperations&);
    51     static void setBlendingFiltersOnLayer(PlatformCALayer*, const BlendMode);
     51    static void setBlendingFiltersOnLayer(PlatformLayer*, const BlendMode);
    5252    static int numAnimatedFilterProperties(FilterOperation::OperationType);
    5353    static const char* animatedFilterPropertyName(FilterOperation::OperationType, int internalFilterPropertyIndex);
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r166542 r167553  
    184184
    185185#if ENABLE(CSS_COMPOSITING)
    186     void setBlendMode(BlendMode);
     186    virtual void setBlendMode(BlendMode) = 0;
    187187#endif
    188188
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm

    r166741 r167553  
    2929
    3030#import "PlatformCAFilters.h"
    31 
    3231#import "BlockExceptions.h"
    3332#import "FloatConversion.h"
     
    4039
    4140// FIXME: Should share these values with FilterEffectRenderer::build() (https://bugs.webkit.org/show_bug.cgi?id=76008).
    42 static double sepiaFullConstants[3][3] = {
     41static const double sepiaFullConstants[3][3] = {
    4342    { 0.393, 0.769, 0.189 },
    4443    { 0.349, 0.686, 0.168 },
     
    4645};
    4746
    48 static double sepiaNoneConstants[3][3] = {
     47static const double sepiaNoneConstants[3][3] = {
    4948    { 1, 0, 0 },
    5049    { 0, 1, 0 },
     
    539538#endif
    540539
    541 void PlatformCAFilters::setBlendingFiltersOnLayer(PlatformCALayer* platformCALayer, const BlendMode blendMode)
     540void PlatformCAFilters::setBlendingFiltersOnLayer(PlatformLayer* layer, const BlendMode blendMode)
    542541{
    543542#if USE_CA_FILTERS
    544     CALayer* layer = platformCALayer->platformLayer();
    545 
    546543    BEGIN_BLOCK_OBJC_EXCEPTIONS
    547544
     
    596593
    597594    END_BLOCK_OBJC_EXCEPTIONS
    598 
    599 #else
    600     UNUSED_PARAM(platformCALayer);
     595#else
     596    UNUSED_PARAM(layer);
    601597    UNUSED_PARAM(blendMode);
    602598#endif
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h

    r166654 r167553  
    123123#endif
    124124
     125#if ENABLE(CSS_COMPOSITING)
     126    virtual void setBlendMode(BlendMode) override;
     127#endif
     128
    125129    virtual void setName(const String&) override;
    126130
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r166654 r167553  
    644644void PlatformCALayerMac::setFilters(const FilterOperations& filters)
    645645{
    646     PlatformCAFilters::setFiltersOnLayer(this->platformLayer(), filters);
     646    PlatformCAFilters::setFiltersOnLayer(platformLayer(), filters);
    647647}
    648648
     
    680680
    681681#if ENABLE(CSS_COMPOSITING)
    682 void PlatformCALayer::setBlendMode(BlendMode blendMode)
    683 {
    684     PlatformCAFilters::setBlendingFiltersOnLayer(this, blendMode);
     682void PlatformCALayerMac::setBlendMode(BlendMode blendMode)
     683{
     684    PlatformCAFilters::setBlendingFiltersOnLayer(platformLayer(), blendMode);
    685685}
    686686#endif
  • trunk/Source/WebKit2/ChangeLog

    r167552 r167553  
     12014-04-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] Implement blend modes
     4        https://bugs.webkit.org/show_bug.cgi?id=131891
     5        <rdar://problem/16490085>
     6
     7        Reviewed by Tim Horton.
     8
     9        Implement blend modes with UI-side compositing.
     10       
     11        PlatformCALayer::setBlendMode() becomes pure virtual, and overridden in
     12        PlatformCALayerMac and PlatformCALayerRemote.
     13        PlatformCAFilters::setBlendingFiltersOnLayer() now takes a raw platform
     14        layer, so it can be called from the UI process on a CALayer*.
     15       
     16        Add BlendMode to LayerProperties, and initialize, encode and decode it,
     17        as well as adding dumping support for blend modes.
     18       
     19        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
     20        (WebKit::applyPropertiesToLayer):
     21        * Shared/mac/RemoteLayerTreeTransaction.h:
     22        * Shared/mac/RemoteLayerTreeTransaction.mm:
     23        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
     24        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
     25        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     26        (WebKit::RemoteLayerTreeTextStream::operator<<):
     27        (WebKit::dumpChangedLayers):
     28        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     29        (WebKit::PlatformCALayerRemote::setBlendMode):
     30        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     31
    1322014-04-19  Joseph Pecoraro  <pecoraro@apple.com>
    233
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm

    r167536 r167553  
    179179        layer.magnificationFilter = toCAFilterType(properties.magnificationFilter);
    180180
     181    if (properties.changedProperties & RemoteLayerTreeTransaction::BlendModeChanged)
     182        PlatformCAFilters::setBlendingFiltersOnLayer(layer, properties.blendMode);
     183
    181184    if (properties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
    182185        layer.speed = properties.speed;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r166545 r167553  
    7373        MinificationFilterChanged = 1 << 20,
    7474        MagnificationFilterChanged = 1 << 21,
    75         SpeedChanged = 1 << 22,
    76         TimeOffsetChanged = 1 << 23,
    77         BackingStoreChanged = 1 << 24,
    78         FiltersChanged = 1 << 25,
    79         AnimationsChanged = 1 << 26,
    80         EdgeAntialiasingMaskChanged = 1 << 27,
    81         CustomAppearanceChanged = 1 << 28,
    82         CustomBehaviorChanged = 1 << 29
     75        BlendModeChanged = 1 << 22,
     76        SpeedChanged = 1 << 23,
     77        TimeOffsetChanged = 1 << 24,
     78        BackingStoreChanged = 1 << 25,
     79        FiltersChanged = 1 << 26,
     80        AnimationsChanged = 1 << 27,
     81        EdgeAntialiasingMaskChanged = 1 << 28,
     82        CustomAppearanceChanged = 1 << 29,
     83        CustomBehaviorChanged = 1 << 30
    8384    };
    8485    typedef unsigned LayerChange;
     
    144145        WebCore::PlatformCALayer::FilterType minificationFilter;
    145146        WebCore::PlatformCALayer::FilterType magnificationFilter;
     147        WebCore::BlendMode blendMode;
    146148        bool hidden;
    147149        bool geometryFlipped;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r167266 r167553  
    9494    , minificationFilter(PlatformCALayer::FilterType::Linear)
    9595    , magnificationFilter(PlatformCALayer::FilterType::Linear)
     96    , blendMode(BlendModeNormal)
    9697    , hidden(false)
    9798    , geometryFlipped(false)
     
    126127    , minificationFilter(other.minificationFilter)
    127128    , magnificationFilter(other.magnificationFilter)
     129    , blendMode(other.blendMode)
    128130    , hidden(other.hidden)
    129131    , geometryFlipped(other.geometryFlipped)
     
    217219        encoder.encodeEnum(magnificationFilter);
    218220
     221    if (changedProperties & BlendModeChanged)
     222        encoder.encodeEnum(blendMode);
     223
    219224    if (changedProperties & SpeedChanged)
    220225        encoder << speed;
     
    369374    if (result.changedProperties & MagnificationFilterChanged) {
    370375        if (!decoder.decodeEnum(result.magnificationFilter))
     376            return false;
     377    }
     378
     379    if (result.changedProperties & BlendModeChanged) {
     380        if (!decoder.decodeEnum(result.blendMode))
    371381            return false;
    372382    }
     
    568578    RemoteLayerTreeTextStream& operator<<(const PlatformCAAnimationRemote::Properties&);
    569579    RemoteLayerTreeTextStream& operator<<(const RemoteLayerBackingStore&);
     580    RemoteLayerTreeTextStream& operator<<(BlendMode);
    570581    RemoteLayerTreeTextStream& operator<<(PlatformCAAnimation::AnimationType);
    571582    RemoteLayerTreeTextStream& operator<<(PlatformCAAnimation::FillModeType);
     
    715726    return ts;
    716727}
    717    
     728
     729RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(BlendMode blendMode)
     730{
     731    RemoteLayerTreeTextStream& ts = *this;
     732    switch (blendMode) {
     733    case BlendModeNormal: ts << "normal"; break;
     734    case BlendModeMultiply: ts << "multiply"; break;
     735    case BlendModeScreen: ts << "screen"; break;
     736    case BlendModeOverlay: ts << "overlay"; break;
     737    case BlendModeDarken: ts << "darken"; break;
     738    case BlendModeLighten: ts << "lighten"; break;
     739    case BlendModeColorDodge: ts << "color-dodge"; break;
     740    case BlendModeColorBurn: ts << "color-burn"; break;
     741    case BlendModeHardLight: ts << "hard-light"; break;
     742    case BlendModeSoftLight: ts << "soft-light"; break;
     743    case BlendModeDifference: ts << "difference"; break;
     744    case BlendModeExclusion: ts << "exclusion"; break;
     745    case BlendModeHue: ts << "hue"; break;
     746    case BlendModeSaturation: ts << "saturation"; break;
     747    case BlendModeColor: ts << "color"; break;
     748    case BlendModeLuminosity: ts << "luminosity"; break;
     749    }
     750    return ts;
     751}
     752
    718753RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::AnimationType type)
    719754{
     
    10181053        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MagnificationFilterChanged)
    10191054            dumpProperty(ts, "magnificationFilter", layerProperties.magnificationFilter);
     1055
     1056        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BlendModeChanged)
     1057            dumpProperty(ts, "blendMode", layerProperties.blendMode);
    10201058
    10211059        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r167273 r167553  
    529529}
    530530
     531#if ENABLE(CSS_COMPOSITING)
     532void PlatformCALayerRemote::setBlendMode(BlendMode blendMode)
     533{
     534    m_properties.blendMode = blendMode;
     535    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BlendModeChanged);
     536}
     537#endif
     538
    531539bool PlatformCALayerRemote::filtersCanBeComposited(const FilterOperations& filters)
    532540{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r167273 r167553  
    125125#endif
    126126
     127#if ENABLE(CSS_COMPOSITING)
     128    virtual void setBlendMode(WebCore::BlendMode) override;
     129#endif
     130
    127131    virtual void setName(const String&) override;
    128132
Note: See TracChangeset for help on using the changeset viewer.