OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/gfx/compositor/compositor_cc.h" | 5 #include "ui/gfx/compositor/compositor_cc.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "third_party/skia/include/images/SkImageEncoder.h" | 8 #include "third_party/skia/include/images/SkImageEncoder.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin
t.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin
t.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
14 #include "ui/gfx/compositor/compositor_switches.h" | 14 #include "ui/gfx/compositor/compositor_switches.h" |
15 #include "ui/gfx/compositor/test_web_graphics_context_3d.h" | 15 #include "ui/gfx/compositor/test_web_graphics_context_3d.h" |
16 #include "ui/gfx/compositor/layer.h" | 16 #include "ui/gfx/compositor/layer.h" |
17 #include "ui/gfx/gl/gl_context.h" | 17 #include "ui/gfx/gl/gl_context.h" |
18 #include "ui/gfx/gl/gl_surface.h" | 18 #include "ui/gfx/gl/gl_surface.h" |
19 #include "ui/gfx/gl/gl_implementation.h" | 19 #include "ui/gfx/gl/gl_implementation.h" |
20 #include "ui/gfx/gl/scoped_make_current.h" | 20 #include "ui/gfx/gl/scoped_make_current.h" |
21 #include "webkit/glue/webthread_impl.h" | 21 #include "webkit/glue/webthread_impl.h" |
22 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 22 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | |
26 webkit_glue::WebThreadImpl* g_compositor_thread = NULL; | 25 webkit_glue::WebThreadImpl* g_compositor_thread = NULL; |
27 | |
28 // If true a context is used that results in no rendering to the screen. | |
29 bool test_context_enabled = false; | |
30 | |
31 } // anonymous namespace | 26 } // anonymous namespace |
32 | 27 |
33 namespace ui { | 28 namespace ui { |
34 | 29 |
35 SharedResourcesCC::SharedResourcesCC() : initialized_(false) { | 30 SharedResourcesCC::SharedResourcesCC() : initialized_(false) { |
36 } | 31 } |
37 | 32 |
38 | 33 |
39 SharedResourcesCC::~SharedResourcesCC() { | 34 SharedResourcesCC::~SharedResourcesCC() { |
40 } | 35 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const gfx::Point& origin, | 114 const gfx::Point& origin, |
120 const gfx::Size& overall_size) { | 115 const gfx::Size& overall_size) { |
121 NOTREACHED(); | 116 NOTREACHED(); |
122 } | 117 } |
123 | 118 |
124 void TextureCC::Draw(const ui::TextureDrawParams& params, | 119 void TextureCC::Draw(const ui::TextureDrawParams& params, |
125 const gfx::Rect& clip_bounds_in_texture) { | 120 const gfx::Rect& clip_bounds_in_texture) { |
126 NOTREACHED(); | 121 NOTREACHED(); |
127 } | 122 } |
128 | 123 |
| 124 // static |
| 125 bool CompositorCC::test_context_enabled_ = false; |
| 126 |
129 CompositorCC::CompositorCC(CompositorDelegate* delegate, | 127 CompositorCC::CompositorCC(CompositorDelegate* delegate, |
130 gfx::AcceleratedWidget widget, | 128 gfx::AcceleratedWidget widget, |
131 const gfx::Size& size) | 129 const gfx::Size& size) |
132 : Compositor(delegate, size), | 130 : Compositor(delegate, size), |
133 widget_(widget), | 131 widget_(widget), |
134 root_web_layer_(WebKit::WebLayer::create(this)) { | 132 root_web_layer_(WebKit::WebLayer::create(this)) { |
135 WebKit::WebLayerTreeView::Settings settings; | 133 WebKit::WebLayerTreeView::Settings settings; |
136 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 134 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
137 settings.showFPSCounter = | 135 settings.showFPSCounter = |
138 command_line->HasSwitch(switches::kUIShowFPSCounter); | 136 command_line->HasSwitch(switches::kUIShowFPSCounter); |
(...skipping 28 matching lines...) Expand all Loading... |
167 void CompositorCC::Terminate() { | 165 void CompositorCC::Terminate() { |
168 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE | 166 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE |
169 WebKit::WebCompositor::shutdown(); | 167 WebKit::WebCompositor::shutdown(); |
170 #endif | 168 #endif |
171 if (g_compositor_thread) { | 169 if (g_compositor_thread) { |
172 delete g_compositor_thread; | 170 delete g_compositor_thread; |
173 g_compositor_thread = NULL; | 171 g_compositor_thread = NULL; |
174 } | 172 } |
175 } | 173 } |
176 | 174 |
| 175 // static |
| 176 void CompositorCC::EnableTestContextIfNecessary() { |
| 177 // TODO: only do this if command line param not set. |
| 178 test_context_enabled_ = true; |
| 179 } |
| 180 |
177 Texture* CompositorCC::CreateTexture() { | 181 Texture* CompositorCC::CreateTexture() { |
178 NOTREACHED(); | 182 NOTREACHED(); |
179 return NULL; | 183 return NULL; |
180 } | 184 } |
181 | 185 |
182 void CompositorCC::Blur(const gfx::Rect& bounds) { | 186 void CompositorCC::Blur(const gfx::Rect& bounds) { |
183 NOTIMPLEMENTED(); | 187 NOTIMPLEMENTED(); |
184 } | 188 } |
185 | 189 |
186 void CompositorCC::ScheduleDraw() { | 190 void CompositorCC::ScheduleDraw() { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 240 |
237 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 241 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, |
238 float scaleFactor) { | 242 float scaleFactor) { |
239 } | 243 } |
240 | 244 |
241 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { | 245 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { |
242 } | 246 } |
243 | 247 |
244 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() { | 248 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() { |
245 WebKit::WebGraphicsContext3D* context; | 249 WebKit::WebGraphicsContext3D* context; |
246 if (test_context_enabled) { | 250 if (test_context_enabled_) { |
247 context = new TestWebGraphicsContext3D(); | 251 context = new TestWebGraphicsContext3D(); |
248 } else { | 252 } else { |
249 gfx::GLShareGroup* share_group = | 253 gfx::GLShareGroup* share_group = |
250 SharedResourcesCC::GetInstance()->GetShareGroup(); | 254 SharedResourcesCC::GetInstance()->GetShareGroup(); |
251 context = new webkit::gpu::WebGraphicsContext3DInProcessImpl( | 255 context = new webkit::gpu::WebGraphicsContext3DInProcessImpl( |
252 widget_, share_group); | 256 widget_, share_group); |
253 } | 257 } |
254 WebKit::WebGraphicsContext3D::Attributes attrs; | 258 WebKit::WebGraphicsContext3D::Attributes attrs; |
255 context->initialize(attrs, 0, true); | 259 context->initialize(attrs, 0, true); |
256 | 260 |
(...skipping 18 matching lines...) Expand all Loading... |
275 void CompositorCC::notifyNeedsComposite() { | 279 void CompositorCC::notifyNeedsComposite() { |
276 ScheduleDraw(); | 280 ScheduleDraw(); |
277 } | 281 } |
278 | 282 |
279 Compositor* Compositor::Create(CompositorDelegate* owner, | 283 Compositor* Compositor::Create(CompositorDelegate* owner, |
280 gfx::AcceleratedWidget widget, | 284 gfx::AcceleratedWidget widget, |
281 const gfx::Size& size) { | 285 const gfx::Size& size) { |
282 return new CompositorCC(owner, widget, size); | 286 return new CompositorCC(owner, widget, size); |
283 } | 287 } |
284 | 288 |
285 COMPOSITOR_EXPORT void SetupTestCompositor() { | |
286 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
287 switches::kDisableTestCompositor)) { | |
288 test_context_enabled = true; | |
289 } | |
290 } | |
291 | |
292 COMPOSITOR_EXPORT void DisableTestCompositor() { | |
293 test_context_enabled = false; | |
294 } | |
295 | |
296 } // namespace ui | 289 } // namespace ui |
OLD | NEW |