| 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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 | 1674 |
| 1675 bool LayerTreeHostImpl::DeferredInitialize( | 1675 bool LayerTreeHostImpl::DeferredInitialize( |
| 1676 scoped_refptr<ContextProvider> offscreen_context_provider) { | 1676 scoped_refptr<ContextProvider> offscreen_context_provider) { |
| 1677 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 1677 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
| 1678 DCHECK(settings_.impl_side_painting); | 1678 DCHECK(settings_.impl_side_painting); |
| 1679 DCHECK(settings_.solid_color_scrollbars); | 1679 DCHECK(settings_.solid_color_scrollbars); |
| 1680 DCHECK(output_surface_->context_provider()); | 1680 DCHECK(output_surface_->context_provider()); |
| 1681 | 1681 |
| 1682 ReleaseTreeResources(); | 1682 ReleaseTreeResources(); |
| 1683 renderer_.reset(); | 1683 renderer_.reset(); |
| 1684 resource_provider_->InitializeGL(); | |
| 1685 bool skip_gl_renderer = false; | |
| 1686 CreateAndSetRenderer( | |
| 1687 output_surface_.get(), resource_provider_.get(), skip_gl_renderer); | |
| 1688 | 1684 |
| 1689 bool success = !!renderer_.get(); | 1685 bool resource_provider_success = resource_provider_->InitializeGL(); |
| 1686 |
| 1687 bool success = resource_provider_success; |
| 1688 if (success) { |
| 1689 bool skip_gl_renderer = false; |
| 1690 CreateAndSetRenderer( |
| 1691 output_surface_.get(), resource_provider_.get(), skip_gl_renderer); |
| 1692 if (!renderer_) |
| 1693 success = false; |
| 1694 } |
| 1695 |
| 1696 if (success) { |
| 1697 if (offscreen_context_provider.get() && |
| 1698 !offscreen_context_provider->BindToCurrentThread()) |
| 1699 success = false; |
| 1700 } |
| 1701 |
| 1690 if (success) { | 1702 if (success) { |
| 1691 EnforceZeroBudget(false); | 1703 EnforceZeroBudget(false); |
| 1692 client_->SetNeedsCommitOnImplThread(); | 1704 client_->SetNeedsCommitOnImplThread(); |
| 1693 } else if (offscreen_context_provider.get()) { | 1705 } else { |
| 1694 if (offscreen_context_provider->BindToCurrentThread()) | 1706 if (offscreen_context_provider.get()) { |
| 1695 offscreen_context_provider->VerifyContexts(); | 1707 if (offscreen_context_provider->BindToCurrentThread()) |
| 1696 offscreen_context_provider = NULL; | 1708 offscreen_context_provider->VerifyContexts(); |
| 1709 offscreen_context_provider = NULL; |
| 1710 } |
| 1711 |
| 1712 client_->DidLoseOutputSurfaceOnImplThread(); |
| 1713 |
| 1714 if (resource_provider_success) { |
| 1715 // If this fails the context provider will be dropped from the output |
| 1716 // surface and destroyed. But the GLRenderer expects the output surface |
| 1717 // to stick around - and hold onto the context3d - as long as it is alive. |
| 1718 // TODO(danakj): Remove the need for this code path: crbug.com/276411 |
| 1719 renderer_.reset(); |
| 1720 |
| 1721 // The resource provider can't stay in GL mode or it tries to clean up GL |
| 1722 // stuff, but the context provider is going away on the output surface |
| 1723 // which contradicts being in GL mode. |
| 1724 // TODO(danakj): Remove the need for this code path: crbug.com/276411 |
| 1725 resource_provider_->InitializeSoftware(); |
| 1726 } |
| 1697 } | 1727 } |
| 1698 | 1728 |
| 1699 SetOffscreenContextProvider(offscreen_context_provider); | 1729 SetOffscreenContextProvider(offscreen_context_provider); |
| 1700 return success; | 1730 return success; |
| 1701 } | 1731 } |
| 1702 | 1732 |
| 1703 void LayerTreeHostImpl::ReleaseGL() { | 1733 void LayerTreeHostImpl::ReleaseGL() { |
| 1704 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 1734 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
| 1705 DCHECK(settings_.impl_side_painting); | 1735 DCHECK(settings_.impl_side_painting); |
| 1706 DCHECK(settings_.solid_color_scrollbars); | 1736 DCHECK(settings_.solid_color_scrollbars); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 | 2568 |
| 2539 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2569 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2540 UIResourceId uid) const { | 2570 UIResourceId uid) const { |
| 2541 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2571 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2542 if (iter != ui_resource_map_.end()) | 2572 if (iter != ui_resource_map_.end()) |
| 2543 return iter->second; | 2573 return iter->second; |
| 2544 return 0; | 2574 return 0; |
| 2545 } | 2575 } |
| 2546 | 2576 |
| 2547 } // namespace cc | 2577 } // namespace cc |
| OLD | NEW |