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

Side by Side Diff: content/common/gpu/texture_image_transport_surface.cc

Issue 10831169: Delay GpuCommandBufferStub::AddDestructionObserver until we need it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 backbuffer_suggested_allocation_(true), 40 backbuffer_suggested_allocation_(true),
41 frontbuffer_suggested_allocation_(true), 41 frontbuffer_suggested_allocation_(true),
42 frontbuffer_is_protected_(true), 42 frontbuffer_is_protected_(true),
43 protection_state_id_(0), 43 protection_state_id_(0),
44 handle_(handle), 44 handle_(handle),
45 parent_stub_(NULL) { 45 parent_stub_(NULL) {
46 helper_.reset(new ImageTransportHelper(this, 46 helper_.reset(new ImageTransportHelper(this,
47 manager, 47 manager,
48 stub, 48 stub,
49 gfx::kNullPluginWindow)); 49 gfx::kNullPluginWindow));
50
51 stub->AddDestructionObserver(this);
52 } 50 }
53 51
54 TextureImageTransportSurface::~TextureImageTransportSurface() { 52 TextureImageTransportSurface::~TextureImageTransportSurface() {
55 DCHECK(stub_destroyed_); 53 DCHECK(stub_destroyed_);
56 Destroy(); 54 Destroy();
57 } 55 }
58 56
59 bool TextureImageTransportSurface::Initialize() { 57 bool TextureImageTransportSurface::Initialize() {
60 GpuChannelManager* manager = helper_->manager(); 58 GpuChannelManager* manager = helper_->manager();
61 GpuChannel* parent_channel = manager->LookupChannel(handle_.parent_client_id); 59 GpuChannel* parent_channel = manager->LookupChannel(handle_.parent_client_id);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 125
128 if (!fbo_id_) { 126 if (!fbo_id_) {
129 glGenFramebuffersEXT(1, &fbo_id_); 127 glGenFramebuffersEXT(1, &fbo_id_);
130 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_id_); 128 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_id_);
131 CreateBackTexture(gfx::Size(1, 1)); 129 CreateBackTexture(gfx::Size(1, 1));
132 130
133 #ifndef NDEBUG 131 #ifndef NDEBUG
134 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 132 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
135 if (status != GL_FRAMEBUFFER_COMPLETE) { 133 if (status != GL_FRAMEBUFFER_COMPLETE) {
136 DLOG(ERROR) << "Framebuffer incomplete."; 134 DLOG(ERROR) << "Framebuffer incomplete.";
135 glDeleteFramebuffersEXT(1, &fbo_id_);
136 fbo_id_ = 0;
137 return false; 137 return false;
138 } 138 }
139 #endif 139 #endif
140 DCHECK(helper_->stub());
141 helper_->stub()->AddDestructionObserver(this);
140 } 142 }
141 143
142 return true; 144 return true;
143 } 145 }
144 146
145 unsigned int TextureImageTransportSurface::GetBackingFrameBufferObject() { 147 unsigned int TextureImageTransportSurface::GetBackingFrameBufferObject() {
146 return fbo_id_; 148 return fbo_id_;
147 } 149 }
148 150
149 void TextureImageTransportSurface::SetBackbufferAllocation(bool allocation) { 151 void TextureImageTransportSurface::SetBackbufferAllocation(bool allocation) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void TextureImageTransportSurface::OnResize(gfx::Size size) { 203 void TextureImageTransportSurface::OnResize(gfx::Size size) {
202 CreateBackTexture(size); 204 CreateBackTexture(size);
203 } 205 }
204 206
205 void TextureImageTransportSurface::OnWillDestroyStub( 207 void TextureImageTransportSurface::OnWillDestroyStub(
206 GpuCommandBufferStub* stub) { 208 GpuCommandBufferStub* stub) {
207 if (stub == parent_stub_) { 209 if (stub == parent_stub_) {
208 ReleaseParentStub(); 210 ReleaseParentStub();
209 helper_->SetPreemptByCounter(NULL); 211 helper_->SetPreemptByCounter(NULL);
210 } else { 212 } else {
213 DCHECK(stub == helper_->stub());
211 stub->RemoveDestructionObserver(this); 214 stub->RemoveDestructionObserver(this);
212 215
213 // We are losing the stub owning us, this is our last chance to clean up the 216 // We are losing the stub owning us, this is our last chance to clean up the
214 // resources we allocated in the stub's context. 217 // resources we allocated in the stub's context.
215 if (fbo_id_) { 218 if (fbo_id_) {
216 glDeleteFramebuffersEXT(1, &fbo_id_); 219 glDeleteFramebuffersEXT(1, &fbo_id_);
217 CHECK_GL_ERROR(); 220 CHECK_GL_ERROR();
218 fbo_id_ = 0; 221 fbo_id_ = 0;
219 } 222 }
220 223
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 Texture& texture = textures_[i]; 506 Texture& texture = textures_[i];
504 texture.info = NULL; 507 texture.info = NULL;
505 if (!texture.sent_to_client) 508 if (!texture.sent_to_client)
506 continue; 509 continue;
507 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 510 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
508 params.identifier = texture.client_id; 511 params.identifier = texture.client_id;
509 helper_->SendAcceleratedSurfaceRelease(params); 512 helper_->SendAcceleratedSurfaceRelease(params);
510 } 513 }
511 parent_stub_ = NULL; 514 parent_stub_ = NULL;
512 } 515 }
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698