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

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

Issue 1356463002: Revert of cc: Implement shared worker contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 frame_swap_message_queue_(swap_frame_message_queue), 43 frame_swap_message_queue_(swap_frame_message_queue),
44 routing_id_(routing_id), 44 routing_id_(routing_id),
45 #if defined(OS_ANDROID) 45 #if defined(OS_ANDROID)
46 prefers_smoothness_(false), 46 prefers_smoothness_(false),
47 main_thread_runner_(base::MessageLoop::current()->task_runner()), 47 main_thread_runner_(base::MessageLoop::current()->task_runner()),
48 #endif 48 #endif
49 layout_test_mode_(RenderThreadImpl::current()->layout_test_mode()), 49 layout_test_mode_(RenderThreadImpl::current()->layout_test_mode()),
50 weak_ptrs_(this) { 50 weak_ptrs_(this) {
51 DCHECK(output_surface_filter_.get()); 51 DCHECK(output_surface_filter_.get());
52 DCHECK(frame_swap_message_queue_.get()); 52 DCHECK(frame_swap_message_queue_.get());
53 DetachFromThread();
53 capabilities_.max_frames_pending = 1; 54 capabilities_.max_frames_pending = 1;
54 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); 55 message_sender_ = RenderThreadImpl::current()->sync_message_filter();
55 DCHECK(message_sender_.get()); 56 DCHECK(message_sender_.get());
56 } 57 }
57 58
58 CompositorOutputSurface::~CompositorOutputSurface() {} 59 CompositorOutputSurface::~CompositorOutputSurface() {
60 DCHECK(CalledOnValidThread());
61 if (!HasClient())
62 return;
63 UpdateSmoothnessTakesPriority(false);
64 if (output_surface_proxy_.get())
65 output_surface_proxy_->ClearOutputSurface();
66 output_surface_filter_->RemoveHandlerOnCompositorThread(
67 routing_id_,
68 output_surface_filter_handler_);
69 }
59 70
60 bool CompositorOutputSurface::BindToClient( 71 bool CompositorOutputSurface::BindToClient(
61 cc::OutputSurfaceClient* client) { 72 cc::OutputSurfaceClient* client) {
73 DCHECK(CalledOnValidThread());
74
62 if (!cc::OutputSurface::BindToClient(client)) 75 if (!cc::OutputSurface::BindToClient(client))
63 return false; 76 return false;
64 77
65 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); 78 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this);
66 output_surface_filter_handler_ = 79 output_surface_filter_handler_ =
67 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, 80 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived,
68 output_surface_proxy_); 81 output_surface_proxy_);
69 output_surface_filter_->AddHandlerOnCompositorThread( 82 output_surface_filter_->AddHandlerOnCompositorThread(
70 routing_id_, 83 routing_id_,
71 output_surface_filter_handler_); 84 output_surface_filter_handler_);
72 85
73 if (!context_provider()) { 86 if (!context_provider()) {
74 // Without a GPU context, the memory policy otherwise wouldn't be set. 87 // Without a GPU context, the memory policy otherwise wouldn't be set.
75 client->SetMemoryPolicy(cc::ManagedMemoryPolicy( 88 client->SetMemoryPolicy(cc::ManagedMemoryPolicy(
76 128 * 1024 * 1024, 89 128 * 1024 * 1024,
77 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 90 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
78 base::SharedMemory::GetHandleLimit() / 3)); 91 base::SharedMemory::GetHandleLimit() / 3));
79 } 92 }
80 93
81 return true; 94 return true;
82 } 95 }
83 96
84 void CompositorOutputSurface::DetachFromClient() {
85 if (!HasClient())
86 return;
87 UpdateSmoothnessTakesPriority(false);
88 if (output_surface_proxy_.get())
89 output_surface_proxy_->ClearOutputSurface();
90 output_surface_filter_->RemoveHandlerOnCompositorThread(
91 routing_id_, output_surface_filter_handler_);
92 cc::OutputSurface::DetachFromClient();
93 }
94
95 void CompositorOutputSurface::ShortcutSwapAck( 97 void CompositorOutputSurface::ShortcutSwapAck(
96 uint32 output_surface_id, 98 uint32 output_surface_id,
97 scoped_ptr<cc::GLFrameData> gl_frame_data) { 99 scoped_ptr<cc::GLFrameData> gl_frame_data) {
98 if (!layout_test_previous_frame_ack_) { 100 if (!layout_test_previous_frame_ack_) {
99 layout_test_previous_frame_ack_.reset(new cc::CompositorFrameAck); 101 layout_test_previous_frame_ack_.reset(new cc::CompositorFrameAck);
100 layout_test_previous_frame_ack_->gl_frame_data.reset(new cc::GLFrameData); 102 layout_test_previous_frame_ack_->gl_frame_data.reset(new cc::GLFrameData);
101 } 103 }
102 104
103 OnSwapAck(output_surface_id, *layout_test_previous_frame_ack_); 105 OnSwapAck(output_surface_id, *layout_test_previous_frame_ack_);
104 106
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 output_surface_id_, 149 output_surface_id_,
148 *frame, 150 *frame,
149 messages_to_deliver_with_frame)); 151 messages_to_deliver_with_frame));
150 // ~send_message_scope. 152 // ~send_message_scope.
151 } 153 }
152 client_->DidSwapBuffers(); 154 client_->DidSwapBuffers();
153 } 155 }
154 } 156 }
155 157
156 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 158 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
157 DCHECK(client_thread_checker_.CalledOnValidThread()); 159 DCHECK(CalledOnValidThread());
158 if (!HasClient()) 160 if (!HasClient())
159 return; 161 return;
160 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 162 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
161 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, 163 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters,
162 OnUpdateVSyncParametersFromBrowser); 164 OnUpdateVSyncParametersFromBrowser);
163 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); 165 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
164 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); 166 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources);
165 IPC_END_MESSAGE_MAP() 167 IPC_END_MESSAGE_MAP()
166 } 168 }
167 169
168 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( 170 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser(
169 base::TimeTicks timebase, 171 base::TimeTicks timebase,
170 base::TimeDelta interval) { 172 base::TimeDelta interval) {
171 DCHECK(client_thread_checker_.CalledOnValidThread()); 173 DCHECK(CalledOnValidThread());
172 CommitVSyncParameters(timebase, interval); 174 CommitVSyncParameters(timebase, interval);
173 } 175 }
174 176
175 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, 177 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id,
176 const cc::CompositorFrameAck& ack) { 178 const cc::CompositorFrameAck& ack) {
177 // Ignore message if it's a stale one coming from a different output surface 179 // Ignore message if it's a stale one coming from a different output surface
178 // (e.g. after a lost context). 180 // (e.g. after a lost context).
179 if (output_surface_id != output_surface_id_) 181 if (output_surface_id != output_surface_id_)
180 return; 182 return;
181 ReclaimResources(&ack); 183 ReclaimResources(&ack);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 main_thread_runner_->PostTask(FROM_HERE, 220 main_thread_runner_->PostTask(FROM_HERE,
219 base::Bind(&SetThreadPriorityToIdle)); 221 base::Bind(&SetThreadPriorityToIdle));
220 } else { 222 } else {
221 main_thread_runner_->PostTask(FROM_HERE, 223 main_thread_runner_->PostTask(FROM_HERE,
222 base::Bind(&SetThreadPriorityToDefault)); 224 base::Bind(&SetThreadPriorityToDefault));
223 } 225 }
224 #endif 226 #endif
225 } 227 }
226 228
227 } // namespace content 229 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_output_surface.h ('k') | content/renderer/gpu/mailbox_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698