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

Side by Side Diff: cc/output/direct_renderer.cc

Issue 2612023002: cc: Implement overdraw feedback debugging feature. (Closed)
Patch Set: fix typo in comment Created 3 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/output/direct_renderer.h" 5 #include "cc/output/direct_renderer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <utility> 10 #include <utility>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 overlay_processor_->Initialize(); 80 overlay_processor_->Initialize();
81 81
82 auto* context_provider = output_surface_->context_provider(); 82 auto* context_provider = output_surface_->context_provider();
83 83
84 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap(); 84 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap();
85 allow_empty_swap_ = use_partial_swap_; 85 allow_empty_swap_ = use_partial_swap_;
86 if (context_provider && 86 if (context_provider &&
87 context_provider->ContextCapabilities().commit_overlay_planes) 87 context_provider->ContextCapabilities().commit_overlay_planes)
88 allow_empty_swap_ = true; 88 allow_empty_swap_ = true;
89 89
90 LOG_IF(WARNING, settings_->show_overdraw_feedback &&
danakj 2017/01/12 00:42:57 use DLOG_IF instead. why doesn't this happen for
reveman 2017/01/13 01:27:42 Done.
danakj 2017/01/16 16:22:01 What about just a simple static bool? It's okay to
reveman 2017/01/16 18:02:26 Done. Although "call once" execution of code using
danakj 2017/01/16 18:17:52 What race are you worried about, DirectRenderer be
reveman 2017/01/16 22:46:18 I'd rather not introduce the assumption that this
91 !output_surface_->capabilities().supports_stencil)
92 << "Overdraw feedback enabled without output surface stencil support.";
danakj 2017/01/12 00:42:57 This error is pretty vague, I think it might be ni
reveman 2017/01/13 01:27:42 Makes sense. Done.
93
90 initialized_ = true; 94 initialized_ = true;
91 } 95 }
92 96
93 // static 97 // static
94 gfx::RectF DirectRenderer::QuadVertexRect() { 98 gfx::RectF DirectRenderer::QuadVertexRect() {
95 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); 99 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f);
96 } 100 }
97 101
98 // static 102 // static
99 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, 103 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const gfx::Size& device_viewport_size) { 222 const gfx::Size& device_viewport_size) {
219 DCHECK(visible_); 223 DCHECK(visible_);
220 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); 224 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame");
221 UMA_HISTOGRAM_COUNTS( 225 UMA_HISTOGRAM_COUNTS(
222 "Renderer4.renderPassCount", 226 "Renderer4.renderPassCount",
223 base::saturated_cast<int>(render_passes_in_draw_order->size())); 227 base::saturated_cast<int>(render_passes_in_draw_order->size()));
224 228
225 RenderPass* root_render_pass = render_passes_in_draw_order->back().get(); 229 RenderPass* root_render_pass = render_passes_in_draw_order->back().get();
226 DCHECK(root_render_pass); 230 DCHECK(root_render_pass);
227 231
232 bool overdraw_tracing_enabled;
233 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
234 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"),
235 &overdraw_tracing_enabled);
236 overdraw_feedback_ =
237 (settings_->show_overdraw_feedback || overdraw_tracing_enabled) &&
238 output_surface_->capabilities().supports_stencil;
239
228 DrawingFrame frame; 240 DrawingFrame frame;
229 frame.render_passes_in_draw_order = render_passes_in_draw_order; 241 frame.render_passes_in_draw_order = render_passes_in_draw_order;
230 frame.root_render_pass = root_render_pass; 242 frame.root_render_pass = root_render_pass;
231 frame.root_damage_rect = root_render_pass->damage_rect; 243 frame.root_damage_rect = root_render_pass->damage_rect;
232 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); 244 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage());
233 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); 245 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_size));
234 frame.device_viewport_size = device_viewport_size; 246 frame.device_viewport_size = device_viewport_size;
235 frame.device_color_space = device_color_space; 247 frame.device_color_space = device_color_space;
236 248
237 // Only reshape when we know we are going to draw. Otherwise, the reshape 249 // Only reshape when we know we are going to draw. Otherwise, the reshape
238 // can leave the window at the wrong size if we never draw and the proper 250 // can leave the window at the wrong size if we never draw and the proper
239 // viewport size is never set. 251 // viewport size is never set.
240 bool frame_has_alpha = frame.root_render_pass->has_transparent_background; 252 bool frame_has_alpha = frame.root_render_pass->has_transparent_background;
253 bool use_stencil = overdraw_feedback_;
241 if (device_viewport_size != reshape_surface_size_ || 254 if (device_viewport_size != reshape_surface_size_ ||
242 device_scale_factor != reshape_device_scale_factor_ || 255 device_scale_factor != reshape_device_scale_factor_ ||
243 device_color_space != reshape_device_color_space_ || 256 device_color_space != reshape_device_color_space_ ||
244 frame_has_alpha != reshape_has_alpha_) { 257 frame_has_alpha != reshape_has_alpha_ ||
258 use_stencil != reshape_use_stencil_) {
245 reshape_surface_size_ = device_viewport_size; 259 reshape_surface_size_ = device_viewport_size;
246 reshape_device_scale_factor_ = device_scale_factor; 260 reshape_device_scale_factor_ = device_scale_factor;
247 reshape_device_color_space_ = device_color_space; 261 reshape_device_color_space_ = device_color_space;
248 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background; 262 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background;
249 output_surface_->Reshape(reshape_surface_size_, 263 reshape_use_stencil_ = overdraw_feedback_;
250 reshape_device_scale_factor_, 264 output_surface_->Reshape(
251 reshape_device_color_space_, reshape_has_alpha_); 265 reshape_surface_size_, reshape_device_scale_factor_,
266 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_);
252 } 267 }
253 268
254 BeginDrawingFrame(&frame); 269 BeginDrawingFrame(&frame);
255 270
256 for (const auto& pass : *render_passes_in_draw_order) { 271 for (const auto& pass : *render_passes_in_draw_order) {
257 if (!pass->filters.IsEmpty()) 272 if (!pass->filters.IsEmpty())
258 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters)); 273 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters));
259 if (!pass->background_filters.IsEmpty()) { 274 if (!pass->background_filters.IsEmpty()) {
260 render_pass_background_filters_.push_back( 275 render_pass_background_filters_.push_back(
261 std::make_pair(pass->id, &pass->background_filters)); 276 std::make_pair(pass->id, &pass->background_filters));
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 auto iter = render_pass_textures_.find(render_pass_id); 623 auto iter = render_pass_textures_.find(render_pass_id);
609 return iter != render_pass_textures_.end() && iter->second->id(); 624 return iter != render_pass_textures_.end() && iter->second->id();
610 } 625 }
611 626
612 // static 627 // static
613 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { 628 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
614 return render_pass->output_rect.size(); 629 return render_pass->output_rect.size();
615 } 630 }
616 631
617 } // namespace cc 632 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('j') | cc/output/gl_renderer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698