| 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 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 base::Thread* g_compositor_thread = NULL; | 48 base::Thread* g_compositor_thread = NULL; |
| 49 | 49 |
| 50 bool test_compositor_enabled = false; | 50 bool test_compositor_enabled = false; |
| 51 | 51 |
| 52 ui::ContextFactory* g_context_factory = NULL; | 52 ui::ContextFactory* g_context_factory = NULL; |
| 53 | 53 |
| 54 const int kCompositorLockTimeoutMs = 67; | 54 const int kCompositorLockTimeoutMs = 67; |
| 55 | 55 |
| 56 // Adapts a pure WebGraphicsContext3D into a cc::OutputSurface. | |
| 57 class WebGraphicsContextToOutputSurfaceAdapter | |
| 58 : public cc::OutputSurface { | |
| 59 public: | |
| 60 explicit WebGraphicsContextToOutputSurfaceAdapter( | |
| 61 WebKit::WebGraphicsContext3D* context) | |
| 62 : context3D_(context), | |
| 63 client_(NULL) { | |
| 64 } | |
| 65 | |
| 66 virtual bool BindToClient( | |
| 67 cc::OutputSurfaceClient* client) OVERRIDE { | |
| 68 DCHECK(client); | |
| 69 if (!context3D_->makeContextCurrent()) | |
| 70 return false; | |
| 71 client_ = client; | |
| 72 return true; | |
| 73 } | |
| 74 | |
| 75 virtual const struct Capabilities& Capabilities() const OVERRIDE { | |
| 76 return capabilities_; | |
| 77 } | |
| 78 | |
| 79 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE { | |
| 80 return context3D_.get(); | |
| 81 } | |
| 82 | |
| 83 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE { | |
| 84 return NULL; | |
| 85 } | |
| 86 | |
| 87 virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE { | |
| 88 } | |
| 89 | |
| 90 private: | |
| 91 scoped_ptr<WebKit::WebGraphicsContext3D> context3D_; | |
| 92 struct Capabilities capabilities_; | |
| 93 cc::OutputSurfaceClient* client_; | |
| 94 }; | |
| 95 | |
| 96 class PendingSwap { | 56 class PendingSwap { |
| 97 public: | 57 public: |
| 98 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); | 58 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); |
| 99 ~PendingSwap(); | 59 ~PendingSwap(); |
| 100 | 60 |
| 101 SwapType type() const { return type_; } | 61 SwapType type() const { return type_; } |
| 102 bool posted() const { return posted_; } | 62 bool posted() const { return posted_; } |
| 103 | 63 |
| 104 private: | 64 private: |
| 105 friend class ui::PostedSwapQueue; | 65 friend class ui::PostedSwapQueue; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (!gfx::GLSurface::InitializeOneOff() || | 108 if (!gfx::GLSurface::InitializeOneOff() || |
| 149 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { | 109 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { |
| 150 LOG(ERROR) << "Could not load the GL bindings"; | 110 LOG(ERROR) << "Could not load the GL bindings"; |
| 151 return false; | 111 return false; |
| 152 } | 112 } |
| 153 return true; | 113 return true; |
| 154 } | 114 } |
| 155 | 115 |
| 156 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( | 116 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( |
| 157 Compositor* compositor) { | 117 Compositor* compositor) { |
| 158 return new WebGraphicsContextToOutputSurfaceAdapter( | 118 return new cc::OutputSurface( |
| 159 CreateContextCommon(compositor, false)); | 119 make_scoped_ptr(CreateContextCommon(compositor, false))); |
| 160 } | 120 } |
| 161 | 121 |
| 162 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { | 122 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { |
| 163 return CreateContextCommon(NULL, true); | 123 return CreateContextCommon(NULL, true); |
| 164 } | 124 } |
| 165 | 125 |
| 166 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { | 126 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { |
| 167 } | 127 } |
| 168 | 128 |
| 169 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon( | 129 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon( |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 root_layer_->SendDamagedRects(); | 460 root_layer_->SendDamagedRects(); |
| 501 disable_schedule_composite_ = false; | 461 disable_schedule_composite_ = false; |
| 502 } | 462 } |
| 503 | 463 |
| 504 void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, | 464 void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, |
| 505 float pageScale) { | 465 float pageScale) { |
| 506 } | 466 } |
| 507 | 467 |
| 508 scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() { | 468 scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() { |
| 509 if (test_compositor_enabled) { | 469 if (test_compositor_enabled) { |
| 510 ui::TestWebGraphicsContext3D* test_context = | 470 scoped_ptr<ui::TestWebGraphicsContext3D> context3d( |
| 511 new ui::TestWebGraphicsContext3D(); | 471 new ui::TestWebGraphicsContext3D); |
| 512 test_context->Initialize(); | 472 context3d->Initialize(); |
| 513 return scoped_ptr<cc::OutputSurface>( | 473 return make_scoped_ptr(new cc::OutputSurface( |
| 514 new WebGraphicsContextToOutputSurfaceAdapter(test_context)); | 474 context3d.PassAs<WebKit::WebGraphicsContext3D>())); |
| 515 } else { | 475 } else { |
| 516 return scoped_ptr<cc::OutputSurface>( | 476 return make_scoped_ptr( |
| 517 ContextFactory::GetInstance()->CreateOutputSurface(this)); | 477 ContextFactory::GetInstance()->CreateOutputSurface(this)); |
| 518 } | 478 } |
| 519 } | 479 } |
| 520 | 480 |
| 521 void Compositor::didRecreateOutputSurface(bool success) { | 481 void Compositor::didRecreateOutputSurface(bool success) { |
| 522 } | 482 } |
| 523 | 483 |
| 524 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { | 484 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { |
| 525 return scoped_ptr<cc::InputHandler>(); | 485 return scoped_ptr<cc::InputHandler>(); |
| 526 } | 486 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 | 564 |
| 605 COMPOSITOR_EXPORT void DisableTestCompositor() { | 565 COMPOSITOR_EXPORT void DisableTestCompositor() { |
| 606 test_compositor_enabled = false; | 566 test_compositor_enabled = false; |
| 607 } | 567 } |
| 608 | 568 |
| 609 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { | 569 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { |
| 610 return test_compositor_enabled; | 570 return test_compositor_enabled; |
| 611 } | 571 } |
| 612 | 572 |
| 613 } // namespace ui | 573 } // namespace ui |
| OLD | NEW |