| 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/ws/frame_generator.h" | 5 #include "services/ui/ws/frame_generator.h" |
| 6 | 6 |
| 7 #include "base/containers/adapters.h" | 7 #include "base/containers/adapters.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/quads/render_pass.h" | 9 #include "cc/quads/render_pass.h" |
| 10 #include "cc/quads/render_pass_draw_quad.h" | 10 #include "cc/quads/render_pass_draw_quad.h" |
| 11 #include "cc/quads/shared_quad_state.h" | 11 #include "cc/quads/shared_quad_state.h" |
| 12 #include "cc/quads/surface_draw_quad.h" | 12 #include "cc/quads/surface_draw_quad.h" |
| 13 #include "gpu/ipc/client/gpu_channel_host.h" | 13 #include "gpu/ipc/client/gpu_channel_host.h" |
| 14 #include "services/ui/surfaces/compositor_frame_sink.h" | 14 #include "services/ui/surfaces/compositor_frame_sink.h" |
| 15 #include "services/ui/ws/frame_generator_delegate.h" | 15 #include "services/ui/ws/frame_generator_delegate.h" |
| 16 #include "services/ui/ws/server_window.h" | 16 #include "services/ui/ws/server_window.h" |
| 17 #include "services/ui/ws/server_window_surface.h" | 17 #include "services/ui/ws/server_window_surface.h" |
| 18 #include "services/ui/ws/server_window_surface_manager.h" | 18 #include "services/ui/ws/server_window_surface_manager.h" |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 | 21 |
| 22 namespace ws { | 22 namespace ws { |
| 23 | 23 |
| 24 FrameGenerator::FrameGenerator( | 24 FrameGenerator::FrameGenerator( |
| 25 FrameGeneratorDelegate* delegate, | 25 FrameGeneratorDelegate* delegate, |
| 26 scoped_refptr<DisplayCompositor> display_compositor) | 26 scoped_refptr<DisplayCompositor> display_compositor) |
| 27 : delegate_(delegate), | 27 : delegate_(delegate), |
| 28 display_compositor_(display_compositor), | 28 display_compositor_(display_compositor), |
| 29 frame_sink_id_(0, display_compositor->GenerateNextClientId()), |
| 29 draw_timer_(false, false), | 30 draw_timer_(false, false), |
| 30 weak_factory_(this) { | 31 weak_factory_(this) { |
| 31 DCHECK(delegate_); | 32 DCHECK(delegate_); |
| 32 } | 33 } |
| 33 | 34 |
| 34 FrameGenerator::~FrameGenerator() { | 35 FrameGenerator::~FrameGenerator() { |
| 35 // Invalidate WeakPtrs now to avoid callbacks back into the | 36 // Invalidate WeakPtrs now to avoid callbacks back into the |
| 36 // FrameGenerator during destruction of |compositor_frame_sink_|. | 37 // FrameGenerator during destruction of |compositor_frame_sink_|. |
| 37 weak_factory_.InvalidateWeakPtrs(); | 38 weak_factory_.InvalidateWeakPtrs(); |
| 38 compositor_frame_sink_.reset(); | 39 compositor_frame_sink_.reset(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void FrameGenerator::OnGpuChannelEstablished( | 42 void FrameGenerator::OnGpuChannelEstablished( |
| 42 scoped_refptr<gpu::GpuChannelHost> channel) { | 43 scoped_refptr<gpu::GpuChannelHost> channel) { |
| 43 if (widget_ != gfx::kNullAcceleratedWidget) { | 44 if (widget_ != gfx::kNullAcceleratedWidget) { |
| 44 compositor_frame_sink_ = base::MakeUnique<surfaces::CompositorFrameSink>( | 45 compositor_frame_sink_ = base::MakeUnique<surfaces::CompositorFrameSink>( |
| 45 base::ThreadTaskRunnerHandle::Get(), widget_, std::move(channel), | 46 frame_sink_id_, base::ThreadTaskRunnerHandle::Get(), widget_, |
| 46 display_compositor_); | 47 std::move(channel), display_compositor_); |
| 47 } else { | 48 } else { |
| 48 gpu_channel_ = std::move(channel); | 49 gpu_channel_ = std::move(channel); |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 void FrameGenerator::RequestRedraw(const gfx::Rect& redraw_region) { | 53 void FrameGenerator::RequestRedraw(const gfx::Rect& redraw_region) { |
| 53 dirty_rect_.Union(redraw_region); | 54 dirty_rect_.Union(redraw_region); |
| 54 WantToDraw(); | 55 WantToDraw(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void FrameGenerator::OnAcceleratedWidgetAvailable( | 58 void FrameGenerator::OnAcceleratedWidgetAvailable( |
| 58 gfx::AcceleratedWidget widget) { | 59 gfx::AcceleratedWidget widget) { |
| 59 widget_ = widget; | 60 widget_ = widget; |
| 60 if (gpu_channel_ && widget != gfx::kNullAcceleratedWidget) { | 61 if (gpu_channel_ && widget != gfx::kNullAcceleratedWidget) { |
| 61 compositor_frame_sink_.reset(new surfaces::CompositorFrameSink( | 62 compositor_frame_sink_.reset(new surfaces::CompositorFrameSink( |
| 62 base::ThreadTaskRunnerHandle::Get(), widget_, std::move(gpu_channel_), | 63 frame_sink_id_, base::ThreadTaskRunnerHandle::Get(), widget_, |
| 63 display_compositor_)); | 64 std::move(gpu_channel_), display_compositor_)); |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 | 67 |
| 67 void FrameGenerator::RequestCopyOfOutput( | 68 void FrameGenerator::RequestCopyOfOutput( |
| 68 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 69 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
| 69 if (compositor_frame_sink_) | 70 if (compositor_frame_sink_) |
| 70 compositor_frame_sink_->RequestCopyOfOutput(std::move(output_request)); | 71 compositor_frame_sink_->RequestCopyOfOutput(std::move(output_request)); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void FrameGenerator::WantToDraw() { | 74 void FrameGenerator::WantToDraw() { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 gfx::Rect() /* opaque_rect */, | 229 gfx::Rect() /* opaque_rect */, |
| 229 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 230 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
| 230 underlay_surface->GetSurfaceId()); | 231 underlay_surface->GetSurfaceId()); |
| 231 DCHECK(!underlay_surface->may_contain_video()); | 232 DCHECK(!underlay_surface->may_contain_video()); |
| 232 } | 233 } |
| 233 } | 234 } |
| 234 | 235 |
| 235 } // namespace ws | 236 } // namespace ws |
| 236 | 237 |
| 237 } // namespace ui | 238 } // namespace ui |
| OLD | NEW |