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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 // If we're not visible, we likely released resources, so we want to | 1513 // If we're not visible, we likely released resources, so we want to |
1514 // aggressively flush here to make sure those DeleteTextures make it to the | 1514 // aggressively flush here to make sure those DeleteTextures make it to the |
1515 // GPU process to free up the memory. | 1515 // GPU process to free up the memory. |
1516 if (output_surface_->context_provider() && !visible_) { | 1516 if (output_surface_->context_provider() && !visible_) { |
1517 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); | 1517 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); |
1518 } | 1518 } |
1519 } | 1519 } |
1520 | 1520 |
1521 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, | 1521 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, |
1522 const gfx::Rect& viewport, | 1522 const gfx::Rect& viewport, |
1523 const gfx::Rect& clip, | |
1524 bool resourceless_software_draw) { | 1523 bool resourceless_software_draw) { |
1525 DCHECK(!resourceless_software_draw_); | 1524 DCHECK(!resourceless_software_draw_); |
1526 const bool transform_changed = external_transform_ != transform; | 1525 const bool transform_changed = external_transform_ != transform; |
1527 const bool viewport_changed = external_viewport_ != viewport; | 1526 const bool viewport_changed = external_viewport_ != viewport; |
1528 const bool clip_changed = external_clip_ != clip; | |
1529 | 1527 |
1530 external_transform_ = transform; | 1528 external_transform_ = transform; |
1531 external_viewport_ = viewport; | 1529 external_viewport_ = viewport; |
1532 external_clip_ = clip; | |
1533 | 1530 |
1534 { | 1531 { |
1535 base::AutoReset<bool> resourceless_software_draw_reset( | 1532 base::AutoReset<bool> resourceless_software_draw_reset( |
1536 &resourceless_software_draw_, resourceless_software_draw); | 1533 &resourceless_software_draw_, resourceless_software_draw); |
1537 | 1534 |
1538 // For resourceless software draw, always set full damage to ensure they | 1535 // For resourceless software draw, always set full damage to ensure they |
1539 // always swap. Otherwise, need to set redraw for any changes to draw | 1536 // always swap. Otherwise, need to set redraw for any changes to draw |
1540 // parameters. | 1537 // parameters. |
1541 const bool draw_params_changed = | 1538 if (transform_changed || viewport_changed || resourceless_software_draw_) { |
1542 transform_changed || viewport_changed || clip_changed; | |
1543 if (resourceless_software_draw_ || draw_params_changed) { | |
1544 SetFullRootLayerDamage(); | 1539 SetFullRootLayerDamage(); |
1545 SetNeedsRedraw(); | 1540 SetNeedsRedraw(); |
1546 } | |
1547 | |
1548 // UpdateDrawProperties does not depend on clip. | |
1549 if (transform_changed || viewport_changed || resourceless_software_draw_) { | |
1550 active_tree_->set_needs_update_draw_properties(); | 1541 active_tree_->set_needs_update_draw_properties(); |
1551 } | 1542 } |
1552 | 1543 |
1553 if (resourceless_software_draw) { | 1544 if (resourceless_software_draw) { |
1554 client_->OnCanDrawStateChanged(CanDraw()); | 1545 client_->OnCanDrawStateChanged(CanDraw()); |
1555 } | 1546 } |
1556 | 1547 |
1557 client_->OnDrawForOutputSurface(resourceless_software_draw_); | 1548 client_->OnDrawForOutputSurface(resourceless_software_draw_); |
1558 } | 1549 } |
1559 | 1550 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 // contents of its texture are updated as the last thing before the frame is | 1661 // contents of its texture are updated as the last thing before the frame is |
1671 // drawn. | 1662 // drawn. |
1672 if (active_tree_->hud_layer()) { | 1663 if (active_tree_->hud_layer()) { |
1673 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1664 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
1674 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1665 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
1675 resource_provider_.get()); | 1666 resource_provider_.get()); |
1676 } | 1667 } |
1677 | 1668 |
1678 renderer_->DrawFrame(&frame->render_passes, | 1669 renderer_->DrawFrame(&frame->render_passes, |
1679 active_tree_->device_scale_factor(), gfx::ColorSpace(), | 1670 active_tree_->device_scale_factor(), gfx::ColorSpace(), |
1680 DeviceViewport(), DeviceClip()); | 1671 DeviceViewport(), DeviceViewport()); |
1681 // The render passes should be consumed by the renderer. | 1672 // The render passes should be consumed by the renderer. |
1682 DCHECK(frame->render_passes.empty()); | 1673 DCHECK(frame->render_passes.empty()); |
1683 | 1674 |
1684 // The next frame should start by assuming nothing has changed, and changes | 1675 // The next frame should start by assuming nothing has changed, and changes |
1685 // are noted as they occur. | 1676 // are noted as they occur. |
1686 // TODO(boliu): If we did a temporary software renderer frame, propogate the | 1677 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
1687 // damage forward to the next frame. | 1678 // damage forward to the next frame. |
1688 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | 1679 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { |
1689 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> | 1680 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> |
1690 DidDrawDamagedArea(); | 1681 DidDrawDamagedArea(); |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 return DeviceViewport().size(); | 2392 return DeviceViewport().size(); |
2402 } | 2393 } |
2403 | 2394 |
2404 gfx::Rect LayerTreeHostImpl::DeviceViewport() const { | 2395 gfx::Rect LayerTreeHostImpl::DeviceViewport() const { |
2405 if (external_viewport_.IsEmpty()) | 2396 if (external_viewport_.IsEmpty()) |
2406 return gfx::Rect(device_viewport_size_); | 2397 return gfx::Rect(device_viewport_size_); |
2407 | 2398 |
2408 return external_viewport_; | 2399 return external_viewport_; |
2409 } | 2400 } |
2410 | 2401 |
2411 gfx::Rect LayerTreeHostImpl::DeviceClip() const { | |
2412 if (external_clip_.IsEmpty()) | |
2413 return DeviceViewport(); | |
2414 | |
2415 return external_clip_; | |
2416 } | |
2417 | |
2418 const gfx::Transform& LayerTreeHostImpl::DrawTransform() const { | 2402 const gfx::Transform& LayerTreeHostImpl::DrawTransform() const { |
2419 return external_transform_; | 2403 return external_transform_; |
2420 } | 2404 } |
2421 | 2405 |
2422 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2406 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
2423 UpdateViewportContainerSizes(); | 2407 UpdateViewportContainerSizes(); |
2424 SetNeedsRedraw(); | 2408 SetNeedsRedraw(); |
2425 SetNeedsOneBeginImplFrame(); | 2409 SetNeedsOneBeginImplFrame(); |
2426 active_tree_->set_needs_update_draw_properties(); | 2410 active_tree_->set_needs_update_draw_properties(); |
2427 SetFullRootLayerDamage(); | 2411 SetFullRootLayerDamage(); |
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4052 return task_runner_provider_->HasImplThread(); | 4036 return task_runner_provider_->HasImplThread(); |
4053 } | 4037 } |
4054 | 4038 |
4055 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4039 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4056 // In single threaded mode we skip the pending tree and commit directly to the | 4040 // In single threaded mode we skip the pending tree and commit directly to the |
4057 // active tree. | 4041 // active tree. |
4058 return !task_runner_provider_->HasImplThread(); | 4042 return !task_runner_provider_->HasImplThread(); |
4059 } | 4043 } |
4060 | 4044 |
4061 } // namespace cc | 4045 } // namespace cc |
OLD | NEW |