| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/texture_image_transport_surface.h" | 5 #include "content/common/gpu/texture_image_transport_surface.h" |
| 6 | 6 |
| 7 #include "content/common/gpu/gpu_channel.h" | 7 #include "content/common/gpu/gpu_channel.h" |
| 8 #include "content/common/gpu/gpu_channel_manager.h" | 8 #include "content/common/gpu/gpu_channel_manager.h" |
| 9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
| 10 #include "gpu/command_buffer/service/context_group.h" | 10 #include "gpu/command_buffer/service/context_group.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 DCHECK(stub_destroyed_); | 104 DCHECK(stub_destroyed_); |
| 105 Destroy(); | 105 Destroy(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool TextureImageTransportSurface::Initialize() { | 108 bool TextureImageTransportSurface::Initialize() { |
| 109 return helper_->Initialize(); | 109 return helper_->Initialize(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void TextureImageTransportSurface::Destroy() { | 112 void TextureImageTransportSurface::Destroy() { |
| 113 if (parent_stub_) { | 113 if (parent_stub_) { |
| 114 parent_stub_->RemoveDestructionObserver(this); | 114 parent_stub_->decoder()->MakeCurrent(); |
| 115 parent_stub_ = NULL; | 115 ReleaseParentStub(); |
| 116 } | |
| 117 for (int i = 0; i < 2; ++i) { | |
| 118 Texture& texture = textures_[i]; | |
| 119 if (!texture.sent_to_client) | |
| 120 continue; | |
| 121 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | |
| 122 params.identifier = texture.client_id; | |
| 123 helper_->SendAcceleratedSurfaceRelease(params); | |
| 124 texture.info = NULL; | |
| 125 } | 116 } |
| 126 | 117 |
| 127 helper_->Destroy(); | 118 helper_->Destroy(); |
| 128 } | 119 } |
| 129 | 120 |
| 130 bool TextureImageTransportSurface::Resize(const gfx::Size&) { | 121 bool TextureImageTransportSurface::Resize(const gfx::Size&) { |
| 131 return true; | 122 return true; |
| 132 } | 123 } |
| 133 | 124 |
| 134 bool TextureImageTransportSurface::IsOffscreen() { | 125 bool TextureImageTransportSurface::IsOffscreen() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void* TextureImageTransportSurface::GetConfig() { | 181 void* TextureImageTransportSurface::GetConfig() { |
| 191 return parent_stub_ ? parent_stub_->surface()->GetConfig() : NULL; | 182 return parent_stub_ ? parent_stub_->surface()->GetConfig() : NULL; |
| 192 } | 183 } |
| 193 | 184 |
| 194 void TextureImageTransportSurface::OnResize(gfx::Size size) { | 185 void TextureImageTransportSurface::OnResize(gfx::Size size) { |
| 195 CreateBackTexture(size); | 186 CreateBackTexture(size); |
| 196 } | 187 } |
| 197 | 188 |
| 198 void TextureImageTransportSurface::OnWillDestroyStub( | 189 void TextureImageTransportSurface::OnWillDestroyStub( |
| 199 GpuCommandBufferStub* stub) { | 190 GpuCommandBufferStub* stub) { |
| 200 stub->RemoveDestructionObserver(this); | |
| 201 if (stub == parent_stub_) { | 191 if (stub == parent_stub_) { |
| 202 // We are losing the parent stub, we need to clear the reference on the | 192 ReleaseParentStub(); |
| 203 // infos (they are not allowed to outlive the stub). | |
| 204 textures_[0].info = NULL; | |
| 205 textures_[1].info = NULL; | |
| 206 parent_stub_ = NULL; | |
| 207 } else { | 193 } else { |
| 194 stub->RemoveDestructionObserver(this); |
| 208 // We are losing the stub owning us, this is our last chance to clean up the | 195 // We are losing the stub owning us, this is our last chance to clean up the |
| 209 // resources we allocated in the stub's context. | 196 // resources we allocated in the stub's context. |
| 210 glDeleteFramebuffersEXT(1, &fbo_id_); | 197 glDeleteFramebuffersEXT(1, &fbo_id_); |
| 211 CHECK_GL_ERROR(); | 198 CHECK_GL_ERROR(); |
| 212 fbo_id_ = 0; | 199 fbo_id_ = 0; |
| 213 | 200 |
| 214 stub_destroyed_ = true; | 201 stub_destroyed_ = true; |
| 215 } | 202 } |
| 216 } | 203 } |
| 217 | 204 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 glFlush(); | 416 glFlush(); |
| 430 CHECK_GL_ERROR(); | 417 CHECK_GL_ERROR(); |
| 431 | 418 |
| 432 #ifndef NDEBUG | 419 #ifndef NDEBUG |
| 433 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 420 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 434 if (status != GL_FRAMEBUFFER_COMPLETE) { | 421 if (status != GL_FRAMEBUFFER_COMPLETE) { |
| 435 DLOG(ERROR) << "Framebuffer incomplete."; | 422 DLOG(ERROR) << "Framebuffer incomplete."; |
| 436 } | 423 } |
| 437 #endif | 424 #endif |
| 438 } | 425 } |
| 426 |
| 427 void TextureImageTransportSurface::ReleaseParentStub() { |
| 428 DCHECK(parent_stub_); |
| 429 parent_stub_->RemoveDestructionObserver(this); |
| 430 for (int i = 0; i < 2; ++i) { |
| 431 Texture& texture = textures_[i]; |
| 432 texture.info = NULL; |
| 433 if (!texture.sent_to_client) |
| 434 continue; |
| 435 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
| 436 params.identifier = texture.client_id; |
| 437 helper_->SendAcceleratedSurfaceRelease(params); |
| 438 } |
| 439 parent_stub_ = NULL; |
| 440 } |
| OLD | NEW |