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