Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 899313003: cc: Split ReleaseResources into Release and Recreate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 delta = outer_->ScrollBy(delta); 109 delta = outer_->ScrollBy(delta);
110 inner_->ScrollBy(delta); 110 inner_->ScrollBy(delta);
111 } 111 }
112 112
113 private: 113 private:
114 LayerImpl* inner_; 114 LayerImpl* inner_;
115 LayerImpl* outer_; 115 LayerImpl* outer_;
116 gfx::ScrollOffset viewport_in_content_coordinates_; 116 gfx::ScrollOffset viewport_in_content_coordinates_;
117 }; 117 };
118 118
119
120 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { 119 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) {
121 if (visible) { 120 if (visible) {
122 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id, 121 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id,
123 "LayerTreeHostImpl", id); 122 "LayerTreeHostImpl", id);
124 return; 123 return;
125 } 124 }
126 125
127 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id); 126 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id);
128 } 127 }
129 128
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 // query the new state of |use_gpu_rasterization_|. 1608 // query the new state of |use_gpu_rasterization_|.
1610 use_gpu_rasterization_ = use_gpu; 1609 use_gpu_rasterization_ = use_gpu;
1611 1610
1612 // Clean up and replace existing tile manager with another one that uses 1611 // Clean up and replace existing tile manager with another one that uses
1613 // appropriate rasterizer. 1612 // appropriate rasterizer.
1614 ReleaseTreeResources(); 1613 ReleaseTreeResources();
1615 if (tile_manager_) { 1614 if (tile_manager_) {
1616 DestroyTileManager(); 1615 DestroyTileManager();
1617 CreateAndSetTileManager(); 1616 CreateAndSetTileManager();
1618 } 1617 }
1618 RecreateTreeResources();
1619 1619
1620 // We have released tilings for both active and pending tree. 1620 // We have released tilings for both active and pending tree.
1621 // We would not have any content to draw until the pending tree is activated. 1621 // We would not have any content to draw until the pending tree is activated.
1622 // Prevent the active tree from drawing until activation. 1622 // Prevent the active tree from drawing until activation.
1623 SetRequiresHighResToDraw(); 1623 SetRequiresHighResToDraw();
1624 } 1624 }
1625 1625
1626 const RendererCapabilitiesImpl& 1626 const RendererCapabilitiesImpl&
1627 LayerTreeHostImpl::GetRendererCapabilities() const { 1627 LayerTreeHostImpl::GetRendererCapabilities() const {
1628 return renderer_->Capabilities(); 1628 return renderer_->Capabilities();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 void LayerTreeHostImpl::ReleaseTreeResources() { 1927 void LayerTreeHostImpl::ReleaseTreeResources() {
1928 active_tree_->ReleaseResources(); 1928 active_tree_->ReleaseResources();
1929 if (pending_tree_) 1929 if (pending_tree_)
1930 pending_tree_->ReleaseResources(); 1930 pending_tree_->ReleaseResources();
1931 if (recycle_tree_) 1931 if (recycle_tree_)
1932 recycle_tree_->ReleaseResources(); 1932 recycle_tree_->ReleaseResources();
1933 1933
1934 EvictAllUIResources(); 1934 EvictAllUIResources();
1935 } 1935 }
1936 1936
1937 void LayerTreeHostImpl::RecreateTreeResources() {
1938 active_tree_->RecreateResources();
1939 if (pending_tree_)
1940 pending_tree_->RecreateResources();
1941 if (recycle_tree_)
1942 recycle_tree_->RecreateResources();
1943 }
1944
1937 void LayerTreeHostImpl::CreateAndSetRenderer() { 1945 void LayerTreeHostImpl::CreateAndSetRenderer() {
1938 DCHECK(!renderer_); 1946 DCHECK(!renderer_);
1939 DCHECK(output_surface_); 1947 DCHECK(output_surface_);
1940 DCHECK(resource_provider_); 1948 DCHECK(resource_provider_);
1941 1949
1942 if (output_surface_->capabilities().delegated_rendering) { 1950 if (output_surface_->capabilities().delegated_rendering) {
1943 renderer_ = DelegatingRenderer::Create(this, &settings_.renderer_settings, 1951 renderer_ = DelegatingRenderer::Create(this, &settings_.renderer_settings,
1944 output_surface_.get(), 1952 output_surface_.get(),
1945 resource_provider_.get()); 1953 resource_provider_.get());
1946 } else if (output_surface_->context_provider()) { 1954 } else if (output_surface_->context_provider()) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 // the old resources (i.e. render_surfaces and texture IDs). Clear them 2126 // the old resources (i.e. render_surfaces and texture IDs). Clear them
2119 // before we destroy the old resource provider. 2127 // before we destroy the old resource provider.
2120 ReleaseTreeResources(); 2128 ReleaseTreeResources();
2121 2129
2122 // Note: order is important here. 2130 // Note: order is important here.
2123 renderer_ = nullptr; 2131 renderer_ = nullptr;
2124 DestroyTileManager(); 2132 DestroyTileManager();
2125 resource_provider_ = nullptr; 2133 resource_provider_ = nullptr;
2126 output_surface_ = nullptr; 2134 output_surface_ = nullptr;
2127 2135
2128 if (!output_surface->BindToClient(this)) 2136 if (!output_surface->BindToClient(this)) {
2137 // Avoid recreating tree resources because we might not have enough
2138 // information to do this yet (eg. we don't have a TileManager at this
2139 // point).
2129 return false; 2140 return false;
2141 }
2130 2142
2131 output_surface_ = output_surface.Pass(); 2143 output_surface_ = output_surface.Pass();
2132 resource_provider_ = ResourceProvider::Create( 2144 resource_provider_ = ResourceProvider::Create(
2133 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, 2145 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_,
2134 proxy_->blocking_main_thread_task_runner(), 2146 proxy_->blocking_main_thread_task_runner(),
2135 settings_.renderer_settings.highp_threshold_min, 2147 settings_.renderer_settings.highp_threshold_min,
2136 settings_.renderer_settings.use_rgba_4444_textures, 2148 settings_.renderer_settings.use_rgba_4444_textures,
2137 settings_.renderer_settings.texture_id_allocation_chunk_size); 2149 settings_.renderer_settings.texture_id_allocation_chunk_size);
2138 2150
2139 if (output_surface_->capabilities().deferred_gl_initialization) 2151 if (output_surface_->capabilities().deferred_gl_initialization)
2140 EnforceZeroBudget(true); 2152 EnforceZeroBudget(true);
2141 2153
2142 CreateAndSetRenderer(); 2154 CreateAndSetRenderer();
2143 2155
2144 if (settings_.impl_side_painting) 2156 if (settings_.impl_side_painting)
2145 CreateAndSetTileManager(); 2157 CreateAndSetTileManager();
2158 RecreateTreeResources();
2146 2159
2147 // Initialize vsync parameters to sane values. 2160 // Initialize vsync parameters to sane values.
2148 const base::TimeDelta display_refresh_interval = 2161 const base::TimeDelta display_refresh_interval =
2149 base::TimeDelta::FromMicroseconds( 2162 base::TimeDelta::FromMicroseconds(
2150 base::Time::kMicrosecondsPerSecond / 2163 base::Time::kMicrosecondsPerSecond /
2151 settings_.renderer_settings.refresh_rate); 2164 settings_.renderer_settings.refresh_rate);
2152 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); 2165 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
2153 2166
2154 // TODO(brianderson): Don't use a hard-coded parent draw time. 2167 // TODO(brianderson): Don't use a hard-coded parent draw time.
2155 base::TimeDelta parent_draw_time = 2168 base::TimeDelta parent_draw_time =
(...skipping 29 matching lines...) Expand all
2185 2198
2186 ReleaseTreeResources(); 2199 ReleaseTreeResources();
2187 renderer_ = nullptr; 2200 renderer_ = nullptr;
2188 DestroyTileManager(); 2201 DestroyTileManager();
2189 2202
2190 resource_provider_->InitializeGL(); 2203 resource_provider_->InitializeGL();
2191 2204
2192 CreateAndSetRenderer(); 2205 CreateAndSetRenderer();
2193 EnforceZeroBudget(false); 2206 EnforceZeroBudget(false);
2194 CreateAndSetTileManager(); 2207 CreateAndSetTileManager();
2208 RecreateTreeResources();
2195 2209
2196 client_->SetNeedsCommitOnImplThread(); 2210 client_->SetNeedsCommitOnImplThread();
2197 } 2211 }
2198 2212
2199 void LayerTreeHostImpl::ReleaseGL() { 2213 void LayerTreeHostImpl::ReleaseGL() {
2200 DCHECK(output_surface_->capabilities().deferred_gl_initialization); 2214 DCHECK(output_surface_->capabilities().deferred_gl_initialization);
2201 DCHECK(settings_.impl_side_painting); 2215 DCHECK(settings_.impl_side_painting);
2202 DCHECK(output_surface_->context_provider()); 2216 DCHECK(output_surface_->context_provider());
2203 2217
2204 ReleaseTreeResources(); 2218 ReleaseTreeResources();
2205 renderer_ = nullptr; 2219 renderer_ = nullptr;
2206 DestroyTileManager(); 2220 DestroyTileManager();
2207 2221
2208 resource_provider_->InitializeSoftware(); 2222 resource_provider_->InitializeSoftware();
2209 output_surface_->ReleaseContextProvider(); 2223 output_surface_->ReleaseContextProvider();
2210 2224
2211 CreateAndSetRenderer(); 2225 CreateAndSetRenderer();
2212 EnforceZeroBudget(true); 2226 EnforceZeroBudget(true);
2213 CreateAndSetTileManager(); 2227 CreateAndSetTileManager();
2228 RecreateTreeResources();
2214 2229
2215 client_->SetNeedsCommitOnImplThread(); 2230 client_->SetNeedsCommitOnImplThread();
2216 } 2231 }
2217 2232
2218 void LayerTreeHostImpl::SetViewportSize(const gfx::Size& device_viewport_size) { 2233 void LayerTreeHostImpl::SetViewportSize(const gfx::Size& device_viewport_size) {
2219 if (device_viewport_size == device_viewport_size_) 2234 if (device_viewport_size == device_viewport_size_)
2220 return; 2235 return;
2221 TRACE_EVENT_INSTANT2("cc", "LayerTreeHostImpl::SetViewportSize", 2236 TRACE_EVENT_INSTANT2("cc", "LayerTreeHostImpl::SetViewportSize",
2222 TRACE_EVENT_SCOPE_THREAD, "width", 2237 TRACE_EVENT_SCOPE_THREAD, "width",
2223 device_viewport_size.width(), "height", 2238 device_viewport_size.width(), "height",
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
3501 } 3516 }
3502 3517
3503 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3518 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3504 std::vector<PictureLayerImpl*>::iterator it = 3519 std::vector<PictureLayerImpl*>::iterator it =
3505 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3520 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3506 DCHECK(it != picture_layers_.end()); 3521 DCHECK(it != picture_layers_.end());
3507 picture_layers_.erase(it); 3522 picture_layers_.erase(it);
3508 } 3523 }
3509 3524
3510 } // namespace cc 3525 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698