Title: [110979] trunk/Source/WebCore
- Revision
- 110979
- Author
- jocelyn.turco...@nokia.com
- Date
- 2012-03-16 03:21:49 -0700 (Fri, 16 Mar 2012)
Log Message
[TexMap] Reuse textures following the same rules as they do internally.
https://bugs.webkit.org/show_bug.cgi?id=80843
Reviewed by Noam Rosenthal.
BitmapTextures were recently changed to be the same size as their contents.
This would obsolete the logic in acquireTextureFromPool which would
assume that a BitmapTexture has good chances of being reused if its
size is bigger or equal to the new size.
This asks the texture instead if it can be reused which now simply
check for an exact size match.
* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::TextureMapper::acquireTextureFromPool):
* platform/graphics/texmap/TextureMapper.h:
(WebCore::BitmapTexture::canReuseWith):
(WebCore::BitmapTexture::reset):
(WebCore::BitmapTexture::didReset):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::BitmapTextureGL::canReuseWith):
(WebCore):
* platform/graphics/texmap/TextureMapperGL.h:
(BitmapTextureGL):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (110978 => 110979)
--- trunk/Source/WebCore/ChangeLog 2012-03-16 10:20:02 UTC (rev 110978)
+++ trunk/Source/WebCore/ChangeLog 2012-03-16 10:21:49 UTC (rev 110979)
@@ -1,3 +1,30 @@
+2012-03-15 Jocelyn Turcotte <jocelyn.turco...@nokia.com>
+
+ [TexMap] Reuse textures following the same rules as they do internally.
+ https://bugs.webkit.org/show_bug.cgi?id=80843
+
+ Reviewed by Noam Rosenthal.
+
+ BitmapTextures were recently changed to be the same size as their contents.
+ This would obsolete the logic in acquireTextureFromPool which would
+ assume that a BitmapTexture has good chances of being reused if its
+ size is bigger or equal to the new size.
+
+ This asks the texture instead if it can be reused which now simply
+ check for an exact size match.
+
+ * platform/graphics/texmap/TextureMapper.cpp:
+ (WebCore::TextureMapper::acquireTextureFromPool):
+ * platform/graphics/texmap/TextureMapper.h:
+ (WebCore::BitmapTexture::canReuseWith):
+ (WebCore::BitmapTexture::reset):
+ (WebCore::BitmapTexture::didReset):
+ * platform/graphics/texmap/TextureMapperGL.cpp:
+ (WebCore::BitmapTextureGL::canReuseWith):
+ (WebCore):
+ * platform/graphics/texmap/TextureMapperGL.h:
+ (BitmapTextureGL):
+
2012-03-16 Robert Kroeger <rjkro...@chromium.org>
Connect up fling event delivery to gesture curve animation framework
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp (110978 => 110979)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp 2012-03-16 10:20:02 UTC (rev 110978)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp 2012-03-16 10:21:49 UTC (rev 110979)
@@ -37,31 +37,10 @@
if (texture->refCount() > 1)
continue;
- // We default to the first available texture.
- if (!selectedTexture) {
+ if (texture->canReuseWith(size)) {
selectedTexture = texture;
- continue;
+ break;
}
-
- 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;
}
if (!selectedTexture) {
@@ -69,7 +48,7 @@
m_texturePool.append(selectedTexture);
}
- selectedTexture->reset(size, false);
+ selectedTexture->reset(size);
return selectedTexture;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h (110978 => 110979)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h 2012-03-16 10:20:02 UTC (rev 110978)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h 2012-03-16 10:21:49 UTC (rev 110979)
@@ -73,13 +73,14 @@
inline Flags flags() const { return m_flags; }
virtual int bpp() const { return 32; }
- virtual void didReset() { }
- void reset(const IntSize& size, Flags flags)
+ virtual bool canReuseWith(const IntSize& contentsSize, Flags flags = 0) { return false; }
+ void reset(const IntSize& size, Flags flags = 0)
{
m_flags = flags;
m_contentSize = size;
didReset();
}
+ virtual void didReset() { }
inline IntSize contentSize() const { return m_contentSize; }
inline int numberOfBytes() const { return size().width() * size().height() * bpp() >> 3; }
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (110978 => 110979)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2012-03-16 10:20:02 UTC (rev 110978)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2012-03-16 10:21:49 UTC (rev 110979)
@@ -390,6 +390,11 @@
return "OpenGL";
}
+bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags)
+{
+ return contentsSize == m_textureSize;
+}
+
void BitmapTextureGL::didReset()
{
if (!m_id)
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (110978 => 110979)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2012-03-16 10:20:02 UTC (rev 110978)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2012-03-16 10:21:49 UTC (rev 110979)
@@ -77,6 +77,7 @@
public:
virtual IntSize size() const;
virtual bool isValid() const;
+ virtual bool canReuseWith(const IntSize& contentsSize, Flags = 0);
virtual void didReset();
void bind();
void initializeStencil();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes