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

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

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Null check before deref offscreenContextProvider Created 7 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 unified diff | Download patch | Annotate | Revision Log
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 "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 "base/synchronization/lock.h"
10 #include "cc/context_provider.h"
9 #include "cc/input_handler.h" 11 #include "cc/input_handler.h"
10 #include "cc/layer.h" 12 #include "cc/layer.h"
11 #include "cc/layer_tree_host.h" 13 #include "cc/layer_tree_host.h"
12 #include "cc/thread.h" 14 #include "cc/thread.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h" 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h "
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo ntext3D.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
20 #include "web_layer_impl.h" 23 #include "web_layer_impl.h"
21 #include "web_to_ccinput_handler_adapter.h" 24 #include "web_to_ccinput_handler_adapter.h"
22 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" 25 #include "webkit/compositor_bindings/web_rendering_stats_impl.h"
23 26
24 using namespace cc; 27 using namespace cc;
25 28
26 namespace WebKit { 29 namespace WebKit {
27 30
28 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client) 31 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client)
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void WebLayerTreeViewImpl::didCompleteSwapBuffers() 279 void WebLayerTreeViewImpl::didCompleteSwapBuffers()
277 { 280 {
278 m_client->didCompleteSwapBuffers(); 281 m_client->didCompleteSwapBuffers();
279 } 282 }
280 283
281 void WebLayerTreeViewImpl::scheduleComposite() 284 void WebLayerTreeViewImpl::scheduleComposite()
282 { 285 {
283 m_client->scheduleComposite(); 286 m_client->scheduleComposite();
284 } 287 }
285 288
289 class WebLayerTreeViewImpl::MainThreadContextProvider : public cc::ContextProvid er {
290 public:
291 virtual bool InitializeOnMainThread() OVERRIDE { return true; }
292 virtual bool BindToCurrentThread() OVERRIDE { return true; }
293
294 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
295 return WebSharedGraphicsContext3D::mainThreadContext();
296 }
297 virtual class GrContext* GrContext() OVERRIDE {
298 return WebSharedGraphicsContext3D::mainThreadGrContext();
299 }
300
301 virtual void VerifyContexts() OVERRIDE {}
302
303 protected:
304 virtual ~MainThreadContextProvider() {}
305 };
306
307 scoped_refptr<cc::ContextProvider> WebLayerTreeViewImpl::OffscreenContextProvide rForMainThread() {
308 if (!m_contextsMainThread)
309 m_contextsMainThread = new MainThreadContextProvider;
310 return m_contextsMainThread;
311 }
312
313 class WebLayerTreeViewImpl::CompositorThreadContextProvider
314 : public cc::ContextProvider {
315 public:
316 CompositorThreadContextProvider() : destroyed_(false) {}
317
318 virtual bool InitializeOnMainThread() OVERRIDE {
319 return WebSharedGraphicsContext3D::createCompositorThreadContext();
320 }
321 virtual bool BindToCurrentThread() OVERRIDE {
322 return Context3d()->makeContextCurrent();
323 }
324
325 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
326 return WebSharedGraphicsContext3D::compositorThreadContext();
327 }
328 virtual class GrContext* GrContext() OVERRIDE {
329 return WebSharedGraphicsContext3D::compositorThreadGrContext();
330 }
331
332 virtual void VerifyContexts() OVERRIDE {
333 if (Context3d() && !Context3d()->isContextLost())
334 return;
335 base::AutoLock lock(destroyed_lock_);
336 destroyed_ = true;
337 }
338 bool DestroyedOnMainThread() {
339 base::AutoLock lock(destroyed_lock_);
340 return destroyed_;
341 }
342
343 protected:
344 virtual ~CompositorThreadContextProvider() {}
345
346 private:
347 base::Lock destroyed_lock_;
348 bool destroyed_;
349 };
350
351 scoped_refptr<cc::ContextProvider> WebLayerTreeViewImpl::OffscreenContextProvide rForCompositorThread() {
352 if (!m_contextsCompositorThread ||
353 m_contextsCompositorThread->DestroyedOnMainThread()) {
354 m_contextsCompositorThread = new CompositorThreadContextProvider;
355 }
356 return m_contextsCompositorThread;
357 }
358
286 } // namespace WebKit 359 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698