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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 22852006: cc: Don't leak the texture returned in CopyOutputRequest ever. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: glrendererleak: fix tests Created 7 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 | « cc/output/gl_renderer.h ('k') | cc/output/output_surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 is_backbuffer_discarded_(false), 155 is_backbuffer_discarded_(false),
156 discard_backbuffer_when_not_visible_(false), 156 discard_backbuffer_when_not_visible_(false),
157 is_using_bind_uniform_(false), 157 is_using_bind_uniform_(false),
158 visible_(true), 158 visible_(true),
159 is_scissor_enabled_(false), 159 is_scissor_enabled_(false),
160 stencil_shadow_(false), 160 stencil_shadow_(false),
161 blend_shadow_(false), 161 blend_shadow_(false),
162 highp_threshold_min_(highp_threshold_min), 162 highp_threshold_min_(highp_threshold_min),
163 highp_threshold_cache_(0), 163 highp_threshold_cache_(0),
164 offscreen_context_labelled_(false), 164 offscreen_context_labelled_(false),
165 on_demand_tile_raster_resource_id_(0), 165 on_demand_tile_raster_resource_id_(0) {
166 weak_factory_(this) {
167 DCHECK(context_); 166 DCHECK(context_);
168 } 167 }
169 168
170 bool GLRenderer::Initialize() { 169 bool GLRenderer::Initialize() {
171 if (!context_->makeContextCurrent()) 170 if (!context_->makeContextCurrent())
172 return false; 171 return false;
173 172
174 std::string unique_context_name = base::StringPrintf( 173 std::string unique_context_name = base::StringPrintf(
175 "%s-%p", 174 "%s-%p",
176 Settings().compositor_name.c_str(), 175 Settings().compositor_name.c_str(),
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), 2170 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(),
2172 pending_read.Pass()); 2171 pending_read.Pass());
2173 2172
2174 // This is a syncronous call since the callback is null. 2173 // This is a syncronous call since the callback is null.
2175 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); 2174 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect);
2176 DoGetFramebufferPixels(static_cast<uint8*>(pixels), 2175 DoGetFramebufferPixels(static_cast<uint8*>(pixels),
2177 window_rect, 2176 window_rect,
2178 AsyncGetFramebufferPixelsCleanupCallback()); 2177 AsyncGetFramebufferPixelsCleanupCallback());
2179 } 2178 }
2180 2179
2181 void GLRenderer::DeleteTextureReleaseCallbackOnImplThread(unsigned texture_id, 2180 static void DeleteTextureReleaseCallbackOnImplThread(
2182 unsigned sync_point, 2181 const scoped_refptr<ContextProvider>& context_provider,
2183 bool lost_resource) { 2182 unsigned texture_id,
2183 unsigned sync_point,
2184 bool lost_resource) {
2184 if (sync_point) 2185 if (sync_point)
2185 context_->waitSyncPoint(sync_point); 2186 context_provider->Context3d()->waitSyncPoint(sync_point);
2186 context_->deleteTexture(texture_id); 2187 context_provider->Context3d()->deleteTexture(texture_id);
2187 } 2188 }
2188 2189
2189 // static 2190 static void DeleteTextureReleaseCallback(
2190 void GLRenderer::DeleteTextureReleaseCallback( 2191 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
2191 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 2192 const scoped_refptr<ContextProvider>& context_provider,
2192 base::WeakPtr<GLRenderer> gl_renderer,
2193 unsigned texture_id, 2193 unsigned texture_id,
2194 unsigned sync_point, 2194 unsigned sync_point,
2195 bool lost_resource) { 2195 bool lost_resource) {
2196 task_runner->PostTask( 2196 task_runner->PostTask(
2197 FROM_HERE, 2197 FROM_HERE,
2198 base::Bind(&GLRenderer::DeleteTextureReleaseCallbackOnImplThread, 2198 base::Bind(&DeleteTextureReleaseCallbackOnImplThread,
2199 gl_renderer, 2199 context_provider,
2200 texture_id, 2200 texture_id,
2201 sync_point, 2201 sync_point,
2202 lost_resource)); 2202 lost_resource));
2203 } 2203 }
2204 2204
2205 void GLRenderer::GetFramebufferPixelsAsync( 2205 void GLRenderer::GetFramebufferPixelsAsync(
2206 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) { 2206 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) {
2207 DCHECK(!request->IsEmpty()); 2207 DCHECK(!request->IsEmpty());
2208 if (request->IsEmpty()) 2208 if (request->IsEmpty())
2209 return; 2209 return;
(...skipping 28 matching lines...) Expand all
2238 return; 2238 return;
2239 } 2239 }
2240 2240
2241 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2241 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
2242 GLC(context_, context_->produceTextureCHROMIUM( 2242 GLC(context_, context_->produceTextureCHROMIUM(
2243 GL_TEXTURE_2D, mailbox.name)); 2243 GL_TEXTURE_2D, mailbox.name));
2244 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 2244 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
2245 sync_point = context_->insertSyncPoint(); 2245 sync_point = context_->insertSyncPoint();
2246 scoped_ptr<TextureMailbox> texture_mailbox = make_scoped_ptr( 2246 scoped_ptr<TextureMailbox> texture_mailbox = make_scoped_ptr(
2247 new TextureMailbox(mailbox, 2247 new TextureMailbox(mailbox,
2248 base::Bind(&GLRenderer::DeleteTextureReleaseCallback, 2248 base::Bind(&DeleteTextureReleaseCallback,
2249 base::MessageLoopProxy::current(), 2249 base::MessageLoopProxy::current(),
2250 weak_factory_.GetWeakPtr(), 2250 output_surface_->context_provider(),
2251 texture_id), 2251 texture_id),
2252 GL_TEXTURE_2D, 2252 GL_TEXTURE_2D,
2253 sync_point)); 2253 sync_point));
2254 request->SendTextureResult(window_rect.size(), texture_mailbox.Pass()); 2254 request->SendTextureResult(window_rect.size(), texture_mailbox.Pass());
2255 return; 2255 return;
2256 } 2256 }
2257 2257
2258 DCHECK(request->force_bitmap_result()); 2258 DCHECK(request->force_bitmap_result());
2259 2259
2260 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 2260 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 std::string unique_context_name = base::StringPrintf( 3156 std::string unique_context_name = base::StringPrintf(
3157 "%s-Offscreen-%p", 3157 "%s-Offscreen-%p",
3158 Settings().compositor_name.c_str(), 3158 Settings().compositor_name.c_str(),
3159 context_); 3159 context_);
3160 resource_provider()->offscreen_context_provider()->Context3d()-> 3160 resource_provider()->offscreen_context_provider()->Context3d()->
3161 pushGroupMarkerEXT(unique_context_name.c_str()); 3161 pushGroupMarkerEXT(unique_context_name.c_str());
3162 } 3162 }
3163 3163
3164 3164
3165 } // namespace cc 3165 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/output_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698