Chromium Code Reviews| 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/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" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 void CompositorCC::OnRootLayerChanged() { | 211 void CompositorCC::OnRootLayerChanged() { |
| 212 root_web_layer_.removeAllChildren(); | 212 root_web_layer_.removeAllChildren(); |
| 213 if (root_layer()) | 213 if (root_layer()) |
| 214 root_web_layer_.addChild(root_layer()->web_layer()); | 214 root_web_layer_.addChild(root_layer()->web_layer()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CompositorCC::DrawTree() { | 217 void CompositorCC::DrawTree() { |
| 218 host_.composite(); | 218 host_.composite(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool CompositorCC::CompositesAsynchronously() { | |
| 222 return g_compositor_thread; | |
| 223 } | |
| 224 | |
| 221 bool CompositorCC::ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds) { | 225 bool CompositorCC::ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds) { |
| 222 if (bounds.right() > size().width() || bounds.bottom() > size().height()) | 226 if (bounds.right() > size().width() || bounds.bottom() > size().height()) |
| 223 return false; | 227 return false; |
| 224 // Convert to OpenGL coordinates. | 228 // Convert to OpenGL coordinates. |
| 225 gfx::Point new_origin(bounds.x(), | 229 gfx::Point new_origin(bounds.x(), |
| 226 size().height() - bounds.height() - bounds.y()); | 230 size().height() - bounds.height() - bounds.y()); |
| 227 | 231 |
| 228 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 232 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
| 229 bounds.width(), bounds.height()); | 233 bounds.width(), bounds.height()); |
| 230 bitmap->allocPixels(); | 234 bitmap->allocPixels(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 if (!command_line->HasSwitch(switches::kDisableUIVsync)) { | 270 if (!command_line->HasSwitch(switches::kDisableUIVsync)) { |
| 267 context->makeContextCurrent(); | 271 context->makeContextCurrent(); |
| 268 gfx::GLContext* gl_context = gfx::GLContext::GetCurrent(); | 272 gfx::GLContext* gl_context = gfx::GLContext::GetCurrent(); |
| 269 gl_context->SetSwapInterval(1); | 273 gl_context->SetSwapInterval(1); |
| 270 gl_context->ReleaseCurrent(NULL); | 274 gl_context->ReleaseCurrent(NULL); |
| 271 } | 275 } |
| 272 | 276 |
| 273 return context; | 277 return context; |
| 274 } | 278 } |
| 275 | 279 |
| 280 void CompositorCC::didCompleteSwapBuffers() { | |
| 281 NotifyEnd(); | |
|
piman
2012/01/06 17:22:54
nit: indent
| |
| 282 } | |
| 283 | |
| 276 void CompositorCC::didRebindGraphicsContext(bool success) { | 284 void CompositorCC::didRebindGraphicsContext(bool success) { |
| 277 } | 285 } |
| 278 | 286 |
| 279 void CompositorCC::scheduleComposite() { | 287 void CompositorCC::scheduleComposite() { |
| 280 ScheduleDraw(); | 288 ScheduleDraw(); |
| 281 } | 289 } |
| 282 | 290 |
| 283 Compositor* Compositor::Create(CompositorDelegate* owner, | 291 Compositor* Compositor::Create(CompositorDelegate* owner, |
| 284 gfx::AcceleratedWidget widget, | 292 gfx::AcceleratedWidget widget, |
| 285 const gfx::Size& size) { | 293 const gfx::Size& size) { |
| 286 return new CompositorCC(owner, widget, size); | 294 return new CompositorCC(owner, widget, size); |
| 287 } | 295 } |
| 288 | 296 |
| 289 COMPOSITOR_EXPORT void SetupTestCompositor() { | 297 COMPOSITOR_EXPORT void SetupTestCompositor() { |
| 290 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 298 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 291 switches::kDisableTestCompositor)) { | 299 switches::kDisableTestCompositor)) { |
| 292 test_compositor_enabled = true; | 300 test_compositor_enabled = true; |
| 293 } | 301 } |
| 294 } | 302 } |
| 295 | 303 |
| 296 COMPOSITOR_EXPORT void DisableTestCompositor() { | 304 COMPOSITOR_EXPORT void DisableTestCompositor() { |
| 297 test_compositor_enabled = false; | 305 test_compositor_enabled = false; |
| 298 } | 306 } |
| 299 | 307 |
| 300 } // namespace ui | 308 } // namespace ui |
| OLD | NEW |