[Texmap] Implementation for pattern compositing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2013 16:01:25 +0000 (16:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2013 16:01:25 +0000 (16:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109588

Patch by Noam Rosenthal <noam@webkit.org> on 2013-04-19
Reviewed by Allan Sandfeld Jensen.

Source/WebCore:

Enable pattern compositing (background images) for CoordinatedGraphics/TextureMapperGL.
Use the existing patternTransform shader uniform, multiplying it by a matrix calculated
using the contentsRect, tileSize and tilePhase.

Covered by existing tests in compositing/patterns.

* platform/graphics/GraphicsLayer.h:
(GraphicsLayer):
    Conditionally enable pattern compositing for coordinated graphics.

* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::TextureMapper::TextureMapper):
* platform/graphics/texmap/TextureMapper.h:
(WebCore::TextureMapper::setPatternTransform):
(WebCore::TextureMapper::setWrapMode):
(WebCore::TextureMapper::wrapMode):
(WebCore::TextureMapper::patternTransform):
    Add wrapMode and patternTransform properties to the TextureMapper state.

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
    Paint with GL_REPEAT and a pattern transform when needed.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computePatternTransformIfNeeded):
(WebCore):
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::setContentsRect):
(WebCore::TextureMapperLayer::setContentsTileSize):
(WebCore::TextureMapperLayer::setContentsTilePhase):
    Apply the patternTransform from the tile size/phase.

* platform/graphics/texmap/TextureMapperLayer.h:
(WebCore::TextureMapperLayer::TextureMapperLayer):
(TextureMapperLayer):
(WebCore::TextureMapperLayer::setShouldMapBackingStoreToContentsRect):
(State):
(WebCore::TextureMapperLayer::State::State):
    Allow the client to configure whether a layer uses its bounds or its
    contents rect to paint the backing store.
    This is needed now since layers with background images, unlike layers
    with regular images, may have bounds that are greater than the contents
    rect.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsTileSize):
(WebCore):
(WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
(WebCore::CoordinatedGraphicsLayer::setShouldSupportContentsTiling):
(WebCore::GraphicsLayer::supportsContentsTiling):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::setLayerState):
(WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
(CoordinatedGraphicsLayerState):
    Logic to pass the tileSize/tilePhase from CoordinatedGraphicsLayer
    to TextureMapperLayer.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
    Don't reset the layer's image contents when this is a directly composited image.

Source/WebKit2:

Serialize the two new properties from CoordinatedGraphicsLayer to CoordinatedGraphicsScene.

* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(CoreIPC::::encode):
(CoreIPC::::decode):
    Encode/decode the new tiling properties.

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
    Enable pattern compositing for coordinated graphics.
    This is needed since we don't want to enable pattern compositing for
    WebKit1 yet.

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
Source/WebCore/platform/graphics/texmap/TextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

index c575026..07160ea 100644 (file)
@@ -1,3 +1,74 @@
+2013-04-19  Noam Rosenthal  <noam@webkit.org>
+
+        [Texmap] Implementation for pattern compositing
+        https://bugs.webkit.org/show_bug.cgi?id=109588
+
+        Reviewed by Allan Sandfeld Jensen.
+
+        Enable pattern compositing (background images) for CoordinatedGraphics/TextureMapperGL.
+        Use the existing patternTransform shader uniform, multiplying it by a matrix calculated
+        using the contentsRect, tileSize and tilePhase.
+
+        Covered by existing tests in compositing/patterns.
+
+        * platform/graphics/GraphicsLayer.h:
+        (GraphicsLayer):
+            Conditionally enable pattern compositing for coordinated graphics.
+
+        * platform/graphics/texmap/TextureMapper.cpp:
+        (WebCore::TextureMapper::TextureMapper):
+        * platform/graphics/texmap/TextureMapper.h:
+        (WebCore::TextureMapper::setPatternTransform):
+        (WebCore::TextureMapper::setWrapMode):
+        (WebCore::TextureMapper::wrapMode):
+        (WebCore::TextureMapper::patternTransform):
+            Add wrapMode and patternTransform properties to the TextureMapper state.
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
+            Paint with GL_REPEAT and a pattern transform when needed.
+
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::computePatternTransformIfNeeded):
+        (WebCore):
+        (WebCore::TextureMapperLayer::paintSelf):
+        (WebCore::TextureMapperLayer::setContentsRect):
+        (WebCore::TextureMapperLayer::setContentsTileSize):
+        (WebCore::TextureMapperLayer::setContentsTilePhase):
+            Apply the patternTransform from the tile size/phase.
+
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (WebCore::TextureMapperLayer::TextureMapperLayer):
+        (TextureMapperLayer):
+        (WebCore::TextureMapperLayer::setShouldMapBackingStoreToContentsRect):
+        (State):
+        (WebCore::TextureMapperLayer::State::State):
+            Allow the client to configure whether a layer uses its bounds or its
+            contents rect to paint the backing store.
+            This is needed now since layers with background images, unlike layers
+            with regular images, may have bounds that are greater than the contents
+            rect.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setContentsTileSize):
+        (WebCore):
+        (WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
+        (WebCore::CoordinatedGraphicsLayer::setShouldSupportContentsTiling):
+        (WebCore::GraphicsLayer::supportsContentsTiling):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+        (CoordinatedGraphicsLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
+        (WebCore::CoordinatedGraphicsScene::setLayerState):
+        (WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
+        (CoordinatedGraphicsLayerState):
+            Logic to pass the tileSize/tilePhase from CoordinatedGraphicsLayer
+            to TextureMapperLayer.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
+            Don't reset the layer's image contents when this is a directly composited image.
+
 2013-04-19  ChangSeok Oh  <changseok.oh@collabora.com>
 
         [GTK][AC] Manage actor's children by using clutter's own way.
 2013-04-19  ChangSeok Oh  <changseok.oh@collabora.com>
 
         [GTK][AC] Manage actor's children by using clutter's own way.
index 184b42c..c95fd41 100644 (file)
@@ -443,11 +443,15 @@ public:
 #endif
     }
 
 #endif
     }
 
+#if USE(COORDINATED_GRAPHICS)
+    static bool supportsContentsTiling();
+#else
     static bool supportsContentsTiling()
     {
         // FIXME: Enable the feature on different ports.
         return false;
     }
     static bool supportsContentsTiling()
     {
         // FIXME: Enable the feature on different ports.
         return false;
     }
+#endif
 
     void updateDebugIndicators();
 
 
     void updateDebugIndicators();
 
index 4dc2899..12b04ba 100644 (file)
@@ -143,6 +143,7 @@ TextureMapper::TextureMapper(AccelerationMode accelerationMode)
     , m_texturePool(adoptPtr(new BitmapTexturePool()))
     , m_accelerationMode(accelerationMode)
     , m_isMaskMode(false)
     , m_texturePool(adoptPtr(new BitmapTexturePool()))
     , m_accelerationMode(accelerationMode)
     , m_isMaskMode(false)
+    , m_wrapMode(StretchWrap)
 { }
 
 TextureMapper::~TextureMapper()
 { }
 
 TextureMapper::~TextureMapper()
index 7dedcb1..138071d 100644 (file)
@@ -115,6 +115,12 @@ public:
     enum PaintFlag {
         PaintingMirrored = 1 << 0,
     };
     enum PaintFlag {
         PaintingMirrored = 1 << 0,
     };
+
+    enum WrapMode {
+        StretchWrap,
+        RepeatWrap
+    };
+
     typedef unsigned PaintFlags;
 
     static PassOwnPtr<TextureMapper> create(AccelerationMode newMode = SoftwareMode);
     typedef unsigned PaintFlags;
 
     static PassOwnPtr<TextureMapper> create(AccelerationMode newMode = SoftwareMode);
@@ -163,12 +169,17 @@ public:
     virtual void removeCachedCustomFilterProgram(CustomFilterProgram*) { }
 #endif
 
     virtual void removeCachedCustomFilterProgram(CustomFilterProgram*) { }
 #endif
 
+    void setPatternTransform(const TransformationMatrix& p) { m_patternTransform = p; }
+    void setWrapMode(WrapMode m) { m_wrapMode = m; }
+
 protected:
     explicit TextureMapper(AccelerationMode);
 
     GraphicsContext* m_context;
 
     bool isInMaskMode() const { return m_isMaskMode; }
 protected:
     explicit TextureMapper(AccelerationMode);
 
     GraphicsContext* m_context;
 
     bool isInMaskMode() const { return m_isMaskMode; }
+    WrapMode wrapMode() const { return m_wrapMode; }
+    const TransformationMatrix& patternTransform() const { return m_patternTransform; }
 
 private:
 #if USE(TEXTURE_MAPPER_GL)
 
 private:
 #if USE(TEXTURE_MAPPER_GL)
@@ -184,6 +195,8 @@ private:
     OwnPtr<BitmapTexturePool> m_texturePool;
     AccelerationMode m_accelerationMode;
     bool m_isMaskMode;
     OwnPtr<BitmapTexturePool> m_texturePool;
     AccelerationMode m_accelerationMode;
     bool m_isMaskMode;
+    TransformationMatrix m_patternTransform;
+    WrapMode m_wrapMode;
 };
 
 }
 };
 
 }
index 7a35c2e..8875694 100644 (file)
@@ -548,8 +548,12 @@ void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* pr
     GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
     m_context3D->bindTexture(target, texture);
     m_context3D->uniform1i(program->samplerLocation(), 0);
     GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
     m_context3D->bindTexture(target, texture);
     m_context3D->uniform1i(program->samplerLocation(), 0);
+    if (wrapMode() == RepeatWrap) {
+        m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT);
+        m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT);
+    }
 
 
-    TransformationMatrix patternTransform;
+    TransformationMatrix patternTransform = this->patternTransform();
     if (flags & ShouldFlipTexture)
         patternTransform.flipY();
     if (flags & ShouldUseARBTextureRect)
     if (flags & ShouldFlipTexture)
         patternTransform.flipY();
     if (flags & ShouldUseARBTextureRect)
@@ -564,6 +568,8 @@ void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* pr
         flags |= ShouldBlend;
 
     draw(rect, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, flags);
         flags |= ShouldBlend;
 
     draw(rect, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, flags);
+    m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+    m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
 }
 
 BitmapTextureGL::BitmapTextureGL(TextureMapperGL* textureMapper)
 }
 
 BitmapTextureGL::BitmapTextureGL(TextureMapperGL* textureMapper)
index b7c5c0b..bcd1c5c 100644 (file)
@@ -99,6 +99,17 @@ static Color blendWithOpacity(const Color& color, float opacity)
     return Color(colorWithOverrideAlpha(rgba, effectiveAlpha));
 }
 
     return Color(colorWithOverrideAlpha(rgba, effectiveAlpha));
 }
 
+void TextureMapperLayer::computePatternTransformIfNeeded()
+{
+    if (!m_patternTransformDirty)
+        return;
+
+    m_patternTransformDirty = false;
+    m_patternTransform =
+        TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_state.contentsTileSize), m_state.contentsRect)
+        .multiply(TransformationMatrix().translate(m_state.contentsTilePhase.x() / m_state.contentsRect.width(), m_state.contentsTilePhase.y() / m_state.contentsRect.height()));
+}
+
 void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
 {
     if (!m_state.visible || !m_state.contentsVisible)
 void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
 {
     if (!m_state.visible || !m_state.contentsVisible)
@@ -110,30 +121,41 @@ void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
     transform.multiply(options.transform);
     transform.multiply(m_currentTransform.combined());
 
     transform.multiply(options.transform);
     transform.multiply(m_currentTransform.combined());
 
-    if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty()) {
+    if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.alpha()) {
         options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
         if (m_state.showDebugBorders)
             options.textureMapper->drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
         return;
     }
 
         options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
         if (m_state.showDebugBorders)
             options.textureMapper->drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
         return;
     }
 
+    options.textureMapper->setWrapMode(TextureMapper::StretchWrap);
+    options.textureMapper->setPatternTransform(TransformationMatrix());
+
+    if (!m_state.contentsTileSize.isEmpty()) {
+        computePatternTransformIfNeeded();
+        options.textureMapper->setWrapMode(TextureMapper::RepeatWrap);
+        options.textureMapper->setPatternTransform(m_patternTransform);
+    }
+
     if (m_backingStore) {
         ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_state.size.isEmpty());
     if (m_backingStore) {
         ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_state.size.isEmpty());
-        ASSERT(!layerRect().isEmpty());
-        m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, options.opacity);
+        FloatRect targetRect = m_state.shouldMapBackingStoreToContentsRect ? m_state.contentsRect : layerRect();
+        ASSERT(!targetRect.isEmpty());
+        m_backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
         if (m_state.showDebugBorders)
         if (m_state.showDebugBorders)
-            m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
+            m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
         // Only draw repaint count for the main backing store.
         if (m_state.showRepaintCounter)
         // Only draw repaint count for the main backing store.
         if (m_state.showRepaintCounter)
-            m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, layerRect(), transform);
+            m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
     }
 
     }
 
-    if (m_contentsLayer) {
-        ASSERT(!layerRect().isEmpty());
-        m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
-        if (m_state.showDebugBorders)
-            m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
-    }
+    if (!m_contentsLayer)
+        return;
+
+    ASSERT(!layerRect().isEmpty());
+    m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
+    if (m_state.showDebugBorders)
+        m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
 }
 
 int TextureMapperLayer::compareGraphicsLayersZValue(const void* a, const void* b)
 }
 
 int TextureMapperLayer::compareGraphicsLayersZValue(const void* a, const void* b)
@@ -551,7 +573,26 @@ void TextureMapperLayer::setChildrenTransform(const TransformationMatrix& childr
 
 void TextureMapperLayer::setContentsRect(const IntRect& contentsRect)
 {
 
 void TextureMapperLayer::setContentsRect(const IntRect& contentsRect)
 {
+    if (contentsRect == m_state.contentsRect)
+        return;
     m_state.contentsRect = contentsRect;
     m_state.contentsRect = contentsRect;
+    m_patternTransformDirty = true;
+}
+
+void TextureMapperLayer::setContentsTileSize(const IntSize& size)
+{
+    if (size == m_state.contentsTileSize)
+        return;
+    m_state.contentsTileSize = size;
+    m_patternTransformDirty = true;
+}
+
+void TextureMapperLayer::setContentsTilePhase(const IntPoint& phase)
+{
+    if (phase == m_state.contentsTilePhase)
+        return;
+    m_state.contentsTilePhase = phase;
+    m_patternTransformDirty = true;
 }
 
 void TextureMapperLayer::setMasksToBounds(bool masksToBounds)
 }
 
 void TextureMapperLayer::setMasksToBounds(bool masksToBounds)
index ca10474..c24fe4e 100644 (file)
@@ -56,6 +56,7 @@ public:
         , m_id(0)
         , m_scrollClient(0)
         , m_isScrollable(false)
         , m_id(0)
         , m_scrollClient(0)
         , m_isScrollable(false)
+        , m_patternTransformDirty(false)
     { }
 
     virtual ~TextureMapperLayer();
     { }
 
     virtual ~TextureMapperLayer();
@@ -98,6 +99,8 @@ public:
     void setBackfaceVisibility(bool);
     void setOpacity(float);
     void setSolidColor(const Color&);
     void setBackfaceVisibility(bool);
     void setOpacity(float);
     void setSolidColor(const Color&);
+    void setContentsTileSize(const IntSize&);
+    void setContentsTilePhase(const IntPoint&);
 #if ENABLE(CSS_FILTERS)
     void setFilters(const FilterOperations&);
 #endif
 #if ENABLE(CSS_FILTERS)
     void setFilters(const FilterOperations&);
 #endif
@@ -119,6 +122,7 @@ public:
     void setFixedToViewport(bool);
     bool fixedToViewport() const { return m_fixedToViewport; }
     void setBackingStore(PassRefPtr<TextureMapperBackingStore>);
     void setFixedToViewport(bool);
     bool fixedToViewport() const { return m_fixedToViewport; }
     void setBackingStore(PassRefPtr<TextureMapperBackingStore>);
+    void setShouldMapBackingStoreToContentsRect(bool m) { m_state.shouldMapBackingStoreToContentsRect = m; }
 
     void syncAnimations();
     bool descendantsOrSelfHaveRunningAnimations() const;
 
     void syncAnimations();
     bool descendantsOrSelfHaveRunningAnimations() const;
@@ -158,6 +162,7 @@ private:
     void paintSelfAndChildren(const TextureMapperPaintOptions&);
     void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
     void applyMask(const TextureMapperPaintOptions&);
     void paintSelfAndChildren(const TextureMapperPaintOptions&);
     void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
     void applyMask(const TextureMapperPaintOptions&);
+    void computePatternTransformIfNeeded();
 
     // GraphicsLayerAnimation::Client
     virtual void setAnimatedTransform(const TransformationMatrix&) OVERRIDE;
 
     // GraphicsLayerAnimation::Client
     virtual void setAnimatedTransform(const TransformationMatrix&) OVERRIDE;
@@ -206,6 +211,8 @@ private:
         TransformationMatrix childrenTransform;
         float opacity;
         FloatRect contentsRect;
         TransformationMatrix childrenTransform;
         float opacity;
         FloatRect contentsRect;
+        IntSize contentsTileSize;
+        IntPoint contentsTilePhase;
         TextureMapperLayer* maskLayer;
         TextureMapperLayer* replicaLayer;
         Color solidColor;
         TextureMapperLayer* maskLayer;
         TextureMapperLayer* replicaLayer;
         Color solidColor;
@@ -225,6 +232,7 @@ private:
         bool visible : 1;
         bool showDebugBorders : 1;
         bool showRepaintCounter : 1;
         bool visible : 1;
         bool showDebugBorders : 1;
         bool showRepaintCounter : 1;
+        bool shouldMapBackingStoreToContentsRect : 1;
 
         State()
             : opacity(1)
 
         State()
             : opacity(1)
@@ -241,6 +249,7 @@ private:
             , visible(true)
             , showDebugBorders(false)
             , showRepaintCounter(false)
             , visible(true)
             , showDebugBorders(false)
             , showRepaintCounter(false)
+            , shouldMapBackingStoreToContentsRect(false)
         {
         }
     };
         {
         }
     };
@@ -255,6 +264,8 @@ private:
     bool m_isScrollable;
     FloatSize m_userScrollOffset;
     FloatSize m_accumulatedScrollOffsetFractionalPart;
     bool m_isScrollable;
     FloatSize m_userScrollOffset;
     FloatSize m_accumulatedScrollOffsetFractionalPart;
+    TransformationMatrix m_patternTransform;
+    bool m_patternTransformDirty;
 };
 
 }
 };
 
 }
index f6a2e14..586e47b 100644 (file)
@@ -340,6 +340,40 @@ void CoordinatedGraphicsLayer::setContentsRect(const IntRect& r)
     didChangeLayerState();
 }
 
     didChangeLayerState();
 }
 
+void CoordinatedGraphicsLayer::setContentsTileSize(const IntSize& s)
+{
+    if (contentsTileSize() == s)
+        return;
+
+    GraphicsLayer::setContentsTileSize(s);
+    m_layerState.contentsTileSize = s;
+    m_layerState.contentsTilingChanged = true;
+    didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsTilePhase(const IntPoint& p)
+{
+    if (contentsTilePhase() == p)
+        return;
+
+    GraphicsLayer::setContentsTilePhase(p);
+    m_layerState.contentsTilePhase = p;
+    m_layerState.contentsTilingChanged = true;
+    didChangeLayerState();
+}
+
+static bool s_shouldSupportContentsTiling = false;
+
+void CoordinatedGraphicsLayer::setShouldSupportContentsTiling(bool s)
+{
+    s_shouldSupportContentsTiling = s;
+}
+
+bool GraphicsLayer::supportsContentsTiling()
+{
+    return s_shouldSupportContentsTiling;
+}
+
 void CoordinatedGraphicsLayer::setContentsNeedsDisplay()
 {
 #if USE(GRAPHICS_SURFACE)
 void CoordinatedGraphicsLayer::setContentsNeedsDisplay()
 {
 #if USE(GRAPHICS_SURFACE)
index 45bfb27..9c63c08 100644 (file)
@@ -86,6 +86,8 @@ public:
     virtual void setBackfaceVisibility(bool) OVERRIDE;
     virtual void setOpacity(float) OVERRIDE;
     virtual void setContentsRect(const IntRect&) OVERRIDE;
     virtual void setBackfaceVisibility(bool) OVERRIDE;
     virtual void setOpacity(float) OVERRIDE;
     virtual void setContentsRect(const IntRect&) OVERRIDE;
+    virtual void setContentsTilePhase(const IntPoint&) OVERRIDE;
+    virtual void setContentsTileSize(const IntSize&) OVERRIDE;
     virtual void setContentsToImage(Image*) OVERRIDE;
     virtual void setContentsToSolidColor(const Color&) OVERRIDE;
     virtual void setShowDebugBorder(bool) OVERRIDE;
     virtual void setContentsToImage(Image*) OVERRIDE;
     virtual void setContentsToSolidColor(const Color&) OVERRIDE;
     virtual void setShowDebugBorder(bool) OVERRIDE;
@@ -145,6 +147,8 @@ public:
     void purgeBackingStores();
     bool hasPendingVisibleChanges();
 
     void purgeBackingStores();
     bool hasPendingVisibleChanges();
 
+    static void setShouldSupportContentsTiling(bool);
+
 private:
 #if USE(GRAPHICS_SURFACE)
     enum PendingCanvasOperation {
 private:
 #if USE(GRAPHICS_SURFACE)
     enum PendingCanvasOperation {
index b21eead..41ffb76 100644 (file)
@@ -323,6 +323,11 @@ void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const Coordi
     if (layerState.contentsRectChanged)
         layer->setContentsRect(layerState.contentsRect);
 
     if (layerState.contentsRectChanged)
         layer->setContentsRect(layerState.contentsRect);
 
+    if (layerState.contentsTilingChanged) {
+        layer->setContentsTilePhase(layerState.contentsTilePhase);
+        layer->setContentsTileSize(layerState.contentsTileSize);
+    }
+
     if (layerState.opacityChanged)
         layer->setOpacity(layerState.opacity);
 
     if (layerState.opacityChanged)
         layer->setOpacity(layerState.opacity);
 
@@ -579,11 +584,14 @@ void CoordinatedGraphicsScene::assignImageBackingToLayer(TextureMapperLayer* lay
 
     if (imageID == InvalidCoordinatedImageBackingID) {
         layer->setBackingStore(0);
 
     if (imageID == InvalidCoordinatedImageBackingID) {
         layer->setBackingStore(0);
+        layer->setShouldMapBackingStoreToContentsRect(false);
         return;
     }
         return;
     }
+
     ImageBackingMap::iterator it = m_imageBackings.find(imageID);
     ASSERT(it != m_imageBackings.end());
     layer->setBackingStore(it->value.get());
     ImageBackingMap::iterator it = m_imageBackings.find(imageID);
     ASSERT(it != m_imageBackings.end());
     layer->setBackingStore(it->value.get());
+    layer->setShouldMapBackingStoreToContentsRect(true);
 }
 
 void CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded()
 }
 
 void CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded()
index c7ff7a4..93e25cb 100644 (file)
@@ -93,6 +93,7 @@ struct CoordinatedGraphicsLayerState {
             bool canvasShouldSwapBuffers: 1;
             bool isScrollableChanged: 1;
             bool committedScrollOffsetChanged: 1;
             bool canvasShouldSwapBuffers: 1;
             bool isScrollableChanged: 1;
             bool committedScrollOffsetChanged: 1;
+            bool contentsTilingChanged: 1;
         };
         unsigned changeMask;
     };
         };
         unsigned changeMask;
     };
@@ -141,6 +142,8 @@ struct CoordinatedGraphicsLayerState {
     TransformationMatrix transform;
     TransformationMatrix childrenTransform;
     IntRect contentsRect;
     TransformationMatrix transform;
     TransformationMatrix childrenTransform;
     IntRect contentsRect;
+    IntPoint contentsTilePhase;
+    IntSize contentsTileSize;
     float opacity;
     Color solidColor;
     Color debugBorderColor;
     float opacity;
     Color solidColor;
     Color debugBorderColor;
index 33ad090..e4b84e1 100644 (file)
@@ -1446,6 +1446,9 @@ void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleCo
     if (!GraphicsLayer::supportsContentsTiling())
         return;
 
     if (!GraphicsLayer::supportsContentsTiling())
         return;
 
+    if (isDirectlyCompositedImage())
+        return;
+
     const RenderStyle* style = renderer()->style();
 
     if (!isSimpleContainer || !style->hasBackgroundImage()) {
     const RenderStyle* style = renderer()->style();
 
     if (!isSimpleContainer || !style->hasBackgroundImage()) {
index cae9de2..6723c53 100644 (file)
@@ -1,3 +1,23 @@
+2013-04-19  Noam Rosenthal  <noam@webkit.org>
+
+        [Texmap] Implementation for pattern compositing
+        https://bugs.webkit.org/show_bug.cgi?id=109588
+
+        Reviewed by Allan Sandfeld Jensen.
+
+        Serialize the two new properties from CoordinatedGraphicsLayer to CoordinatedGraphicsScene.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+        (CoreIPC::::encode):
+        (CoreIPC::::decode):
+            Encode/decode the new tiling properties.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
+            Enable pattern compositing for coordinated graphics.
+            This is needed since we don't want to enable pattern compositing for
+            WebKit1 yet.
+
 2013-04-18  Tim Horton  <timothy_horton@apple.com>
 
         PDFPlugin: Update PDFLayerController's scale factors earlier
 2013-04-18  Tim Horton  <timothy_horton@apple.com>
 
         PDFPlugin: Update PDFLayerController's scale factors earlier
index 66654f8..c02734a 100644 (file)
@@ -849,6 +849,11 @@ void ArgumentCoder<CoordinatedGraphicsLayerState>::encode(ArgumentEncoder& encod
     if (state.contentsRectChanged)
         encoder << state.contentsRect;
 
     if (state.contentsRectChanged)
         encoder << state.contentsRect;
 
+    if (state.contentsTilingChanged) {
+        encoder << state.contentsTileSize;
+        encoder << state.contentsTilePhase;
+    }
+
     if (state.opacityChanged)
         encoder << state.opacity;
 
     if (state.opacityChanged)
         encoder << state.opacity;
 
@@ -928,6 +933,13 @@ bool ArgumentCoder<CoordinatedGraphicsLayerState>::decode(ArgumentDecoder& decod
     if (state.contentsRectChanged && !decoder.decode(state.contentsRect))
         return false;
 
     if (state.contentsRectChanged && !decoder.decode(state.contentsRect))
         return false;
 
+    if (state.contentsTilingChanged) {
+        if (!decoder.decode(state.contentsTileSize))
+            return false;
+        if (!decoder.decode(state.contentsTilePhase))
+            return false;
+    }
+
     if (state.opacityChanged && !decoder.decode(state.opacity))
         return false;
 
     if (state.opacityChanged && !decoder.decode(state.opacity))
         return false;
 
index 1a337e9..9d33920 100644 (file)
@@ -121,6 +121,10 @@ CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
 
     CoordinatedSurface::setFactory(createCoordinatedSurface);
 
 
     CoordinatedSurface::setFactory(createCoordinatedSurface);
 
+    // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed.
+    // See https://bugs.webkit.org/show_bug.cgi?id=114869
+    CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true);
+
     if (m_webPage->hasPageOverlay())
         createPageOverlayLayer();
 
     if (m_webPage->hasPageOverlay())
         createPageOverlayLayer();