Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1981)

Unified Diff: WebKit/chromium/src/WebViewImpl.cpp

Issue 650002: Implementing ACCELERATED_COMPOSITING via Skia Base URL: http://svn.webkit.org/repository/webkit/trunk/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « WebKit/chromium/src/WebViewImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebKit/chromium/src/WebViewImpl.cpp
===================================================================
--- WebKit/chromium/src/WebViewImpl.cpp (revision 55428)
+++ WebKit/chromium/src/WebViewImpl.cpp (working copy)
@@ -110,6 +110,13 @@
#include "RenderTheme.h"
#endif
+#if USE(ACCELERATED_COMPOSITING)
+#include "webkit/glue/webkit_glue.h"
+#if WEBKIT_USING_SKIA
+#include "skia/LayerSkia.h"
+#endif
+#endif
+
// Get rid of WTF's pow define so we can use std::pow.
#undef pow
#include <cmath> // for std::pow
@@ -245,6 +252,10 @@
, m_suggestionsPopup(0)
, m_isTransparent(false)
, m_tabsToLinks(false)
+#if USE(ACCELERATED_COMPOSITING)
+ , m_layerRenderer(0)
+ , m_isAcceleratedCompositing(false)
+#endif
{
// WebKit/win/WebView.cpp does the same thing, except they call the
// KJS specific wrapper around this method. We need to have threading
@@ -873,9 +884,27 @@
void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
{
- WebFrameImpl* webframe = mainFrameImpl();
- if (webframe)
- webframe->paint(canvas, rect);
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (!isAcceleratedCompositing()) {
+#endif
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe)
+ webframe->paint(canvas, rect);
+#if USE(ACCELERATED_COMPOSITING)
+ } else {
+ // Draw the contents of the root layer
+ updateRootLayerContents(rect);
+
+ // Composite everything into the canvas that's passed to us.
+ m_layerRenderer->updateLayerContents();
+ SkIRect canvasIRect;
+ canvasIRect.set(rect.x, rect.y, rect.x+rect.width, rect.y+rect.height);
+ SkRect canvasRect;
+ canvasRect.set(canvasIRect);
+ m_layerRenderer->drawLayersInCanvas(static_cast<skia::PlatformCanvas*>(canvas), canvasRect);
+ }
+#endif
}
// FIXME: m_currentInputEvent should be removed once ChromeClient::show() can
@@ -1916,4 +1945,83 @@
return m_tabsToLinks;
}
+#if USE(ACCELERATED_COMPOSITING)
+void WebViewImpl::setRootGraphicsLayer(WebCore::PlatformLayer* layer)
+{
+ setAcceleratedCompositing(layer ? true : false);
+ if (m_layerRenderer)
+ m_layerRenderer->setRootLayer(layer);
+}
+
+void WebViewImpl::setAcceleratedCompositing(bool accelerated)
+{
+ if (m_isAcceleratedCompositing == accelerated)
+ return;
+
+ if (accelerated) {
+ m_layerRenderer = LayerRendererSkia::create();
+ if (m_layerRenderer) {
+ m_isAcceleratedCompositing = true;
+ }
+ } else {
+ m_layerRenderer = 0;
+ m_isAcceleratedCompositing = false;
+ }
+}
+
+void WebViewImpl::updateRootLayerContents(const WebRect& rect)
+{
+ if (!isAcceleratedCompositing())
+ return;
+
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe) {
+ FrameView* view = webframe->frameView();
+ if (view) {
+ WebRect viewRect = view->frameRect();
+
+
+ SkIRect scrollFrame;
+ scrollFrame.set(view->scrollX(), view->scrollY(), view->layoutWidth()+view->scrollX(), view->layoutHeight()+view->scrollY());
+ m_layerRenderer->setScrollFrame(scrollFrame);
+ LayerSkia* rootLayer = m_layerRenderer->rootLayer();
+ if (rootLayer) {
+ SkIRect rootLayerBounds;
+ IntRect visibleRect = view->visibleContentRect(true);
+
+ // Set the backing store size used by the root layer to be the size of the visible
+ // area. Note that the root layer bounds could be larger than the backing store size
+ // but there's no reason to waste memory by allocating backing store larger than the
+ // visible portion.
+ rootLayerBounds.set(0, 0, visibleRect.width(), visibleRect.height());
+ rootLayer->setBackingStoreRect(rootLayerBounds);
+ GraphicsContext* rootLayerContext = rootLayer->graphicsContext();
+ rootLayerContext->save();
+
+ webframe->paintWithContext(*(rootLayer->graphicsContext()), rect);
+ rootLayerContext->restore();
+ }
+ }
+ }
+}
+
+void WebViewImpl::setRootLayerNeedsDisplay()
+{
+ // TODO(vangelis): For now we're posting a repaint event for the entire page
+ // which is an overkill.
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe) {
+ FrameView* view = webframe->frameView();
+ if (view) {
+ IntRect visibleRect = view->visibleContentRect(true);
+ m_client->didInvalidateRect(visibleRect);
+ }
+ }
+
+ if (m_layerRenderer)
+ m_layerRenderer->setNeedsDisplay();
+}
+
+#endif
+
} // namespace WebKit
« no previous file with comments | « WebKit/chromium/src/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698