OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/surfaces/surface_display_output_surface.h" | 5 #include "cc/surfaces/surface_display_output_surface.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/output/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 capabilities_.adjust_deadline_for_parent = true; | 53 capabilities_.adjust_deadline_for_parent = true; |
54 capabilities_.can_force_reclaim_resources = true; | 54 capabilities_.can_force_reclaim_resources = true; |
55 } | 55 } |
56 | 56 |
57 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { | 57 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { |
58 DCHECK(thread_checker_.CalledOnValidThread()); | 58 DCHECK(thread_checker_.CalledOnValidThread()); |
59 if (HasClient()) | 59 if (HasClient()) |
60 DetachFromClient(); | 60 DetachFromClient(); |
61 } | 61 } |
62 | 62 |
63 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) { | 63 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame frame) { |
64 gfx::Size frame_size = | 64 gfx::Size frame_size = |
65 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); | 65 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
66 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { | 66 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { |
67 if (!delegated_surface_id_.is_null()) { | 67 if (!delegated_surface_id_.is_null()) { |
68 factory_.Destroy(delegated_surface_id_); | 68 factory_.Destroy(delegated_surface_id_); |
69 } | 69 } |
70 delegated_surface_id_ = surface_id_allocator_->GenerateId(); | 70 delegated_surface_id_ = surface_id_allocator_->GenerateId(); |
71 factory_.Create(delegated_surface_id_); | 71 factory_.Create(delegated_surface_id_); |
72 last_swap_frame_size_ = frame_size; | 72 last_swap_frame_size_ = frame_size; |
73 } | 73 } |
74 display_->SetSurfaceId(delegated_surface_id_, | 74 display_->SetSurfaceId(delegated_surface_id_, |
75 frame->metadata.device_scale_factor); | 75 frame.metadata.device_scale_factor); |
76 | 76 |
77 client_->DidSwapBuffers(); | 77 client_->DidSwapBuffers(); |
78 | 78 |
79 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame()); | 79 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame); |
80 frame->AssignTo(frame_copy.get()); | 80 *frame_copy = std::move(frame); |
81 factory_.SubmitCompositorFrame( | 81 factory_.SubmitCompositorFrame( |
82 delegated_surface_id_, std::move(frame_copy), | 82 delegated_surface_id_, std::move(frame_copy), |
83 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, | 83 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, |
84 base::Unretained(this))); | 84 base::Unretained(this))); |
85 } | 85 } |
86 | 86 |
87 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { | 87 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { |
88 DCHECK(thread_checker_.CalledOnValidThread()); | 88 DCHECK(thread_checker_.CalledOnValidThread()); |
89 | 89 |
90 surface_manager_->RegisterSurfaceFactoryClient( | 90 surface_manager_->RegisterSurfaceFactoryClient( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 SetMemoryPolicy(policy); | 159 SetMemoryPolicy(policy); |
160 } | 160 } |
161 | 161 |
162 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { | 162 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { |
163 // TODO(danakj): Why the lost check? | 163 // TODO(danakj): Why the lost check? |
164 if (!output_surface_lost_) | 164 if (!output_surface_lost_) |
165 client_->DidSwapBuffersComplete(); | 165 client_->DidSwapBuffersComplete(); |
166 } | 166 } |
167 | 167 |
168 } // namespace cc | 168 } // namespace cc |
OLD | NEW |