OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 #include "KeyboardCodesWin.h" | 103 #include "KeyboardCodesWin.h" |
104 #include "RenderThemeChromiumWin.h" | 104 #include "RenderThemeChromiumWin.h" |
105 #else | 105 #else |
106 #if OS(LINUX) | 106 #if OS(LINUX) |
107 #include "RenderThemeChromiumLinux.h" | 107 #include "RenderThemeChromiumLinux.h" |
108 #endif | 108 #endif |
109 #include "KeyboardCodesPosix.h" | 109 #include "KeyboardCodesPosix.h" |
110 #include "RenderTheme.h" | 110 #include "RenderTheme.h" |
111 #endif | 111 #endif |
112 | 112 |
| 113 #if USE(ACCELERATED_COMPOSITING) |
| 114 #include "webkit/glue/webkit_glue.h" |
| 115 #if WEBKIT_USING_SKIA |
| 116 #include "skia/LayerSkia.h" |
| 117 #endif |
| 118 #endif |
| 119 |
113 // Get rid of WTF's pow define so we can use std::pow. | 120 // Get rid of WTF's pow define so we can use std::pow. |
114 #undef pow | 121 #undef pow |
115 #include <cmath> // for std::pow | 122 #include <cmath> // for std::pow |
116 | 123 |
117 using namespace WebCore; | 124 using namespace WebCore; |
118 | 125 |
119 namespace WebKit { | 126 namespace WebKit { |
120 | 127 |
121 // Change the text zoom level by kTextSizeMultiplierRatio each time the user | 128 // Change the text zoom level by kTextSizeMultiplierRatio each time the user |
122 // zooms text in or out (ie., change by 20%). The min and max values limit | 129 // zooms text in or out (ie., change by 20%). The min and max values limit |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 , m_dragTargetDispatch(false) | 245 , m_dragTargetDispatch(false) |
239 , m_dragIdentity(0) | 246 , m_dragIdentity(0) |
240 , m_dropEffect(DropEffectDefault) | 247 , m_dropEffect(DropEffectDefault) |
241 , m_operationsAllowed(WebDragOperationNone) | 248 , m_operationsAllowed(WebDragOperationNone) |
242 , m_dragOperation(WebDragOperationNone) | 249 , m_dragOperation(WebDragOperationNone) |
243 , m_suggestionsPopupShowing(false) | 250 , m_suggestionsPopupShowing(false) |
244 , m_suggestionsPopupClient(0) | 251 , m_suggestionsPopupClient(0) |
245 , m_suggestionsPopup(0) | 252 , m_suggestionsPopup(0) |
246 , m_isTransparent(false) | 253 , m_isTransparent(false) |
247 , m_tabsToLinks(false) | 254 , m_tabsToLinks(false) |
| 255 #if USE(ACCELERATED_COMPOSITING) |
| 256 , m_layerRenderer(0) |
| 257 , m_isAcceleratedCompositing(false) |
| 258 #endif |
248 { | 259 { |
249 // WebKit/win/WebView.cpp does the same thing, except they call the | 260 // WebKit/win/WebView.cpp does the same thing, except they call the |
250 // KJS specific wrapper around this method. We need to have threading | 261 // KJS specific wrapper around this method. We need to have threading |
251 // initialized because CollatorICU requires it. | 262 // initialized because CollatorICU requires it. |
252 WTF::initializeThreading(); | 263 WTF::initializeThreading(); |
253 | 264 |
254 // set to impossible point so we always get the first mouse pos | 265 // set to impossible point so we always get the first mouse pos |
255 m_lastMousePosition = WebPoint(-1, -1); | 266 m_lastMousePosition = WebPoint(-1, -1); |
256 | 267 |
257 // the page will take ownership of the various clients | 268 // the page will take ownership of the various clients |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 877 |
867 // setFrameRect may have the side-effect of causing existing page | 878 // setFrameRect may have the side-effect of causing existing page |
868 // layout to be invalidated, so layout needs to be called last. | 879 // layout to be invalidated, so layout needs to be called last. |
869 | 880 |
870 webframe->layout(); | 881 webframe->layout(); |
871 } | 882 } |
872 } | 883 } |
873 | 884 |
874 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) | 885 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
875 { | 886 { |
876 WebFrameImpl* webframe = mainFrameImpl(); | 887 |
877 if (webframe) | 888 #if USE(ACCELERATED_COMPOSITING) |
878 webframe->paint(canvas, rect); | 889 if (!isAcceleratedCompositing()) { |
| 890 #endif |
| 891 WebFrameImpl* webframe = mainFrameImpl(); |
| 892 if (webframe) |
| 893 webframe->paint(canvas, rect); |
| 894 #if USE(ACCELERATED_COMPOSITING) |
| 895 } else { |
| 896 // Draw the contents of the root layer |
| 897 updateRootLayerContents(rect); |
| 898 |
| 899 // Composite everything into the canvas that's passed to us. |
| 900 m_layerRenderer->updateLayerContents(); |
| 901 SkIRect canvasIRect; |
| 902 canvasIRect.set(rect.x, rect.y, rect.x+rect.width, rect.y+rect.height); |
| 903 SkRect canvasRect; |
| 904 canvasRect.set(canvasIRect); |
| 905 m_layerRenderer->drawLayersInCanvas(static_cast<skia::PlatformCanvas*>(c
anvas), canvasRect); |
| 906 } |
| 907 #endif |
879 } | 908 } |
880 | 909 |
881 // FIXME: m_currentInputEvent should be removed once ChromeClient::show() can | 910 // FIXME: m_currentInputEvent should be removed once ChromeClient::show() can |
882 // get the current-event information from WebCore. | 911 // get the current-event information from WebCore. |
883 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; | 912 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; |
884 | 913 |
885 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) | 914 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) |
886 { | 915 { |
887 // If we've started a drag and drop operation, ignore input events until | 916 // If we've started a drag and drop operation, ignore input events until |
888 // we're done. | 917 // we're done. |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 void WebViewImpl::setTabsToLinks(bool enable) | 1938 void WebViewImpl::setTabsToLinks(bool enable) |
1910 { | 1939 { |
1911 m_tabsToLinks = enable; | 1940 m_tabsToLinks = enable; |
1912 } | 1941 } |
1913 | 1942 |
1914 bool WebViewImpl::tabsToLinks() const | 1943 bool WebViewImpl::tabsToLinks() const |
1915 { | 1944 { |
1916 return m_tabsToLinks; | 1945 return m_tabsToLinks; |
1917 } | 1946 } |
1918 | 1947 |
| 1948 #if USE(ACCELERATED_COMPOSITING) |
| 1949 void WebViewImpl::setRootGraphicsLayer(WebCore::PlatformLayer* layer) |
| 1950 { |
| 1951 setAcceleratedCompositing(layer ? true : false); |
| 1952 if (m_layerRenderer) |
| 1953 m_layerRenderer->setRootLayer(layer); |
| 1954 } |
| 1955 |
| 1956 void WebViewImpl::setAcceleratedCompositing(bool accelerated) |
| 1957 { |
| 1958 if (m_isAcceleratedCompositing == accelerated) |
| 1959 return; |
| 1960 |
| 1961 if (accelerated) { |
| 1962 m_layerRenderer = LayerRendererSkia::create(); |
| 1963 if (m_layerRenderer) { |
| 1964 m_isAcceleratedCompositing = true; |
| 1965 } |
| 1966 } else { |
| 1967 m_layerRenderer = 0; |
| 1968 m_isAcceleratedCompositing = false; |
| 1969 } |
| 1970 } |
| 1971 |
| 1972 void WebViewImpl::updateRootLayerContents(const WebRect& rect) |
| 1973 { |
| 1974 if (!isAcceleratedCompositing()) |
| 1975 return; |
| 1976 |
| 1977 WebFrameImpl* webframe = mainFrameImpl(); |
| 1978 if (webframe) { |
| 1979 FrameView* view = webframe->frameView(); |
| 1980 if (view) { |
| 1981 WebRect viewRect = view->frameRect(); |
| 1982 |
| 1983 |
| 1984 SkIRect scrollFrame; |
| 1985 scrollFrame.set(view->scrollX(), view->scrollY(), view->layoutWidth(
)+view->scrollX(), view->layoutHeight()+view->scrollY()); |
| 1986 m_layerRenderer->setScrollFrame(scrollFrame); |
| 1987 LayerSkia* rootLayer = m_layerRenderer->rootLayer(); |
| 1988 if (rootLayer) { |
| 1989 SkIRect rootLayerBounds; |
| 1990 IntRect visibleRect = view->visibleContentRect(true); |
| 1991 |
| 1992 // Set the backing store size used by the root layer to be the s
ize of the visible |
| 1993 // area. Note that the root layer bounds could be larger than t
he backing store size |
| 1994 // but there's no reason to waste memory by allocating backing s
tore larger than the |
| 1995 // visible portion. |
| 1996 rootLayerBounds.set(0, 0, visibleRect.width(), visibleRect.heigh
t()); |
| 1997 rootLayer->setBackingStoreRect(rootLayerBounds); |
| 1998 GraphicsContext* rootLayerContext = rootLayer->graphicsContext()
; |
| 1999 rootLayerContext->save(); |
| 2000 |
| 2001 webframe->paintWithContext(*(rootLayer->graphicsContext()), rect
); |
| 2002 rootLayerContext->restore(); |
| 2003 } |
| 2004 } |
| 2005 } |
| 2006 } |
| 2007 |
| 2008 void WebViewImpl::setRootLayerNeedsDisplay() |
| 2009 { |
| 2010 // TODO(vangelis): For now we're posting a repaint event for the entire page |
| 2011 // which is an overkill. |
| 2012 WebFrameImpl* webframe = mainFrameImpl(); |
| 2013 if (webframe) { |
| 2014 FrameView* view = webframe->frameView(); |
| 2015 if (view) { |
| 2016 IntRect visibleRect = view->visibleContentRect(true); |
| 2017 m_client->didInvalidateRect(visibleRect); |
| 2018 } |
| 2019 } |
| 2020 |
| 2021 if (m_layerRenderer) |
| 2022 m_layerRenderer->setNeedsDisplay(); |
| 2023 } |
| 2024 |
| 2025 #endif |
| 2026 |
1919 } // namespace WebKit | 2027 } // namespace WebKit |
OLD | NEW |