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

Unified 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: 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index f51c61ac2fd55faa576b0ea64255d26d90705fd5..f376998427462de90d39825bb1aaa0dd58270088 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -116,6 +116,21 @@ class ViewportAnchor {
gfx::ScrollOffset viewport_in_content_coordinates_;
};
+template <typename Object>
+class ScopedCaller {
danakj 2015/02/05 20:45:49 did you look around in base/ for something like th
vmpstr 2015/02/05 21:41:32 I couldn't really find anything that would do a si
+ public:
+ using Function = void (Object::*)();
+ ScopedCaller(Object* object, Function on_entry, Function on_exit)
+ : object_(object), on_exit_(on_exit) {
+ (object_->*on_entry)();
+ }
+
+ ~ScopedCaller() { (object_->*on_exit_)(); }
+
+ private:
+ Object* object_;
+ Function on_exit_;
+};
void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) {
if (visible) {
@@ -1611,7 +1626,9 @@ void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) {
// Clean up and replace existing tile manager with another one that uses
// appropriate rasterizer.
- ReleaseTreeResources();
+ ScopedCaller<LayerTreeHostImpl> scoped_release_resources(
+ this, &LayerTreeHostImpl::ReleaseTreeResources,
+ &LayerTreeHostImpl::RecreateTreeResources);
if (tile_manager_) {
DestroyTileManager();
CreateAndSetTileManager();
@@ -1934,6 +1951,14 @@ void LayerTreeHostImpl::ReleaseTreeResources() {
EvictAllUIResources();
}
+void LayerTreeHostImpl::RecreateTreeResources() {
+ active_tree_->RecreateResources();
+ if (pending_tree_)
+ pending_tree_->RecreateResources();
+ if (recycle_tree_)
+ recycle_tree_->RecreateResources();
+}
+
void LayerTreeHostImpl::CreateAndSetRenderer() {
DCHECK(!renderer_);
DCHECK(output_surface_);
@@ -2125,8 +2150,12 @@ bool LayerTreeHostImpl::InitializeRenderer(
resource_provider_ = nullptr;
output_surface_ = nullptr;
- if (!output_surface->BindToClient(this))
+ if (!output_surface->BindToClient(this)) {
+ // Avoid recreating tree resources because we might not have enough
+ // information to do this yet (eg. we don't have a TileManager at this
+ // point).
return false;
+ }
output_surface_ = output_surface.Pass();
resource_provider_ = ResourceProvider::Create(
@@ -2143,6 +2172,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
if (settings_.impl_side_painting)
CreateAndSetTileManager();
+ RecreateTreeResources();
// Initialize vsync parameters to sane values.
const base::TimeDelta display_refresh_interval =
@@ -2183,7 +2213,9 @@ void LayerTreeHostImpl::DeferredInitialize() {
DCHECK(settings_.impl_side_painting);
DCHECK(output_surface_->context_provider());
- ReleaseTreeResources();
+ ScopedCaller<LayerTreeHostImpl> scoped_release_resources(
enne (OOO) 2015/02/05 20:43:52 This seems like overkill. Neither of the function
vmpstr 2015/02/05 21:41:32 It's ReleaseResources is also implemented in textu
+ this, &LayerTreeHostImpl::ReleaseTreeResources,
+ &LayerTreeHostImpl::RecreateTreeResources);
renderer_ = nullptr;
DestroyTileManager();
@@ -2201,7 +2233,9 @@ void LayerTreeHostImpl::ReleaseGL() {
DCHECK(settings_.impl_side_painting);
DCHECK(output_surface_->context_provider());
- ReleaseTreeResources();
+ ScopedCaller<LayerTreeHostImpl> scoped_release_resources(
+ this, &LayerTreeHostImpl::ReleaseTreeResources,
+ &LayerTreeHostImpl::RecreateTreeResources);
renderer_ = nullptr;
DestroyTileManager();
« 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