| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/surfaces/compositor_frame_sink.h" | 5 #include "services/ui/surfaces/compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "cc/output/copy_output_request.h" | 7 #include "cc/output/copy_output_request.h" |
| 8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
| 9 #include "cc/output/renderer_settings.h" | 9 #include "cc/output/renderer_settings.h" |
| 10 #include "cc/output/texture_mailbox_deleter.h" | 10 #include "cc/output/texture_mailbox_deleter.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace surfaces { | 26 namespace surfaces { |
| 27 | 27 |
| 28 CompositorFrameSink::CompositorFrameSink( | 28 CompositorFrameSink::CompositorFrameSink( |
| 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 30 gfx::AcceleratedWidget widget, | 30 gfx::AcceleratedWidget widget, |
| 31 scoped_refptr<gpu::GpuChannelHost> gpu_channel, | 31 scoped_refptr<gpu::GpuChannelHost> gpu_channel, |
| 32 const scoped_refptr<DisplayCompositor>& display_compositor) | 32 const scoped_refptr<DisplayCompositor>& display_compositor) |
| 33 : frame_sink_id_(display_compositor->GenerateNextClientId(), 0), | 33 : frame_sink_id_(display_compositor->GenerateNextClientId(), 0), |
| 34 task_runner_(task_runner), | 34 task_runner_(task_runner), |
| 35 display_compositor_(display_compositor), | 35 display_compositor_(display_compositor), |
| 36 factory_(frame_sink_id_, display_compositor->manager(), this), | 36 factory_(frame_sink_id_, display_compositor->manager(), this) { |
| 37 allocator_(frame_sink_id_) { | |
| 38 display_compositor_->manager()->RegisterFrameSinkId(frame_sink_id_); | 37 display_compositor_->manager()->RegisterFrameSinkId(frame_sink_id_); |
| 39 display_compositor_->manager()->RegisterSurfaceFactoryClient(frame_sink_id_, | 38 display_compositor_->manager()->RegisterSurfaceFactoryClient(frame_sink_id_, |
| 40 this); | 39 this); |
| 41 | 40 |
| 42 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 41 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
| 43 gpu_channel->gpu_memory_buffer_manager(); | 42 gpu_channel->gpu_memory_buffer_manager(); |
| 44 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( | 43 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( |
| 45 new SurfacesContextProvider(widget, std::move(gpu_channel))); | 44 new SurfacesContextProvider(widget, std::move(gpu_channel))); |
| 46 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 45 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
| 47 CHECK(surfaces_context_provider->BindToCurrentThread()); | 46 CHECK(surfaces_context_provider->BindToCurrentThread()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 frame_sink_id_); | 85 frame_sink_id_); |
| 87 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); | 86 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); |
| 88 } | 87 } |
| 89 | 88 |
| 90 void CompositorFrameSink::SubmitCompositorFrame( | 89 void CompositorFrameSink::SubmitCompositorFrame( |
| 91 cc::CompositorFrame frame, | 90 cc::CompositorFrame frame, |
| 92 const base::Callback<void()>& callback) { | 91 const base::Callback<void()>& callback) { |
| 93 gfx::Size frame_size = | 92 gfx::Size frame_size = |
| 94 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 93 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
| 95 if (frame_size.IsEmpty() || frame_size != display_size_) { | 94 if (frame_size.IsEmpty() || frame_size != display_size_) { |
| 96 if (!surface_id_.is_null()) | 95 if (!local_frame_id_.is_null()) |
| 97 factory_.Destroy(surface_id_); | 96 factory_.Destroy(local_frame_id_); |
| 98 surface_id_ = allocator_.GenerateId(); | 97 local_frame_id_ = allocator_.GenerateId(); |
| 99 factory_.Create(surface_id_); | 98 factory_.Create(local_frame_id_); |
| 100 display_size_ = frame_size; | 99 display_size_ = frame_size; |
| 101 display_->Resize(display_size_); | 100 display_->Resize(display_size_); |
| 102 } | 101 } |
| 103 display_->SetSurfaceId(surface_id_, frame.metadata.device_scale_factor); | 102 display_->SetSurfaceId(cc::SurfaceId(frame_sink_id_, local_frame_id_), |
| 104 factory_.SubmitCompositorFrame(surface_id_, std::move(frame), callback); | 103 frame.metadata.device_scale_factor); |
| 104 factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame), callback); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void CompositorFrameSink::RequestCopyOfOutput( | 107 void CompositorFrameSink::RequestCopyOfOutput( |
| 108 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 108 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
| 109 factory_.RequestCopyOfSurface(surface_id_, std::move(output_request)); | 109 factory_.RequestCopyOfSurface(local_frame_id_, std::move(output_request)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void CompositorFrameSink::ReturnResources( | 112 void CompositorFrameSink::ReturnResources( |
| 113 const cc::ReturnedResourceArray& resources) { | 113 const cc::ReturnedResourceArray& resources) { |
| 114 // TODO(fsamuel): Implement this. | 114 // TODO(fsamuel): Implement this. |
| 115 } | 115 } |
| 116 | 116 |
| 117 void CompositorFrameSink::SetBeginFrameSource( | 117 void CompositorFrameSink::SetBeginFrameSource( |
| 118 cc::BeginFrameSource* begin_frame_source) { | 118 cc::BeginFrameSource* begin_frame_source) { |
| 119 // TODO(fsamuel): Implement this. | 119 // TODO(fsamuel): Implement this. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 void CompositorFrameSink::DisplayDidDrawAndSwap() { | 134 void CompositorFrameSink::DisplayDidDrawAndSwap() { |
| 135 // This notification is not relevant to our client outside of tests. We | 135 // This notification is not relevant to our client outside of tests. We |
| 136 // unblock the client from the DrawCallback when the surface is going to | 136 // unblock the client from the DrawCallback when the surface is going to |
| 137 // be drawn. | 137 // be drawn. |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace surfaces | 140 } // namespace surfaces |
| 141 } // namespace ui | 141 } // namespace ui |
| OLD | NEW |