Diff
Modified: trunk/Source/WebCore/ChangeLog (104446 => 104447)
--- trunk/Source/WebCore/ChangeLog 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/ChangeLog 2012-01-09 11:54:06 UTC (rev 104447)
@@ -1,3 +1,33 @@
+2012-01-09 No'am Rosenthal <[email protected]>
+
+ [Texmap] Move surface management from TextureMapperNode to TextureMapper
+ https://bugs.webkit.org/show_bug.cgi?id=75779
+
+ Instead of a TextureMapperSurfaceManager class inside of TextureMapperNode.cpp, we now
+ maintain that surface pool inside of the TextureMapper class. This will later allow us to
+ allocate intermediate surface from within TextureMapperGL, a functionality we need for
+ filters.
+
+ Also, surfaces are not automatically created with the viewport size, but rather with the
+ size passed as a parameter. The surface from the pool is the smallest texture that is
+ larger than the required size, or any texture if such texture is not yet allocated.
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Tests in LayoutTests/compositing already cover this.
+
+ * GNUmakefile.list.am: Added TextureMapper.cpp to the build.
+ * Target.pri: Added TextureMapper.cpp to the build.
+ * WebCore.gypi: Added TextureMapper.cpp to the build.
+ * platform/graphics/texmap/TextureMapper.cpp: Added.
+ * platform/graphics/texmap/TextureMapper.h:
+ * platform/graphics/texmap/TextureMapperNode.cpp:
+ (WebCore::TextureMapperNode::paint):
+ (WebCore::TextureMapperNode::paintReflection):
+ (WebCore::TextureMapperNode::paintRecursive):
+ * platform/graphics/texmap/TextureMapperNode.h:
+ (WebCore::TextureMapperNode::TextureMapperNode):
+
2012-01-09 Mario Sanchez Prada <[email protected]>
[Gtk] Regression: text-inserted events lack text inserted and current line
Modified: trunk/Source/WebCore/GNUmakefile.list.am (104446 => 104447)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-01-09 11:54:06 UTC (rev 104447)
@@ -5656,6 +5656,7 @@
webcore_sources += \
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp \
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h \
+ Source/WebCore/platform/graphics/texmap/TextureMapper.cpp \
Source/WebCore/platform/graphics/texmap/TextureMapper.h \
Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp \
Source/WebCore/platform/graphics/texmap/TextureMapperNode.h \
@@ -5671,6 +5672,7 @@
Source/WebCore/platform/graphics/opengl/TextureMapperGL.h \
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp \
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h \
+ Source/WebCore/platform/graphics/texmap/TextureMapper.cpp \
Source/WebCore/platform/graphics/texmap/TextureMapper.h \
Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp \
Source/WebCore/platform/graphics/texmap/TextureMapperNode.h \
Modified: trunk/Source/WebCore/Target.pri (104446 => 104447)
--- trunk/Source/WebCore/Target.pri 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/Target.pri 2012-01-09 11:54:06 UTC (rev 104447)
@@ -1170,6 +1170,7 @@
rendering/BidiRun.cpp \
rendering/CounterNode.cpp \
rendering/EllipsisBox.cpp \
+ rendering/FilterEffectRenderer.cpp \
rendering/FixedTableLayout.cpp \
rendering/HitTestingTransformState.cpp \
rendering/HitTestResult.cpp \
@@ -2284,6 +2285,7 @@
rendering/break_lines.h \
rendering/CounterNode.h \
rendering/EllipsisBox.h \
+ rendering/FilterEffectRenderer.h \
rendering/FixedTableLayout.h \
rendering/HitTestingTransformState.h \
rendering/HitTestResult.h \
@@ -3905,6 +3907,7 @@
SOURCES += \
platform/graphics/qt/TextureMapperQt.cpp \
+ platform/graphics/texmap/TextureMapper.cpp \
platform/graphics/texmap/TextureMapperNode.cpp \
platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Modified: trunk/Source/WebCore/WebCore.gypi (104446 => 104447)
--- trunk/Source/WebCore/WebCore.gypi 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/WebCore.gypi 2012-01-09 11:54:06 UTC (rev 104447)
@@ -3922,6 +3922,7 @@
'platform/graphics/skia/TransformationMatrixSkia.cpp',
'platform/graphics/texmap/GraphicsLayerTextureMapper.cpp',
'platform/graphics/texmap/GraphicsLayerTextureMapper.h',
+ 'platform/graphics/texmap/TextureMapper.cpp',
'platform/graphics/texmap/TextureMapper.h',
'platform/graphics/texmap/TextureMapperNode.cpp',
'platform/graphics/texmap/TextureMapperNode.h',
Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp (0 => 104447)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp 2012-01-09 11:54:06 UTC (rev 104447)
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "TextureMapper.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+
+namespace WebCore {
+
+PassRefPtr<BitmapTexture> TextureMapper::acquireTextureFromPool(const IntSize& size)
+{
+ if (m_texturePool.isEmpty()) {
+ RefPtr<BitmapTexture> selectedTexture = createTexture();
+ selectedTexture->reset(size, false);
+ selectedTexture->lock();
+ return selectedTexture;
+ }
+
+ size_t index = 0;
+ RefPtr<BitmapTexture> selectedTexture = m_texturePool[0];
+
+ for (size_t i = 1; i < m_texturePool.size(); ++i) {
+ RefPtr<BitmapTexture> texture = m_texturePool[i];
+
+ IntSize textureSize = texture->size();
+ IntSize selectedTextureSize = selectedTexture->size();
+
+ // We prefer to pick a texture that's equal or larger than the requested size.
+ if (textureSize.width() < size.width() || textureSize.height() < size.height())
+ continue;
+
+ // We select the new texture if the currently selected texture is smaller than the
+ // required size, and the new texture has a smaller area.
+ int textureArea = textureSize.width() * textureSize.height();
+ int selectedTextureArea = selectedTextureSize.width() * selectedTextureSize.height();
+ bool selectedTextureFitsSize =
+ selectedTextureSize.width() >= size.width()
+ && selectedTextureSize.height() >= size.height();
+
+ if (selectedTextureFitsSize && selectedTextureArea <= textureArea)
+ continue;
+
+ selectedTexture = texture;
+ index = i;
+ }
+
+ m_texturePool.remove(index);
+ selectedTexture->reset(size, false);
+ selectedTexture->lock();
+ return selectedTexture;
+}
+
+void TextureMapper::releaseTextureToPool(BitmapTexture* texture)
+{
+ if (!texture)
+ return;
+ m_texturePool.append(texture);
+ texture->unlock();
+}
+
+}
+#endif
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h (104446 => 104447)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h 2012-01-09 11:54:06 UTC (rev 104447)
@@ -126,7 +126,10 @@
virtual void beginPainting() { }
virtual void endPainting() { }
+ virtual void releaseTextureToPool(BitmapTexture* surface);
+ virtual PassRefPtr<BitmapTexture> acquireTextureFromPool(const IntSize&);
+
protected:
TextureMapper()
: m_interpolationQuality(InterpolationDefault)
@@ -138,6 +141,7 @@
TextDrawingModeFlags m_textDrawingMode;
TransformationMatrix m_transform;
IntSize m_viewportSize;
+ Vector<RefPtr<BitmapTexture> > m_texturePool;
};
};
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp (104446 => 104447)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp 2012-01-09 11:54:06 UTC (rev 104447)
@@ -31,40 +31,6 @@
namespace WebCore {
-class TextureMapperSurfaceManager {
-public:
- TextureMapper* textureMapper;
- Vector<RefPtr<BitmapTexture> > surfaces;
- IntSize viewportSize;
-
- PassRefPtr<BitmapTexture> getIntermediateSurface()
- {
- IntSize newViewportSize = textureMapper->viewportSize();
- if (newViewportSize != viewportSize) {
- viewportSize = newViewportSize;
- surfaces.clear();
- }
- if (surfaces.isEmpty()) {
- RefPtr<BitmapTexture> newSurface = textureMapper->createTexture();
- newSurface->reset(viewportSize, false);
- return newSurface.get();
- }
- RefPtr<BitmapTexture> surface = surfaces.last();
- surface->reset(viewportSize, false);
- surfaces.removeLast();
- surface->lock();
- return surface.get();
- }
-
- void releaseIntermediateSurface(BitmapTexture* surface)
- {
- if (!surface)
- return;
- surfaces.append(surface);
- surface->unlock();
- }
-};
-
TextureMapperNode* toTextureMapperNode(GraphicsLayer* layer)
{
return layer ? toGraphicsLayerTextureMapper(layer)->node() : 0;
@@ -346,11 +312,7 @@
if (m_size.isEmpty())
return;
- if (!m_surfaceManager)
- m_surfaceManager = new TextureMapperSurfaceManager;
- m_surfaceManager->textureMapper = m_textureMapper;
TextureMapperPaintOptions opt;
- opt.surfaceManager = m_surfaceManager;
opt.textureMapper = m_textureMapper;
opt.textureMapper->bindSurface(0);
paintRecursive(opt);
@@ -496,7 +458,7 @@
// The mask has to be adjusted to target coordinates.
if (maskTexture) {
- maskSurface = options.surfaceManager->getIntermediateSurface();
+ maskSurface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
options.textureMapper->bindSurface(maskSurface.get());
options.textureMapper->drawTexture(*maskTexture.get(), entireRect(), m_transforms.target, 1, 0);
maskTexture = maskSurface;
@@ -504,7 +466,7 @@
// The replica's mask has to be adjusted to target coordinates.
if (replicaMaskTexture) {
- replicaMaskSurface = options.surfaceManager->getIntermediateSurface();
+ replicaMaskSurface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
options.textureMapper->bindSurface(replicaMaskSurface.get());
options.textureMapper->drawTexture(*replicaMaskTexture.get(), entireRect(), m_transforms.target, 1, 0);
replicaMaskTexture = replicaMaskSurface;
@@ -512,21 +474,21 @@
// We might need to apply the mask of the content layer before we draw the reflection, as there might be yet another mask for the reflection itself.
if (useIntermediateBufferForMask) {
- RefPtr<BitmapTexture> maskSurface = options.surfaceManager->getIntermediateSurface();
+ RefPtr<BitmapTexture> maskSurface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
options.textureMapper->bindSurface(maskSurface.get());
options.textureMapper->drawTexture(*surface.get(), viewportRect, TransformationMatrix(), 1, maskTexture.get());
- options.surfaceManager->releaseIntermediateSurface(surface.get());
+ options.textureMapper->releaseTextureToPool(surface.get());
surface = maskSurface;
maskTexture.clear();
}
// We blend the layer and its replica in an intermediate buffer before blending into the target surface.
if (useIntermediateBufferForReplica) {
- RefPtr<BitmapTexture> replicaSurface = options.surfaceManager->getIntermediateSurface();
+ RefPtr<BitmapTexture> replicaSurface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
options.textureMapper->bindSurface(replicaSurface.get());
options.textureMapper->drawTexture(*surface.get(), viewportRect, m_transforms.replica, m_state.replicaLayer->m_opacity, replicaMaskTexture.get());
options.textureMapper->drawTexture(*surface.get(), viewportRect, TransformationMatrix(), 1, maskTexture.get());
- options.surfaceManager->releaseIntermediateSurface(surface.get());
+ options.textureMapper->releaseTextureToPool(surface.get());
surface = replicaSurface;
}
@@ -539,8 +501,8 @@
// Draw the original.
options.textureMapper->drawTexture(*surface.get(), viewportRect, TransformationMatrix(), options.opacity, maskTexture.get());
- options.surfaceManager->releaseIntermediateSurface(maskSurface.get());
- options.surfaceManager->releaseIntermediateSurface(replicaMaskSurface.get());
+ options.textureMapper->releaseTextureToPool(maskSurface.get());
+ options.textureMapper->releaseTextureToPool(replicaMaskSurface.get());
return true;
}
@@ -570,12 +532,12 @@
// The mask has to be adjusted to target coordinates.
if (m_state.maskLayer) {
- maskSurface = options.surfaceManager->getIntermediateSurface();
+ maskSurface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
options.textureMapper->bindSurface(maskSurface.get());
options.textureMapper->drawTexture(*m_state.maskLayer->texture(), entireRect(), m_transforms.target, 1.0, 0);
}
- surface = options.surfaceManager->getIntermediateSurface();
+ surface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
optionsForDescendants.surface = surface.get();
options.isSurface = true;
optionsForDescendants.opacity = 1;
@@ -588,8 +550,8 @@
options.textureMapper->drawTexture(*surface.get(), viewportRect, TransformationMatrix(), options.opacity, 0);
}
- options.surfaceManager->releaseIntermediateSurface(surface.get());
- options.surfaceManager->releaseIntermediateSurface(maskSurface.get());
+ options.textureMapper->releaseTextureToPool(surface.get());
+ options.textureMapper->releaseTextureToPool(maskSurface.get());
}
TextureMapperNode::~TextureMapperNode()
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h (104446 => 104447)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h 2012-01-09 10:16:20 UTC (rev 104446)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h 2012-01-09 11:54:06 UTC (rev 104447)
@@ -39,17 +39,20 @@
class TextureMapperPlatformLayer;
class TextureMapperNode;
class GraphicsLayerTextureMapper;
-class TextureMapperSurfaceManager;
class TextureMapperPaintOptions {
public:
BitmapTexture* surface;
TextureMapper* textureMapper;
- TextureMapperSurfaceManager* surfaceManager;
float opacity;
bool isSurface;
- TextureMapperPaintOptions() : surface(0), textureMapper(0), opacity(1.0), isSurface(false) { }
+ TextureMapperPaintOptions()
+ : surface(0)
+ , textureMapper(0)
+ , opacity(1)
+ , isSurface(false)
+ { }
};
class TextureMapperAnimation : public RefCounted<TextureMapperAnimation> {
@@ -135,7 +138,11 @@
};
TextureMapperNode()
- : m_parent(0), m_effectTarget(0), m_opacity(1.0), m_surfaceManager(0), m_textureMapper(0) { }
+ : m_parent(0)
+ , m_effectTarget(0)
+ , m_opacity(1)
+ , m_textureMapper(0)
+ { }
virtual ~TextureMapperNode();
@@ -317,7 +324,6 @@
};
State m_state;
- TextureMapperSurfaceManager* m_surfaceManager;
TextureMapper* m_textureMapper;
Vector<RefPtr<TextureMapperAnimation> > m_animations;