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 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 // Once all layers have been drawn, pending texture uploads should no | 1577 // Once all layers have been drawn, pending texture uploads should no |
1578 // longer block future uploads. | 1578 // longer block future uploads. |
1579 resource_provider_->MarkPendingUploadsAsNonBlocking(); | 1579 resource_provider_->MarkPendingUploadsAsNonBlocking(); |
1580 } | 1580 } |
1581 | 1581 |
1582 void LayerTreeHostImpl::FinishAllRendering() { | 1582 void LayerTreeHostImpl::FinishAllRendering() { |
1583 if (renderer_) | 1583 if (renderer_) |
1584 renderer_->Finish(); | 1584 renderer_->Finish(); |
1585 } | 1585 } |
1586 | 1586 |
| 1587 bool LayerTreeHostImpl::CanUseGpuRasterization() { |
| 1588 if (!(output_surface_ && output_surface_->context_provider() && |
| 1589 output_surface_->worker_context_provider())) |
| 1590 return false; |
| 1591 |
| 1592 ContextProvider* context_provider = |
| 1593 output_surface_->worker_context_provider(); |
| 1594 base::AutoLock context_lock(*context_provider->GetLock()); |
| 1595 if (!context_provider->GrContext()) |
| 1596 return false; |
| 1597 |
| 1598 return true; |
| 1599 } |
| 1600 |
1587 void LayerTreeHostImpl::UpdateGpuRasterizationStatus() { | 1601 void LayerTreeHostImpl::UpdateGpuRasterizationStatus() { |
1588 bool use_gpu = false; | 1602 bool use_gpu = false; |
1589 bool use_msaa = false; | 1603 bool use_msaa = false; |
1590 bool using_msaa_for_complex_content = | 1604 bool using_msaa_for_complex_content = |
1591 renderer() && settings_.gpu_rasterization_msaa_sample_count > 0 && | 1605 renderer() && settings_.gpu_rasterization_msaa_sample_count > 0 && |
1592 GetRendererCapabilities().max_msaa_samples >= | 1606 GetRendererCapabilities().max_msaa_samples >= |
1593 settings_.gpu_rasterization_msaa_sample_count; | 1607 settings_.gpu_rasterization_msaa_sample_count; |
1594 if (settings_.gpu_rasterization_forced) { | 1608 if (settings_.gpu_rasterization_forced) { |
1595 use_gpu = true; | 1609 use_gpu = true; |
1596 gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED; | 1610 gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED; |
1597 use_msaa = !content_is_suitable_for_gpu_rasterization_ && | 1611 use_msaa = !content_is_suitable_for_gpu_rasterization_ && |
1598 using_msaa_for_complex_content; | 1612 using_msaa_for_complex_content; |
1599 if (use_msaa) { | 1613 if (use_msaa) { |
1600 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; | 1614 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; |
1601 } | 1615 } |
1602 } else if (!settings_.gpu_rasterization_enabled) { | 1616 } else if (!settings_.gpu_rasterization_enabled) { |
1603 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; | 1617 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; |
1604 } else if (!has_gpu_rasterization_trigger_) { | 1618 } else if (!has_gpu_rasterization_trigger_) { |
1605 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_VIEWPORT; | 1619 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_VIEWPORT; |
1606 } else if (content_is_suitable_for_gpu_rasterization_) { | 1620 } else if (content_is_suitable_for_gpu_rasterization_) { |
1607 use_gpu = true; | 1621 use_gpu = true; |
1608 gpu_rasterization_status_ = GpuRasterizationStatus::ON; | 1622 gpu_rasterization_status_ = GpuRasterizationStatus::ON; |
1609 } else if (using_msaa_for_complex_content) { | 1623 } else if (using_msaa_for_complex_content) { |
1610 use_gpu = use_msaa = true; | 1624 use_gpu = use_msaa = true; |
1611 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; | 1625 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; |
1612 } else { | 1626 } else { |
1613 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_CONTENT; | 1627 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_CONTENT; |
1614 } | 1628 } |
1615 | 1629 |
| 1630 if (use_gpu && !use_gpu_rasterization_) { |
| 1631 if (!CanUseGpuRasterization()) { |
| 1632 // If GPU rasterization is unusable, e.g. if GlContext could not |
| 1633 // be created due to losing the GL context, force use of software |
| 1634 // raster. |
| 1635 use_gpu = false; |
| 1636 use_msaa = false; |
| 1637 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; |
| 1638 } |
| 1639 } |
| 1640 |
1616 if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_) | 1641 if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_) |
1617 return; | 1642 return; |
1618 | 1643 |
1619 // Note that this must happen first, in case the rest of the calls want to | 1644 // Note that this must happen first, in case the rest of the calls want to |
1620 // query the new state of |use_gpu_rasterization_|. | 1645 // query the new state of |use_gpu_rasterization_|. |
1621 use_gpu_rasterization_ = use_gpu; | 1646 use_gpu_rasterization_ = use_gpu; |
1622 use_msaa_ = use_msaa; | 1647 use_msaa_ = use_msaa; |
1623 | 1648 |
1624 // Clean up and replace existing tile manager with another one that uses | 1649 // Clean up and replace existing tile manager with another one that uses |
1625 // appropriate rasterizer. | 1650 // appropriate rasterizer. |
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3396 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3421 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3397 | 3422 |
3398 curve->UpdateTarget( | 3423 curve->UpdateTarget( |
3399 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3424 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3400 .InSecondsF(), | 3425 .InSecondsF(), |
3401 new_target); | 3426 new_target); |
3402 | 3427 |
3403 return true; | 3428 return true; |
3404 } | 3429 } |
3405 } // namespace cc | 3430 } // namespace cc |
OLD | NEW |