OLD | NEW |
---|---|
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 "ui/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "third_party/skia/include/images/SkImageEncoder.h" | 12 #include "third_party/skia/include/images/SkImageEncoder.h" |
13 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" |
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSuppor t.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSuppor t.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h" | |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h" |
20 #include "ui/compositor/compositor_observer.h" | 19 #include "ui/compositor/compositor_observer.h" |
21 #include "ui/compositor/compositor_switches.h" | 20 #include "ui/compositor/compositor_switches.h" |
22 #include "ui/compositor/dip_util.h" | 21 #include "ui/compositor/dip_util.h" |
23 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
24 #include "ui/compositor/test_web_graphics_context_3d.h" | 23 #include "ui/compositor/test_web_graphics_context_3d.h" |
25 #include "ui/gl/gl_context.h" | 24 #include "ui/gl/gl_context.h" |
26 #include "ui/gl/gl_implementation.h" | 25 #include "ui/gl/gl_implementation.h" |
27 #include "ui/gl/gl_surface.h" | 26 #include "ui/gl/gl_surface.h" |
28 #include "webkit/glue/webthread_impl.h" | 27 #include "webkit/glue/webthread_impl.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 // Stop all outstanding draws before telling the ContextFactory to tear | 171 // Stop all outstanding draws before telling the ContextFactory to tear |
173 // down any contexts that the |host_| may rely upon. | 172 // down any contexts that the |host_| may rely upon. |
174 host_.reset(); | 173 host_.reset(); |
175 | 174 |
176 if (!test_compositor_enabled) | 175 if (!test_compositor_enabled) |
177 ContextFactory::GetInstance()->RemoveCompositor(this); | 176 ContextFactory::GetInstance()->RemoveCompositor(this); |
178 } | 177 } |
179 | 178 |
180 void Compositor::Initialize(bool use_thread) { | 179 void Compositor::Initialize(bool use_thread) { |
181 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 180 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
181 WebKit::WebCompositorSupport* compositor_support = | |
182 WebKit::Platform::current()->compositorSupport(); | |
182 // These settings must be applied before we initialize the compositor. | 183 // These settings must be applied before we initialize the compositor. |
183 WebKit::WebCompositor::setPartialSwapEnabled( | 184 compositor_support->setPartialSwapEnabled( |
184 command_line->HasSwitch(switches::kUIEnablePartialSwap)); | 185 command_line->HasSwitch(switches::kUIEnablePartialSwap)); |
185 WebKit::WebCompositor::setPerTilePaintingEnabled( | 186 compositor_support->setPerTilePaintingEnabled( |
186 command_line->HasSwitch(switches::kUIEnablePerTilePainting)); | 187 command_line->HasSwitch(switches::kUIEnablePerTilePainting)); |
187 if (use_thread) | 188 if (use_thread) |
188 g_compositor_thread = new webkit_glue::WebThreadImpl("Browser Compositor"); | 189 g_compositor_thread = new webkit_glue::WebThreadImpl("Browser Compositor"); |
189 WebKit::WebCompositor::initialize(g_compositor_thread); | 190 compositor_support->initialize(g_compositor_thread); |
190 } | 191 } |
191 | 192 |
192 void Compositor::Terminate() { | 193 void Compositor::Terminate() { |
193 WebKit::WebCompositor::shutdown(); | 194 WebKit::Platform::current()->compositorSupport()->shutdown(); |
194 if (g_compositor_thread) { | 195 if (g_compositor_thread) { |
195 delete g_compositor_thread; | 196 delete g_compositor_thread; |
196 g_compositor_thread = NULL; | 197 g_compositor_thread = NULL; |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 void Compositor::ScheduleDraw() { | 201 void Compositor::ScheduleDraw() { |
201 if (g_compositor_thread) { | 202 if (g_compositor_thread) { |
202 // TODO(nduca): Temporary while compositor calls | 203 // TODO(nduca): Temporary while compositor calls |
203 // compositeImmediately() directly. | 204 // compositeImmediately() directly. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 test_compositor_enabled = true; | 456 test_compositor_enabled = true; |
456 } | 457 } |
457 #if defined(OS_CHROMEOS) | 458 #if defined(OS_CHROMEOS) |
458 // If the test is running on the chromeos envrionment (such as | 459 // If the test is running on the chromeos envrionment (such as |
459 // device or vm bots), use the real compositor. | 460 // device or vm bots), use the real compositor. |
460 if (base::chromeos::IsRunningOnChromeOS()) | 461 if (base::chromeos::IsRunningOnChromeOS()) |
461 test_compositor_enabled = false; | 462 test_compositor_enabled = false; |
462 #endif | 463 #endif |
463 } | 464 } |
464 | 465 |
465 COMPOSITOR_EXPORT void DisableTestCompositor() { | 466 COMPOSITOR_EXPORT void DisableTestCompositor() { |
Nico
2012/09/11 06:36:04
drive-by nit: we don't usually have _EXPORT macros
| |
466 test_compositor_enabled = false; | 467 test_compositor_enabled = false; |
467 } | 468 } |
468 | 469 |
469 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { | 470 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { |
470 return test_compositor_enabled; | 471 return test_compositor_enabled; |
471 } | 472 } |
472 | 473 |
473 } // namespace ui | 474 } // namespace ui |
OLD | NEW |