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

Side by Side Diff: webkit/compositor_bindings/web_layer_tree_view_impl.cc

Issue 11778068: Revert 175827 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/compositor_bindings/web_layer_tree_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/compositor_bindings/web_layer_tree_view_impl.h" 5 #include "web_layer_tree_view_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/font_atlas.h" 8 #include "cc/font_atlas.h"
9 #include "cc/input_handler.h" 9 #include "cc/input_handler.h"
10 #include "cc/layer.h" 10 #include "cc/layer.h"
11 #include "cc/layer_tree_host.h" 11 #include "cc/layer_tree_host.h"
12 #include "cc/switches.h" 12 #include "cc/switches.h"
13 #include "cc/thread.h" 13 #include "cc/thread.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h" 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h "
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
21 #include "webkit/compositor_bindings/web_layer_impl.h" 21 #include "web_layer_impl.h"
22 #include "web_to_ccinput_handler_adapter.h"
22 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" 23 #include "webkit/compositor_bindings/web_rendering_stats_impl.h"
23 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" 24
24 25 using namespace cc;
25 26
26 namespace WebKit { 27 namespace WebKit {
27 28
28 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client) 29 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client)
29 : client_(client) { 30 : m_client(client)
30 } 31 {
31 32 }
32 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { 33
33 } 34 WebLayerTreeViewImpl::~WebLayerTreeViewImpl()
34 35 {
35 bool WebLayerTreeViewImpl::initialize( 36 }
36 const WebLayerTreeView::Settings& web_settings, 37
37 scoped_ptr<cc::Thread> impl_thread) { 38 bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSetti ngs, scoped_ptr<Thread> implThread)
38 cc::LayerTreeSettings settings; 39 {
39 settings.acceleratePainting = web_settings.acceleratePainting; 40 LayerTreeSettings settings;
40 settings.renderVSyncEnabled = web_settings.renderVSyncEnabled; 41 settings.acceleratePainting = webSettings.acceleratePainting;
41 settings.perTilePaintingEnabled = web_settings.perTilePaintingEnabled; 42 settings.renderVSyncEnabled = webSettings.renderVSyncEnabled;
42 settings.acceleratedAnimationEnabled = 43 settings.perTilePaintingEnabled = webSettings.perTilePaintingEnabled;
43 web_settings.acceleratedAnimationEnabled; 44 settings.acceleratedAnimationEnabled = webSettings.acceleratedAnimationEnabl ed;
44 settings.pageScalePinchZoomEnabled = web_settings.pageScalePinchZoomEnabled; 45 settings.pageScalePinchZoomEnabled = webSettings.pageScalePinchZoomEnabled;
45 settings.refreshRate = web_settings.refreshRate; 46 settings.refreshRate = webSettings.refreshRate;
46 settings.defaultTileSize = web_settings.defaultTileSize; 47 settings.defaultTileSize = webSettings.defaultTileSize;
47 settings.maxUntiledLayerSize = web_settings.maxUntiledLayerSize; 48 settings.maxUntiledLayerSize = webSettings.maxUntiledLayerSize;
48 settings.initialDebugState.showFPSCounter = web_settings.showFPSCounter; 49 settings.initialDebugState.showFPSCounter = webSettings.showFPSCounter;
49 settings.initialDebugState.showPaintRects = web_settings.showPaintRects; 50 settings.initialDebugState.showPaintRects = webSettings.showPaintRects;
50 settings.initialDebugState.showPlatformLayerTree = 51 settings.initialDebugState.showPlatformLayerTree = webSettings.showPlatformL ayerTree;
51 web_settings.showPlatformLayerTree; 52 settings.initialDebugState.showDebugBorders = webSettings.showDebugBorders;
52 settings.initialDebugState.showDebugBorders = web_settings.showDebugBorders; 53 m_layerTreeHost = LayerTreeHost::create(this, settings, implThread.Pass());
53 layer_tree_host_ = cc::LayerTreeHost::create(this, 54 if (!m_layerTreeHost.get())
54 settings, 55 return false;
55 impl_thread.Pass()); 56 return true;
56 if (!layer_tree_host_) 57 }
57 return false; 58
58 return true; 59 void WebLayerTreeViewImpl::setSurfaceReady()
59 } 60 {
60 61 m_layerTreeHost->setSurfaceReady();
61 cc::LayerTreeHost* WebLayerTreeViewImpl::layer_tree_host() const { 62 }
62 return layer_tree_host_.get(); 63
63 } 64 void WebLayerTreeViewImpl::setRootLayer(const WebLayer& root)
64 65 {
65 void WebLayerTreeViewImpl::setSurfaceReady() { 66 m_layerTreeHost->setRootLayer(static_cast<const WebLayerImpl*>(&root)->layer ());
66 layer_tree_host_->setSurfaceReady(); 67 }
67 } 68
68 69 void WebLayerTreeViewImpl::clearRootLayer()
69 void WebLayerTreeViewImpl::setRootLayer(const WebLayer& root) { 70 {
70 layer_tree_host_->setRootLayer( 71 m_layerTreeHost->setRootLayer(scoped_refptr<Layer>());
71 static_cast<const WebLayerImpl*>(&root)->layer()); 72 }
72 } 73
73 74 void WebLayerTreeViewImpl::setViewportSize(const WebSize& layoutViewportSize, co nst WebSize& deviceViewportSize)
74 void WebLayerTreeViewImpl::clearRootLayer() { 75 {
75 layer_tree_host_->setRootLayer(scoped_refptr<cc::Layer>()); 76 if (!deviceViewportSize.isEmpty())
76 } 77 m_layerTreeHost->setViewportSize(layoutViewportSize, deviceViewportSize) ;
77 78 else
78 void WebLayerTreeViewImpl::setViewportSize( 79 m_layerTreeHost->setViewportSize(layoutViewportSize, layoutViewportSize) ;
79 const WebSize& layout_viewport_size, const WebSize& device_viewport_size) { 80 }
80 if (!device_viewport_size.isEmpty()) { 81
81 layer_tree_host_->setViewportSize(layout_viewport_size, 82 WebSize WebLayerTreeViewImpl::layoutViewportSize() const
82 device_viewport_size); 83 {
83 } else { 84 return m_layerTreeHost->layoutViewportSize();
84 layer_tree_host_->setViewportSize(layout_viewport_size, 85 }
85 layout_viewport_size); 86
86 } 87 WebSize WebLayerTreeViewImpl::deviceViewportSize() const
87 } 88 {
88 89 return m_layerTreeHost->deviceViewportSize();
89 WebSize WebLayerTreeViewImpl::layoutViewportSize() const { 90 }
90 return layer_tree_host_->layoutViewportSize(); 91
91 } 92 WebFloatPoint WebLayerTreeViewImpl::adjustEventPointForPinchZoom(const WebFloatP oint& point) const
92 93 {
93 WebSize WebLayerTreeViewImpl::deviceViewportSize() const { 94 return m_layerTreeHost->adjustEventPointForPinchZoom(point);
94 return layer_tree_host_->deviceViewportSize(); 95 }
95 } 96
96 97 void WebLayerTreeViewImpl::setDeviceScaleFactor(const float deviceScaleFactor)
97 WebFloatPoint WebLayerTreeViewImpl::adjustEventPointForPinchZoom( 98 {
98 const WebFloatPoint& point) const { 99 m_layerTreeHost->setDeviceScaleFactor(deviceScaleFactor);
99 return layer_tree_host_->adjustEventPointForPinchZoom(point); 100 }
100 } 101
101 102 float WebLayerTreeViewImpl::deviceScaleFactor() const
102 void WebLayerTreeViewImpl::setDeviceScaleFactor(float device_scale_factor) { 103 {
103 layer_tree_host_->setDeviceScaleFactor(device_scale_factor); 104 return m_layerTreeHost->deviceScaleFactor();
104 } 105 }
105 106
106 float WebLayerTreeViewImpl::deviceScaleFactor() const { 107 void WebLayerTreeViewImpl::setBackgroundColor(WebColor color)
107 return layer_tree_host_->deviceScaleFactor(); 108 {
108 } 109 m_layerTreeHost->setBackgroundColor(color);
109 110 }
110 void WebLayerTreeViewImpl::setBackgroundColor(WebColor color) { 111
111 layer_tree_host_->setBackgroundColor(color); 112 void WebLayerTreeViewImpl::setHasTransparentBackground(bool transparent)
112 } 113 {
113 114 m_layerTreeHost->setHasTransparentBackground(transparent);
114 void WebLayerTreeViewImpl::setHasTransparentBackground(bool transparent) { 115 }
115 layer_tree_host_->setHasTransparentBackground(transparent); 116
116 } 117 void WebLayerTreeViewImpl::setVisible(bool visible)
117 118 {
118 void WebLayerTreeViewImpl::setVisible(bool visible) { 119 m_layerTreeHost->setVisible(visible);
119 layer_tree_host_->setVisible(visible); 120 }
120 } 121
121 122 void WebLayerTreeViewImpl::setPageScaleFactorAndLimits(float pageScaleFactor, fl oat minimum, float maximum)
122 void WebLayerTreeViewImpl::setPageScaleFactorAndLimits(float page_scale_factor, 123 {
123 float minimum, 124 m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor, minimum, maxim um);
124 float maximum) { 125 }
125 layer_tree_host_->setPageScaleFactorAndLimits(page_scale_factor, 126
126 minimum, maximum); 127 void WebLayerTreeViewImpl::startPageScaleAnimation(const WebPoint& scroll, bool useAnchor, float newPageScale, double durationSec)
127 } 128 {
128 129 base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * b ase::Time::kMicrosecondsPerSecond);
129 void WebLayerTreeViewImpl::startPageScaleAnimation(const WebPoint& scroll, 130 m_layerTreeHost->startPageScaleAnimation(gfx::Vector2d(scroll.x, scroll.y), useAnchor, newPageScale, duration);
130 bool use_anchor, 131 }
131 float new_page_scale, 132
132 double duration_sec) { 133 void WebLayerTreeViewImpl::setNeedsAnimate()
133 int64 duration_us = duration_sec * base::Time::kMicrosecondsPerSecond; 134 {
134 base::TimeDelta duration = base::TimeDelta::FromMicroseconds(duration_us); 135 m_layerTreeHost->setNeedsAnimate();
135 layer_tree_host_->startPageScaleAnimation(gfx::Vector2d(scroll.x, scroll.y), 136 }
136 use_anchor, 137
137 new_page_scale, 138 void WebLayerTreeViewImpl::setNeedsRedraw()
138 duration); 139 {
139 } 140 m_layerTreeHost->setNeedsRedraw();
140 141 }
141 void WebLayerTreeViewImpl::setNeedsAnimate() { 142
142 layer_tree_host_->setNeedsAnimate(); 143 bool WebLayerTreeViewImpl::commitRequested() const
143 } 144 {
144 145 return m_layerTreeHost->commitRequested();
145 void WebLayerTreeViewImpl::setNeedsRedraw() { 146 }
146 layer_tree_host_->setNeedsRedraw(); 147
147 } 148 void WebLayerTreeViewImpl::composite()
148 149 {
149 bool WebLayerTreeViewImpl::commitRequested() const { 150 m_layerTreeHost->composite();
150 return layer_tree_host_->commitRequested(); 151 }
151 } 152
152 153 void WebLayerTreeViewImpl::updateAnimations(double frameBeginTimeSeconds)
153 void WebLayerTreeViewImpl::composite() { 154 {
154 layer_tree_host_->composite(); 155 base::TimeTicks frameBeginTime = base::TimeTicks::FromInternalValue(frameBeg inTimeSeconds * base::Time::kMicrosecondsPerSecond);
155 } 156 m_layerTreeHost->updateAnimations(frameBeginTime);
156 157 }
157 void WebLayerTreeViewImpl::didStopFlinging() { 158
158 layer_tree_host_->didStopFlinging(); 159 void WebLayerTreeViewImpl::didStopFlinging()
159 } 160 {
160 161 m_layerTreeHost->didStopFlinging();
161 void WebLayerTreeViewImpl::updateAnimations(double frame_begin_time_seconds) { 162 }
162 int64 frame_begin_time_us = 163
163 frame_begin_time_seconds * base::Time::kMicrosecondsPerSecond; 164 bool WebLayerTreeViewImpl::compositeAndReadback(void *pixels, const WebRect& rec t)
164 base::TimeTicks frame_begin_time = 165 {
165 base::TimeTicks::FromInternalValue(frame_begin_time_us); 166 return m_layerTreeHost->compositeAndReadback(pixels, rect);
166 layer_tree_host_->updateAnimations(frame_begin_time); 167 }
167 } 168
168 169 void WebLayerTreeViewImpl::finishAllRendering()
169 bool WebLayerTreeViewImpl::compositeAndReadback(void* pixels, 170 {
170 const WebRect& rect) { 171 m_layerTreeHost->finishAllRendering();
171 return layer_tree_host_->compositeAndReadback(pixels, rect); 172 }
172 } 173
173 174 void WebLayerTreeViewImpl::setDeferCommits(bool deferCommits)
174 void WebLayerTreeViewImpl::finishAllRendering() { 175 {
175 layer_tree_host_->finishAllRendering(); 176 m_layerTreeHost->setDeferCommits(deferCommits);
176 } 177 }
177 178
178 void WebLayerTreeViewImpl::setDeferCommits(bool defer_commits) { 179 void WebLayerTreeViewImpl::renderingStats(WebRenderingStats& stats) const
179 layer_tree_host_->setDeferCommits(defer_commits); 180 {
180 } 181 m_layerTreeHost->renderingStats(
181 182 &static_cast<WebRenderingStatsImpl&>(stats).rendering_stats);
182 void WebLayerTreeViewImpl::renderingStats(WebRenderingStats& stats) const { 183 }
183 layer_tree_host_->renderingStats( 184
184 &static_cast<WebRenderingStatsImpl&>(stats).rendering_stats); 185 void WebLayerTreeViewImpl::setShowFPSCounter(bool show)
185 } 186 {
186 187 LayerTreeDebugState debugState = m_layerTreeHost->debugState();
187 void WebLayerTreeViewImpl::setShowFPSCounter(bool show) { 188 debugState.showFPSCounter = show;
188 cc::LayerTreeDebugState debug_state = layer_tree_host_->debugState(); 189 m_layerTreeHost->setDebugState(debugState);
189 debug_state.showFPSCounter = show; 190 }
190 layer_tree_host_->setDebugState(debug_state); 191
191 } 192 void WebLayerTreeViewImpl::setShowPaintRects(bool show)
192 193 {
193 void WebLayerTreeViewImpl::setShowPaintRects(bool show) { 194 LayerTreeDebugState debugState = m_layerTreeHost->debugState();
194 cc::LayerTreeDebugState debug_state = layer_tree_host_->debugState(); 195 debugState.showPaintRects = show;
195 debug_state.showPaintRects = show; 196 m_layerTreeHost->setDebugState(debugState);
196 layer_tree_host_->setDebugState(debug_state); 197 }
197 } 198
198 199 void WebLayerTreeViewImpl::setContinuousPaintingEnabled(bool enabled)
199 void WebLayerTreeViewImpl::setContinuousPaintingEnabled(bool enabled) { 200 {
200 cc::LayerTreeDebugState debug_state = layer_tree_host_->debugState(); 201 LayerTreeDebugState debugState = m_layerTreeHost->debugState();
201 debug_state.continuousPainting = enabled; 202 debugState.continuousPainting = enabled;
202 layer_tree_host_->setDebugState(debug_state); 203 m_layerTreeHost->setDebugState(debugState);
203 } 204 }
204 205
205 scoped_ptr<cc::FontAtlas> WebLayerTreeViewImpl::createFontAtlas() { 206 scoped_ptr<FontAtlas> WebLayerTreeViewImpl::createFontAtlas()
206 int font_height; 207 {
207 WebRect ascii_to_web_rect_table[128]; 208 int fontHeight;
208 gfx::Rect ascii_to_rect_table[128]; 209 WebRect asciiToWebRectTable[128];
209 SkBitmap bitmap; 210 gfx::Rect asciiToRectTable[128];
210 211 SkBitmap bitmap;
211 client_->createFontAtlas(bitmap, ascii_to_web_rect_table, font_height); 212
212 213 m_client->createFontAtlas(bitmap, asciiToWebRectTable, fontHeight);
213 for (int i = 0; i < 128; ++i) 214
214 ascii_to_rect_table[i] = ascii_to_web_rect_table[i]; 215 for (int i = 0; i < 128; ++i)
215 216 asciiToRectTable[i] = asciiToWebRectTable[i];
216 return cc::FontAtlas::create(bitmap, ascii_to_rect_table, font_height).Pass(); 217
217 } 218 return FontAtlas::create(bitmap, asciiToRectTable, fontHeight).Pass();
218 219 }
219 void WebLayerTreeViewImpl::willBeginFrame() { 220
220 client_->willBeginFrame(); 221 void WebLayerTreeViewImpl::willBeginFrame()
221 } 222 {
222 223 m_client->willBeginFrame();
223 void WebLayerTreeViewImpl::didBeginFrame() { 224 }
224 client_->didBeginFrame(); 225
225 } 226 void WebLayerTreeViewImpl::didBeginFrame()
226 227 {
227 void WebLayerTreeViewImpl::animate(double monotonic_frame_begin_time) { 228 m_client->didBeginFrame();
228 client_->updateAnimations(monotonic_frame_begin_time); 229 }
229 } 230
230 231 void WebLayerTreeViewImpl::animate(double monotonicFrameBeginTime)
231 void WebLayerTreeViewImpl::layout() { 232 {
232 client_->layout(); 233 m_client->updateAnimations(monotonicFrameBeginTime);
233 } 234 }
234 235
235 void WebLayerTreeViewImpl::applyScrollAndScale(gfx::Vector2d scroll_delta, 236 void WebLayerTreeViewImpl::layout()
236 float page_scale) { 237 {
237 client_->applyScrollAndScale(scroll_delta, page_scale); 238 m_client->layout();
238 } 239 }
239 240
240 scoped_ptr<cc::OutputSurface> WebLayerTreeViewImpl::createOutputSurface() { 241 void WebLayerTreeViewImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale)
241 WebKit::WebCompositorOutputSurface* web = client_->createOutputSurface(); 242 {
242 return make_scoped_ptr(static_cast<cc::OutputSurface*>(web)); 243 m_client->applyScrollAndScale(scrollDelta, pageScale);
243 } 244 }
244 245
245 void WebLayerTreeViewImpl::didRecreateOutputSurface(bool success) { 246 scoped_ptr<cc::OutputSurface> WebLayerTreeViewImpl::createOutputSurface()
246 client_->didRecreateOutputSurface(success); 247 {
247 } 248 WebKit::WebCompositorOutputSurface* web = m_client->createOutputSurface();
248 249 return make_scoped_ptr(static_cast<cc::OutputSurface*>(web));
249 scoped_ptr<cc::InputHandler> WebLayerTreeViewImpl::createInputHandler() { 250 }
250 scoped_ptr<cc::InputHandler> ret; 251
251 scoped_ptr<WebInputHandler> handler(client_->createInputHandler()); 252 void WebLayerTreeViewImpl::didRecreateOutputSurface(bool success)
252 if (handler) 253 {
253 ret = WebToCCInputHandlerAdapter::create(handler.Pass()); 254 m_client->didRecreateOutputSurface(success);
254 return ret.Pass(); 255 }
255 } 256
256 257 scoped_ptr<InputHandler> WebLayerTreeViewImpl::createInputHandler()
257 void WebLayerTreeViewImpl::willCommit() { 258 {
258 client_->willCommit(); 259 scoped_ptr<InputHandler> ret;
259 } 260 scoped_ptr<WebInputHandler> handler(m_client->createInputHandler());
260 261 if (handler)
261 void WebLayerTreeViewImpl::didCommit() { 262 ret = WebToCCInputHandlerAdapter::create(handler.Pass());
262 client_->didCommit(); 263 return ret.Pass();
263 } 264 }
264 265
265 void WebLayerTreeViewImpl::didCommitAndDrawFrame() { 266 void WebLayerTreeViewImpl::willCommit()
266 client_->didCommitAndDrawFrame(); 267 {
267 } 268 m_client->willCommit();
268 269 }
269 void WebLayerTreeViewImpl::didCompleteSwapBuffers() { 270
270 client_->didCompleteSwapBuffers(); 271 void WebLayerTreeViewImpl::didCommit()
271 } 272 {
272 273 m_client->didCommit();
273 void WebLayerTreeViewImpl::scheduleComposite() { 274 }
274 client_->scheduleComposite(); 275
275 } 276 void WebLayerTreeViewImpl::didCommitAndDrawFrame()
276 277 {
277 } // namespace WebKit 278 m_client->didCommitAndDrawFrame();
279 }
280
281 void WebLayerTreeViewImpl::didCompleteSwapBuffers()
282 {
283 m_client->didCompleteSwapBuffers();
284 }
285
286 void WebLayerTreeViewImpl::scheduleComposite()
287 {
288 m_client->scheduleComposite();
289 }
290
291 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/compositor_bindings/web_layer_tree_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698