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

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

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "config.h" 5 #include "config.h"
6 #include "webkit/compositor_bindings/web_compositor_support_impl.h" 6 #include "webkit/compositor_bindings/web_compositor_support_impl.h"
7 7
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop_proxy.h"
10 #include "cc/settings.h" 11 #include "cc/settings.h"
12 #include "cc/thread_impl.h"
11 #include "webkit/compositor_bindings/web_animation_impl.h" 13 #include "webkit/compositor_bindings/web_animation_impl.h"
12 #include "webkit/compositor_bindings/web_compositor_impl.h"
13 #include "webkit/compositor_bindings/web_content_layer_impl.h" 14 #include "webkit/compositor_bindings/web_content_layer_impl.h"
14 #include "webkit/compositor_bindings/web_delegated_renderer_layer_impl.h" 15 #include "webkit/compositor_bindings/web_delegated_renderer_layer_impl.h"
15 #include "webkit/compositor_bindings/web_external_texture_layer_impl.h" 16 #include "webkit/compositor_bindings/web_external_texture_layer_impl.h"
16 #include "webkit/compositor_bindings/web_float_animation_curve_impl.h" 17 #include "webkit/compositor_bindings/web_float_animation_curve_impl.h"
17 #include "webkit/compositor_bindings/web_image_layer_impl.h" 18 #include "webkit/compositor_bindings/web_image_layer_impl.h"
18 #include "webkit/compositor_bindings/web_io_surface_layer_impl.h" 19 #include "webkit/compositor_bindings/web_io_surface_layer_impl.h"
19 #include "webkit/compositor_bindings/web_layer_impl.h" 20 #include "webkit/compositor_bindings/web_layer_impl.h"
20 #include "webkit/compositor_bindings/web_layer_tree_view_impl.h" 21 #include "webkit/compositor_bindings/web_layer_tree_view_impl.h"
21 #include "webkit/compositor_bindings/web_scrollbar_layer_impl.h" 22 #include "webkit/compositor_bindings/web_scrollbar_layer_impl.h"
22 #include "webkit/compositor_bindings/web_solid_color_layer_impl.h" 23 #include "webkit/compositor_bindings/web_solid_color_layer_impl.h"
23 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h" 24 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h"
24 #include "webkit/compositor_bindings/web_video_layer_impl.h" 25 #include "webkit/compositor_bindings/web_video_layer_impl.h"
26 #include "webkit/glue/webthread_impl.h"
25 27
26 using WebKit::WebAnimation; 28 using WebKit::WebAnimation;
27 using WebKit::WebAnimationCurve; 29 using WebKit::WebAnimationCurve;
28 using WebKit::WebContentLayer; 30 using WebKit::WebContentLayer;
29 using WebKit::WebContentLayerClient; 31 using WebKit::WebContentLayerClient;
30 using WebKit::WebDelegatedRendererLayer; 32 using WebKit::WebDelegatedRendererLayer;
31 using WebKit::WebExternalTextureLayer; 33 using WebKit::WebExternalTextureLayer;
32 using WebKit::WebExternalTextureLayerClient; 34 using WebKit::WebExternalTextureLayerClient;
33 using WebKit::WebFloatAnimationCurve; 35 using WebKit::WebFloatAnimationCurve;
34 using WebKit::WebIOSurfaceLayer; 36 using WebKit::WebIOSurfaceLayer;
35 using WebKit::WebImageLayer; 37 using WebKit::WebImageLayer;
36 using WebKit::WebImageLayer; 38 using WebKit::WebImageLayer;
37 using WebKit::WebLayer; 39 using WebKit::WebLayer;
38 using WebKit::WebLayerTreeView; 40 using WebKit::WebLayerTreeView;
39 using WebKit::WebLayerTreeViewClient; 41 using WebKit::WebLayerTreeViewClient;
40 using WebKit::WebScrollbar; 42 using WebKit::WebScrollbar;
41 using WebKit::WebScrollbarLayer; 43 using WebKit::WebScrollbarLayer;
42 using WebKit::WebScrollbarThemeGeometry; 44 using WebKit::WebScrollbarThemeGeometry;
43 using WebKit::WebScrollbarThemePainter; 45 using WebKit::WebScrollbarThemePainter;
44 using WebKit::WebSolidColorLayer; 46 using WebKit::WebSolidColorLayer;
45 using WebKit::WebTransformAnimationCurve; 47 using WebKit::WebTransformAnimationCurve;
46 using WebKit::WebVideoFrameProvider; 48 using WebKit::WebVideoFrameProvider;
47 using WebKit::WebVideoLayer; 49 using WebKit::WebVideoLayer;
48 50
49 using WebKit::WebCompositorImpl;
50
51 namespace webkit { 51 namespace webkit {
52 52
53 WebCompositorSupportImpl::WebCompositorSupportImpl() { 53 WebCompositorSupportImpl::WebCompositorSupportImpl()
54 : initialized_(false) {
54 } 55 }
55 56
56 WebCompositorSupportImpl::~WebCompositorSupportImpl() { 57 WebCompositorSupportImpl::~WebCompositorSupportImpl() {
57 } 58 }
58 59
59 void WebCompositorSupportImpl::initialize(WebKit::WebThread* thread) { 60 void WebCompositorSupportImpl::initialize(WebKit::WebThread* impl_thread) {
60 if (thread) { 61 DCHECK(!initialized_);
62 initialized_ = true;
63 if (impl_thread) {
61 TRACE_EVENT_INSTANT0("test_gpu", "ThreadedCompositingInitialization"); 64 TRACE_EVENT_INSTANT0("test_gpu", "ThreadedCompositingInitialization");
65 impl_thread_message_loop_proxy_ =
66 static_cast<webkit_glue::WebThreadImpl*>(impl_thread)->
67 message_loop()->message_loop_proxy();
68 } else {
69 impl_thread_message_loop_proxy_ = NULL;
62 } 70 }
63 WebCompositorImpl::initialize(thread);
64 } 71 }
65 72
66 bool WebCompositorSupportImpl::isThreadingEnabled() { 73 bool WebCompositorSupportImpl::isThreadingEnabled() {
67 return WebCompositorImpl::isThreadingEnabled(); 74 return impl_thread_message_loop_proxy_;
68 } 75 }
69 76
70 void WebCompositorSupportImpl::shutdown() { 77 void WebCompositorSupportImpl::shutdown() {
71 WebCompositorImpl::shutdown(); 78 DCHECK(initialized_);
79 initialized_ = false;
80 impl_thread_message_loop_proxy_ = NULL;
72 } 81 }
73 82
74 void WebCompositorSupportImpl::setPerTilePaintingEnabled(bool enabled) { 83 void WebCompositorSupportImpl::setPerTilePaintingEnabled(bool enabled) {
75 cc::Settings::setPerTilePaintingEnabled(enabled); 84 cc::Settings::setPerTilePaintingEnabled(enabled);
76 } 85 }
77 86
78 void WebCompositorSupportImpl::setPartialSwapEnabled(bool enabled) { 87 void WebCompositorSupportImpl::setPartialSwapEnabled(bool enabled) {
79 cc::Settings::setPartialSwapEnabled(enabled); 88 cc::Settings::setPartialSwapEnabled(enabled);
80 } 89 }
81 90
82 void WebCompositorSupportImpl::setAcceleratedAnimationEnabled(bool enabled) { 91 void WebCompositorSupportImpl::setAcceleratedAnimationEnabled(bool enabled) {
83 cc::Settings::setAcceleratedAnimationEnabled(enabled); 92 cc::Settings::setAcceleratedAnimationEnabled(enabled);
84 } 93 }
85 94
86 void WebCompositorSupportImpl::setPageScalePinchZoomEnabled(bool enabled) { 95 void WebCompositorSupportImpl::setPageScalePinchZoomEnabled(bool enabled) {
87 cc::Settings::setPageScalePinchZoomEnabled(enabled); 96 cc::Settings::setPageScalePinchZoomEnabled(enabled);
88 } 97 }
89 98
90 WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView( 99 WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView(
91 WebLayerTreeViewClient* client, const WebLayer& root, 100 WebLayerTreeViewClient* client, const WebLayer& root,
92 const WebLayerTreeView::Settings& settings) { 101 const WebLayerTreeView::Settings& settings) {
102 DCHECK(initialized_);
93 scoped_ptr<WebKit::WebLayerTreeViewImpl> layerTreeViewImpl( 103 scoped_ptr<WebKit::WebLayerTreeViewImpl> layerTreeViewImpl(
94 new WebKit::WebLayerTreeViewImpl(client)); 104 new WebKit::WebLayerTreeViewImpl(client));
95 if (!layerTreeViewImpl->initialize(settings)) 105 scoped_ptr<cc::Thread> impl_thread;
106 if (impl_thread_message_loop_proxy_)
107 impl_thread = cc::ThreadImpl::createForDifferentThread(
108 impl_thread_message_loop_proxy_);
109 if (!layerTreeViewImpl->initialize(settings, impl_thread.Pass()))
96 return NULL; 110 return NULL;
97 layerTreeViewImpl->setRootLayer(root); 111 layerTreeViewImpl->setRootLayer(root);
98 return layerTreeViewImpl.release(); 112 return layerTreeViewImpl.release();
99 } 113 }
100 114
101 WebLayer* WebCompositorSupportImpl::createLayer() { 115 WebLayer* WebCompositorSupportImpl::createLayer() {
102 return new WebKit::WebLayerImpl(); 116 return new WebKit::WebLayerImpl();
103 } 117 }
104 118
105 WebContentLayer* WebCompositorSupportImpl::createContentLayer( 119 WebContentLayer* WebCompositorSupportImpl::createContentLayer(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() { 166 WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() {
153 return new WebKit::WebFloatAnimationCurveImpl(); 167 return new WebKit::WebFloatAnimationCurveImpl();
154 } 168 }
155 169
156 WebTransformAnimationCurve* 170 WebTransformAnimationCurve*
157 WebCompositorSupportImpl::createTransformAnimationCurve() { 171 WebCompositorSupportImpl::createTransformAnimationCurve() {
158 return new WebKit::WebTransformAnimationCurveImpl(); 172 return new WebKit::WebTransformAnimationCurveImpl();
159 } 173 }
160 174
161 } // namespace webkit 175 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/compositor_bindings/web_compositor_support_impl.h ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698