[Qt][WK2] Allow opaque tiles
authornoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2012 16:53:31 +0000 (16:53 +0000)
committernoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2012 16:53:31 +0000 (16:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78809

Source/WebCore:

Add a supportsAlpha property to TiledBackingStore.
We invalidate all the tiles if that property changes, because the buffers need to be
recreated in a different format.

Reviewed by Kenneth Rohde Christiansen.

No behavior changes.

* platform/graphics/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::TiledBackingStore):
(WebCore::TiledBackingStore::setSupportsAlpha):
(WebCore):
* platform/graphics/TiledBackingStore.h:
(TiledBackingStore):
(WebCore::TiledBackingStore::supportsAlpha):

Source/WebKit2:

Set the supportsAlpha flag for TiledBackingStore when the layer has contentsOpaque enabled.
Use the flag for ShareableBitmaps created by TiledBackingStore.

For now this will not have impact on performance/memory, because we allocate the same type
of buffers for opaque and transparent tiles.

Reviewed by Kenneth Rohde Christiansen.

* WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
(WebCore::WebGraphicsLayer::setContentsOpaque):
(WebCore::WebGraphicsLayer::setContentsScale):
(WebCore::WebGraphicsLayer::createBackingStore):
(WebCore):
(WebCore::WebGraphicsLayer::updateContentBuffers):
* WebProcess/WebCoreSupport/WebGraphicsLayer.h:
(WebGraphicsLayer):
* WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
(WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/TiledBackingStore.cpp
Source/WebCore/platform/graphics/TiledBackingStore.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp

index 0bb3f6a..75cebab 100644 (file)
@@ -1,3 +1,24 @@
+2012-02-16  No'am Rosenthal  <noam.rosenthal@nokia.com>
+
+        [Qt][WK2] Allow opaque tiles
+        https://bugs.webkit.org/show_bug.cgi?id=78809
+
+        Add a supportsAlpha property to TiledBackingStore.
+        We invalidate all the tiles if that property changes, because the buffers need to be
+        recreated in a different format.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        No behavior changes.
+
+        * platform/graphics/TiledBackingStore.cpp:
+        (WebCore::TiledBackingStore::TiledBackingStore):
+        (WebCore::TiledBackingStore::setSupportsAlpha):
+        (WebCore):
+        * platform/graphics/TiledBackingStore.h:
+        (TiledBackingStore):
+        (WebCore::TiledBackingStore::supportsAlpha):
+
 2012-02-16  Sergio Villar Senin  <svillar@igalia.com>
 
         [soup] Move important SoupSession feature initialization to WebCore
index 755a865..3b4b29c 100644 (file)
@@ -46,6 +46,7 @@ TiledBackingStore::TiledBackingStore(TiledBackingStoreClient* client, PassOwnPtr
     , m_contentsScale(1.f)
     , m_pendingScale(0)
     , m_contentsFrozen(false)
+    , m_supportsAlpha(false)
 {
 }
 
@@ -507,6 +508,14 @@ void TiledBackingStore::setContentsFrozen(bool freeze)
     }
 }
 
+void TiledBackingStore::setSupportsAlpha(bool a)
+{
+    if (a == supportsAlpha())
+        return;
+    m_supportsAlpha = a;
+    invalidate(contentsRect());
+}
+
 }
 
 #endif
index d55b4eb..f2e2a80 100644 (file)
@@ -73,6 +73,9 @@ public:
     double tileDistance(const IntRect& viewport, const Tile::Coordinate&) const;
     float coverageRatio(const WebCore::IntRect& contentsRect);
 
+    void setSupportsAlpha(bool);
+    bool supportsAlpha() const { return m_supportsAlpha; }
+
 private:
     void startTileBufferUpdateTimer();
     void startTileCreationTimer();
@@ -120,6 +123,7 @@ private:
     float m_pendingScale;
 
     bool m_contentsFrozen;
+    bool m_supportsAlpha;
 
     friend class Tile;
 };
index a11ceb1..c0bbccb 100644 (file)
@@ -1,3 +1,27 @@
+2012-02-16  No'am Rosenthal  <noam.rosenthal@nokia.com>
+
+        [Qt][WK2] Allow opaque tiles
+        https://bugs.webkit.org/show_bug.cgi?id=78809
+
+        Set the supportsAlpha flag for TiledBackingStore when the layer has contentsOpaque enabled.
+        Use the flag for ShareableBitmaps created by TiledBackingStore.
+
+        For now this will not have impact on performance/memory, because we allocate the same type
+        of buffers for opaque and transparent tiles.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+        (WebCore::WebGraphicsLayer::setContentsOpaque):
+        (WebCore::WebGraphicsLayer::setContentsScale):
+        (WebCore::WebGraphicsLayer::createBackingStore):
+        (WebCore):
+        (WebCore::WebGraphicsLayer::updateContentBuffers):
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
+        (WebGraphicsLayer):
+        * WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
+        (WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):
+
 2012-02-16  Sergio Villar Senin  <svillar@igalia.com>
 
         [soup] Move important SoupSession feature initialization to WebCore
index 5e97fd5..26ad739 100644 (file)
@@ -251,6 +251,8 @@ void WebGraphicsLayer::setContentsOpaque(bool b)
 {
     if (contentsOpaque() == b)
         return;
+    if (m_mainBackingStore)
+        m_mainBackingStore->setSupportsAlpha(!b);
     GraphicsLayer::setContentsOpaque(b);
     notifyChange();
 }
@@ -488,11 +490,17 @@ void WebGraphicsLayer::setContentsScale(float scale)
     m_contentsScale = scale;
     if (m_mainBackingStore && m_mainBackingStore->contentsScale() != scale) {
         m_previousBackingStore = m_mainBackingStore.release();
-        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
-        m_mainBackingStore->setContentsScale(scale);
+        createBackingStore();
     }
 }
 
+void WebGraphicsLayer::createBackingStore()
+{
+    m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
+    m_mainBackingStore->setSupportsAlpha(!contentsOpaque());
+    m_mainBackingStore->setContentsScale(m_contentsScale);
+}
+
 void WebGraphicsLayer::tiledBackingStorePaint(GraphicsContext* context, const IntRect& rect)
 {
     if (rect.isEmpty())
@@ -576,10 +584,8 @@ void WebGraphicsLayer::updateContentBuffers()
     m_inUpdateMode = true;
     // This is the only place we (re)create the main tiled backing store,
     // once we have a remote client and we are ready to send our data to the UI process.
-    if (!m_mainBackingStore) {
-        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
-        m_mainBackingStore->setContentsScale(m_contentsScale);
-    }
+    if (!m_mainBackingStore)
+        createBackingStore();
     m_mainBackingStore->updateTileBuffers();
     m_inUpdateMode = false;
 }
index a6cc439..4096d37 100644 (file)
@@ -158,6 +158,7 @@ private:
 
     void notifyChange();
     void notifyChangeRecursively();
+    void createBackingStore();
     HashSet<String> m_transformAnimations;
 
     bool selfOrAncestorHasActiveTransformAnimations() const;
index 7cea0b4..93afe99 100644 (file)
@@ -84,7 +84,7 @@ Vector<IntRect> TiledBackingStoreRemoteTile::updateBackBuffer()
     // 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(), ShareableBitmap::SupportsAlpha);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_rect.size(), m_tiledBackingStore->supportsAlpha() ? ShareableBitmap::SupportsAlpha : 0);
     OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext());
     graphicsContext->drawImageBuffer(m_localBuffer.get(), ColorSpaceDeviceRGB, IntPoint(0, 0));