Index: ui/gl/gl_image_io_surface.mm |
diff --git a/ui/gl/gl_image_io_surface.mm b/ui/gl/gl_image_io_surface.mm |
index 3059333cc8896feb96c15f2b4147e3e927a3f417..d94a60a5e217d4a272b06e477de47da5672d7395 100644 |
--- a/ui/gl/gl_image_io_surface.mm |
+++ b/ui/gl/gl_image_io_surface.mm |
@@ -222,6 +222,23 @@ bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface, |
return true; |
} |
+bool GLImageIOSurface::InitializeWithCVPixelBuffer( |
+ CVPixelBufferRef cv_pixel_buffer, |
+ gfx::GenericSharedMemoryId io_surface_id, |
+ BufferFormat format) { |
+ IOSurfaceRef io_surface = CVPixelBufferGetIOSurface(cv_pixel_buffer); |
+ if (!io_surface) { |
+ LOG(ERROR) << "Can't init GLImage from CVPixelBuffer with no IOSurface"; |
+ return false; |
+ } |
+ |
+ if (!Initialize(io_surface, io_surface_id, format)) |
+ return false; |
+ |
+ cv_pixel_buffer_.reset(cv_pixel_buffer, base::scoped_policy::RETAIN); |
+ return true; |
+} |
+ |
void GLImageIOSurface::Destroy(bool have_context) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
if (have_context && framebuffer_) { |
@@ -233,6 +250,7 @@ void GLImageIOSurface::Destroy(bool have_context) { |
glDeleteTextures(2, yuv_textures_); |
} |
io_surface_.reset(); |
+ cv_pixel_buffer_.reset(); |
} |
gfx::Size GLImageIOSurface::GetSize() { |
@@ -409,6 +427,10 @@ base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { |
return io_surface_; |
} |
+base::ScopedCFTypeRef<CVPixelBufferRef> GLImageIOSurface::cv_pixel_buffer() { |
+ return cv_pixel_buffer_; |
+} |
+ |
// static |
void GLImageIOSurface::SetLayerForWidget(gfx::AcceleratedWidget widget, |
CALayer* layer) { |