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

Side by Side Diff: ui/gl/gl_image_io_surface.mm

Issue 1861923002: Mac h264: Retain CVPixelBuffer inside GLImageIOSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix assert Created 4 years, 8 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 | « ui/gl/gl_image_io_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/gl/gl_image_io_surface.h" 5 #include "ui/gl/gl_image_io_surface.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 215 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
216 return false; 216 return false;
217 } 217 }
218 218
219 format_ = format; 219 format_ = format;
220 io_surface_.reset(io_surface, base::scoped_policy::RETAIN); 220 io_surface_.reset(io_surface, base::scoped_policy::RETAIN);
221 io_surface_id_ = io_surface_id; 221 io_surface_id_ = io_surface_id;
222 return true; 222 return true;
223 } 223 }
224 224
225 bool GLImageIOSurface::InitializeWithCVPixelBuffer(
226 CVPixelBufferRef cv_pixel_buffer,
227 gfx::GenericSharedMemoryId io_surface_id,
228 BufferFormat format) {
229 IOSurfaceRef io_surface = CVPixelBufferGetIOSurface(cv_pixel_buffer);
230 if (!io_surface) {
231 LOG(ERROR) << "Can't init GLImage from CVPixelBuffer with no IOSurface";
232 return false;
233 }
234
235 if (!Initialize(io_surface, io_surface_id, format))
236 return false;
237
238 cv_pixel_buffer_.reset(cv_pixel_buffer, base::scoped_policy::RETAIN);
239 return true;
240 }
241
225 void GLImageIOSurface::Destroy(bool have_context) { 242 void GLImageIOSurface::Destroy(bool have_context) {
226 DCHECK(thread_checker_.CalledOnValidThread()); 243 DCHECK(thread_checker_.CalledOnValidThread());
227 if (have_context && framebuffer_) { 244 if (have_context && framebuffer_) {
228 glDeleteProgram(program_); 245 glDeleteProgram(program_);
229 glDeleteShader(vertex_shader_); 246 glDeleteShader(vertex_shader_);
230 glDeleteShader(fragment_shader_); 247 glDeleteShader(fragment_shader_);
231 glDeleteBuffersARB(1, &vertex_buffer_); 248 glDeleteBuffersARB(1, &vertex_buffer_);
232 glDeleteFramebuffersEXT(1, &framebuffer_); 249 glDeleteFramebuffersEXT(1, &framebuffer_);
233 glDeleteTextures(2, yuv_textures_); 250 glDeleteTextures(2, yuv_textures_);
234 } 251 }
235 io_surface_.reset(); 252 io_surface_.reset();
253 cv_pixel_buffer_.reset();
236 } 254 }
237 255
238 gfx::Size GLImageIOSurface::GetSize() { 256 gfx::Size GLImageIOSurface::GetSize() {
239 return size_; 257 return size_;
240 } 258 }
241 259
242 unsigned GLImageIOSurface::GetInternalFormat() { 260 unsigned GLImageIOSurface::GetInternalFormat() {
243 return internalformat_; 261 return internalformat_;
244 } 262 }
245 263
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 auto guid = 420 auto guid =
403 GetGenericSharedMemoryGUIDForTracing(process_tracing_id, io_surface_id_); 421 GetGenericSharedMemoryGUIDForTracing(process_tracing_id, io_surface_id_);
404 pmd->CreateSharedGlobalAllocatorDump(guid); 422 pmd->CreateSharedGlobalAllocatorDump(guid);
405 pmd->AddOwnershipEdge(dump->guid(), guid); 423 pmd->AddOwnershipEdge(dump->guid(), guid);
406 } 424 }
407 425
408 base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { 426 base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() {
409 return io_surface_; 427 return io_surface_;
410 } 428 }
411 429
430 base::ScopedCFTypeRef<CVPixelBufferRef> GLImageIOSurface::cv_pixel_buffer() {
431 return cv_pixel_buffer_;
432 }
433
412 // static 434 // static
413 void GLImageIOSurface::SetLayerForWidget(gfx::AcceleratedWidget widget, 435 void GLImageIOSurface::SetLayerForWidget(gfx::AcceleratedWidget widget,
414 CALayer* layer) { 436 CALayer* layer) {
415 if (layer) 437 if (layer)
416 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); 438 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer));
417 else 439 else
418 g_widget_to_layer_map.Pointer()->erase(widget); 440 g_widget_to_layer_map.Pointer()->erase(widget);
419 } 441 }
420 442
421 // static 443 // static
422 unsigned GLImageIOSurface::GetInternalFormatForTesting( 444 unsigned GLImageIOSurface::GetInternalFormatForTesting(
423 gfx::BufferFormat format) { 445 gfx::BufferFormat format) {
424 DCHECK(ValidFormat(format)); 446 DCHECK(ValidFormat(format));
425 return TextureFormat(format); 447 return TextureFormat(format);
426 } 448 }
427 } // namespace gl 449 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698