OLD | NEW |
---|---|
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 "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 "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.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/thread.h" | 12 #include "cc/thread.h" |
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h" |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" |
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo ntext3D.h" | |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
21 #include "ui/gl/context_provider.h" | |
20 #include "web_layer_impl.h" | 22 #include "web_layer_impl.h" |
21 #include "web_to_ccinput_handler_adapter.h" | 23 #include "web_to_ccinput_handler_adapter.h" |
22 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" | 24 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" |
23 | 25 |
24 using namespace cc; | 26 using namespace cc; |
25 | 27 |
26 namespace WebKit { | 28 namespace WebKit { |
27 | 29 |
28 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client) | 30 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client) |
29 : m_client(client) | 31 : m_client(client) |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 void WebLayerTreeViewImpl::didCompleteSwapBuffers() | 278 void WebLayerTreeViewImpl::didCompleteSwapBuffers() |
277 { | 279 { |
278 m_client->didCompleteSwapBuffers(); | 280 m_client->didCompleteSwapBuffers(); |
279 } | 281 } |
280 | 282 |
281 void WebLayerTreeViewImpl::scheduleComposite() | 283 void WebLayerTreeViewImpl::scheduleComposite() |
282 { | 284 { |
283 m_client->scheduleComposite(); | 285 m_client->scheduleComposite(); |
284 } | 286 } |
285 | 287 |
288 class WebLayerTreeViewImpl::MainThreadContextProvider : public ui::ContextProvid er { | |
289 public: | |
290 virtual bool InitializeOnMainThread() OVERRIDE { return true; } | |
291 virtual bool BindToCurrentThread() OVERRIDE { return true; } | |
292 | |
293 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | |
294 return WebSharedGraphicsContext3D::mainThreadContext(); | |
295 } | |
296 virtual class GrContext* GrContext() OVERRIDE { | |
297 return WebSharedGraphicsContext3D::mainThreadGrContext(); | |
298 } | |
299 | |
300 virtual void VerifyContexts() OVERRIDE {} | |
301 protected: | |
piman
2013/02/21 22:49:48
nit: blank line before 'protected:'
danakj
2013/02/22 01:56:31
Done.
| |
302 virtual ~MainThreadContextProvider() {} | |
303 }; | |
304 | |
305 scoped_refptr<ui::ContextProvider> WebLayerTreeViewImpl::OffscreenContextProvide rForMainThread() { | |
306 if (!m_contextsMainThread) | |
307 m_contextsMainThread = new MainThreadContextProvider; | |
308 return m_contextsMainThread; | |
309 } | |
310 | |
311 class WebLayerTreeViewImpl::CompositorThreadContextProvider | |
312 : public ui::ContextProvider { | |
313 public: | |
314 CompositorThreadContextProvider() : destroyed_(false) {} | |
315 | |
316 virtual bool InitializeOnMainThread() OVERRIDE { | |
317 return WebSharedGraphicsContext3D::createCompositorThreadContext(); | |
318 } | |
319 virtual bool BindToCurrentThread() OVERRIDE { | |
320 return Context3d()->makeContextCurrent(); | |
321 } | |
322 | |
323 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | |
324 return WebSharedGraphicsContext3D::compositorThreadContext(); | |
325 } | |
326 virtual class GrContext* GrContext() OVERRIDE { | |
327 return WebSharedGraphicsContext3D::compositorThreadGrContext(); | |
328 } | |
329 | |
330 virtual void VerifyContexts() OVERRIDE { | |
331 if (!Context3d() || Context3d()->isContextLost()) | |
332 destroyed_ = true; | |
piman
2013/02/21 22:49:48
same here wrt thread safety
danakj
2013/02/22 01:56:31
Done.
| |
333 } | |
334 bool destroyed() const { return destroyed_; } | |
335 protected: | |
piman
2013/02/21 22:49:48
nit: blank line before 'protected:'
danakj
2013/02/22 01:56:31
Done.
| |
336 virtual ~CompositorThreadContextProvider() {} | |
337 private: | |
piman
2013/02/21 22:49:48
nit: blank line before 'private:'
danakj
2013/02/22 01:56:31
Done.
| |
338 bool destroyed_; | |
339 }; | |
340 | |
341 scoped_refptr<ui::ContextProvider> WebLayerTreeViewImpl::OffscreenContextProvide rForCompositorThread() { | |
342 if (!m_contextsCompositorThread || | |
343 m_contextsCompositorThread->destroyed()) { | |
344 m_contextsCompositorThread = new CompositorThreadContextProvider; | |
345 } | |
346 return m_contextsCompositorThread; | |
347 } | |
348 | |
286 } // namespace WebKit | 349 } // namespace WebKit |
OLD | NEW |