Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 DCHECK(initialized_); | 159 DCHECK(initialized_); |
| 160 if (visible_ == visible) | 160 if (visible_ == visible) |
| 161 return; | 161 return; |
| 162 visible_ = visible; | 162 visible_ = visible; |
| 163 DidChangeVisibility(); | 163 DidChangeVisibility(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void DirectRenderer::DecideRenderPassAllocationsForFrame( | 166 void DirectRenderer::DecideRenderPassAllocationsForFrame( |
| 167 const RenderPassList& render_passes_in_draw_order) { | 167 const RenderPassList& render_passes_in_draw_order) { |
| 168 render_pass_bypass_quads_.clear(); | 168 render_pass_bypass_quads_.clear(); |
| 169 render_pass_filters_.clear(); | |
|
danakj
2016/12/01 01:50:46
This isn't part of allocating.. while I appreciate
ajuma
2016/12/13 15:08:11
Done.
| |
| 170 render_pass_background_filters_.clear(); | |
| 169 | 171 |
| 170 std::unordered_map<RenderPassId, gfx::Size, RenderPassIdHash> | 172 std::unordered_map<RenderPassId, gfx::Size, RenderPassIdHash> |
| 171 render_passes_in_frame; | 173 render_passes_in_frame; |
| 172 RenderPass* root_render_pass = render_passes_in_draw_order.back().get(); | 174 RenderPass* root_render_pass = render_passes_in_draw_order.back().get(); |
| 173 for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i) { | 175 for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i) { |
| 174 RenderPass* pass = render_passes_in_draw_order[i].get(); | 176 RenderPass* pass = render_passes_in_draw_order[i].get(); |
| 175 if (pass != root_render_pass) { | 177 if (pass != root_render_pass) { |
| 178 if (!pass->filters.IsEmpty()) | |
| 179 render_pass_filters_.push_back(std::make_pair(pass->id, pass->filters)); | |
|
danakj
2016/12/01 01:50:46
why copy the filters, you could store a pointer to
weiliangc
2016/12/01 21:20:54
I mean we store the filters pointers here, and whe
danakj
2016/12/01 21:26:02
i'm not totally sure what you mean, but what i mea
ajuma
2016/12/13 15:08:11
Changed to storing a pointer to the RenderPass's f
| |
| 180 if (!pass->background_filters.IsEmpty()) { | |
| 181 render_pass_background_filters_.push_back( | |
| 182 std::make_pair(pass->id, pass->background_filters)); | |
| 183 } | |
| 176 if (const TileDrawQuad* tile_quad = CanPassBeDrawnDirectly(pass)) { | 184 if (const TileDrawQuad* tile_quad = CanPassBeDrawnDirectly(pass)) { |
| 177 render_pass_bypass_quads_[pass->id] = *tile_quad; | 185 render_pass_bypass_quads_[pass->id] = *tile_quad; |
| 178 continue; | 186 continue; |
| 179 } | 187 } |
| 188 } else { | |
| 189 DCHECK(pass->filters.IsEmpty()); | |
| 190 DCHECK(pass->background_filters.IsEmpty()); | |
| 180 } | 191 } |
| 181 render_passes_in_frame.insert(std::pair<RenderPassId, gfx::Size>( | 192 render_passes_in_frame.insert(std::pair<RenderPassId, gfx::Size>( |
| 182 pass->id, RenderPassTextureSize(pass))); | 193 pass->id, RenderPassTextureSize(pass))); |
| 183 } | 194 } |
| 184 | 195 |
| 185 std::vector<RenderPassId> passes_to_delete; | 196 std::vector<RenderPassId> passes_to_delete; |
| 186 for (auto pass_iter = render_pass_textures_.begin(); | 197 for (auto pass_iter = render_pass_textures_.begin(); |
| 187 pass_iter != render_pass_textures_.end(); ++pass_iter) { | 198 pass_iter != render_pass_textures_.end(); ++pass_iter) { |
| 188 auto it = render_passes_in_frame.find(pass_iter->first); | 199 auto it = render_passes_in_frame.find(pass_iter->first); |
| 189 if (it == render_passes_in_frame.end()) { | 200 if (it == render_passes_in_frame.end()) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 output_surface_plane.quad_rect_in_target_space = | 281 output_surface_plane.quad_rect_in_target_space = |
| 271 root_render_pass->output_rect; | 282 root_render_pass->output_rect; |
| 272 output_surface_plane.use_output_surface_for_resource = true; | 283 output_surface_plane.use_output_surface_for_resource = true; |
| 273 output_surface_plane.overlay_handled = true; | 284 output_surface_plane.overlay_handled = true; |
| 274 frame.overlay_list.push_back(output_surface_plane); | 285 frame.overlay_list.push_back(output_surface_plane); |
| 275 } | 286 } |
| 276 | 287 |
| 277 // Attempt to replace some or all of the quads of the root render pass with | 288 // Attempt to replace some or all of the quads of the root render pass with |
| 278 // overlays. | 289 // overlays. |
| 279 overlay_processor_->ProcessForOverlays( | 290 overlay_processor_->ProcessForOverlays( |
| 280 resource_provider_, root_render_pass, &frame.overlay_list, | 291 resource_provider_, root_render_pass, render_pass_filters_, |
| 292 render_pass_background_filters_, &frame.overlay_list, | |
| 281 &frame.ca_layer_overlay_list, &frame.root_damage_rect); | 293 &frame.ca_layer_overlay_list, &frame.root_damage_rect); |
| 282 | 294 |
| 283 // We can skip all drawing if the damage rect is now empty. | 295 // We can skip all drawing if the damage rect is now empty. |
| 284 bool skip_drawing_root_render_pass = | 296 bool skip_drawing_root_render_pass = |
| 285 frame.root_damage_rect.IsEmpty() && allow_empty_swap_; | 297 frame.root_damage_rect.IsEmpty() && allow_empty_swap_; |
| 286 | 298 |
| 287 // If we have to draw but don't support partial swap, the whole output should | 299 // If we have to draw but don't support partial swap, the whole output should |
| 288 // be considered damaged. | 300 // be considered damaged. |
| 289 if (!skip_drawing_root_render_pass && !use_partial_swap_) | 301 if (!skip_drawing_root_render_pass && !use_partial_swap_) |
| 290 frame.root_damage_rect = root_render_pass->output_rect; | 302 frame.root_damage_rect = root_render_pass->output_rect; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 return; | 410 return; |
| 399 } | 411 } |
| 400 | 412 |
| 401 std::vector<gfx::QuadF> quads; | 413 std::vector<gfx::QuadF> quads; |
| 402 poly.ToQuads2D(&quads); | 414 poly.ToQuads2D(&quads); |
| 403 for (size_t i = 0; i < quads.size(); ++i) { | 415 for (size_t i = 0; i < quads.size(); ++i) { |
| 404 DoDrawQuad(frame, poly.original_ref(), &quads[i]); | 416 DoDrawQuad(frame, poly.original_ref(), &quads[i]); |
| 405 } | 417 } |
| 406 } | 418 } |
| 407 | 419 |
| 420 const FilterOperations* DirectRenderer::FiltersForPass(RenderPassId id) const { | |
|
danakj
2016/12/01 01:50:46
const&?
weiliangc
2016/12/01 21:20:54
like mentioned in line 179, if we store pointers,
danakj
2016/12/01 21:26:02
here I'm talking about the |id|
ajuma
2016/12/13 15:08:11
Changed |id| to const&, but then changed back to p
| |
| 421 auto it = | |
| 422 std::find_if(render_pass_filters_.begin(), render_pass_filters_.end(), | |
| 423 [id](const std::pair<RenderPassId, FilterOperations>& p) { | |
| 424 return p.first == id; | |
| 425 }); | |
| 426 return it == render_pass_filters_.end() ? nullptr : &it->second; | |
| 427 } | |
| 428 | |
| 429 const FilterOperations* DirectRenderer::BackgroundFiltersForPass( | |
| 430 RenderPassId id) const { | |
|
danakj
2016/12/01 01:50:46
const&
ajuma
2016/12/13 15:08:11
Done.
| |
| 431 auto it = | |
| 432 std::find_if(render_pass_background_filters_.begin(), | |
| 433 render_pass_background_filters_.end(), | |
| 434 [id](const std::pair<RenderPassId, FilterOperations>& p) { | |
| 435 return p.first == id; | |
| 436 }); | |
| 437 return it == render_pass_background_filters_.end() ? nullptr : &it->second; | |
| 438 } | |
| 439 | |
| 408 void DirectRenderer::FlushPolygons( | 440 void DirectRenderer::FlushPolygons( |
| 409 std::deque<std::unique_ptr<DrawPolygon>>* poly_list, | 441 std::deque<std::unique_ptr<DrawPolygon>>* poly_list, |
| 410 DrawingFrame* frame, | 442 DrawingFrame* frame, |
| 411 const gfx::Rect& render_pass_scissor, | 443 const gfx::Rect& render_pass_scissor, |
| 412 bool use_render_pass_scissor) { | 444 bool use_render_pass_scissor) { |
| 413 if (poly_list->empty()) { | 445 if (poly_list->empty()) { |
| 414 return; | 446 return; |
| 415 } | 447 } |
| 416 | 448 |
| 417 BspTree bsp_tree(poly_list); | 449 BspTree bsp_tree(poly_list); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 auto iter = render_pass_textures_.find(id); | 604 auto iter = render_pass_textures_.find(id); |
| 573 return iter != render_pass_textures_.end() && iter->second->id(); | 605 return iter != render_pass_textures_.end() && iter->second->id(); |
| 574 } | 606 } |
| 575 | 607 |
| 576 // static | 608 // static |
| 577 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 609 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 578 return render_pass->output_rect.size(); | 610 return render_pass->output_rect.size(); |
| 579 } | 611 } |
| 580 | 612 |
| 581 } // namespace cc | 613 } // namespace cc |
| OLD | NEW |