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_factory.h" | 5 #include "cc/surfaces/surface_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 void SurfaceFactory::EvictSurface() { | 38 void SurfaceFactory::EvictSurface() { |
39 if (!current_surface_) | 39 if (!current_surface_) |
40 return; | 40 return; |
41 Destroy(std::move(current_surface_)); | 41 Destroy(std::move(current_surface_)); |
42 } | 42 } |
43 | 43 |
44 void SurfaceFactory::SubmitCompositorFrame( | 44 void SurfaceFactory::SubmitCompositorFrame( |
45 const LocalSurfaceId& local_surface_id, | 45 const LocalSurfaceId& local_surface_id, |
46 CompositorFrame frame, | 46 CompositorFrame frame, |
47 const DrawCallback& callback) { | 47 const DrawCallback& callback, |
| 48 const WillDrawCallback& will_draw_callback) { |
48 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); | 49 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); |
49 DCHECK(local_surface_id.is_valid()); | 50 DCHECK(local_surface_id.is_valid()); |
50 | 51 |
51 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { | 52 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { |
52 if (latency.latency_components().size() > 0) { | 53 if (latency.latency_components().size() > 0) { |
53 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, | 54 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, |
54 0, 0); | 55 0, 0); |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 std::unique_ptr<Surface> surface; | 59 std::unique_ptr<Surface> surface; |
59 bool create_new_surface = | 60 bool create_new_surface = |
60 (!current_surface_ || | 61 (!current_surface_ || |
61 local_surface_id != current_surface_->surface_id().local_surface_id()); | 62 local_surface_id != current_surface_->surface_id().local_surface_id()); |
62 if (!create_new_surface) { | 63 if (!create_new_surface) { |
63 surface = std::move(current_surface_); | 64 surface = std::move(current_surface_); |
64 } else { | 65 } else { |
65 surface = Create(local_surface_id); | 66 surface = Create(local_surface_id); |
66 } | 67 } |
67 surface->QueueFrame(std::move(frame), callback); | 68 surface->QueueFrame(std::move(frame), callback, will_draw_callback); |
68 | 69 |
69 if (current_surface_ && create_new_surface) { | 70 if (current_surface_ && create_new_surface) { |
70 surface->SetPreviousFrameSurface(current_surface_.get()); | 71 surface->SetPreviousFrameSurface(current_surface_.get()); |
71 Destroy(std::move(current_surface_)); | 72 Destroy(std::move(current_surface_)); |
72 } | 73 } |
73 current_surface_ = std::move(surface); | 74 current_surface_ = std::move(surface); |
74 } | 75 } |
75 | 76 |
76 void SurfaceFactory::RequestCopyOfSurface( | 77 void SurfaceFactory::RequestCopyOfSurface( |
77 std::unique_ptr<CopyOutputRequest> copy_request) { | 78 std::unique_ptr<CopyOutputRequest> copy_request) { |
78 if (!current_surface_) { | 79 if (!current_surface_) { |
79 copy_request->SendEmptyResult(); | 80 copy_request->SendEmptyResult(); |
80 return; | 81 return; |
81 } | 82 } |
82 DCHECK(current_surface_->factory().get() == this); | 83 DCHECK(current_surface_->factory().get() == this); |
83 current_surface_->RequestCopyOfOutput(std::move(copy_request)); | 84 current_surface_->RequestCopyOfOutput(std::move(copy_request)); |
84 manager_->SurfaceModified(current_surface_->surface_id()); | 85 manager_->SurfaceModified(current_surface_->surface_id()); |
85 } | 86 } |
86 | 87 |
87 void SurfaceFactory::ClearSurface() { | 88 void SurfaceFactory::ClearSurface() { |
88 if (!current_surface_) | 89 if (!current_surface_) |
89 return; | 90 return; |
90 current_surface_->EvictFrame(); | 91 current_surface_->EvictFrame(); |
91 manager_->SurfaceModified(current_surface_->surface_id()); | 92 manager_->SurfaceModified(current_surface_->surface_id()); |
92 } | 93 } |
93 | 94 |
94 void SurfaceFactory::WillDrawSurface(const LocalSurfaceId& id, | |
95 const gfx::Rect& damage_rect) { | |
96 client_->WillDrawSurface(id, damage_rect); | |
97 } | |
98 | |
99 void SurfaceFactory::ReceiveFromChild( | 95 void SurfaceFactory::ReceiveFromChild( |
100 const TransferableResourceArray& resources) { | 96 const TransferableResourceArray& resources) { |
101 holder_.ReceiveFromChild(resources); | 97 holder_.ReceiveFromChild(resources); |
102 } | 98 } |
103 | 99 |
104 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { | 100 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { |
105 holder_.RefResources(resources); | 101 holder_.RefResources(resources); |
106 } | 102 } |
107 | 103 |
108 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { | 104 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 surface->AddObserver(this); | 146 surface->AddObserver(this); |
151 return surface; | 147 return surface; |
152 } | 148 } |
153 | 149 |
154 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { | 150 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { |
155 surface->RemoveObserver(this); | 151 surface->RemoveObserver(this); |
156 manager_->DestroySurface(std::move(surface)); | 152 manager_->DestroySurface(std::move(surface)); |
157 } | 153 } |
158 | 154 |
159 } // namespace cc | 155 } // namespace cc |
OLD | NEW |