Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (118703 => 118704)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-05-28 19:37:04 UTC (rev 118703)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-05-28 19:57:26 UTC (rev 118704)
@@ -556,6 +556,14 @@
#if ENABLE(WEB_TIMING)
m_page->settings()->setMemoryInfoEnabled(true);
#endif
+
+#if USE(ACCELERATED_COMPOSITING)
+ // The compositor will be needed for overlay rendering, so create it
+ // unconditionally. It will allocate OpenGL objects lazily, so this incurs
+ // no overhead in the unlikely case where the compositor is not needed.
+ Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
+ createMethodCallMessage(&WebPagePrivate::createCompositor, this));
+#endif
}
class DeferredTaskLoadManualScript: public DeferredTask<&WebPagePrivate::m_wouldLoadManualScript> {
@@ -5887,11 +5895,6 @@
m_compositor = WebPageCompositorPrivate::create(this, 0);
m_compositor->setContext(m_ownedContext.get());
- if (!m_compositor->hardwareCompositing()) {
- destroyCompositor();
- return false;
- }
-
return true;
}
Modified: trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp (118703 => 118704)
--- trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp 2012-05-28 19:37:04 UTC (rev 118703)
+++ trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp 2012-05-28 19:57:26 UTC (rev 118704)
@@ -60,19 +60,10 @@
return;
m_context = context;
- if (!m_context) {
+ if (!m_context)
m_layerRenderer.clear();
- return;
- }
-
- m_layerRenderer = LayerRenderer::create(m_context);
}
-bool WebPageCompositorPrivate::hardwareCompositing() const
-{
- return m_layerRenderer && m_layerRenderer->hardwareCompositing();
-}
-
void WebPageCompositorPrivate::setRootLayer(LayerCompositingThread* rootLayer)
{
m_rootLayer = rootLayer;
@@ -85,9 +76,24 @@
void WebPageCompositorPrivate::prepareFrame(double animationTime)
{
- if (!m_layerRenderer)
+ if (!m_context)
return;
+ // The LayerRenderer is involved in rendering the BackingStore when
+ // WebPageCompositor is used to render the web page. The presence of a
+ // WebPageCompositorClient (m_client) indicates this is the case, so
+ // create a LayerRenderer if there are layers or if there's a client.
+ if (!m_rootLayer && !m_overlayLayer && !m_client)
+ return;
+
+ if (!m_layerRenderer) {
+ m_layerRenderer = LayerRenderer::create(m_context);
+ if (!m_layerRenderer->hardwareCompositing()) {
+ m_layerRenderer.clear();
+ return;
+ }
+ }
+
// Unfortunately, we have to use currentTime() because the animations are
// started in that time coordinate system.
animationTime = currentTime();
@@ -99,19 +105,16 @@
void WebPageCompositorPrivate::render(const IntRect& targetRect, const IntRect& clipRect, const TransformationMatrix& transformIn, const FloatRect& transformedContents, const FloatRect& /*viewport*/)
{
- if (!m_layerRenderer) {
- // It's not safe to call into the BackingStore if the compositor hasn't been set yet.
- // For thread safety, we have to do it using a round-trip to the WebKit thread, so the
- // embedder might call this before the round-trip to WebPagePrivate::setCompositor() is
- // done.
- if (m_webPage->compositor() != this)
- return;
+ // m_layerRenderer should have been created in prepareFrame
+ if (!m_layerRenderer)
+ return;
- // The clip rect is in OpenGL coordinate system, so turn it upside down to get to window coordinates.
- IntRect dstRect(clipRect.x(), m_context->surfaceSize().height() - clipRect.y() - clipRect.height(), clipRect.width(), clipRect.height());
- m_webPage->m_backingStore->d->blitContents(dstRect, enclosingIntRect(transformedContents), true);
+ // It's not safe to call into the BackingStore if the compositor hasn't been set yet.
+ // For thread safety, we have to do it using a round-trip to the WebKit thread, so the
+ // embedder might call this before the round-trip to WebPagePrivate::setCompositor() is
+ // done.
+ if (m_webPage->compositor() != this)
return;
- }
m_layerRenderer->setClearSurfaceOnDrawLayers(false);
@@ -145,6 +148,12 @@
bool WebPageCompositorPrivate::drawLayers(const IntRect& dstRect, const FloatRect& contents)
{
+ // Is there anything to draw?
+ if (!m_rootLayer && !m_overlayLayer)
+ return false;
+
+ // prepareFrame creates the LayerRenderer if needed
+ prepareFrame(currentTime());
if (!m_layerRenderer)
return false;
@@ -157,7 +166,6 @@
// WebKit uses upper left as the origin of the window coordinate system. The passed in 'dstRect'
// is in WebKit window coordinate system. Here we setup the viewport to the corresponding value
// in OpenGL window coordinates.
- m_layerRenderer->prepareFrame(currentTime(), m_rootLayer.get());
int viewportY = std::max(0, m_context->surfaceSize().height() - dstRect.maxY());
IntRect viewport = IntRect(dstRect.x(), viewportY, dstRect.width(), dstRect.height());
Modified: trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h (118703 => 118704)
--- trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h 2012-05-28 19:37:04 UTC (rev 118703)
+++ trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h 2012-05-28 19:57:26 UTC (rev 118704)
@@ -58,9 +58,6 @@
const WebCore::FloatRect& contents, // This is public API, thus takes transformed contents
const WebCore::FloatRect& viewport);
- // Internal
- bool hardwareCompositing() const;
-
Platform::Graphics::GLES2Context* context() const { return m_context; }
void setContext(Platform::Graphics::GLES2Context*);
Modified: trunk/Source/WebKit/blackberry/ChangeLog (118703 => 118704)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-05-28 19:37:04 UTC (rev 118703)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-05-28 19:57:26 UTC (rev 118704)
@@ -1,5 +1,33 @@
2012-05-28 Arvid Nilsson <anils...@rim.com>
+ [BlackBerry] Always create a compositor
+ https://bugs.webkit.org/show_bug.cgi?id=87598
+
+ Reviewed by Rob Buis.
+
+ There will likely be compositing layers either due to web content or
+ due to overlays.
+
+ Defer initialization of OpenGL objects (i.e., delay creation of the
+ LayerRenderer object) until we actually need to draw and there are such
+ layers, to avoid initializing OpenGL in the unlikely case that there
+ are no compositing layers or overlay layers.
+
+ PR #156811
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::init):
+ (BlackBerry::WebKit::WebPagePrivate::createCompositor):
+ * Api/WebPageCompositor.cpp:
+ (BlackBerry::WebKit::WebPageCompositorPrivate::setContext):
+ (BlackBerry::WebKit::WebPageCompositorPrivate::prepareFrame):
+ (BlackBerry::WebKit::WebPageCompositorPrivate::render):
+ (BlackBerry::WebKit::WebPageCompositorPrivate::drawLayers):
+ * Api/WebPageCompositor_p.h:
+ (WebPageCompositorPrivate):
+
+2012-05-28 Arvid Nilsson <anils...@rim.com>
+
[BlackBerry] Dangling pointer in WebPagePrivate::setCompositor() message
https://bugs.webkit.org/show_bug.cgi?id=87590