| 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 "components/exo/compositor_frame_sink_holder.h" | 5 #include "components/exo/compositor_frame_sink_holder.h" |
| 6 | 6 |
| 7 #include "cc/resources/returned_resource.h" | 7 #include "cc/resources/returned_resource.h" |
| 8 #include "components/exo/surface.h" | 8 #include "components/exo/surface.h" |
| 9 | 9 |
| 10 namespace exo { | 10 namespace exo { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 cc::ResourceId id, | 34 cc::ResourceId id, |
| 35 const cc::ReleaseCallback& callback) { | 35 const cc::ReleaseCallback& callback) { |
| 36 DCHECK(!callback.is_null()); | 36 DCHECK(!callback.is_null()); |
| 37 release_callbacks_[id] = callback; | 37 release_callbacks_[id] = callback; |
| 38 } | 38 } |
| 39 | 39 |
| 40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
| 41 // cc::mojom::MojoCompositorFrameSinkClient overrides: | 41 // cc::mojom::MojoCompositorFrameSinkClient overrides: |
| 42 | 42 |
| 43 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() { | 43 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() { |
| 44 // TODO(staraz): Implement this | 44 if (surface_) |
| 45 surface_->DidReceiveCompositorFrameAck(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) { | 48 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 48 begin_frame_source_->OnBeginFrame(args); | 49 begin_frame_source_->OnBeginFrame(args); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void CompositorFrameSinkHolder::ReclaimResources( | 52 void CompositorFrameSinkHolder::ReclaimResources( |
| 52 const cc::ReturnedResourceArray& resources) { | 53 const cc::ReturnedResourceArray& resources) { |
| 53 for (auto& resource : resources) { | 54 for (auto& resource : resources) { |
| 54 auto it = release_callbacks_.find(resource.id); | 55 auto it = release_callbacks_.find(resource.id); |
| 55 DCHECK(it != release_callbacks_.end()); | 56 DCHECK(it != release_callbacks_.end()); |
| 56 if (it != release_callbacks_.end()) { | 57 if (it != release_callbacks_.end()) { |
| 57 it->second.Run(resource.sync_token, resource.lost); | 58 it->second.Run(resource.sync_token, resource.lost); |
| 58 release_callbacks_.erase(it); | 59 release_callbacks_.erase(it); |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 } | 62 } |
| 62 | 63 |
| 63 void CompositorFrameSinkHolder::WillDrawSurface( | 64 void CompositorFrameSinkHolder::WillDrawSurface( |
| 64 const cc::LocalSurfaceId& local_surface_id, | 65 const cc::LocalSurfaceId& local_surface_id, |
| 65 const gfx::Rect& damage_rect) { | 66 const gfx::Rect& damage_rect) {} |
| 66 if (surface_) | |
| 67 surface_->WillDraw(); | |
| 68 } | |
| 69 | 67 |
| 70 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
| 71 // cc::ExternalBeginFrameSourceClient overrides: | 69 // cc::ExternalBeginFrameSourceClient overrides: |
| 72 | 70 |
| 73 void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) { | 71 void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) { |
| 74 frame_sink_->SetNeedsBeginFrame(needs_begin_frames); | 72 frame_sink_->SetNeedsBeginFrame(needs_begin_frames); |
| 75 } | 73 } |
| 76 | 74 |
| 77 void CompositorFrameSinkHolder::OnDidFinishFrame(const cc::BeginFrameAck& ack) { | 75 void CompositorFrameSinkHolder::OnDidFinishFrame(const cc::BeginFrameAck& ack) { |
| 78 // If there was damage, the submitted CompositorFrame includes the ack. | 76 // If there was damage, the submitted CompositorFrame includes the ack. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 | 88 |
| 91 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
| 92 // ExoComopositorFrameSink, private: | 90 // ExoComopositorFrameSink, private: |
| 93 | 91 |
| 94 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() { | 92 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() { |
| 95 if (surface_) | 93 if (surface_) |
| 96 surface_->RemoveSurfaceObserver(this); | 94 surface_->RemoveSurfaceObserver(this); |
| 97 } | 95 } |
| 98 | 96 |
| 99 } // namespace exo | 97 } // namespace exo |
| OLD | NEW |