Title: [108055] trunk/Source
Revision
108055
Author
[email protected]
Date
2012-02-17 03:09:07 -0800 (Fri, 17 Feb 2012)

Log Message

[Qt][WK2] Allow partial updates
https://bugs.webkit.org/show_bug.cgi?id=78824

Source/WebCore:

BitmapTextureGL should not zero-fill the textures when resetting.
This was needed in the previous buffer management system, where texture were not completely
filled by the backing store.

Reviewed by Simon Hausmann.

No new behavior.

* platform/graphics/opengl/TextureMapperGL.cpp:
(BitmapTextureGL):
(WebCore::texSubImage2DResourceSafe):
(WebCore):
(WebCore::BitmapTextureGL::reset):

Source/WebKit2:

Instead of using UpdateInfo to fill the entire tile's texture, we use it as a patch that
contains only the dirty rectangle of the current paint. This requires a lot less memory
for small updates, for example when typing a text in an input field.
This shows a significant reduction in overhead when testing on Mac with Instruments.

Reviewed by Simon Hausmann.

* UIProcess/qt/LayerBackingStore.cpp:
(WebKit::LayerBackingStoreTile::swapBuffers):
(WebKit::LayerBackingStoreTile::setBackBuffer):
(WebKit):
(WebKit::LayerBackingStore::updateTile):
* UIProcess/qt/LayerBackingStore.h:
(LayerBackingStoreTile):
* UIProcess/qt/LayerTreeHostProxyQt.cpp:
(WebKit::LayerTreeHostProxy::updateTileForLayer):
* WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
(WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108054 => 108055)


--- trunk/Source/WebCore/ChangeLog	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebCore/ChangeLog	2012-02-17 11:09:07 UTC (rev 108055)
@@ -1,3 +1,22 @@
+2012-02-17  No'am Rosenthal  <[email protected]>
+
+        [Qt][WK2] Allow partial updates
+        https://bugs.webkit.org/show_bug.cgi?id=78824
+
+        BitmapTextureGL should not zero-fill the textures when resetting.
+        This was needed in the previous buffer management system, where texture were not completely
+        filled by the backing store.
+
+        Reviewed by Simon Hausmann.
+
+        No new behavior.
+
+        * platform/graphics/opengl/TextureMapperGL.cpp:
+        (BitmapTextureGL):
+        (WebCore::texSubImage2DResourceSafe):
+        (WebCore):
+        (WebCore::BitmapTextureGL::reset):
+
 2012-02-17  Yosifumi Inoue  <[email protected]>
 
         [Forms] Integrate InputType::dispatchChangeEventInResponseToSetValue into InputType::setValue

Modified: trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp (108054 => 108055)


--- trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp	2012-02-17 11:09:07 UTC (rev 108055)
@@ -579,19 +579,6 @@
     return "OpenGL";
 }
 
-// This function is similar with GraphicsContext3D::texImage2DResourceSafe.
-static void texImage2DResourceSafe(size_t width, size_t height)
-{
-    const int pixelSize = 4; // RGBA
-    OwnArrayPtr<unsigned char> zero;
-    if (width && height) {
-        unsigned int size = width * height * pixelSize;
-        zero = adoptArrayPtr(new unsigned char[size]);
-        memset(zero.get(), 0, size);
-    }
-    GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, zero.get()))
-}
-
 void BitmapTextureGL::reset(const IntSize& newSize, bool opaque)
 {
     BitmapTexture::reset(newSize, opaque);
@@ -609,7 +596,7 @@
         GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR))
         GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE))
         GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE))
-        texImage2DResourceSafe(m_textureSize.width(), m_textureSize.height());
+        GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0))
     }
     m_actualSize = newSize;
     m_relativeSize = FloatSize(float(newSize.width()) / m_textureSize.width(), float(newSize.height()) / m_textureSize.height());

Modified: trunk/Source/WebKit2/ChangeLog (108054 => 108055)


--- trunk/Source/WebKit2/ChangeLog	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-17 11:09:07 UTC (rev 108055)
@@ -1,3 +1,27 @@
+2012-02-17  No'am Rosenthal  <[email protected]>
+
+        [Qt][WK2] Allow partial updates
+        https://bugs.webkit.org/show_bug.cgi?id=78824
+
+        Instead of using UpdateInfo to fill the entire tile's texture, we use it as a patch that
+        contains only the dirty rectangle of the current paint. This requires a lot less memory
+        for small updates, for example when typing a text in an input field.
+        This shows a significant reduction in overhead when testing on Mac with Instruments.
+
+        Reviewed by Simon Hausmann.
+
+        * UIProcess/qt/LayerBackingStore.cpp:
+        (WebKit::LayerBackingStoreTile::swapBuffers):
+        (WebKit::LayerBackingStoreTile::setBackBuffer):
+        (WebKit):
+        (WebKit::LayerBackingStore::updateTile):
+        * UIProcess/qt/LayerBackingStore.h:
+        (LayerBackingStoreTile):
+        * UIProcess/qt/LayerTreeHostProxyQt.cpp:
+        (WebKit::LayerTreeHostProxy::updateTileForLayer):
+        * WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
+        (WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):
+
 2012-02-16  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Make sure print operation object is alive until printing finishes in WebKit2

Modified: trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.cpp (108054 => 108055)


--- trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.cpp	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.cpp	2012-02-17 11:09:07 UTC (rev 108055)
@@ -34,20 +34,35 @@
     if (!m_backBuffer)
         return;
 
-    FloatRect targetRect = m_targetRect;
+    FloatRect targetRect(m_targetRect);
     targetRect.scale(1. / m_scale);
-    setRect(targetRect);
+    bool shouldReset = false;
+    if (targetRect != rect()) {
+        setRect(targetRect);
+        shouldReset = true;
+    }
     RefPtr<BitmapTexture> texture = this->texture();
     if (!texture) {
         texture = textureMapper->createTexture();
         setTexture(texture.get());
+        shouldReset = true;
     }
 
-    texture->reset(enclosingIntRect(m_sourceRect).size(), false);
-    texture->updateContents(m_backBuffer->createQImage().constBits(), IntRect(IntPoint::zero(), m_backBuffer->size()));
+    // FIXME: create an opaque texture when the bitmap is opaque.
+    if (shouldReset)
+        texture->reset(m_sourceRect.size(), false /* opaque */);
+
+    texture->updateContents(m_backBuffer->createQImage().constBits(), m_sourceRect);
     m_backBuffer.clear();
 }
 
+void LayerBackingStoreTile::setBackBuffer(const WebCore::IntRect& targetRect, const WebCore::IntRect& sourceRect, ShareableBitmap* buffer)
+{
+    m_sourceRect = sourceRect;
+    m_targetRect = targetRect;
+    m_backBuffer = buffer;
+}
+
 void LayerBackingStore::createTile(int id, float scale)
 {
     m_tiles.add(id, LayerBackingStoreTile(scale));

Modified: trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.h (108054 => 108055)


--- trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.h	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.h	2012-02-17 11:09:07 UTC (rev 108055)
@@ -37,17 +37,12 @@
 
     inline float scale() const { return m_scale; }
     void swapBuffers(WebCore::TextureMapper*);
-    void setBackBuffer(const WebCore::FloatRect& target, const WebCore::FloatRect& source, ShareableBitmap* buffer)
-    {
-        m_targetRect = target;
-        m_sourceRect = source;
-        m_backBuffer = buffer;
-    }
+    void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, ShareableBitmap* buffer);
 
 private:
     RefPtr<ShareableBitmap> m_backBuffer;
-    WebCore::FloatRect m_sourceRect;
-    WebCore::FloatRect m_targetRect;
+    WebCore::IntRect m_sourceRect;
+    WebCore::IntRect m_targetRect;
     float m_scale;
 };
 

Modified: trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp (108054 => 108055)


--- trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp	2012-02-17 11:09:07 UTC (rev 108055)
@@ -507,7 +507,8 @@
     data.layerID = layerID;
     data.remoteTileID = tileID;
     data.bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
-    data.sourceRect = IntRect(IntPoint::zero(), updateInfo.updateRectBounds.size());
+    ASSERT(updateInfo.updateRects.size() == 1);
+    data.sourceRect = updateInfo.updateRects.first();
     data.targetRect = updateInfo.updateRectBounds;
     pushUpdateToQueue(UpdateTileMessage::create(data));
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp (108054 => 108055)


--- trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp	2012-02-17 11:07:05 UTC (rev 108054)
+++ trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp	2012-02-17 11:09:07 UTC (rev 108055)
@@ -72,24 +72,17 @@
     if (!isDirty())
         return Vector<IntRect>();
 
-    // FIXME: Only use a local buffer when we know the tile is animated (after the first invalidate)
-    // and destroy it after a few seconds of inactivity. We can render directly to shared
-    // memory in other cases.
-    if (!m_localBuffer || m_localBuffer->size() != m_rect.size()) {
-        m_localBuffer = ImageBuffer::create(m_rect.size());
-        m_localBuffer->context()->translate(-m_rect.x(), -m_rect.y());
-        m_localBuffer->context()->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale()));
-    }
-    // This assumes that the GraphicsContext on the ImageBuffer acts synchronously
-    // for us to be able to draw this buffer on the ShareableBitmap right after.
-    m_tiledBackingStore->client()->tiledBackingStorePaint(m_localBuffer->context(), m_tiledBackingStore->mapToContents(m_dirtyRect));
-
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_rect.size(), m_tiledBackingStore->supportsAlpha() ? ShareableBitmap::SupportsAlpha : 0);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_dirtyRect.size(), m_tiledBackingStore->supportsAlpha() ? ShareableBitmap::SupportsAlpha : 0);
     OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext());
-    graphicsContext->drawImageBuffer(m_localBuffer.get(), ColorSpaceDeviceRGB, IntPoint(0, 0));
+    graphicsContext->translate(-m_dirtyRect.x(), -m_dirtyRect.y());
+    graphicsContext->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale()));
+    m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(m_dirtyRect));
 
     UpdateInfo updateInfo;
     updateInfo.updateRectBounds = m_rect;
+    IntRect updateRect = m_dirtyRect;
+    updateRect.move(-m_rect.x(), -m_rect.y());
+    updateInfo.updateRects.append(updateRect);
     updateInfo.updateScaleFactor = m_tiledBackingStore->contentsScale();
     bitmap->createHandle(updateInfo.bitmapHandle);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to