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

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

Issue 2855723002: Don't submit frames with no render passes in cc tests (Closed)
Patch Set: c Created 3 years, 7 months 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/display.cc ('k') | cc/surfaces/surface_aggregator.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.h" 5 #include "cc/surfaces/surface.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // If there are no blockers, then immediately activate the frame. 77 // If there are no blockers, then immediately activate the frame.
78 ActivateFrame(FrameData(std::move(frame), callback, will_draw_callback)); 78 ActivateFrame(FrameData(std::move(frame), callback, will_draw_callback));
79 } 79 }
80 80
81 // Returns resources for the previous pending frame. 81 // Returns resources for the previous pending frame.
82 UnrefFrameResourcesAndRunDrawCallback(std::move(previous_pending_frame_data)); 82 UnrefFrameResourcesAndRunDrawCallback(std::move(previous_pending_frame_data));
83 } 83 }
84 84
85 void Surface::RequestCopyOfOutput( 85 void Surface::RequestCopyOfOutput(
86 std::unique_ptr<CopyOutputRequest> copy_request) { 86 std::unique_ptr<CopyOutputRequest> copy_request) {
87 if (!active_frame_data_ || 87 if (!active_frame_data_) {
88 active_frame_data_->frame.render_pass_list.empty()) {
89 copy_request->SendEmptyResult(); 88 copy_request->SendEmptyResult();
90 return; 89 return;
91 } 90 }
92 91
93 std::vector<std::unique_ptr<CopyOutputRequest>>& copy_requests = 92 std::vector<std::unique_ptr<CopyOutputRequest>>& copy_requests =
94 active_frame_data_->frame.render_pass_list.back()->copy_requests; 93 active_frame_data_->frame.render_pass_list.back()->copy_requests;
95 94
96 if (copy_request->has_source()) { 95 if (copy_request->has_source()) {
97 const base::UnguessableToken& source = copy_request->source(); 96 const base::UnguessableToken& source = copy_request->source();
98 // Remove existing CopyOutputRequests made on the Surface by the same 97 // Remove existing CopyOutputRequests made on the Surface by the same
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 159 }
161 160
162 // A frame is activated if all its Surface ID dependences are active or a 161 // A frame is activated if all its Surface ID dependences are active or a
163 // deadline has hit and the frame was forcibly activated by the display 162 // deadline has hit and the frame was forcibly activated by the display
164 // compositor. 163 // compositor.
165 void Surface::ActivateFrame(FrameData frame_data) { 164 void Surface::ActivateFrame(FrameData frame_data) {
166 DCHECK(factory_); 165 DCHECK(factory_);
167 166
168 // Save root pass copy requests. 167 // Save root pass copy requests.
169 std::vector<std::unique_ptr<CopyOutputRequest>> old_copy_requests; 168 std::vector<std::unique_ptr<CopyOutputRequest>> old_copy_requests;
170 if (active_frame_data_ && 169 if (active_frame_data_) {
171 !active_frame_data_->frame.render_pass_list.empty()) {
172 std::swap(old_copy_requests, 170 std::swap(old_copy_requests,
173 active_frame_data_->frame.render_pass_list.back()->copy_requests); 171 active_frame_data_->frame.render_pass_list.back()->copy_requests);
174 } 172 }
175 173
176 ClearCopyRequests(); 174 ClearCopyRequests();
177 175
178 TakeLatencyInfo(&frame_data.frame.metadata.latency_info); 176 TakeLatencyInfo(&frame_data.frame.metadata.latency_info);
179 177
180 base::Optional<FrameData> previous_frame_data = std::move(active_frame_data_); 178 base::Optional<FrameData> previous_frame_data = std::move(active_frame_data_);
181 179
182 active_frame_data_ = std::move(frame_data); 180 active_frame_data_ = std::move(frame_data);
183 181
184 for (auto& copy_request : old_copy_requests) 182 for (auto& copy_request : old_copy_requests)
185 RequestCopyOfOutput(std::move(copy_request)); 183 RequestCopyOfOutput(std::move(copy_request));
186 184
187 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't 185 ++frame_index_;
188 // increment frame index for them.
189 if (!active_frame_data_->frame.render_pass_list.empty())
190 ++frame_index_;
191 186
192 previous_frame_surface_id_ = surface_id(); 187 previous_frame_surface_id_ = surface_id();
193 188
194 UnrefFrameResourcesAndRunDrawCallback(std::move(previous_frame_data)); 189 UnrefFrameResourcesAndRunDrawCallback(std::move(previous_frame_data));
195 190
196 for (auto& observer : observers_) 191 for (auto& observer : observers_)
197 observer.OnSurfaceActivated(this); 192 observer.OnSurfaceActivated(this);
198 } 193 }
199 194
200 void Surface::UpdateBlockingSurfaces(bool has_previous_pending_frame, 195 void Surface::UpdateBlockingSurfaces(bool has_previous_pending_frame,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 frame->metadata.latency_info.swap(*latency_info); 341 frame->metadata.latency_info.swap(*latency_info);
347 return; 342 return;
348 } 343 }
349 std::copy(frame->metadata.latency_info.begin(), 344 std::copy(frame->metadata.latency_info.begin(),
350 frame->metadata.latency_info.end(), 345 frame->metadata.latency_info.end(),
351 std::back_inserter(*latency_info)); 346 std::back_inserter(*latency_info));
352 frame->metadata.latency_info.clear(); 347 frame->metadata.latency_info.clear();
353 } 348 }
354 349
355 } // namespace cc 350 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698