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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: 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
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/display.h" 5 #include "cc/surfaces/display.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); 270 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first);
271 if (surface) 271 if (surface)
272 surface->RunDrawCallback(); 272 surface->RunDrawCallback();
273 } 273 }
274 274
275 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(), 275 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(),
276 stored_latency_info_.begin(), 276 stored_latency_info_.begin(),
277 stored_latency_info_.end()); 277 stored_latency_info_.end());
278 stored_latency_info_.clear(); 278 stored_latency_info_.clear();
279 bool have_copy_requests = false; 279 bool have_copy_requests = false;
280 bool force_render_surface = false;
280 for (const auto& pass : frame.render_pass_list) { 281 for (const auto& pass : frame.render_pass_list) {
281 have_copy_requests |= !pass->copy_requests.empty(); 282 have_copy_requests |= !pass->copy_requests.empty();
283 force_render_surface |= pass->force_render_surface;
282 } 284 }
283 285
284 gfx::Size surface_size; 286 gfx::Size surface_size;
285 bool have_damage = false; 287 bool have_damage = false;
286 RenderPass& last_render_pass = *frame.render_pass_list.back(); 288 RenderPass& last_render_pass = *frame.render_pass_list.back();
287 if (last_render_pass.output_rect.size() != current_surface_size_ && 289 if (last_render_pass.output_rect.size() != current_surface_size_ &&
288 last_render_pass.damage_rect == last_render_pass.output_rect && 290 last_render_pass.damage_rect == last_render_pass.output_rect &&
289 !current_surface_size_.IsEmpty()) { 291 !current_surface_size_.IsEmpty()) {
290 // Resize the output rect to the current surface size so that we won't 292 // Resize the output rect to the current surface size so that we won't
291 // skip the draw and so that the GL swap won't stretch the output. 293 // skip the draw and so that the GL swap won't stretch the output.
292 last_render_pass.output_rect.set_size(current_surface_size_); 294 last_render_pass.output_rect.set_size(current_surface_size_);
293 last_render_pass.damage_rect = last_render_pass.output_rect; 295 last_render_pass.damage_rect = last_render_pass.output_rect;
294 } 296 }
295 surface_size = last_render_pass.output_rect.size(); 297 surface_size = last_render_pass.output_rect.size();
296 have_damage = !last_render_pass.damage_rect.size().IsEmpty(); 298 have_damage = !last_render_pass.damage_rect.size().IsEmpty();
297 299
298 bool size_matches = surface_size == current_surface_size_; 300 bool size_matches = surface_size == current_surface_size_;
299 if (!size_matches) 301 if (!size_matches)
300 TRACE_EVENT_INSTANT0("cc", "Size mismatch.", TRACE_EVENT_SCOPE_THREAD); 302 TRACE_EVENT_INSTANT0("cc", "Size mismatch.", TRACE_EVENT_SCOPE_THREAD);
301 303
302 bool should_draw = have_copy_requests || (have_damage && size_matches); 304 bool should_draw = force_render_surface || have_copy_requests ||
reveman 2017/05/10 13:06:17 hm, I don't think this should force a draw. copy r
wutao 2017/05/11 19:36:34 Right.
305 (have_damage && size_matches);
303 306
304 // If the surface is suspended then the resources to be used by the draw are 307 // If the surface is suspended then the resources to be used by the draw are
305 // likely destroyed. 308 // likely destroyed.
306 if (output_surface_->SurfaceIsSuspendForRecycle()) { 309 if (output_surface_->SurfaceIsSuspendForRecycle()) {
307 TRACE_EVENT_INSTANT0("cc", "Surface is suspended for recycle.", 310 TRACE_EVENT_INSTANT0("cc", "Surface is suspended for recycle.",
308 TRACE_EVENT_SCOPE_THREAD); 311 TRACE_EVENT_SCOPE_THREAD);
309 should_draw = false; 312 should_draw = false;
310 } 313 }
311 314
312 client_->DisplayWillDrawAndSwap(should_draw, frame.render_pass_list); 315 client_->DisplayWillDrawAndSwap(should_draw, frame.render_pass_list);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 const SurfaceId& Display::CurrentSurfaceId() { 418 const SurfaceId& Display::CurrentSurfaceId() {
416 return current_surface_id_; 419 return current_surface_id_;
417 } 420 }
418 421
419 void Display::ForceImmediateDrawAndSwapIfPossible() { 422 void Display::ForceImmediateDrawAndSwapIfPossible() {
420 if (scheduler_) 423 if (scheduler_)
421 scheduler_->ForceImmediateSwapIfPossible(); 424 scheduler_->ForceImmediateSwapIfPossible();
422 } 425 }
423 426
424 } // namespace cc 427 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698