Commit 2360439b authored by piman@chromium.org's avatar piman@chromium.org

texture_image_transport: have a current context when we're releasing textures

In some cases, the TextureImageTransportSurface may get destroyed when no
context is current. When that's the case, glDeleteTextures becomes a noop and we
leak them.

BUG=123933
TEST=manual


Review URL: http://codereview.chromium.org/10200012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133732 0039d316-1c4b-4281-b951-d872f2087c98
parent b03df4be
......@@ -111,17 +111,8 @@ bool TextureImageTransportSurface::Initialize() {
void TextureImageTransportSurface::Destroy() {
if (parent_stub_) {
parent_stub_->RemoveDestructionObserver(this);
parent_stub_ = NULL;
}
for (int i = 0; i < 2; ++i) {
Texture& texture = textures_[i];
if (!texture.sent_to_client)
continue;
GpuHostMsg_AcceleratedSurfaceRelease_Params params;
params.identifier = texture.client_id;
helper_->SendAcceleratedSurfaceRelease(params);
texture.info = NULL;
parent_stub_->decoder()->MakeCurrent();
ReleaseParentStub();
}
helper_->Destroy();
......@@ -197,14 +188,10 @@ void TextureImageTransportSurface::OnResize(gfx::Size size) {
void TextureImageTransportSurface::OnWillDestroyStub(
GpuCommandBufferStub* stub) {
stub->RemoveDestructionObserver(this);
if (stub == parent_stub_) {
// We are losing the parent stub, we need to clear the reference on the
// infos (they are not allowed to outlive the stub).
textures_[0].info = NULL;
textures_[1].info = NULL;
parent_stub_ = NULL;
ReleaseParentStub();
} else {
stub->RemoveDestructionObserver(this);
// We are losing the stub owning us, this is our last chance to clean up the
// resources we allocated in the stub's context.
glDeleteFramebuffersEXT(1, &fbo_id_);
......@@ -436,3 +423,18 @@ void TextureImageTransportSurface::AttachBackTextureToFBO() {
}
#endif
}
void TextureImageTransportSurface::ReleaseParentStub() {
DCHECK(parent_stub_);
parent_stub_->RemoveDestructionObserver(this);
for (int i = 0; i < 2; ++i) {
Texture& texture = textures_[i];
texture.info = NULL;
if (!texture.sent_to_client)
continue;
GpuHostMsg_AcceleratedSurfaceRelease_Params params;
params.identifier = texture.client_id;
helper_->SendAcceleratedSurfaceRelease(params);
}
parent_stub_ = NULL;
}
......@@ -75,6 +75,7 @@ class TextureImageTransportSurface :
void CreateBackTexture(const gfx::Size& size);
void ReleaseBackTexture();
void AttachBackTextureToFBO();
void ReleaseParentStub();
int back() const { return 1 - front_; }
// The framebuffer that represents this surface (service id). Allocated lazily
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment