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

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

Issue 2612023002: cc: Implement overdraw feedback debugging feature. (Closed)
Patch Set: make sure overdraw_feedback_ is initialized and reset properly 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
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('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 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/auto_reset.h"
13 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
14 #include "base/numerics/safe_conversions.h" 15 #include "base/numerics/safe_conversions.h"
15 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
16 #include "cc/base/math_util.h" 17 #include "cc/base/math_util.h"
17 #include "cc/output/bsp_tree.h" 18 #include "cc/output/bsp_tree.h"
18 #include "cc/output/bsp_walk_action.h" 19 #include "cc/output/bsp_walk_action.h"
19 #include "cc/output/copy_output_request.h" 20 #include "cc/output/copy_output_request.h"
20 #include "cc/output/renderer_settings.h" 21 #include "cc/output/renderer_settings.h"
21 #include "cc/quads/draw_quad.h" 22 #include "cc/quads/draw_quad.h"
22 #include "cc/resources/scoped_resource.h" 23 #include "cc/resources/scoped_resource.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const gfx::Size& device_viewport_size) { 219 const gfx::Size& device_viewport_size) {
219 DCHECK(visible_); 220 DCHECK(visible_);
220 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); 221 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame");
221 UMA_HISTOGRAM_COUNTS( 222 UMA_HISTOGRAM_COUNTS(
222 "Renderer4.renderPassCount", 223 "Renderer4.renderPassCount",
223 base::saturated_cast<int>(render_passes_in_draw_order->size())); 224 base::saturated_cast<int>(render_passes_in_draw_order->size()));
224 225
225 RenderPass* root_render_pass = render_passes_in_draw_order->back().get(); 226 RenderPass* root_render_pass = render_passes_in_draw_order->back().get();
226 DCHECK(root_render_pass); 227 DCHECK(root_render_pass);
227 228
229 bool overdraw_tracing_enabled;
230 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
231 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"),
232 &overdraw_tracing_enabled);
233 bool overdraw_feedback =
234 settings_->show_overdraw_feedback || overdraw_tracing_enabled;
235 if (overdraw_feedback && !output_surface_->capabilities().supports_stencil) {
236 #if DCHECK_IS_ON()
237 DLOG_IF(WARNING, !overdraw_feedback_support_missing_logged_once_)
238 << "Overdraw feedback enabled on platform without support.";
239 overdraw_feedback_support_missing_logged_once_ = true;
240 #endif
241 overdraw_feedback = false;
242 }
243 base::AutoReset<bool> auto_reset_overdraw_feedback(&overdraw_feedback_,
244 overdraw_feedback);
245
228 DrawingFrame frame; 246 DrawingFrame frame;
229 frame.render_passes_in_draw_order = render_passes_in_draw_order; 247 frame.render_passes_in_draw_order = render_passes_in_draw_order;
230 frame.root_render_pass = root_render_pass; 248 frame.root_render_pass = root_render_pass;
231 frame.root_damage_rect = root_render_pass->damage_rect; 249 frame.root_damage_rect = root_render_pass->damage_rect;
232 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); 250 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage());
233 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); 251 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_size));
234 frame.device_viewport_size = device_viewport_size; 252 frame.device_viewport_size = device_viewport_size;
235 frame.device_color_space = device_color_space; 253 frame.device_color_space = device_color_space;
236 254
237 // Only reshape when we know we are going to draw. Otherwise, the reshape 255 // 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 256 // can leave the window at the wrong size if we never draw and the proper
239 // viewport size is never set. 257 // viewport size is never set.
240 bool frame_has_alpha = frame.root_render_pass->has_transparent_background; 258 bool frame_has_alpha = frame.root_render_pass->has_transparent_background;
259 bool use_stencil = overdraw_feedback_;
241 if (device_viewport_size != reshape_surface_size_ || 260 if (device_viewport_size != reshape_surface_size_ ||
242 device_scale_factor != reshape_device_scale_factor_ || 261 device_scale_factor != reshape_device_scale_factor_ ||
243 device_color_space != reshape_device_color_space_ || 262 device_color_space != reshape_device_color_space_ ||
244 frame_has_alpha != reshape_has_alpha_) { 263 frame_has_alpha != reshape_has_alpha_ ||
264 use_stencil != reshape_use_stencil_) {
245 reshape_surface_size_ = device_viewport_size; 265 reshape_surface_size_ = device_viewport_size;
246 reshape_device_scale_factor_ = device_scale_factor; 266 reshape_device_scale_factor_ = device_scale_factor;
247 reshape_device_color_space_ = device_color_space; 267 reshape_device_color_space_ = device_color_space;
248 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background; 268 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background;
249 output_surface_->Reshape(reshape_surface_size_, 269 reshape_use_stencil_ = overdraw_feedback_;
250 reshape_device_scale_factor_, 270 output_surface_->Reshape(
251 reshape_device_color_space_, reshape_has_alpha_); 271 reshape_surface_size_, reshape_device_scale_factor_,
272 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_);
252 } 273 }
253 274
254 BeginDrawingFrame(&frame); 275 BeginDrawingFrame(&frame);
255 276
256 for (const auto& pass : *render_passes_in_draw_order) { 277 for (const auto& pass : *render_passes_in_draw_order) {
257 if (!pass->filters.IsEmpty()) 278 if (!pass->filters.IsEmpty())
258 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters)); 279 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters));
259 if (!pass->background_filters.IsEmpty()) { 280 if (!pass->background_filters.IsEmpty()) {
260 render_pass_background_filters_.push_back( 281 render_pass_background_filters_.push_back(
261 std::make_pair(pass->id, &pass->background_filters)); 282 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); 629 auto iter = render_pass_textures_.find(render_pass_id);
609 return iter != render_pass_textures_.end() && iter->second->id(); 630 return iter != render_pass_textures_.end() && iter->second->id();
610 } 631 }
611 632
612 // static 633 // static
613 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { 634 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
614 return render_pass->output_rect.size(); 635 return render_pass->output_rect.size();
615 } 636 }
616 637
617 } // namespace cc 638 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698