Chromium Code Reviews| 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 "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/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 54 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 55 scoped_ptr<cc::SoftwareOutputDevice> software_device, | 55 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
| 56 bool use_swap_compositor_frame_message) | 56 bool use_swap_compositor_frame_message) |
| 57 : OutputSurface(context_provider, software_device.Pass()), | 57 : OutputSurface(context_provider, software_device.Pass()), |
| 58 output_surface_id_(output_surface_id), | 58 output_surface_id_(output_surface_id), |
| 59 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), | 59 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), |
| 60 output_surface_filter_( | 60 output_surface_filter_( |
| 61 RenderThreadImpl::current()->compositor_output_surface_filter()), | 61 RenderThreadImpl::current()->compositor_output_surface_filter()), |
| 62 routing_id_(routing_id), | 62 routing_id_(routing_id), |
| 63 prefers_smoothness_(false), | 63 prefers_smoothness_(false), |
| 64 layout_test_mode_(RenderThreadImpl::current()->layout_test_mode()), | |
| 64 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 65 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. | 66 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. |
| 66 main_thread_handle_(base::PlatformThreadHandle()) | 67 main_thread_handle_(base::PlatformThreadHandle()) |
| 67 #else | 68 #else |
| 68 main_thread_handle_(base::PlatformThread::CurrentHandle()) | 69 main_thread_handle_(base::PlatformThread::CurrentHandle()) |
| 69 #endif | 70 #endif |
| 70 { | 71 { |
| 71 DCHECK(output_surface_filter_.get()); | 72 DCHECK(output_surface_filter_.get()); |
| 72 DetachFromThread(); | 73 DetachFromThread(); |
| 73 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); | 74 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 104 // Without a GPU context, the memory policy otherwise wouldn't be set. | 105 // Without a GPU context, the memory policy otherwise wouldn't be set. |
| 105 client->SetMemoryPolicy(cc::ManagedMemoryPolicy( | 106 client->SetMemoryPolicy(cc::ManagedMemoryPolicy( |
| 106 64 * 1024 * 1024, | 107 64 * 1024 * 1024, |
| 107 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 108 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 108 cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit)); | 109 cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit)); |
| 109 } | 110 } |
| 110 | 111 |
| 111 return true; | 112 return true; |
| 112 } | 113 } |
| 113 | 114 |
| 115 void CompositorOutputSurface::ShortcutSwapAck( | |
| 116 int output_surface_id, | |
| 117 scoped_ptr<cc::CompositorFrameAck> ack) { | |
| 118 ReclaimResources(ack.get()); | |
| 119 OnSwapBuffersComplete(); | |
| 120 } | |
| 121 | |
| 114 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 122 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| 123 if (layout_test_mode_) { | |
| 124 // This code path is here to support layout tests that are currently | |
| 125 // doing a readback in the renderer instead of the browser. So they | |
| 126 // are using deprecated code paths in the renderer and don't need to | |
| 127 // actually swap anything to the browser. We shortcut the swap to the | |
| 128 // browser here and just ack directly within the renderer process. | |
| 129 // Once crbug.com/311404 is fixed, this can be removed. | |
| 130 DCHECK(use_swap_compositor_frame_message_); | |
| 131 DidSwapBuffers(); | |
| 132 | |
| 133 // This would indicate that crbug.com/311404 is being fixed, and this | |
| 134 // block needs to be removed. | |
| 135 DCHECK(!frame->delegated_frame_data); | |
| 136 | |
| 137 scoped_ptr<cc::CompositorFrameAck> ack(new cc::CompositorFrameAck); | |
| 138 if (frame->gl_frame_data) | |
| 139 ack->gl_frame_data = frame->gl_frame_data.Pass(); | |
| 140 if (frame->software_frame_data) | |
| 141 ack->last_software_frame_id = frame->software_frame_data->id; | |
| 142 base::MessageLoopProxy::current()->PostTask( | |
| 143 FROM_HERE, | |
| 144 base::Bind(&CompositorOutputSurface::ShortcutSwapAck, | |
| 145 base::Unretained(this), | |
|
piman
2014/02/07 21:51:24
Is this Unretained safe?
danakj
2014/02/07 21:58:44
I *think* so, cuz I'm not seeing crashes on layout
piman
2014/02/07 23:07:17
I don't see anything that would guarantee it.
On s
danakj
2014/02/08 00:55:32
ok! done.
| |
| 146 output_surface_id_, | |
|
piman
2014/02/07 21:51:24
nit: You're not using this AFAICT
danakj
2014/02/07 21:58:44
Oh, ya. I was passing this to the OnSwapAck() but
| |
| 147 base::Passed(&ack))); | |
| 148 return; | |
| 149 } | |
| 150 | |
| 115 if (use_swap_compositor_frame_message_) { | 151 if (use_swap_compositor_frame_message_) { |
| 116 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, | 152 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, |
| 117 output_surface_id_, | 153 output_surface_id_, |
| 118 *frame)); | 154 *frame)); |
| 119 DidSwapBuffers(); | 155 DidSwapBuffers(); |
| 120 return; | 156 return; |
| 121 } | 157 } |
| 122 | 158 |
| 123 if (frame->gl_frame_data) { | 159 if (frame->gl_frame_data) { |
| 124 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); | 160 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 // If this is the last surface to stop preferring smoothness, | 262 // If this is the last surface to stop preferring smoothness, |
| 227 // Reset the main thread's priority to the default. | 263 // Reset the main thread's priority to the default. |
| 228 if (prefers_smoothness_ == true && | 264 if (prefers_smoothness_ == true && |
| 229 --g_prefer_smoothness_count == 0) { | 265 --g_prefer_smoothness_count == 0) { |
| 230 SetThreadPriorityToDefault(main_thread_handle_); | 266 SetThreadPriorityToDefault(main_thread_handle_); |
| 231 } | 267 } |
| 232 prefers_smoothness_ = prefers_smoothness; | 268 prefers_smoothness_ = prefers_smoothness; |
| 233 } | 269 } |
| 234 | 270 |
| 235 } // namespace content | 271 } // namespace content |
| OLD | NEW |