Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/android/in_process/synchronous_compositor_output_surfa ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
| 12 #include "cc/output/output_surface_client.h" | 12 #include "cc/output/output_surface_client.h" |
| 13 #include "cc/output/software_output_device.h" | 13 #include "cc/output/software_output_device.h" |
| 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/render_process_host.h" | |
| 17 #include "content/renderer/gpu/frame_swap_message_queue.h" | |
| 16 #include "gpu/command_buffer/client/gles2_interface.h" | 18 #include "gpu/command_buffer/client/gles2_interface.h" |
| 17 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 20 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
| 20 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 21 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 22 | 24 |
| 23 namespace content { | 25 namespace content { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 29 content::RenderProcessHost* GetInProcessRenderer() { | |
| 30 content::RenderProcessHost::iterator it = | |
| 31 content::RenderProcessHost::AllHostsIterator(); | |
| 32 if (it.IsAtEnd()) { | |
| 33 // There should always be one RPH in single process mode. | |
| 34 NOTREACHED(); | |
| 35 return NULL; | |
| 36 } | |
| 37 | |
| 38 content::RenderProcessHost* rph = it.GetCurrentValue(); | |
| 39 it.Advance(); | |
| 40 DCHECK(it.IsAtEnd()); // Not multiprocess compatible. | |
| 41 return rph; | |
| 42 } | |
|
piman
2014/05/20 19:54:05
You may want to check with boliu@ if this is the r
mkosiba (inactive)
2014/05/22 17:40:24
Bo's already on the review. I moved this to Synchr
| |
| 43 | |
| 27 void DidActivatePendingTree(int routing_id) { | 44 void DidActivatePendingTree(int routing_id) { |
| 28 SynchronousCompositorOutputSurfaceDelegate* delegate = | 45 SynchronousCompositorOutputSurfaceDelegate* delegate = |
| 29 SynchronousCompositorImpl::FromRoutingID(routing_id); | 46 SynchronousCompositorImpl::FromRoutingID(routing_id); |
| 30 if (delegate) | 47 if (delegate) |
| 31 delegate->DidActivatePendingTree(); | 48 delegate->DidActivatePendingTree(); |
| 32 } | 49 } |
| 33 | 50 |
| 34 } // namespace | 51 } // namespace |
| 35 | 52 |
| 36 class SynchronousCompositorOutputSurface::SoftwareDevice | 53 class SynchronousCompositorOutputSurface::SoftwareDevice |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 58 } | 75 } |
| 59 | 76 |
| 60 private: | 77 private: |
| 61 SynchronousCompositorOutputSurface* surface_; | 78 SynchronousCompositorOutputSurface* surface_; |
| 62 SkCanvas null_canvas_; | 79 SkCanvas null_canvas_; |
| 63 | 80 |
| 64 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); | 81 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); |
| 65 }; | 82 }; |
| 66 | 83 |
| 67 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 84 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
| 68 int routing_id) | 85 int routing_id, |
| 86 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) | |
| 69 : cc::OutputSurface( | 87 : cc::OutputSurface( |
| 70 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 88 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), |
| 71 routing_id_(routing_id), | 89 routing_id_(routing_id), |
| 72 needs_begin_frame_(false), | 90 needs_begin_frame_(false), |
| 73 invoking_composite_(false), | 91 invoking_composite_(false), |
| 74 did_swap_buffer_(false), | 92 did_swap_buffer_(false), |
| 75 current_sw_canvas_(NULL), | 93 current_sw_canvas_(NULL), |
| 76 memory_policy_(0), | 94 memory_policy_(0), |
| 77 output_surface_client_(NULL), | 95 output_surface_client_(NULL), |
| 96 frame_swap_message_queue_(frame_swap_message_queue), | |
| 78 weak_ptr_factory_(this) { | 97 weak_ptr_factory_(this) { |
| 79 capabilities_.deferred_gl_initialization = true; | 98 capabilities_.deferred_gl_initialization = true; |
| 80 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 99 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
| 81 capabilities_.adjust_deadline_for_parent = false; | 100 capabilities_.adjust_deadline_for_parent = false; |
| 82 // Cannot call out to GetDelegate() here as the output surface is not | 101 // Cannot call out to GetDelegate() here as the output surface is not |
| 83 // constructed on the correct thread. | 102 // constructed on the correct thread. |
| 84 | 103 |
| 85 memory_policy_.priority_cutoff_when_visible = | 104 memory_policy_.priority_cutoff_when_visible = |
| 86 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 105 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 87 } | 106 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 delegate->SetContinuousInvalidate(needs_begin_frame_); | 151 delegate->SetContinuousInvalidate(needs_begin_frame_); |
| 133 } | 152 } |
| 134 | 153 |
| 135 void SynchronousCompositorOutputSurface::SwapBuffers( | 154 void SynchronousCompositorOutputSurface::SwapBuffers( |
| 136 cc::CompositorFrame* frame) { | 155 cc::CompositorFrame* frame) { |
| 137 DCHECK(CalledOnValidThread()); | 156 DCHECK(CalledOnValidThread()); |
| 138 if (!ForcedDrawToSoftwareDevice()) { | 157 if (!ForcedDrawToSoftwareDevice()) { |
| 139 DCHECK(context_provider_); | 158 DCHECK(context_provider_); |
| 140 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); | 159 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); |
| 141 } | 160 } |
| 161 { | |
| 162 // We don't care about the SendMessageScope since we're already on the UI | |
| 163 // thread. | |
| 164 std::vector<IPC::Message> messages_to_deliver_with_frame; | |
|
piman
2014/05/20 19:54:05
nit: indent
mkosiba (inactive)
2014/05/22 17:40:24
Done.
| |
| 165 frame_swap_message_queue_->DrainMessages(frame->metadata.source_frame_number, | |
| 166 &messages_to_deliver_with_frame); | |
| 167 RenderProcessHost* rph = GetInProcessRenderer(); | |
| 168 for (std::vector<IPC::Message>::iterator i = | |
| 169 messages_to_deliver_with_frame.begin(); | |
| 170 i != messages_to_deliver_with_frame.end(); | |
| 171 ++i) { | |
| 172 rph->OnMessageReceived(*i); | |
| 173 } | |
| 174 } | |
| 142 UpdateFrameMetaData(frame->metadata); | 175 UpdateFrameMetaData(frame->metadata); |
| 143 | 176 |
| 144 did_swap_buffer_ = true; | 177 did_swap_buffer_ = true; |
| 145 client_->DidSwapBuffers(); | 178 client_->DidSwapBuffers(); |
| 146 } | 179 } |
| 147 | 180 |
| 148 void SynchronousCompositorOutputSurface::UpdateFrameMetaData( | 181 void SynchronousCompositorOutputSurface::UpdateFrameMetaData( |
| 149 const cc::CompositorFrameMetadata& frame_info) { | 182 const cc::CompositorFrameMetadata& frame_info) { |
| 150 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 183 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 151 BrowserThread::PostTask( | 184 BrowserThread::PostTask( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 307 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 275 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 308 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 276 } | 309 } |
| 277 | 310 |
| 278 SynchronousCompositorOutputSurfaceDelegate* | 311 SynchronousCompositorOutputSurfaceDelegate* |
| 279 SynchronousCompositorOutputSurface::GetDelegate() { | 312 SynchronousCompositorOutputSurface::GetDelegate() { |
| 280 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 313 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 281 } | 314 } |
| 282 | 315 |
| 283 } // namespace content | 316 } // namespace content |
| OLD | NEW |