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

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

Issue 2543473004: cc: Move filters from RenderPassDrawQuad to RenderPass (Closed)
Patch Set: Address review comments Created 4 years 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 reshape_device_scale_factor_ = device_scale_factor; 247 reshape_device_scale_factor_ = device_scale_factor;
248 reshape_device_color_space_ = device_color_space; 248 reshape_device_color_space_ = device_color_space;
249 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background; 249 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background;
250 output_surface_->Reshape(reshape_surface_size_, 250 output_surface_->Reshape(reshape_surface_size_,
251 reshape_device_scale_factor_, 251 reshape_device_scale_factor_,
252 reshape_device_color_space_, reshape_has_alpha_); 252 reshape_device_color_space_, reshape_has_alpha_);
253 } 253 }
254 254
255 BeginDrawingFrame(&frame); 255 BeginDrawingFrame(&frame);
256 256
257 for (const auto& pass : *render_passes_in_draw_order) {
258 if (!pass->filters.IsEmpty())
259 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters));
260 if (!pass->background_filters.IsEmpty()) {
261 render_pass_background_filters_.push_back(
262 std::make_pair(pass->id, &pass->background_filters));
263 }
264 std::sort(render_pass_filters_.begin(), render_pass_filters_.end());
265 std::sort(render_pass_background_filters_.begin(),
266 render_pass_background_filters_.end());
267 }
268
257 // Draw all non-root render passes except for the root render pass. 269 // Draw all non-root render passes except for the root render pass.
258 for (const auto& pass : *render_passes_in_draw_order) { 270 for (const auto& pass : *render_passes_in_draw_order) {
259 if (pass.get() == root_render_pass) 271 if (pass.get() == root_render_pass)
260 break; 272 break;
261 DrawRenderPassAndExecuteCopyRequests(&frame, pass.get()); 273 DrawRenderPassAndExecuteCopyRequests(&frame, pass.get());
262 } 274 }
263 275
264 // Create the overlay candidate for the output surface, and mark it as 276 // Create the overlay candidate for the output surface, and mark it as
265 // always handled. 277 // always handled.
266 if (output_surface_->IsDisplayedAsOverlayPlane()) { 278 if (output_surface_->IsDisplayedAsOverlayPlane()) {
267 OverlayCandidate output_surface_plane; 279 OverlayCandidate output_surface_plane;
268 output_surface_plane.display_rect = 280 output_surface_plane.display_rect =
269 gfx::RectF(root_render_pass->output_rect); 281 gfx::RectF(root_render_pass->output_rect);
270 output_surface_plane.quad_rect_in_target_space = 282 output_surface_plane.quad_rect_in_target_space =
271 root_render_pass->output_rect; 283 root_render_pass->output_rect;
272 output_surface_plane.use_output_surface_for_resource = true; 284 output_surface_plane.use_output_surface_for_resource = true;
273 output_surface_plane.overlay_handled = true; 285 output_surface_plane.overlay_handled = true;
274 frame.overlay_list.push_back(output_surface_plane); 286 frame.overlay_list.push_back(output_surface_plane);
275 } 287 }
276 288
277 // Attempt to replace some or all of the quads of the root render pass with 289 // Attempt to replace some or all of the quads of the root render pass with
278 // overlays. 290 // overlays.
279 overlay_processor_->ProcessForOverlays( 291 overlay_processor_->ProcessForOverlays(
280 resource_provider_, root_render_pass, &frame.overlay_list, 292 resource_provider_, root_render_pass, render_pass_filters_,
293 render_pass_background_filters_, &frame.overlay_list,
281 &frame.ca_layer_overlay_list, &frame.root_damage_rect); 294 &frame.ca_layer_overlay_list, &frame.root_damage_rect);
282 295
283 // We can skip all drawing if the damage rect is now empty. 296 // We can skip all drawing if the damage rect is now empty.
284 bool skip_drawing_root_render_pass = 297 bool skip_drawing_root_render_pass =
285 frame.root_damage_rect.IsEmpty() && allow_empty_swap_; 298 frame.root_damage_rect.IsEmpty() && allow_empty_swap_;
286 299
287 // If we have to draw but don't support partial swap, the whole output should 300 // If we have to draw but don't support partial swap, the whole output should
288 // be considered damaged. 301 // be considered damaged.
289 if (!skip_drawing_root_render_pass && !use_partial_swap_) 302 if (!skip_drawing_root_render_pass && !use_partial_swap_)
290 frame.root_damage_rect = root_render_pass->output_rect; 303 frame.root_damage_rect = root_render_pass->output_rect;
291 304
292 if (skip_drawing_root_render_pass) { 305 if (skip_drawing_root_render_pass) {
293 // If any of the overlays is the output surface, then ensure that the 306 // If any of the overlays is the output surface, then ensure that the
294 // backbuffer be allocated (allocation of the backbuffer is a side-effect 307 // backbuffer be allocated (allocation of the backbuffer is a side-effect
295 // of BindFramebufferToOutputSurface). 308 // of BindFramebufferToOutputSurface).
296 for (auto& overlay : frame.overlay_list) { 309 for (auto& overlay : frame.overlay_list) {
297 if (overlay.use_output_surface_for_resource) { 310 if (overlay.use_output_surface_for_resource) {
298 BindFramebufferToOutputSurface(&frame); 311 BindFramebufferToOutputSurface(&frame);
299 break; 312 break;
300 } 313 }
301 } 314 }
302 } else { 315 } else {
303 DrawRenderPassAndExecuteCopyRequests(&frame, root_render_pass); 316 DrawRenderPassAndExecuteCopyRequests(&frame, root_render_pass);
304 } 317 }
305 318
306 FinishDrawingFrame(&frame); 319 FinishDrawingFrame(&frame);
307 render_passes_in_draw_order->clear(); 320 render_passes_in_draw_order->clear();
321 render_pass_filters_.clear();
322 render_pass_background_filters_.clear();
308 } 323 }
309 324
310 gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass( 325 gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass(
311 const DrawingFrame* frame) { 326 const DrawingFrame* frame) {
312 if (frame->current_render_pass == frame->root_render_pass) 327 if (frame->current_render_pass == frame->root_render_pass)
313 return frame->root_damage_rect; 328 return frame->root_damage_rect;
314 329
315 // If the root damage rect has been expanded due to overlays, all the other 330 // If the root damage rect has been expanded due to overlays, all the other
316 // damage rect calculations are incorrect. 331 // damage rect calculations are incorrect.
317 if (!frame->root_render_pass->damage_rect.Contains(frame->root_damage_rect)) 332 if (!frame->root_render_pass->damage_rect.Contains(frame->root_damage_rect))
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return; 413 return;
399 } 414 }
400 415
401 std::vector<gfx::QuadF> quads; 416 std::vector<gfx::QuadF> quads;
402 poly.ToQuads2D(&quads); 417 poly.ToQuads2D(&quads);
403 for (size_t i = 0; i < quads.size(); ++i) { 418 for (size_t i = 0; i < quads.size(); ++i) {
404 DoDrawQuad(frame, poly.original_ref(), &quads[i]); 419 DoDrawQuad(frame, poly.original_ref(), &quads[i]);
405 } 420 }
406 } 421 }
407 422
423 const FilterOperations* DirectRenderer::FiltersForPass(
424 const RenderPassId& id) const {
425 auto it =
426 std::lower_bound(render_pass_filters_.begin(), render_pass_filters_.end(),
427 std::pair<RenderPassId, FilterOperations*>(id, nullptr));
428 if (it != render_pass_filters_.end() && it->first == id)
429 return it->second;
430 return nullptr;
431 }
432
433 const FilterOperations* DirectRenderer::BackgroundFiltersForPass(
434 const RenderPassId& id) const {
435 auto it =
436 std::lower_bound(render_pass_background_filters_.begin(),
437 render_pass_background_filters_.end(),
438 std::pair<RenderPassId, FilterOperations*>(id, nullptr));
439 if (it != render_pass_background_filters_.end() && it->first == id)
440 return it->second;
441 return nullptr;
442 }
443
408 void DirectRenderer::FlushPolygons( 444 void DirectRenderer::FlushPolygons(
409 std::deque<std::unique_ptr<DrawPolygon>>* poly_list, 445 std::deque<std::unique_ptr<DrawPolygon>>* poly_list,
410 DrawingFrame* frame, 446 DrawingFrame* frame,
411 const gfx::Rect& render_pass_scissor, 447 const gfx::Rect& render_pass_scissor,
412 bool use_render_pass_scissor) { 448 bool use_render_pass_scissor) {
413 if (poly_list->empty()) { 449 if (poly_list->empty()) {
414 return; 450 return;
415 } 451 }
416 452
417 BspTree bsp_tree(poly_list); 453 BspTree bsp_tree(poly_list);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 auto iter = render_pass_textures_.find(id); 608 auto iter = render_pass_textures_.find(id);
573 return iter != render_pass_textures_.end() && iter->second->id(); 609 return iter != render_pass_textures_.end() && iter->second->id();
574 } 610 }
575 611
576 // static 612 // static
577 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { 613 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
578 return render_pass->output_rect.size(); 614 return render_pass->output_rect.size();
579 } 615 }
580 616
581 } // namespace cc 617 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698