- Revision
- 120016
- Author
- [email protected]
- Date
- 2012-06-11 16:12:28 -0700 (Mon, 11 Jun 2012)
Log Message
[chromium] Use WebGraphicsContext3D in rate limiting logic inside compositor
https://bugs.webkit.org/show_bug.cgi?id=86259
Reviewed by Adrienne Walker.
This refactors the compositor's rate limiting implementation to use the Platform API's WebGraphicsContext3D
directly instead of WebCore::GraphicsContext3D to cut down on the number of spurious WebCore dependencies in the
compositor. The one change in contract is that the caller to CCLayerTreeHost::startRateLimit() now has to call
CCLayerTreeHost::stopRateLimit() before allowing the referenced context to go away since CCLayerTreeHost no
longer retains a reference, but this was always happening already.
* platform/graphics/chromium/Canvas2DLayerChromium.cpp:
(WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium):
(WebCore::Canvas2DLayerChromium::setNeedsDisplayRect):
* platform/graphics/chromium/RateLimiter.cpp:
(WebCore::RateLimiter::create):
(WebCore::RateLimiter::RateLimiter):
(WebCore::RateLimiter::start):
(WebCore::RateLimiter::rateLimitContext):
* platform/graphics/chromium/RateLimiter.h:
(WebKit):
(RateLimiter):
* platform/graphics/chromium/TextureLayerChromium.cpp:
(WebCore::TextureLayerChromium::~TextureLayerChromium):
(WebCore::TextureLayerChromium::setRateLimitContext):
(WebCore::TextureLayerChromium::setNeedsDisplayRect):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::startRateLimiter):
(WebCore::CCLayerTreeHost::stopRateLimiter):
(WebCore::CCLayerTreeHost::rateLimit):
(WebCore):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (120015 => 120016)
--- trunk/Source/WebCore/ChangeLog 2012-06-11 22:58:16 UTC (rev 120015)
+++ trunk/Source/WebCore/ChangeLog 2012-06-11 23:12:28 UTC (rev 120016)
@@ -1,3 +1,39 @@
+2012-06-11 James Robinson <[email protected]>
+
+ [chromium] Use WebGraphicsContext3D in rate limiting logic inside compositor
+ https://bugs.webkit.org/show_bug.cgi?id=86259
+
+ Reviewed by Adrienne Walker.
+
+ This refactors the compositor's rate limiting implementation to use the Platform API's WebGraphicsContext3D
+ directly instead of WebCore::GraphicsContext3D to cut down on the number of spurious WebCore dependencies in the
+ compositor. The one change in contract is that the caller to CCLayerTreeHost::startRateLimit() now has to call
+ CCLayerTreeHost::stopRateLimit() before allowing the referenced context to go away since CCLayerTreeHost no
+ longer retains a reference, but this was always happening already.
+
+ * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
+ (WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium):
+ (WebCore::Canvas2DLayerChromium::setNeedsDisplayRect):
+ * platform/graphics/chromium/RateLimiter.cpp:
+ (WebCore::RateLimiter::create):
+ (WebCore::RateLimiter::RateLimiter):
+ (WebCore::RateLimiter::start):
+ (WebCore::RateLimiter::rateLimitContext):
+ * platform/graphics/chromium/RateLimiter.h:
+ (WebKit):
+ (RateLimiter):
+ * platform/graphics/chromium/TextureLayerChromium.cpp:
+ (WebCore::TextureLayerChromium::~TextureLayerChromium):
+ (WebCore::TextureLayerChromium::setRateLimitContext):
+ (WebCore::TextureLayerChromium::setNeedsDisplayRect):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::startRateLimiter):
+ (WebCore::CCLayerTreeHost::stopRateLimiter):
+ (WebCore::CCLayerTreeHost::rateLimit):
+ (WebCore):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+ (CCLayerTreeHost):
+
2012-06-11 Dana Jansens <[email protected]>
[chromium] Separate CCVideoDrawQuad and from the layer tree and video provider by removing ManagedTexture and WebVideoFrame pointers from the quad
Modified: trunk/Source/WebCore/platform/graphics/chromium/RateLimiter.cpp (120015 => 120016)
--- trunk/Source/WebCore/platform/graphics/chromium/RateLimiter.cpp 2012-06-11 22:58:16 UTC (rev 120015)
+++ trunk/Source/WebCore/platform/graphics/chromium/RateLimiter.cpp 2012-06-11 23:12:28 UTC (rev 120016)
@@ -28,26 +28,22 @@
#if USE(ACCELERATED_COMPOSITING)
#include "RateLimiter.h"
-
-#include "Extensions3DChromium.h"
-#include "GraphicsContext3D.h"
#include "TraceEvent.h"
+#include <public/WebGraphicsContext3D.h>
namespace WebCore {
-PassRefPtr<RateLimiter> RateLimiter::create(GraphicsContext3D* context, RateLimiterClient *client)
+PassRefPtr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* context, RateLimiterClient *client)
{
return adoptRef(new RateLimiter(context, client));
}
-RateLimiter::RateLimiter(GraphicsContext3D* context, RateLimiterClient *client)
+RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClient *client)
: m_context(context)
, m_timer(this, &RateLimiter::rateLimitContext)
, m_client(client)
{
ASSERT(context);
- ASSERT(context->getExtensions());
- m_contextSupportsRateLimitingExtension = context->getExtensions()->supports("GL_CHROMIUM_rate_limit_offscreen_context");
}
RateLimiter::~RateLimiter()
@@ -56,7 +52,7 @@
void RateLimiter::start()
{
- if (m_contextSupportsRateLimitingExtension && !m_timer.isActive())
+ if (!m_timer.isActive())
m_timer.startOneShot(0);
}
@@ -67,12 +63,10 @@
void RateLimiter::rateLimitContext(Timer<RateLimiter>*)
{
- TRACE_EVENT("RateLimiter::rateLimitContext", this, 0);
+ TRACE_EVENT0("cc", "RateLimiter::rateLimitContext");
- Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-
m_client->rateLimit();
- extensions->rateLimitOffscreenContextCHROMIUM();
+ m_context->rateLimitOffscreenContextCHROMIUM();
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/RateLimiter.h (120015 => 120016)
--- trunk/Source/WebCore/platform/graphics/chromium/RateLimiter.h 2012-06-11 22:58:16 UTC (rev 120015)
+++ trunk/Source/WebCore/platform/graphics/chromium/RateLimiter.h 2012-06-11 23:12:28 UTC (rev 120016)
@@ -32,10 +32,12 @@
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+namespace WebKit {
+class WebGraphicsContext3D;
+}
+
namespace WebCore {
-class GraphicsContext3D;
-
class RateLimiterClient {
public:
virtual void rateLimit() = 0;
@@ -44,16 +46,16 @@
// A class containing a timer, which calls rateLimitCHROMIUM on expiry
class RateLimiter : public RefCounted<RateLimiter> {
public:
- static PassRefPtr<RateLimiter> create(GraphicsContext3D*, RateLimiterClient*);
+ static PassRefPtr<RateLimiter> create(WebKit::WebGraphicsContext3D*, RateLimiterClient*);
~RateLimiter();
void start();
void stop();
private:
- RateLimiter(GraphicsContext3D*, RateLimiterClient*);
- RefPtr<GraphicsContext3D> m_context;
- bool m_contextSupportsRateLimitingExtension;
+ RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*);
+
+ WebKit::WebGraphicsContext3D* m_context;
Timer<RateLimiter> m_timer;
void rateLimitContext(Timer<RateLimiter>*);
RateLimiterClient *m_client;
Modified: trunk/Source/WebCore/platform/graphics/chromium/TextureLayerChromium.cpp (120015 => 120016)
--- trunk/Source/WebCore/platform/graphics/chromium/TextureLayerChromium.cpp 2012-06-11 22:58:16 UTC (rev 120015)
+++ trunk/Source/WebCore/platform/graphics/chromium/TextureLayerChromium.cpp 2012-06-11 23:12:28 UTC (rev 120016)
@@ -30,6 +30,7 @@
#include "TextureLayerChromium.h"
#include "Extensions3D.h"
+#include "GraphicsContext3DPrivate.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCTextureLayerImpl.h"
@@ -58,7 +59,7 @@
if (m_textureId)
layerTreeHost()->acquireLayerTextures();
if (m_rateLimitContext && m_client)
- layerTreeHost()->stopRateLimiter(m_client->context());
+ layerTreeHost()->stopRateLimiter(GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_client->context()));
}
}
@@ -88,7 +89,7 @@
void TextureLayerChromium::setRateLimitContext(bool rateLimit)
{
if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost())
- layerTreeHost()->stopRateLimiter(m_client->context());
+ layerTreeHost()->stopRateLimiter(GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_client->context()));
m_rateLimitContext = rateLimit;
}
@@ -114,7 +115,7 @@
LayerChromium::setNeedsDisplayRect(dirtyRect);
if (m_rateLimitContext && m_client && layerTreeHost())
- layerTreeHost()->startRateLimiter(m_client->context());
+ layerTreeHost()->startRateLimiter(GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_client->context()));
}
void TextureLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (120015 => 120016)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-06-11 22:58:16 UTC (rev 120015)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-06-11 23:12:28 UTC (rev 120016)
@@ -633,10 +633,11 @@
m_client->applyScrollAndScale(scrollDelta, info.pageScaleDelta);
}
-void CCLayerTreeHost::startRateLimiter(GraphicsContext3D* context)
+void CCLayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context)
{
if (m_animating)
return;
+
ASSERT(context);
RateLimiterMap::iterator it = m_rateLimiters.find(context);
if (it != m_rateLimiters.end())
@@ -648,15 +649,8 @@
}
}
-void CCLayerTreeHost::rateLimit()
+void CCLayerTreeHost::stopRateLimiter(WebKit::WebGraphicsContext3D* context)
{
- // Force a no-op command on the compositor context, so that any ratelimiting commands will wait for the compositing
- // context, and therefore for the SwapBuffers.
- m_proxy->forceSerializeOnSwapBuffers();
-}
-
-void CCLayerTreeHost::stopRateLimiter(GraphicsContext3D* context)
-{
RateLimiterMap::iterator it = m_rateLimiters.find(context);
if (it != m_rateLimiters.end()) {
it->second->stop();
@@ -664,6 +658,13 @@
}
}
+void CCLayerTreeHost::rateLimit()
+{
+ // Force a no-op command on the compositor context, so that any ratelimiting commands will wait for the compositing
+ // context, and therefore for the SwapBuffers.
+ m_proxy->forceSerializeOnSwapBuffers();
+}
+
bool CCLayerTreeHost::bufferedUpdates()
{
return m_settings.maxPartialTextureUpdates != numeric_limits<size_t>::max();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (120015 => 120016)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-06-11 22:58:16 UTC (rev 120015)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-06-11 23:12:28 UTC (rev 120016)
@@ -242,9 +242,10 @@
void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec);
void applyScrollAndScale(const CCScrollAndScaleSet&);
- void startRateLimiter(GraphicsContext3D*);
- void stopRateLimiter(GraphicsContext3D*);
+ void startRateLimiter(WebKit::WebGraphicsContext3D*);
+ void stopRateLimiter(WebKit::WebGraphicsContext3D*);
+
// RateLimitClient implementation
virtual void rateLimit() OVERRIDE;
@@ -304,7 +305,7 @@
size_t m_memoryAllocationBytes;
bool m_memoryAllocationIsForDisplay;
- typedef HashMap<GraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap;
+ typedef HashMap<WebKit::WebGraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap;
RateLimiterMap m_rateLimiters;
float m_pageScaleFactor;