Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: ui/compositor/compositor.cc

Issue 12041062: Have a common implementation of cc::OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 }; 45 };
46 46
47 base::Thread* g_compositor_thread = NULL; 47 base::Thread* g_compositor_thread = NULL;
48 48
49 bool g_test_compositor_enabled = false; 49 bool g_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 cc::OutputSurface.
56 class WebGraphicsContextToOutputSurfaceAdapter
57 : public cc::OutputSurface {
58 public:
59 explicit WebGraphicsContextToOutputSurfaceAdapter(
60 WebKit::WebGraphicsContext3D* context)
61 : context3D_(context),
62 client_(NULL) {
63 }
64
65 virtual bool BindToClient(
66 cc::OutputSurfaceClient* client) OVERRIDE {
67 DCHECK(client);
68 if (!context3D_->makeContextCurrent())
69 return false;
70 client_ = client;
71 return true;
72 }
73
74 virtual const struct Capabilities& Capabilities() const OVERRIDE {
75 return capabilities_;
76 }
77
78 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE {
79 return context3D_.get();
80 }
81
82 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE {
83 return NULL;
84 }
85
86 virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE {
87 }
88
89 private:
90 scoped_ptr<WebKit::WebGraphicsContext3D> context3D_;
91 struct Capabilities capabilities_;
92 cc::OutputSurfaceClient* client_;
93 };
94
95 class PendingSwap { 55 class PendingSwap {
96 public: 56 public:
97 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); 57 PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps);
98 ~PendingSwap(); 58 ~PendingSwap();
99 59
100 SwapType type() const { return type_; } 60 SwapType type() const { return type_; }
101 bool posted() const { return posted_; } 61 bool posted() const { return posted_; }
102 62
103 private: 63 private:
104 friend class ui::PostedSwapQueue; 64 friend class ui::PostedSwapQueue;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (!gfx::GLSurface::InitializeOneOff() || 107 if (!gfx::GLSurface::InitializeOneOff() ||
148 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { 108 gfx::GetGLImplementation() == gfx::kGLImplementationNone) {
149 LOG(ERROR) << "Could not load the GL bindings"; 109 LOG(ERROR) << "Could not load the GL bindings";
150 return false; 110 return false;
151 } 111 }
152 return true; 112 return true;
153 } 113 }
154 114
155 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( 115 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface(
156 Compositor* compositor) { 116 Compositor* compositor) {
157 return new WebGraphicsContextToOutputSurfaceAdapter( 117 return new cc::OutputSurface(
158 CreateContextCommon(compositor, false)); 118 make_scoped_ptr(CreateContextCommon(compositor, false)));
159 } 119 }
160 120
161 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { 121 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() {
162 return CreateContextCommon(NULL, true); 122 return CreateContextCommon(NULL, true);
163 } 123 }
164 124
165 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { 125 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
166 } 126 }
167 127
168 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon( 128 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon(
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 root_layer_->SendDamagedRects(); 459 root_layer_->SendDamagedRects();
500 disable_schedule_composite_ = false; 460 disable_schedule_composite_ = false;
501 } 461 }
502 462
503 void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, 463 void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta,
504 float pageScale) { 464 float pageScale) {
505 } 465 }
506 466
507 scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() { 467 scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() {
508 if (g_test_compositor_enabled) { 468 if (g_test_compositor_enabled) {
509 ui::TestWebGraphicsContext3D* test_context = 469 scoped_ptr<ui::TestWebGraphicsContext3D> context3d(
510 new ui::TestWebGraphicsContext3D(); 470 new ui::TestWebGraphicsContext3D);
511 test_context->Initialize(); 471 context3d->Initialize();
512 return scoped_ptr<cc::OutputSurface>( 472 return make_scoped_ptr(new cc::OutputSurface(
513 new WebGraphicsContextToOutputSurfaceAdapter(test_context)); 473 context3d.PassAs<WebKit::WebGraphicsContext3D>()));
514 } else { 474 } else {
515 return scoped_ptr<cc::OutputSurface>( 475 return make_scoped_ptr(
516 ContextFactory::GetInstance()->CreateOutputSurface(this)); 476 ContextFactory::GetInstance()->CreateOutputSurface(this));
517 } 477 }
518 } 478 }
519 479
520 void Compositor::didRecreateOutputSurface(bool success) { 480 void Compositor::didRecreateOutputSurface(bool success) {
521 } 481 }
522 482
523 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { 483 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() {
524 return scoped_ptr<cc::InputHandler>(); 484 return scoped_ptr<cc::InputHandler>();
525 } 485 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 559
600 COMPOSITOR_EXPORT void DisableTestCompositor() { 560 COMPOSITOR_EXPORT void DisableTestCompositor() {
601 g_test_compositor_enabled = false; 561 g_test_compositor_enabled = false;
602 } 562 }
603 563
604 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 564 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
605 return g_test_compositor_enabled; 565 return g_test_compositor_enabled;
606 } 566 }
607 567
608 } // namespace ui 568 } // namespace ui
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_output_surface.cc ('k') | webkit/compositor_bindings/compositor_bindings.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698