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 webkit_glue::WebThreadImpl* g_compositor_thread = NULL; | 25 webkit_glue::WebThreadImpl* g_compositor_thread = NULL; |
| 26 // If true a context is used that results in no rendering. |
| 27 bool test_context_enabled = false; |
26 } // anonymous namespace | 28 } // anonymous namespace |
27 | 29 |
28 namespace ui { | 30 namespace ui { |
29 | 31 |
30 SharedResourcesCC::SharedResourcesCC() : initialized_(false) { | 32 SharedResourcesCC::SharedResourcesCC() : initialized_(false) { |
31 } | 33 } |
32 | 34 |
33 | 35 |
34 SharedResourcesCC::~SharedResourcesCC() { | 36 SharedResourcesCC::~SharedResourcesCC() { |
35 } | 37 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 const gfx::Point& origin, | 116 const gfx::Point& origin, |
115 const gfx::Size& overall_size) { | 117 const gfx::Size& overall_size) { |
116 NOTREACHED(); | 118 NOTREACHED(); |
117 } | 119 } |
118 | 120 |
119 void TextureCC::Draw(const ui::TextureDrawParams& params, | 121 void TextureCC::Draw(const ui::TextureDrawParams& params, |
120 const gfx::Rect& clip_bounds_in_texture) { | 122 const gfx::Rect& clip_bounds_in_texture) { |
121 NOTREACHED(); | 123 NOTREACHED(); |
122 } | 124 } |
123 | 125 |
124 // static | |
125 bool CompositorCC::test_context_enabled_ = false; | |
126 | |
127 CompositorCC::CompositorCC(CompositorDelegate* delegate, | 126 CompositorCC::CompositorCC(CompositorDelegate* delegate, |
128 gfx::AcceleratedWidget widget, | 127 gfx::AcceleratedWidget widget, |
129 const gfx::Size& size) | 128 const gfx::Size& size) |
130 : Compositor(delegate, size), | 129 : Compositor(delegate, size), |
131 widget_(widget), | 130 widget_(widget), |
132 root_web_layer_(WebKit::WebLayer::create(this)) { | 131 root_web_layer_(WebKit::WebLayer::create(this)) { |
133 WebKit::WebLayerTreeView::Settings settings; | 132 WebKit::WebLayerTreeView::Settings settings; |
134 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 133 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
135 settings.showFPSCounter = | 134 settings.showFPSCounter = |
136 command_line->HasSwitch(switches::kUIShowFPSCounter); | 135 command_line->HasSwitch(switches::kUIShowFPSCounter); |
(...skipping 28 matching lines...) Expand all Loading... |
165 void CompositorCC::Terminate() { | 164 void CompositorCC::Terminate() { |
166 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE | 165 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE |
167 WebKit::WebCompositor::shutdown(); | 166 WebKit::WebCompositor::shutdown(); |
168 #endif | 167 #endif |
169 if (g_compositor_thread) { | 168 if (g_compositor_thread) { |
170 delete g_compositor_thread; | 169 delete g_compositor_thread; |
171 g_compositor_thread = NULL; | 170 g_compositor_thread = NULL; |
172 } | 171 } |
173 } | 172 } |
174 | 173 |
175 // static | |
176 void CompositorCC::EnableTestContextIfNecessary() { | |
177 // TODO: only do this if command line param not set. | |
178 test_context_enabled_ = true; | |
179 } | |
180 | |
181 Texture* CompositorCC::CreateTexture() { | 174 Texture* CompositorCC::CreateTexture() { |
182 NOTREACHED(); | 175 NOTREACHED(); |
183 return NULL; | 176 return NULL; |
184 } | 177 } |
185 | 178 |
186 void CompositorCC::Blur(const gfx::Rect& bounds) { | 179 void CompositorCC::Blur(const gfx::Rect& bounds) { |
187 NOTIMPLEMENTED(); | 180 NOTIMPLEMENTED(); |
188 } | 181 } |
189 | 182 |
190 void CompositorCC::ScheduleDraw() { | 183 void CompositorCC::ScheduleDraw() { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 233 |
241 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 234 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, |
242 float scaleFactor) { | 235 float scaleFactor) { |
243 } | 236 } |
244 | 237 |
245 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { | 238 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { |
246 } | 239 } |
247 | 240 |
248 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() { | 241 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() { |
249 WebKit::WebGraphicsContext3D* context; | 242 WebKit::WebGraphicsContext3D* context; |
250 if (test_context_enabled_) { | 243 if (test_context_enabled) { |
251 context = new TestWebGraphicsContext3D(); | 244 context = new TestWebGraphicsContext3D(); |
252 } else { | 245 } else { |
253 gfx::GLShareGroup* share_group = | 246 gfx::GLShareGroup* share_group = |
254 SharedResourcesCC::GetInstance()->GetShareGroup(); | 247 SharedResourcesCC::GetInstance()->GetShareGroup(); |
255 context = new webkit::gpu::WebGraphicsContext3DInProcessImpl( | 248 context = new webkit::gpu::WebGraphicsContext3DInProcessImpl( |
256 widget_, share_group); | 249 widget_, share_group); |
257 } | 250 } |
258 WebKit::WebGraphicsContext3D::Attributes attrs; | 251 WebKit::WebGraphicsContext3D::Attributes attrs; |
259 context->initialize(attrs, 0, true); | 252 context->initialize(attrs, 0, true); |
260 | 253 |
(...skipping 18 matching lines...) Expand all Loading... |
279 void CompositorCC::notifyNeedsComposite() { | 272 void CompositorCC::notifyNeedsComposite() { |
280 ScheduleDraw(); | 273 ScheduleDraw(); |
281 } | 274 } |
282 | 275 |
283 Compositor* Compositor::Create(CompositorDelegate* owner, | 276 Compositor* Compositor::Create(CompositorDelegate* owner, |
284 gfx::AcceleratedWidget widget, | 277 gfx::AcceleratedWidget widget, |
285 const gfx::Size& size) { | 278 const gfx::Size& size) { |
286 return new CompositorCC(owner, widget, size); | 279 return new CompositorCC(owner, widget, size); |
287 } | 280 } |
288 | 281 |
| 282 COMPOSITOR_EXPORT void SetupTestCompositor() { |
| 283 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 284 switches::kDisableTestCompositor)) { |
| 285 test_context_enabled = true; |
| 286 } |
| 287 } |
| 288 |
| 289 COMPOSITOR_EXPORT void DisableTestCompositor() { |
| 290 test_context_enabled = false; |
| 291 } |
| 292 |
289 } // namespace ui | 293 } // namespace ui |
OLD | NEW |