Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: cc/surfaces/surface_factory.cc

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: nit Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 } 79 }
80 80
81 void SurfaceFactory::SubmitCompositorFrame(const LocalFrameId& local_frame_id, 81 void SurfaceFactory::SubmitCompositorFrame(const LocalFrameId& local_frame_id,
82 CompositorFrame frame, 82 CompositorFrame frame,
83 const DrawCallback& callback) { 83 const DrawCallback& callback) {
84 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); 84 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame");
85 OwningSurfaceMap::iterator it = surface_map_.find(local_frame_id); 85 OwningSurfaceMap::iterator it = surface_map_.find(local_frame_id);
86 DCHECK(it != surface_map_.end()); 86 DCHECK(it != surface_map_.end());
87 DCHECK(it->second->factory().get() == this); 87 DCHECK(it->second->factory().get() == this);
88 const CompositorFrame& previous_frame = it->second->GetEligibleFrame();
89 // Tell the SurfaceManager if this is the first frame submitted with this 88 // Tell the SurfaceManager if this is the first frame submitted with this
90 // LocalFrameId. 89 // LocalFrameId.
91 if (!previous_frame.delegated_frame_data) { 90 if (!it->second->HasFrame()) {
92 float device_scale_factor = frame.metadata.device_scale_factor; 91 float device_scale_factor = frame.metadata.device_scale_factor;
93 gfx::Size frame_size; 92 gfx::Size frame_size;
94 // CompositorFrames may not be populated with a RenderPass in unit tests. 93 // CompositorFrames may not be populated with a RenderPass in unit tests.
95 if (frame.delegated_frame_data && 94 if (!frame.render_pass_list.empty())
96 !frame.delegated_frame_data->render_pass_list.empty()) { 95 frame_size = frame.render_pass_list[0]->output_rect.size();
97 frame_size =
98 frame.delegated_frame_data->render_pass_list[0]->output_rect.size();
99 }
100 manager_->SurfaceCreated(it->second->surface_id(), frame_size, 96 manager_->SurfaceCreated(it->second->surface_id(), frame_size,
101 device_scale_factor); 97 device_scale_factor);
102 } 98 }
103 it->second->QueueFrame(std::move(frame), callback); 99 it->second->QueueFrame(std::move(frame), callback);
104 if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id))) { 100 if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id))) {
105 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 101 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
106 it->second->RunDrawCallbacks(); 102 it->second->RunDrawCallbacks();
107 } 103 }
108 } 104 }
109 105
110 void SurfaceFactory::RequestCopyOfSurface( 106 void SurfaceFactory::RequestCopyOfSurface(
111 const LocalFrameId& local_frame_id, 107 const LocalFrameId& local_frame_id,
112 std::unique_ptr<CopyOutputRequest> copy_request) { 108 std::unique_ptr<CopyOutputRequest> copy_request) {
113 OwningSurfaceMap::iterator it = surface_map_.find(local_frame_id); 109 OwningSurfaceMap::iterator it = surface_map_.find(local_frame_id);
114 if (it == surface_map_.end()) { 110 if (it == surface_map_.end()) {
115 copy_request->SendEmptyResult(); 111 copy_request->SendEmptyResult();
116 return; 112 return;
117 } 113 }
118 DCHECK(it->second->factory().get() == this); 114 DCHECK(it->second->factory().get() == this);
119 it->second->RequestCopyOfOutput(std::move(copy_request)); 115 it->second->RequestCopyOfOutput(std::move(copy_request));
120 manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id)); 116 manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id));
121 } 117 }
122 118
119 void SurfaceFactory::ClearSurface(const LocalFrameId& local_frame_id) {
120 OwningSurfaceMap::iterator it = surface_map_.find(local_frame_id);
121 DCHECK(it != surface_map_.end());
122 DCHECK(it->second->factory().get() == this);
123 it->second->EvictFrame();
124 manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id));
125 }
126
123 void SurfaceFactory::WillDrawSurface(const LocalFrameId& id, 127 void SurfaceFactory::WillDrawSurface(const LocalFrameId& id,
124 const gfx::Rect& damage_rect) { 128 const gfx::Rect& damage_rect) {
125 client_->WillDrawSurface(id, damage_rect); 129 client_->WillDrawSurface(id, damage_rect);
126 } 130 }
127 131
128 void SurfaceFactory::ReceiveFromChild( 132 void SurfaceFactory::ReceiveFromChild(
129 const TransferableResourceArray& resources) { 133 const TransferableResourceArray& resources) {
130 holder_.ReceiveFromChild(resources); 134 holder_.ReceiveFromChild(resources);
131 } 135 }
132 136
133 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 137 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
134 holder_.RefResources(resources); 138 holder_.RefResources(resources);
135 } 139 }
136 140
137 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 141 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
138 holder_.UnrefResources(resources); 142 holder_.UnrefResources(resources);
139 } 143 }
140 144
141 } // namespace cc 145 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698