Title: [107294] trunk/Source/WebKit
- Revision
- 107294
- Author
- [email protected]
- Date
- 2012-02-09 14:46:57 -0800 (Thu, 09 Feb 2012)
Log Message
[BlackBerry] Upstream BlackBerry WebKitSupport WebPageCompositor class
https://bugs.webkit.org/show_bug.cgi?id=78276
Reviewed by Antonio Gomes.
Initial upstream, no new tests.
* blackberry/WebKitSupport/WebPageCompositor.cpp: Added.
* blackberry/WebKitSupport/WebPageCompositor.h: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (107293 => 107294)
--- trunk/Source/WebKit/ChangeLog 2012-02-09 22:33:16 UTC (rev 107293)
+++ trunk/Source/WebKit/ChangeLog 2012-02-09 22:46:57 UTC (rev 107294)
@@ -1,3 +1,15 @@
+2012-02-09 Rob Buis <[email protected]>
+
+ [BlackBerry] Upstream BlackBerry WebKitSupport WebPageCompositor class
+ https://bugs.webkit.org/show_bug.cgi?id=78276
+
+ Reviewed by Antonio Gomes.
+
+ Initial upstream, no new tests.
+
+ * blackberry/WebKitSupport/WebPageCompositor.cpp: Added.
+ * blackberry/WebKitSupport/WebPageCompositor.h: Added.
+
2012-02-08 Jacky Jiang <[email protected]>
[BlackBerry] Upstream BlackBerry WebCoreSupport FrameNetworkingContextBlackBerry and IconDatabaseClientBlackBerry classes
Added: trunk/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp (0 => 107294)
--- trunk/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp 2012-02-09 22:46:57 UTC (rev 107294)
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2010, 2011, 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
+ */
+
+#include "config.h"
+#include "WebPageCompositor.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "LayerWebKitThread.h"
+#include "WebPage_p.h"
+
+#include <GenericTimerClient.h>
+#include <ThreadTimerClient.h>
+
+using namespace WebCore;
+
+namespace BlackBerry {
+namespace WebKit {
+
+WebPageCompositor::WebPageCompositor(WebPagePrivate* page)
+ : m_webPage(page)
+ , m_layerRenderer(LayerRenderer::create(page->m_page))
+ , m_generation(0)
+ , m_compositedGeneration(-1)
+ , m_compositingOntoMainWindow(false)
+ , m_blitTimer(this, &BlackBerry::WebKit::WebPageCompositor::blitTimerFired)
+ , m_timerClient(new BlackBerry::Platform::GenericTimerClient(BlackBerry::Platform::userInterfaceThreadTimerClient()))
+{
+ m_blitTimer.setClient(m_timerClient);
+}
+
+WebPageCompositor::~WebPageCompositor()
+{
+ m_blitTimer.stop();
+ delete m_timerClient;
+}
+
+bool WebPageCompositor::hardwareCompositing() const
+{
+ return m_layerRenderer->hardwareCompositing();
+}
+
+void WebPageCompositor::setRootLayer(LayerCompositingThread* rootLayer)
+{
+ m_rootLayer = rootLayer;
+ m_layerRenderer->setRootLayer(m_rootLayer.get());
+}
+
+void WebPageCompositor::setCompositingOntoMainWindow(bool compositingOntoMainWindow)
+{
+ m_compositingOntoMainWindow = compositingOntoMainWindow;
+ m_layerRenderer->setClearSurfaceOnDrawLayers(!compositingOntoMainWindow);
+}
+
+void WebPageCompositor::commit(LayerWebKitThread* rootLayer)
+{
+ if (!rootLayer)
+ return;
+
+ rootLayer->commitOnCompositingThread();
+ ++m_generation;
+}
+
+bool WebPageCompositor::drawLayers(const IntRect& dstRect, const FloatRect& contents)
+{
+ // Save a draw if we already drew this generation, for example due to a concurrent scroll operation.
+ if (m_compositedGeneration == m_generation && dstRect == m_compositedDstRect
+ && contents == m_compositedContentsRect && !m_compositingOntoMainWindow)
+ return false;
+
+ m_layerRenderer->drawLayers(contents, m_layoutRectForCompositing, m_contentsSizeForCompositing, dstRect);
+ m_lastCompositingResults = m_layerRenderer->lastRenderingResults();
+
+ m_compositedDstRect = dstRect;
+ m_compositedContentsRect = contents;
+ m_compositedGeneration = m_generation;
+
+ if (m_lastCompositingResults.needsAnimationFrame) {
+ ++m_generation; // The animation update moves us along one generation
+ // Using a timeout of 0 actually won't start a timer, it will send a message
+ m_blitTimer.start(1.0 / 60.0);
+ m_webPage->updateDelegatedOverlays();
+ }
+
+ return true;
+}
+
+void WebPageCompositor::releaseLayerResources()
+{
+ m_layerRenderer->releaseLayerResources();
+}
+
+void WebPageCompositor::blitTimerFired()
+{
+ m_webPage->blitVisibleContents();
+}
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // USE(ACCELERATED_COMPOSITING)
Added: trunk/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h (0 => 107294)
--- trunk/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h 2012-02-09 22:46:57 UTC (rev 107294)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010, 2011, 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 WebPageCompositor_h
+#define WebPageCompositor_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerCompositingThread.h"
+#include "LayerRenderer.h"
+
+#include <BlackBerryPlatformTimer.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class LayerWebKitThread;
+};
+
+namespace BlackBerry {
+namespace WebKit {
+
+class WebPagePrivate;
+
+// This class may only be used on the compositing thread
+class WebPageCompositor {
+public:
+ WebPageCompositor(WebPagePrivate*);
+ ~WebPageCompositor();
+
+ bool hardwareCompositing() const;
+
+ void setRootLayer(WebCore::LayerCompositingThread*);
+
+ void setCompositingOntoMainWindow(bool);
+
+ void commit(WebCore::LayerWebKitThread* rootLayerProxy);
+
+ bool drawLayers(const WebCore::IntRect& dstRect, const WebCore::FloatRect& contents);
+
+ WebCore::IntRect layoutRectForCompositing() const { return m_layoutRectForCompositing; }
+ void setLayoutRectForCompositing(const WebCore::IntRect& rect) { m_layoutRectForCompositing = rect; }
+
+ WebCore::IntSize contentsSizeForCompositing() const { return m_contentsSizeForCompositing; }
+ void setContentsSizeForCompositing(const WebCore::IntSize& size) { m_contentsSizeForCompositing = size; }
+
+ WebCore::LayerRenderingResults lastCompositingResults() const { return m_lastCompositingResults; }
+ void setLastCompositingResults(const WebCore::LayerRenderingResults& results) { m_lastCompositingResults = results; }
+
+ void releaseLayerResources();
+
+private:
+ void blitTimerFired();
+
+ WebPagePrivate* m_webPage;
+ OwnPtr<WebCore::LayerRenderer> m_layerRenderer;
+ RefPtr<WebCore::LayerCompositingThread> m_rootLayer;
+ WebCore::IntRect m_layoutRectForCompositing;
+ WebCore::IntSize m_contentsSizeForCompositing;
+ WebCore::LayerRenderingResults m_lastCompositingResults;
+ int m_generation;
+ int m_compositedGeneration;
+ WebCore::IntRect m_compositedDstRect;
+ WebCore::FloatRect m_compositedContentsRect;
+ bool m_compositingOntoMainWindow;
+ BlackBerry::Platform::Timer<WebPageCompositor> m_blitTimer;
+ BlackBerry::Platform::TimerClient* m_timerClient;
+};
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // WebPageCompositor_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes