Fix several leaks in the Sky compositor
When tearing down the Sky compostior, we need to destroy the GL context and all the textures in the resource manager. R=ojan@chromium.org Review URL: https://codereview.chromium.org/761503004
This commit is contained in:
parent
c7a656aca9
commit
7e05650376
@ -19,9 +19,9 @@ LayerHost::LayerHost(LayerHostClient* client)
|
|||||||
state_(kWaitingForSurfaceService),
|
state_(kWaitingForSurfaceService),
|
||||||
frame_requested_(false),
|
frame_requested_(false),
|
||||||
surface_holder_(this, client->GetShell()),
|
surface_holder_(this, client->GetShell()),
|
||||||
gl_context_(mojo::GLContext::Create(client->GetShell())),
|
gl_context_owner_(client->GetShell()),
|
||||||
ganesh_context_(gl_context_),
|
ganesh_context_(gl_context()),
|
||||||
resource_manager_(gl_context_),
|
resource_manager_(gl_context()),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
#include "mojo/gpu/gl_context_owner.h"
|
||||||
#include "mojo/skia/ganesh_context.h"
|
#include "mojo/skia/ganesh_context.h"
|
||||||
#include "sky/compositor/layer_host_client.h"
|
#include "sky/compositor/layer_host_client.h"
|
||||||
#include "sky/compositor/resource_manager.h"
|
#include "sky/compositor/resource_manager.h"
|
||||||
@ -26,7 +27,7 @@ class LayerHost : public SurfaceHolder::Client {
|
|||||||
LayerHostClient* client() const { return client_; }
|
LayerHostClient* client() const { return client_; }
|
||||||
|
|
||||||
const base::WeakPtr<mojo::GLContext>& gl_context() const {
|
const base::WeakPtr<mojo::GLContext>& gl_context() const {
|
||||||
return gl_context_;
|
return gl_context_owner_.context();
|
||||||
}
|
}
|
||||||
|
|
||||||
mojo::GaneshContext* ganesh_context() const {
|
mojo::GaneshContext* ganesh_context() const {
|
||||||
@ -63,7 +64,7 @@ class LayerHost : public SurfaceHolder::Client {
|
|||||||
State state_;
|
State state_;
|
||||||
bool frame_requested_;
|
bool frame_requested_;
|
||||||
SurfaceHolder surface_holder_;
|
SurfaceHolder surface_holder_;
|
||||||
base::WeakPtr<mojo::GLContext> gl_context_;
|
mojo::GLContextOwner gl_context_owner_;
|
||||||
mojo::GaneshContext ganesh_context_;
|
mojo::GaneshContext ganesh_context_;
|
||||||
ResourceManager resource_manager_;
|
ResourceManager resource_manager_;
|
||||||
scoped_refptr<Layer> root_layer_;
|
scoped_refptr<Layer> root_layer_;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/stl_util.h"
|
||||||
#include "gpu/GLES2/gl2chromium.h"
|
#include "gpu/GLES2/gl2chromium.h"
|
||||||
#include "gpu/GLES2/gl2extchromium.h"
|
#include "gpu/GLES2/gl2extchromium.h"
|
||||||
#include "mojo/converters/geometry/geometry_type_converters.h"
|
#include "mojo/converters/geometry/geometry_type_converters.h"
|
||||||
@ -24,6 +25,8 @@ ResourceManager::ResourceManager(base::WeakPtr<mojo::GLContext> gl_context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager::~ResourceManager() {
|
ResourceManager::~ResourceManager() {
|
||||||
|
STLDeleteContainerPairSecondPointers(resource_to_texture_map_.begin(),
|
||||||
|
resource_to_texture_map_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<mojo::GLTexture> ResourceManager::CreateTexture(
|
scoped_ptr<mojo::GLTexture> ResourceManager::CreateTexture(
|
||||||
@ -73,11 +76,14 @@ void ResourceManager::ReturnResources(
|
|||||||
for (size_t i = 0u; i < resources.size(); ++i) {
|
for (size_t i = 0u; i < resources.size(); ++i) {
|
||||||
mojo::ReturnedResourcePtr resource = resources[i].Pass();
|
mojo::ReturnedResourcePtr resource = resources[i].Pass();
|
||||||
DCHECK_EQ(1, resource->count);
|
DCHECK_EQ(1, resource->count);
|
||||||
glWaitSyncPointCHROMIUM(resource->sync_point);
|
auto iter = resource_to_texture_map_.find(resource->id);
|
||||||
mojo::GLTexture* texture = resource_to_texture_map_[resource->id];
|
if (iter == resource_to_texture_map_.end())
|
||||||
|
continue;
|
||||||
|
mojo::GLTexture* texture = iter->second;
|
||||||
DCHECK_NE(0u, texture->texture_id());
|
DCHECK_NE(0u, texture->texture_id());
|
||||||
resource_to_texture_map_.erase(resource->id);
|
resource_to_texture_map_.erase(iter);
|
||||||
// TODO(abarth): Consider recycling the texture.
|
// TODO(abarth): Consider recycling the texture.
|
||||||
|
glWaitSyncPointCHROMIUM(resource->sync_point);
|
||||||
delete texture;
|
delete texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user