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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "cc/font_atlas.h" | 15 #include "cc/font_atlas.h" |
16 #include "cc/input_handler.h" | 16 #include "cc/input_handler.h" |
17 #include "cc/layer.h" | 17 #include "cc/layer.h" |
18 #include "cc/layer_tree_host.h" | 18 #include "cc/layer_tree_host.h" |
| 19 #include "cc/output_surface.h" |
19 #include "cc/thread_impl.h" | 20 #include "cc/thread_impl.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput
Surface.h" | |
22 #include "ui/compositor/compositor_observer.h" | 22 #include "ui/compositor/compositor_observer.h" |
23 #include "ui/compositor/compositor_switches.h" | 23 #include "ui/compositor/compositor_switches.h" |
24 #include "ui/compositor/dip_util.h" | 24 #include "ui/compositor/dip_util.h" |
25 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
26 #include "ui/compositor/test_web_graphics_context_3d.h" | 26 #include "ui/compositor/test_web_graphics_context_3d.h" |
27 #include "ui/gl/gl_context.h" | 27 #include "ui/gl/gl_context.h" |
28 #include "ui/gl/gl_implementation.h" | 28 #include "ui/gl/gl_implementation.h" |
29 #include "ui/gl/gl_surface.h" | 29 #include "ui/gl/gl_surface.h" |
30 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
31 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 31 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
(...skipping 13 matching lines...) Expand all Loading... |
45 }; | 45 }; |
46 | 46 |
47 base::Thread* g_compositor_thread = NULL; | 47 base::Thread* g_compositor_thread = NULL; |
48 | 48 |
49 bool test_compositor_enabled = false; | 49 bool test_compositor_enabled = false; |
50 | 50 |
51 ui::ContextFactory* g_context_factory = NULL; | 51 ui::ContextFactory* g_context_factory = NULL; |
52 | 52 |
53 const int kCompositorLockTimeoutMs = 67; | 53 const int kCompositorLockTimeoutMs = 67; |
54 | 54 |
55 // Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface. | 55 // Adapts a pure WebGraphicsContext3D into a cc::OutputSurface. |
56 class WebGraphicsContextToOutputSurfaceAdapter | 56 class WebGraphicsContextToOutputSurfaceAdapter |
57 : public WebKit::WebCompositorOutputSurface { | 57 : public cc::OutputSurface { |
58 public: | 58 public: |
59 explicit WebGraphicsContextToOutputSurfaceAdapter( | 59 explicit WebGraphicsContextToOutputSurfaceAdapter( |
60 WebKit::WebGraphicsContext3D* context) | 60 WebKit::WebGraphicsContext3D* context) |
61 : context3D_(context), | 61 : context3D_(context), |
62 client_(NULL) { | 62 client_(NULL) { |
63 } | 63 } |
64 | 64 |
65 virtual bool bindToClient( | 65 virtual bool BindToClient( |
66 WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE { | 66 cc::OutputSurfaceClient* client) OVERRIDE { |
67 DCHECK(client); | 67 DCHECK(client); |
68 if (!context3D_->makeContextCurrent()) | 68 if (!context3D_->makeContextCurrent()) |
69 return false; | 69 return false; |
70 client_ = client; | 70 client_ = client; |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 virtual const Capabilities& capabilities() const OVERRIDE { | 74 virtual const struct Capabilities& Capabilities() const OVERRIDE { |
75 return capabilities_; | 75 return capabilities_; |
76 } | 76 } |
77 | 77 |
78 virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE { | 78 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE { |
79 return context3D_.get(); | 79 return context3D_.get(); |
80 } | 80 } |
81 | 81 |
82 virtual void sendFrameToParentCompositor( | 82 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE { |
83 const WebKit::WebCompositorFrame&) OVERRIDE { | 83 return NULL; |
| 84 } |
| 85 |
| 86 virtual void SendFrameToParentCompositor( |
| 87 const cc::CompositorFrame&) OVERRIDE { |
84 } | 88 } |
85 | 89 |
86 private: | 90 private: |
87 scoped_ptr<WebKit::WebGraphicsContext3D> context3D_; | 91 scoped_ptr<WebKit::WebGraphicsContext3D> context3D_; |
88 Capabilities capabilities_; | 92 struct Capabilities capabilities_; |
89 WebKit::WebCompositorOutputSurfaceClient* client_; | 93 cc::OutputSurfaceClient* client_; |
90 }; | 94 }; |
91 | 95 |
92 class PendingSwap { | 96 class PendingSwap { |
93 public: | 97 public: |
94 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); | 98 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); |
95 ~PendingSwap(); | 99 ~PendingSwap(); |
96 | 100 |
97 SwapType type() const { return type_; } | 101 SwapType type() const { return type_; } |
98 bool posted() const { return posted_; } | 102 bool posted() const { return posted_; } |
99 | 103 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. | 146 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. |
143 base::ThreadRestrictions::ScopedAllowIO allow_io; | 147 base::ThreadRestrictions::ScopedAllowIO allow_io; |
144 if (!gfx::GLSurface::InitializeOneOff() || | 148 if (!gfx::GLSurface::InitializeOneOff() || |
145 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { | 149 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { |
146 LOG(ERROR) << "Could not load the GL bindings"; | 150 LOG(ERROR) << "Could not load the GL bindings"; |
147 return false; | 151 return false; |
148 } | 152 } |
149 return true; | 153 return true; |
150 } | 154 } |
151 | 155 |
152 WebKit::WebCompositorOutputSurface* DefaultContextFactory::CreateOutputSurface( | 156 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( |
153 Compositor* compositor) { | 157 Compositor* compositor) { |
154 return new WebGraphicsContextToOutputSurfaceAdapter( | 158 return new WebGraphicsContextToOutputSurfaceAdapter( |
155 CreateContextCommon(compositor, false)); | 159 CreateContextCommon(compositor, false)); |
156 } | 160 } |
157 | 161 |
158 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { | 162 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { |
159 return CreateContextCommon(NULL, true); | 163 return CreateContextCommon(NULL, true); |
160 } | 164 } |
161 | 165 |
162 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { | 166 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 disable_schedule_composite_ = true; | 494 disable_schedule_composite_ = true; |
491 if (root_layer_) | 495 if (root_layer_) |
492 root_layer_->SendDamagedRects(); | 496 root_layer_->SendDamagedRects(); |
493 disable_schedule_composite_ = false; | 497 disable_schedule_composite_ = false; |
494 } | 498 } |
495 | 499 |
496 void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, | 500 void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, |
497 float pageScale) { | 501 float pageScale) { |
498 } | 502 } |
499 | 503 |
500 scoped_ptr<WebKit::WebCompositorOutputSurface> | 504 scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() { |
501 Compositor::createOutputSurface() { | |
502 if (test_compositor_enabled) { | 505 if (test_compositor_enabled) { |
503 ui::TestWebGraphicsContext3D* test_context = | 506 ui::TestWebGraphicsContext3D* test_context = |
504 new ui::TestWebGraphicsContext3D(); | 507 new ui::TestWebGraphicsContext3D(); |
505 test_context->Initialize(); | 508 test_context->Initialize(); |
506 return scoped_ptr<WebKit::WebCompositorOutputSurface>( | 509 return scoped_ptr<cc::OutputSurface>( |
507 new WebGraphicsContextToOutputSurfaceAdapter(test_context)); | 510 new WebGraphicsContextToOutputSurfaceAdapter(test_context)); |
508 } else { | 511 } else { |
509 return scoped_ptr<WebKit::WebCompositorOutputSurface>( | 512 return scoped_ptr<cc::OutputSurface>( |
510 ContextFactory::GetInstance()->CreateOutputSurface(this)); | 513 ContextFactory::GetInstance()->CreateOutputSurface(this)); |
511 } | 514 } |
512 } | 515 } |
513 | 516 |
514 void Compositor::didRecreateOutputSurface(bool success) { | 517 void Compositor::didRecreateOutputSurface(bool success) { |
515 } | 518 } |
516 | 519 |
517 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { | 520 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { |
518 return scoped_ptr<cc::InputHandler>(); | 521 return scoped_ptr<cc::InputHandler>(); |
519 } | 522 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 600 |
598 COMPOSITOR_EXPORT void DisableTestCompositor() { | 601 COMPOSITOR_EXPORT void DisableTestCompositor() { |
599 test_compositor_enabled = false; | 602 test_compositor_enabled = false; |
600 } | 603 } |
601 | 604 |
602 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { | 605 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { |
603 return test_compositor_enabled; | 606 return test_compositor_enabled; |
604 } | 607 } |
605 | 608 |
606 } // namespace ui | 609 } // namespace ui |
OLD | NEW |