Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[TexMap] Avoid constructing Vector when setting new children of Textu…
…reMapperLayer

https://bugs.webkit.org/show_bug.cgi?id=137265

Reviewed by Brent Fulgham.

Instead of constructing a vector object and populating it with TextureMapperLayers
every time the children of a GraphicsLayer change, the children vector is now passed
directly to TextureMapperLayer::setChildren(), which properly downcasts GraphicsLayers
and adds the new TextureMapperLayer children.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
(WebCore::toTextureMapperLayerVector): Deleted.
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::setChildren):
* platform/graphics/texmap/TextureMapperLayer.h:


Canonical link: https://commits.webkit.org/158148@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
zdobersek committed Jan 7, 2015
1 parent 062fb1d commit cee2459
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
19 changes: 19 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,22 @@
2015-01-06 Zan Dobersek <zdobersek@igalia.com>

[TexMap] Avoid constructing Vector when setting new children of TextureMapperLayer
https://bugs.webkit.org/show_bug.cgi?id=137265

Reviewed by Brent Fulgham.

Instead of constructing a vector object and populating it with TextureMapperLayers
every time the children of a GraphicsLayer change, the children vector is now passed
directly to TextureMapperLayer::setChildren(), which properly downcasts GraphicsLayers
and adds the new TextureMapperLayer children.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
(WebCore::toTextureMapperLayerVector): Deleted.
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::setChildren):
* platform/graphics/texmap/TextureMapperLayer.h:

2015-01-07 Zan Dobersek <zdobersek@igalia.com>

[TexMap] m_layer member in GraphicsLayerTextureMapper is always non-null
Expand Down
Expand Up @@ -408,23 +408,13 @@ void GraphicsLayerTextureMapper::setDebugBorder(const Color& color, float width)
m_changeMask |= DebugVisualsChange;
}

static void toTextureMapperLayerVector(const Vector<GraphicsLayer*>& layers, Vector<TextureMapperLayer*>& texmapLayers)
{
texmapLayers.reserveCapacity(layers.size());
for (auto* layer : layers)
texmapLayers.append(&downcast<GraphicsLayerTextureMapper>(layer)->layer());
}

void GraphicsLayerTextureMapper::commitLayerChanges()
{
if (m_changeMask == NoChanges)
return;

if (m_changeMask & ChildrenChange) {
Vector<TextureMapperLayer*> textureMapperLayerChildren;
toTextureMapperLayerVector(children(), textureMapperLayerChildren);
m_layer.setChildren(textureMapperLayerChildren);
}
if (m_changeMask & ChildrenChange)
m_layer.setChildren(children());

if (m_changeMask & MaskLayerChange)
m_layer.setMaskLayer(&downcast<GraphicsLayerTextureMapper>(maskLayer())->layer());
Expand Down
Expand Up @@ -21,6 +21,7 @@
#include "TextureMapperLayer.h"

#include "FloatQuad.h"
#include "GraphicsLayerTextureMapper.h"
#include "Region.h"
#include <wtf/MathExtras.h>

Expand Down Expand Up @@ -448,11 +449,11 @@ TextureMapperLayer::~TextureMapperLayer()
removeFromParent();
}

void TextureMapperLayer::setChildren(const Vector<TextureMapperLayer*>& newChildren)
void TextureMapperLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
{
removeAllChildren();
for (auto* child : newChildren)
addChild(child);
addChild(&downcast<GraphicsLayerTextureMapper>(child)->layer());
}

void TextureMapperLayer::addChild(TextureMapperLayer* childLayer)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Expand Up @@ -31,6 +31,7 @@

namespace WebCore {

class GraphicsLayer;
class Region;
class TextureMapperPaintOptions;
class TextureMapperPlatformLayer;
Expand Down Expand Up @@ -77,7 +78,7 @@ class TextureMapperLayer : public GraphicsLayerAnimation::Client {
TextureMapper* textureMapper() const { return rootLayer().m_textureMapper; }
void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; }

void setChildren(const Vector<TextureMapperLayer*>&);
void setChildren(const Vector<GraphicsLayer*>&);
void setMaskLayer(TextureMapperLayer*);
void setReplicaLayer(TextureMapperLayer*);
void setPosition(const FloatPoint&);
Expand Down

0 comments on commit cee2459

Please sign in to comment.