| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 render_surface_layer->filter().get()); | 407 render_surface_layer->filter().get()); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 | 410 |
| 411 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 411 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
| 412 scoped_ptr<RenderPass> render_pass) { | 412 scoped_ptr<RenderPass> render_pass) { |
| 413 render_passes_by_id[render_pass->id] = render_pass.get(); | 413 render_passes_by_id[render_pass->id] = render_pass.get(); |
| 414 render_passes.push_back(render_pass.Pass()); | 414 render_passes.push_back(render_pass.Pass()); |
| 415 } | 415 } |
| 416 | 416 |
| 417 static DrawMode GetDrawMode(OutputSurface* output_surface) { |
| 418 if (output_surface->ForcedDrawToSoftwareDevice()) { |
| 419 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
| 420 } else if (output_surface->context3d()) { |
| 421 return DRAW_MODE_HARDWARE; |
| 422 } else { |
| 423 DCHECK(output_surface->software_device()); |
| 424 return DRAW_MODE_SOFTWARE; |
| 425 } |
| 426 } |
| 427 |
| 417 static void AppendQuadsForLayer(RenderPass* target_render_pass, | 428 static void AppendQuadsForLayer(RenderPass* target_render_pass, |
| 418 LayerImpl* layer, | 429 LayerImpl* layer, |
| 419 const OcclusionTrackerImpl& occlusion_tracker, | 430 const OcclusionTrackerImpl& occlusion_tracker, |
| 420 AppendQuadsData* append_quads_data) { | 431 AppendQuadsData* append_quads_data) { |
| 421 bool for_surface = false; | 432 bool for_surface = false; |
| 422 QuadCuller quad_culler(&target_render_pass->quad_list, | 433 QuadCuller quad_culler(&target_render_pass->quad_list, |
| 423 &target_render_pass->shared_quad_state_list, | 434 &target_render_pass->shared_quad_state_list, |
| 424 layer, | 435 layer, |
| 425 occlusion_tracker, | 436 occlusion_tracker, |
| 426 layer->ShowDebugBorders(), | 437 layer->ShowDebugBorders(), |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 // still draw the frame. However when the layer being checkerboarded is moving | 596 // still draw the frame. However when the layer being checkerboarded is moving |
| 586 // due to an impl-animation, we drop the frame to avoid flashing due to the | 597 // due to an impl-animation, we drop the frame to avoid flashing due to the |
| 587 // texture suddenly appearing in the future. | 598 // texture suddenly appearing in the future. |
| 588 bool draw_frame = true; | 599 bool draw_frame = true; |
| 589 // When we have a copy request for a layer, we need to draw no matter | 600 // When we have a copy request for a layer, we need to draw no matter |
| 590 // what, as the layer may disappear after this frame. | 601 // what, as the layer may disappear after this frame. |
| 591 bool have_copy_request = false; | 602 bool have_copy_request = false; |
| 592 | 603 |
| 593 int layers_drawn = 0; | 604 int layers_drawn = 0; |
| 594 | 605 |
| 606 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); |
| 607 |
| 595 LayerIteratorType end = | 608 LayerIteratorType end = |
| 596 LayerIteratorType::End(frame->render_surface_layer_list); | 609 LayerIteratorType::End(frame->render_surface_layer_list); |
| 597 for (LayerIteratorType it = | 610 for (LayerIteratorType it = |
| 598 LayerIteratorType::Begin(frame->render_surface_layer_list); | 611 LayerIteratorType::Begin(frame->render_surface_layer_list); |
| 599 it != end; | 612 it != end; |
| 600 ++it) { | 613 ++it) { |
| 601 RenderPass::Id target_render_pass_id = | 614 RenderPass::Id target_render_pass_id = |
| 602 it.target_render_surface_layer()->render_surface()->RenderPassId(); | 615 it.target_render_surface_layer()->render_surface()->RenderPassId(); |
| 603 RenderPass* target_render_pass = | 616 RenderPass* target_render_pass = |
| 604 frame->render_passes_by_id[target_render_pass_id]; | 617 frame->render_passes_by_id[target_render_pass_id]; |
| 605 | 618 |
| 606 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); | 619 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); |
| 607 occlusion_tracker.EnterLayer(it, prevent_occlusion); | 620 occlusion_tracker.EnterLayer(it, prevent_occlusion); |
| 608 | 621 |
| 609 AppendQuadsData append_quads_data(target_render_pass->id); | 622 AppendQuadsData append_quads_data(target_render_pass->id); |
| 610 if (output_surface_->ForcedDrawToSoftwareDevice()) | |
| 611 append_quads_data.allow_tile_draw_quads = false; | |
| 612 | 623 |
| 613 if (it.represents_target_render_surface()) { | 624 if (it.represents_target_render_surface()) { |
| 614 if (it->HasCopyRequest()) { | 625 if (it->HasCopyRequest()) { |
| 615 have_copy_request = true; | 626 have_copy_request = true; |
| 616 it->TakeCopyRequests(&target_render_pass->copy_requests); | 627 it->TakeCopyRequests(&target_render_pass->copy_requests); |
| 617 } | 628 } |
| 618 } else if (it.represents_contributing_render_surface()) { | 629 } else if (it.represents_contributing_render_surface()) { |
| 619 RenderPass::Id contributing_render_pass_id = | 630 RenderPass::Id contributing_render_pass_id = |
| 620 it->render_surface()->RenderPassId(); | 631 it->render_surface()->RenderPassId(); |
| 621 RenderPass* contributing_render_pass = | 632 RenderPass* contributing_render_pass = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 632 if (occlusion_tracker.Occluded( | 643 if (occlusion_tracker.Occluded( |
| 633 it->render_target(), | 644 it->render_target(), |
| 634 it->visible_content_rect(), | 645 it->visible_content_rect(), |
| 635 it->draw_transform(), | 646 it->draw_transform(), |
| 636 impl_draw_transform_is_unknown, | 647 impl_draw_transform_is_unknown, |
| 637 it->is_clipped(), | 648 it->is_clipped(), |
| 638 it->clip_rect(), | 649 it->clip_rect(), |
| 639 &has_occlusion_from_outside_target_surface)) { | 650 &has_occlusion_from_outside_target_surface)) { |
| 640 append_quads_data.had_occlusion_from_outside_target_surface |= | 651 append_quads_data.had_occlusion_from_outside_target_surface |= |
| 641 has_occlusion_from_outside_target_surface; | 652 has_occlusion_from_outside_target_surface; |
| 642 } else { | 653 } else if (it->WillDraw(draw_mode, resource_provider_.get())) { |
| 643 DCHECK_EQ(active_tree_, it->layer_tree_impl()); | 654 DCHECK_EQ(active_tree_, it->layer_tree_impl()); |
| 644 it->WillDraw(resource_provider_.get()); | 655 |
| 645 frame->will_draw_layers.push_back(*it); | 656 frame->will_draw_layers.push_back(*it); |
| 646 | 657 |
| 647 if (it->HasContributingDelegatedRenderPasses()) { | 658 if (it->HasContributingDelegatedRenderPasses()) { |
| 648 RenderPass::Id contributing_render_pass_id = | 659 RenderPass::Id contributing_render_pass_id = |
| 649 it->FirstContributingRenderPassId(); | 660 it->FirstContributingRenderPassId(); |
| 650 while (frame->render_passes_by_id.find(contributing_render_pass_id) != | 661 while (frame->render_passes_by_id.find(contributing_render_pass_id) != |
| 651 frame->render_passes_by_id.end()) { | 662 frame->render_passes_by_id.end()) { |
| 652 RenderPass* render_pass = | 663 RenderPass* render_pass = |
| 653 frame->render_passes_by_id[contributing_render_pass_id]; | 664 frame->render_passes_by_id[contributing_render_pass_id]; |
| 654 | 665 |
| (...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 } | 2253 } |
| 2243 | 2254 |
| 2244 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2255 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
| 2245 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2256 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
| 2246 paint_time_counter_->ClearHistory(); | 2257 paint_time_counter_->ClearHistory(); |
| 2247 | 2258 |
| 2248 debug_state_ = debug_state; | 2259 debug_state_ = debug_state; |
| 2249 } | 2260 } |
| 2250 | 2261 |
| 2251 } // namespace cc | 2262 } // namespace cc |
| OLD | NEW |