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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 using gpu::gles2::MailboxManager; | 23 using gpu::gles2::MailboxManager; |
24 using gpu::gles2::Texture; | 24 using gpu::gles2::Texture; |
25 using gpu::gles2::TextureManager; | 25 using gpu::gles2::TextureManager; |
26 using gpu::gles2::TextureRef; | 26 using gpu::gles2::TextureRef; |
27 using gpu::Mailbox; | 27 using gpu::Mailbox; |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 namespace { | 30 namespace { |
31 | 31 |
32 bool IsContextValid(ImageTransportHelper* helper) { | 32 bool IsContextValid(ImageTransportHelper* helper) { |
33 return helper->stub()->decoder()->GetGLContext()->IsCurrent(NULL) || | 33 return helper->stub()->decoder()->GetGLContext()->IsCurrent(NULL); |
34 helper->stub()->decoder()->WasContextLost(); | |
35 } | 34 } |
36 | 35 |
37 } // namespace | 36 } // namespace |
38 | 37 |
39 TextureImageTransportSurface::TextureImageTransportSurface( | 38 TextureImageTransportSurface::TextureImageTransportSurface( |
40 GpuChannelManager* manager, | 39 GpuChannelManager* manager, |
41 GpuCommandBufferStub* stub, | 40 GpuCommandBufferStub* stub, |
42 const gfx::GLSurfaceHandle& handle) | 41 const gfx::GLSurfaceHandle& handle) |
43 : fbo_id_(0), | 42 : fbo_id_(0), |
44 current_size_(1, 1), | 43 current_size_(1, 1), |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 float scale_factor) { | 167 float scale_factor) { |
169 DCHECK_GE(size.width(), 1); | 168 DCHECK_GE(size.width(), 1); |
170 DCHECK_GE(size.height(), 1); | 169 DCHECK_GE(size.height(), 1); |
171 current_size_ = size; | 170 current_size_ = size; |
172 scale_factor_ = scale_factor; | 171 scale_factor_ = scale_factor; |
173 if (backbuffer_suggested_allocation_) | 172 if (backbuffer_suggested_allocation_) |
174 CreateBackTexture(); | 173 CreateBackTexture(); |
175 } | 174 } |
176 | 175 |
177 void TextureImageTransportSurface::OnWillDestroyStub() { | 176 void TextureImageTransportSurface::OnWillDestroyStub() { |
178 DCHECK(IsContextValid(helper_.get())); | 177 bool have_context = IsContextValid(helper_.get()); |
179 helper_->stub()->RemoveDestructionObserver(this); | 178 helper_->stub()->RemoveDestructionObserver(this); |
180 | 179 |
181 // We are losing the stub owning us, this is our last chance to clean up the | 180 // We are losing the stub owning us, this is our last chance to clean up the |
182 // resources we allocated in the stub's context. | 181 // resources we allocated in the stub's context. |
183 ReleaseBackTexture(); | 182 if (have_context) { |
184 ReleaseFrontTexture(); | 183 ReleaseBackTexture(); |
184 ReleaseFrontTexture(); | |
185 } else { | |
piman
2014/04/01 23:00:02
It's not specific to this change, but this makes m
no sievers
2014/04/01 23:39:37
In the stack from 355275 we are not leaking becaus
piman
2014/04/01 23:50:58
Only if the context isn't know to be lost, though.
| |
186 backbuffer_ = NULL; | |
187 back_mailbox_ = Mailbox(); | |
188 frontbuffer_ = NULL; | |
189 front_mailbox_ = Mailbox(); | |
190 } | |
185 | 191 |
186 if (fbo_id_) { | 192 if (fbo_id_ && have_context) { |
187 glDeleteFramebuffersEXT(1, &fbo_id_); | 193 glDeleteFramebuffersEXT(1, &fbo_id_); |
188 CHECK_GL_ERROR(); | 194 CHECK_GL_ERROR(); |
189 fbo_id_ = 0; | |
190 } | 195 } |
196 fbo_id_ = 0; | |
191 | 197 |
192 stub_destroyed_ = true; | 198 stub_destroyed_ = true; |
193 } | 199 } |
194 | 200 |
195 void TextureImageTransportSurface::SetLatencyInfo( | 201 void TextureImageTransportSurface::SetLatencyInfo( |
196 const std::vector<ui::LatencyInfo>& latency_info) { | 202 const std::vector<ui::LatencyInfo>& latency_info) { |
197 for (size_t i = 0; i < latency_info.size(); i++) | 203 for (size_t i = 0; i < latency_info.size(); i++) |
198 latency_info_.push_back(latency_info[i]); | 204 latency_info_.push_back(latency_info[i]); |
199 } | 205 } |
200 | 206 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 | 454 |
449 #ifndef NDEBUG | 455 #ifndef NDEBUG |
450 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 456 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
451 if (status != GL_FRAMEBUFFER_COMPLETE) { | 457 if (status != GL_FRAMEBUFFER_COMPLETE) { |
452 DLOG(FATAL) << "Framebuffer incomplete: " << status; | 458 DLOG(FATAL) << "Framebuffer incomplete: " << status; |
453 } | 459 } |
454 #endif | 460 #endif |
455 } | 461 } |
456 | 462 |
457 } // namespace content | 463 } // namespace content |
OLD | NEW |