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

Side by Side Diff: content/renderer/gpu/compositor_output_surface.cc

Issue 12041062: Have a common implementation of cc::OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 "content/renderer/gpu/compositor_output_surface.h" 5 #include "content/renderer/gpu/compositor_output_surface.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "cc/compositor_frame.h" 8 #include "cc/compositor_frame.h"
9 #include "cc/output_surface_client.h" 9 #include "cc/output_surface_client.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 18 matching lines...) Expand all
29 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; 29 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID};
30 return new IPC::ForwardingMessageFilter( 30 return new IPC::ForwardingMessageFilter(
31 messages_to_filter, arraysize(messages_to_filter), 31 messages_to_filter, arraysize(messages_to_filter),
32 target_task_runner); 32 target_task_runner);
33 } 33 }
34 34
35 CompositorOutputSurface::CompositorOutputSurface( 35 CompositorOutputSurface::CompositorOutputSurface(
36 int32 routing_id, 36 int32 routing_id,
37 WebGraphicsContext3D* context3D, 37 WebGraphicsContext3D* context3D,
38 cc::SoftwareOutputDevice* software_device) 38 cc::SoftwareOutputDevice* software_device)
39 : output_surface_filter_( 39 : OutputSurface(make_scoped_ptr(context3D),
40 make_scoped_ptr(software_device)),
41 output_surface_filter_(
40 RenderThreadImpl::current()->compositor_output_surface_filter()), 42 RenderThreadImpl::current()->compositor_output_surface_filter()),
41 client_(NULL), 43 routing_id_(routing_id) {
42 routing_id_(routing_id),
43 context3D_(context3D),
44 software_device_(software_device) {
45 DCHECK(output_surface_filter_); 44 DCHECK(output_surface_filter_);
46 capabilities_.has_parent_compositor = false; 45 capabilities_.has_parent_compositor = false;
47 DetachFromThread(); 46 DetachFromThread();
48 } 47 }
49 48
50 CompositorOutputSurface::~CompositorOutputSurface() { 49 CompositorOutputSurface::~CompositorOutputSurface() {
51 DCHECK(CalledOnValidThread()); 50 DCHECK(CalledOnValidThread());
52 if (!client_) 51 if (!client_)
53 return; 52 return;
54 output_surface_proxy_->ClearOutputSurface(); 53 output_surface_proxy_->ClearOutputSurface();
55 output_surface_filter_->RemoveRoute(routing_id_); 54 output_surface_filter_->RemoveRoute(routing_id_);
56 } 55 }
57 56
58 const struct cc::OutputSurface::Capabilities&
59 CompositorOutputSurface::Capabilities() const {
60 DCHECK(CalledOnValidThread());
61 return capabilities_;
62 }
63
64 bool CompositorOutputSurface::BindToClient( 57 bool CompositorOutputSurface::BindToClient(
65 cc::OutputSurfaceClient* client) { 58 cc::OutputSurfaceClient* client) {
66 DCHECK(CalledOnValidThread()); 59 DCHECK(CalledOnValidThread());
67 DCHECK(!client_);
68 if (context3D_.get()) {
69 if (!context3D_->makeContextCurrent())
70 return false;
71 }
72 60
73 client_ = client; 61 if (!cc::OutputSurface::BindToClient(client))
62 return false;
74 63
75 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); 64 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this);
76 output_surface_filter_->AddRoute( 65 output_surface_filter_->AddRoute(
77 routing_id_, 66 routing_id_,
78 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, 67 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived,
79 output_surface_proxy_)); 68 output_surface_proxy_));
80 69
81 return true; 70 return true;
82 } 71 }
83 72
84 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const {
85 DCHECK(CalledOnValidThread());
86 return context3D_.get();
87 }
88
89 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const {
90 return software_device_.get();
91 }
92
93 void CompositorOutputSurface::SendFrameToParentCompositor( 73 void CompositorOutputSurface::SendFrameToParentCompositor(
94 cc::CompositorFrame* frame) { 74 cc::CompositorFrame* frame) {
95 DCHECK(CalledOnValidThread()); 75 DCHECK(CalledOnValidThread());
96 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); 76 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame));
97 } 77 }
98 78
99 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 79 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
100 DCHECK(CalledOnValidThread()); 80 DCHECK(CalledOnValidThread());
101 if (!client_) 81 if (!client_)
102 return; 82 return;
103 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 83 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
104 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); 84 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
105 IPC_END_MESSAGE_MAP() 85 IPC_END_MESSAGE_MAP()
106 } 86 }
107 87
108 void CompositorOutputSurface::OnUpdateVSyncParameters( 88 void CompositorOutputSurface::OnUpdateVSyncParameters(
109 base::TimeTicks timebase, base::TimeDelta interval) { 89 base::TimeTicks timebase, base::TimeDelta interval) {
110 DCHECK(CalledOnValidThread()); 90 DCHECK(CalledOnValidThread());
111 DCHECK(client_); 91 DCHECK(client_);
112 client_->OnVSyncParametersChanged(timebase, interval); 92 client_->OnVSyncParametersChanged(timebase, interval);
113 } 93 }
114 94
115 bool CompositorOutputSurface::Send(IPC::Message* message) { 95 bool CompositorOutputSurface::Send(IPC::Message* message) {
116 return ChildThread::current()->sync_message_filter()->Send(message); 96 return ChildThread::current()->sync_message_filter()->Send(message);
117 } 97 }
118 98
119 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698