Diff
Modified: trunk/Source/WebCore/ChangeLog (118705 => 118706)
--- trunk/Source/WebCore/ChangeLog 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/ChangeLog 2012-05-28 21:20:33 UTC (rev 118706)
@@ -1,3 +1,63 @@
+2012-05-28 Arvid Nilsson <anils...@rim.com>
+
+ [BlackBerry] Make custom compositing thread layers more flexible
+ https://bugs.webkit.org/show_bug.cgi?id=87600
+
+ Reviewed by Rob Buis.
+
+ Introduce a LayerCompositingThreadClient that's used to fine tune the
+ behaviour of custom layers. Let the LayerTiler be a
+ LayerCompositingThreadClient and thus decouple it from
+ LayerCompositingThread. Adjust method signatures to allow a one-to-many
+ relationship between Client and Layer.
+
+ Remove the old LayerCompositingThread::drawCustom() in favour of this new
+ Client interface.
+
+ PR #156812
+
+ * platform/graphics/blackberry/LayerCompositingThread.cpp:
+ (WebCore::LayerCompositingThread::create):
+ (WebCore::LayerCompositingThread::LayerCompositingThread):
+ (WebCore::LayerCompositingThread::~LayerCompositingThread):
+ (WebCore::LayerCompositingThread::deleteTextures):
+ (WebCore::LayerCompositingThread::drawTextures):
+ (WebCore::LayerCompositingThread::hasMissingTextures):
+ (WebCore::LayerCompositingThread::drawMissingTextures):
+ (WebCore::LayerCompositingThread::updateTextureContentsIfNeeded):
+ (WebCore::LayerCompositingThread::bindContentsTexture):
+ (WebCore::LayerCompositingThread::setVisible):
+ (WebCore::LayerCompositingThread::scheduleCommit):
+ * platform/graphics/blackberry/LayerCompositingThread.h:
+ (WebCore):
+ (LayerCompositingThread):
+ * platform/graphics/blackberry/LayerCompositingThreadClient.h: Added.
+ (WebCore):
+ (LayerCompositingThreadClient):
+ (WebCore::LayerCompositingThreadClient::~LayerCompositingThreadClient):
+ (WebCore::LayerCompositingThreadClient::bindContentsTexture):
+ (WebCore::LayerCompositingThreadClient::hasMissingTextures):
+ (WebCore::LayerCompositingThreadClient::drawMissingTextures):
+ (WebCore::LayerCompositingThreadClient::scheduleCommit):
+ * platform/graphics/blackberry/LayerRenderer.cpp:
+ (WebCore::LayerRenderer::drawDebugBorder):
+ * platform/graphics/blackberry/LayerTiler.cpp:
+ (WebCore::LayerTiler::LayerTiler):
+ (WebCore::LayerTiler::layerCompositingThreadDestroyed):
+ (WebCore::LayerTiler::layerVisibilityChanged):
+ (WebCore::LayerTiler::uploadTexturesIfNeeded):
+ (WebCore::LayerTiler::deleteTextures):
+ (WebCore::LayerTiler::scheduleCommit):
+ (WebCore):
+ (WebCore::LayerTiler::bindContentsTexture):
+ * platform/graphics/blackberry/LayerTiler.h:
+ (LayerTiler):
+ (WebCore::LayerTiler::hasMissingTextures):
+ * platform/graphics/blackberry/LayerWebKitThread.cpp:
+ (WebCore::LayerWebKitThread::LayerWebKitThread):
+ * platform/graphics/blackberry/LayerWebKitThread.h:
+ (LayerWebKitThread):
+
2012-05-25 Jesus Sanchez-Palencia <jesus.palen...@openbossa.org>
WebKitTestRunner needs to support layoutTestController.setJavaScriptProfilingEnabled
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp 2012-05-28 21:20:33 UTC (rev 118706)
@@ -36,6 +36,7 @@
#include "LayerCompositingThread.h"
+#include "LayerCompositingThreadClient.h"
#include "LayerMessage.h"
#include "LayerRenderer.h"
#include "LayerWebKitThread.h"
@@ -54,12 +55,12 @@
namespace WebCore {
-PassRefPtr<LayerCompositingThread> LayerCompositingThread::create(LayerType type, PassRefPtr<LayerTiler> tiler)
+PassRefPtr<LayerCompositingThread> LayerCompositingThread::create(LayerType type, LayerCompositingThreadClient* client)
{
- return adoptRef(new LayerCompositingThread(type, tiler));
+ return adoptRef(new LayerCompositingThread(type, client));
}
-LayerCompositingThread::LayerCompositingThread(LayerType type, PassRefPtr<LayerTiler> tiler)
+LayerCompositingThread::LayerCompositingThread(LayerType type, LayerCompositingThreadClient* client)
: LayerData(type)
, m_layerRenderer(0)
, m_superlayer(0)
@@ -67,7 +68,7 @@
, m_drawOpacity(0)
, m_visible(false)
, m_commitScheduled(false)
- , m_tiler(tiler)
+ , m_client(client)
{
}
@@ -75,9 +76,6 @@
{
ASSERT(isCompositingThread());
- if (m_tiler)
- m_tiler->layerCompositingThreadDestroyed();
-
ASSERT(!superlayer());
// Remove the superlayer reference from all sublayers.
@@ -91,6 +89,9 @@
// layer renderer to track us anymore
if (m_layerRenderer)
m_layerRenderer->removeLayer(this);
+
+ if (m_client)
+ m_client->layerCompositingThreadDestroyed(this);
}
void LayerCompositingThread::setLayerRenderer(LayerRenderer* renderer)
@@ -107,8 +108,8 @@
{
releaseTextureResources();
- if (m_tiler)
- m_tiler->deleteTextures();
+ if (m_client)
+ m_client->deleteTextures(this);
}
void LayerCompositingThread::setDrawTransform(const TransformationMatrix& matrix)
@@ -258,15 +259,8 @@
return;
}
- if (m_layerType == CustomLayer) {
- // Custom layers don't have a LayerTiler, so they either have to set
- // m_texID or implement drawCustom.
- drawCustom(positionLocation, texCoordLocation);
- return;
- }
-
- if (m_tiler)
- m_tiler->drawTextures(this, positionLocation, texCoordLocation);
+ if (m_client)
+ m_client->drawTextures(this, positionLocation, texCoordLocation);
}
void LayerCompositingThread::drawSurface(const TransformationMatrix& drawTransform, LayerCompositingThread* mask, int positionLocation, int texCoordLocation)
@@ -295,18 +289,15 @@
}
}
-void LayerCompositingThread::drawMissingTextures(int positionLocation, int texCoordLocation, const FloatRect& visibleRect)
+bool LayerCompositingThread::hasMissingTextures() const
{
- if (m_pluginView || m_texID)
- return;
+ return m_client ? m_client->hasMissingTextures(this) : false;
+}
-#if ENABLE(VIDEO)
- if (m_mediaPlayer)
- return;
-#endif
-
- if (m_tiler)
- m_tiler->drawMissingTextures(this, positionLocation, texCoordLocation);
+void LayerCompositingThread::drawMissingTextures(int positionLocation, int texCoordLocation, const FloatRect& /*visibleRect*/)
+{
+ if (m_client)
+ m_client->drawMissingTextures(this, positionLocation, texCoordLocation);
}
void LayerCompositingThread::releaseTextureResources()
@@ -421,16 +412,14 @@
void LayerCompositingThread::updateTextureContentsIfNeeded()
{
- if (m_texID || pluginView())
- return;
+ if (m_client)
+ m_client->uploadTexturesIfNeeded(this);
+}
-#if ENABLE(VIDEO)
- if (mediaPlayer())
- return;
-#endif
-
- if (m_tiler)
- m_tiler->uploadTexturesIfNeeded();
+void LayerCompositingThread::bindContentsTexture()
+{
+ if (m_client)
+ m_client->bindContentsTexture(this);
}
void LayerCompositingThread::setVisible(bool visible)
@@ -440,16 +429,8 @@
m_visible = visible;
- if (m_texID || pluginView())
- return;
-
-#if ENABLE(VIDEO)
- if (mediaPlayer())
- return;
-#endif
-
- if (m_tiler)
- m_tiler->layerVisibilityChanged(visible);
+ if (m_client)
+ m_client->layerVisibilityChanged(this, visible);
}
void LayerCompositingThread::setNeedsCommit()
@@ -460,7 +441,7 @@
void LayerCompositingThread::scheduleCommit()
{
- if (!m_tiler)
+ if (!m_client)
return;
if (!isWebKitThread()) {
@@ -475,9 +456,7 @@
m_commitScheduled = false;
- // FIXME: The only way to get at our LayerWebKitThread is to go through the tiler.
- if (LayerWebKitThread* layer = m_tiler->layer())
- layer->setNeedsCommit();
+ m_client->scheduleCommit();
}
bool LayerCompositingThread::updateAnimations(double currentTime)
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h 2012-05-28 21:20:33 UTC (rev 118706)
@@ -54,11 +54,12 @@
namespace WebCore {
+class LayerCompositingThreadClient;
class LayerRenderer;
class LayerCompositingThread : public ThreadSafeRefCounted<LayerCompositingThread>, public LayerData, public BlackBerry::Platform::GuardedPointerBase {
public:
- static PassRefPtr<LayerCompositingThread> create(LayerType, PassRefPtr<LayerTiler>);
+ static PassRefPtr<LayerCompositingThread> create(LayerType, LayerCompositingThreadClient*);
// Thread safe
void setPluginView(PluginView*);
@@ -72,11 +73,7 @@
// Returns true if we have an animation
bool updateAnimations(double currentTime);
void updateTextureContentsIfNeeded();
- void bindContentsTexture()
- {
- if (m_tiler)
- m_tiler->bindContentsTexture();
- }
+ void bindContentsTexture();
const LayerCompositingThread* rootLayer() const;
void setSublayers(const Vector<RefPtr<LayerCompositingThread> >&);
@@ -110,10 +107,9 @@
void deleteTextures();
void drawTextures(int positionLocation, int texCoordLocation, const FloatRect& visibleRect);
- bool hasMissingTextures() const { return m_tiler ? m_tiler->hasMissingTextures() : false; }
+ bool hasMissingTextures() const;
void drawMissingTextures(int positionLocation, int texCoordLocation, const FloatRect& visibleRect);
void drawSurface(const TransformationMatrix&, LayerCompositingThread* mask, int positionLocation, int texCoordLocation);
- bool isDirty() const { return m_tiler ? m_tiler->hasDirtyTiles() : false; }
void releaseTextureResources();
@@ -147,10 +143,8 @@
protected:
virtual ~LayerCompositingThread();
- virtual void drawCustom(int positionLocation, int texCoordLocation) { }
-
private:
- LayerCompositingThread(LayerType, PassRefPtr<LayerTiler>);
+ LayerCompositingThread(LayerType, LayerCompositingThreadClient*);
void updateTileContents(const IntRect& tile);
@@ -189,9 +183,10 @@
bool m_visible;
bool m_commitScheduled;
- RefPtr<LayerTiler> m_tiler;
Vector<RefPtr<LayerAnimation> > m_runningAnimations;
Vector<RefPtr<LayerAnimation> > m_suspendedAnimations;
+
+ LayerCompositingThreadClient* m_client;
};
} // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h (0 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h 2012-05-28 21:20:33 UTC (rev 118706)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LayerCompositingThreadClient_h
+#define LayerCompositingThreadClient_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+class LayerCompositingThread;
+
+class LayerCompositingThreadClient {
+public:
+ virtual ~LayerCompositingThreadClient() { }
+
+ virtual void layerCompositingThreadDestroyed(LayerCompositingThread*) = 0;
+
+ virtual void layerVisibilityChanged(LayerCompositingThread*, bool visible) = 0;
+
+ virtual void uploadTexturesIfNeeded(LayerCompositingThread*) = 0;
+ virtual void drawTextures(LayerCompositingThread*, int positionLocation, int texCoordLocation, double scale) = 0;
+ virtual void deleteTextures(LayerCompositingThread*) = 0;
+
+ // Optional. Allows layers to serve as a mask for other layers
+ virtual void bindContentsTexture(LayerCompositingThread*) { }
+
+ // Optional. Allows layers to have uncached regions, typically drawn as checkerboard
+ virtual bool hasMissingTextures(const LayerCompositingThread*) const { return false; }
+ virtual void drawMissingTextures(LayerCompositingThread*, int positionLocation, int texCoordLocation) { }
+
+ // Unlike the other methods here, this one will be called on the WebKit thread
+ virtual void scheduleCommit() { }
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp 2012-05-28 21:20:33 UTC (rev 118706)
@@ -48,7 +48,6 @@
#define ENABLE_SCISSOR 1
#define DEBUG_SHADER_COMPILATION 0
-#define DEBUG_DIRTY_LAYERS 0 // Show dirty layers as red.
#define DEBUG_LAYER_ANIMATIONS 0 // Show running animations as green.
#define DEBUG_CLIPPING 0
@@ -568,11 +567,6 @@
{
Color borderColor = layer->borderColor();
-#if DEBUG_DIRTY_LAYERS
- if (layer->isDirty())
- borderColor = Color(0xFF, 0x00, 0x00, 0xFF);
-#endif
-
#if DEBUG_LAYER_ANIMATIONS
if (layer->hasRunningAnimations())
borderColor = Color(0x00, 0xFF, 0x00, 0xFF);
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp 2012-05-28 21:20:33 UTC (rev 118706)
@@ -75,6 +75,7 @@
, m_hasMissingTextures(false)
, m_contentsScale(0.0)
{
+ ref(); // This ref() is matched by a deref in layerCompositingThreadDestroyed();
}
LayerTiler::~LayerTiler()
@@ -90,9 +91,10 @@
m_layer = 0;
}
-void LayerTiler::layerCompositingThreadDestroyed()
+void LayerTiler::layerCompositingThreadDestroyed(LayerCompositingThread*)
{
ASSERT(isCompositingThread());
+ deref(); // Matched by ref() in constructor;
}
void LayerTiler::setNeedsDisplay(const FloatRect& dirtyRect)
@@ -349,7 +351,7 @@
m_pendingTextureJobs.clear();
}
-void LayerTiler::layerVisibilityChanged(bool visible)
+void LayerTiler::layerVisibilityChanged(LayerCompositingThread*, bool visible)
{
// For visible layers, we handle the tile-level visibility
// in the draw loop, see LayerTiler::drawTextures().
@@ -369,7 +371,7 @@
}
}
-void LayerTiler::uploadTexturesIfNeeded()
+void LayerTiler::uploadTexturesIfNeeded(LayerCompositingThread*)
{
TileJobsMap tileJobsMap;
Deque<TextureJob>::const_iterator textureJobIterEnd = m_textureJobs.end();
@@ -611,7 +613,7 @@
m_renderJobs.remove(index);
}
-void LayerTiler::deleteTextures()
+void LayerTiler::deleteTextures(LayerCompositingThread*)
{
// Since textures are deleted by a synchronous message
// from WebKit thread to compositing thread, we don't need
@@ -675,6 +677,14 @@
updateTileSize();
}
+void LayerTiler::scheduleCommit()
+{
+ ASSERT(isWebKitThread());
+
+ if (m_layer)
+ m_layer->setNeedsCommit();
+}
+
bool LayerTiler::shouldPrefillTile(const TileIndex& index)
{
// For now, we use the heuristic of prefilling the first screenful of tiles.
@@ -716,19 +726,8 @@
return IntRect(origin, size);
}
-bool LayerTiler::hasDirtyTiles() const
+void LayerTiler::bindContentsTexture(LayerCompositingThread*)
{
- for (TileMap::const_iterator it = m_tilesCompositingThread.begin(); it != m_tilesCompositingThread.end(); ++it) {
- const LayerTile* tile = (*it).second;
- if (tile->isDirty())
- return true;
- }
-
- return false;
-}
-
-void LayerTiler::bindContentsTexture()
-{
ASSERT(m_tilesCompositingThread.size() == 1);
if (m_tilesCompositingThread.size() != 1)
return;
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.h (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.h 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.h 2012-05-28 21:20:33 UTC (rev 118706)
@@ -24,6 +24,7 @@
#include "Color.h"
#include "FloatRect.h"
#include "IntRect.h"
+#include "LayerCompositingThreadClient.h"
#include "LayerTile.h"
#include "LayerTileIndex.h"
@@ -38,7 +39,7 @@
class LayerCompositingThread;
class LayerWebKitThread;
-class LayerTiler : public ThreadSafeRefCounted<LayerTiler> {
+class LayerTiler : public ThreadSafeRefCounted<LayerTiler>, public LayerCompositingThreadClient {
public:
TileIndex indexOfTile(const IntPoint& origin);
IntPoint originOfTile(const TileIndex&);
@@ -58,18 +59,18 @@
void setNeedsDisplay();
void updateTextureContentsIfNeeded(double scale);
void disableTiling(bool);
+ virtual void scheduleCommit();
// Compositing thread
- void layerCompositingThreadDestroyed();
- void uploadTexturesIfNeeded();
- void drawTextures(LayerCompositingThread*, int positionLocation, int texCoordLocation);
- bool hasMissingTextures() const { return m_hasMissingTextures; }
- void drawMissingTextures(LayerCompositingThread*, int positionLocation, int texCoordLocation);
- void deleteTextures();
+ virtual void layerCompositingThreadDestroyed(LayerCompositingThread*);
+ virtual void layerVisibilityChanged(LayerCompositingThread*, bool visible);
+ virtual void uploadTexturesIfNeeded(LayerCompositingThread*);
+ virtual void bindContentsTexture(LayerCompositingThread*);
+ virtual void drawTextures(LayerCompositingThread*, int positionLocation, int texCoordLocation);
+ virtual bool hasMissingTextures(const LayerCompositingThread*) const { return m_hasMissingTextures; }
+ virtual void drawMissingTextures(LayerCompositingThread*, int positionLocation, int texCoordLocation);
+ virtual void deleteTextures(LayerCompositingThread*);
void commitPendingTextureUploads();
- void layerVisibilityChanged(bool visible);
- bool hasDirtyTiles() const;
- void bindContentsTexture();
// Thread safe
void addRenderJob(const TileIndex&);
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp 2012-05-28 21:20:33 UTC (rev 118706)
@@ -67,21 +67,9 @@
{
if (type == Layer)
m_tiler = LayerTiler::create(this);
- m_layerCompositingThread = LayerCompositingThread::create(type, m_tiler);
+ m_layerCompositingThread = LayerCompositingThread::create(type, m_tiler.get());
}
-LayerWebKitThread::LayerWebKitThread(PassRefPtr<LayerCompositingThread> layerCompositingThread, GraphicsLayerBlackBerry* owner)
- : LayerData(CustomLayer)
- , m_owner(owner)
- , m_superlayer(0)
- , m_contents(0)
- , m_scale(1.0)
- , m_isDrawable(false)
- , m_isMask(false)
-{
- m_layerCompositingThread = layerCompositingThread;
-}
-
LayerWebKitThread::~LayerWebKitThread()
{
m_layerCompositingThread->clearAnimations();
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h (118705 => 118706)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h 2012-05-28 20:00:49 UTC (rev 118705)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h 2012-05-28 21:20:33 UTC (rev 118706)
@@ -149,9 +149,6 @@
protected:
LayerWebKitThread(LayerType, GraphicsLayerBlackBerry* owner);
- // Create a custom Layer{WebKitThread, CompositingThread} pair, used when you need to subclass both.
- LayerWebKitThread(PassRefPtr<LayerCompositingThread>, GraphicsLayerBlackBerry* owner);
-
void setNeedsTexture(bool needsTexture) { m_needsTexture = needsTexture; }
void setLayerProgramShader(LayerData::LayerProgramShader shader) { m_layerProgramShader = shader; }
void createFrontBufferLock();