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

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

Issue 1131463004: content: Cleanup IOSurface/SurfaceTexture destruction code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | content/common/gpu/gpu_memory_buffer_factory_surface_texture.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gpu_memory_buffer_factory_io_surface.h" 5 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gl/gl_image_io_surface.h" 10 #include "ui/gl/gl_image_io_surface.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 handle.io_surface_id = IOSurfaceGetID(io_surface); 139 handle.io_surface_id = IOSurfaceGetID(io_surface);
140 return handle; 140 return handle;
141 } 141 }
142 142
143 void GpuMemoryBufferFactoryIOSurface::DestroyGpuMemoryBuffer( 143 void GpuMemoryBufferFactoryIOSurface::DestroyGpuMemoryBuffer(
144 gfx::GpuMemoryBufferId id, 144 gfx::GpuMemoryBufferId id,
145 int client_id) { 145 int client_id) {
146 base::AutoLock lock(io_surfaces_lock_); 146 base::AutoLock lock(io_surfaces_lock_);
147 147
148 IOSurfaceMapKey key(id, client_id); 148 IOSurfaceMapKey key(id, client_id);
149 IOSurfaceMap::iterator it = io_surfaces_.find(key); 149 DCHECK(io_surfaces_.find(key) != io_surfaces_.end());
150 if (it != io_surfaces_.end()) 150 io_surfaces_.erase(key);
151 io_surfaces_.erase(it);
152 } 151 }
153 152
154 gpu::ImageFactory* GpuMemoryBufferFactoryIOSurface::AsImageFactory() { 153 gpu::ImageFactory* GpuMemoryBufferFactoryIOSurface::AsImageFactory() {
155 return this; 154 return this;
156 } 155 }
157 156
158 scoped_refptr<gfx::GLImage> 157 scoped_refptr<gfx::GLImage>
159 GpuMemoryBufferFactoryIOSurface::CreateImageForGpuMemoryBuffer( 158 GpuMemoryBufferFactoryIOSurface::CreateImageForGpuMemoryBuffer(
160 const gfx::GpuMemoryBufferHandle& handle, 159 const gfx::GpuMemoryBufferHandle& handle,
161 const gfx::Size& size, 160 const gfx::Size& size,
162 gfx::GpuMemoryBuffer::Format format, 161 gfx::GpuMemoryBuffer::Format format,
163 unsigned internalformat, 162 unsigned internalformat,
164 int client_id) { 163 int client_id) {
165 base::AutoLock lock(io_surfaces_lock_); 164 base::AutoLock lock(io_surfaces_lock_);
166 165
167 DCHECK_EQ(handle.type, gfx::IO_SURFACE_BUFFER); 166 DCHECK_EQ(handle.type, gfx::IO_SURFACE_BUFFER);
168 IOSurfaceMapKey key(handle.id, client_id); 167 IOSurfaceMapKey key(handle.id, client_id);
169 IOSurfaceMap::iterator it = io_surfaces_.find(key); 168 IOSurfaceMap::iterator it = io_surfaces_.find(key);
170 if (it == io_surfaces_.end()) 169 if (it == io_surfaces_.end())
171 return scoped_refptr<gfx::GLImage>(); 170 return scoped_refptr<gfx::GLImage>();
172 171
173 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size)); 172 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size));
174 if (!image->Initialize(it->second.get())) 173 if (!image->Initialize(it->second.get()))
175 return scoped_refptr<gfx::GLImage>(); 174 return scoped_refptr<gfx::GLImage>();
176 175
177 return image; 176 return image;
178 } 177 }
179 178
180 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/gpu_memory_buffer_factory_surface_texture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698