| OLD | NEW |
| 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 #ifndef UI_GL_GL_IMAGE_IO_SURFACE_H_ | 5 #ifndef UI_GL_GL_IMAGE_IO_SURFACE_H_ |
| 6 #define UI_GL_GL_IMAGE_IO_SURFACE_H_ | 6 #define UI_GL_GL_IMAGE_IO_SURFACE_H_ |
| 7 | 7 |
| 8 #include <CoreVideo/CVPixelBuffer.h> |
| 8 #include <IOSurface/IOSurface.h> | 9 #include <IOSurface/IOSurface.h> |
| 9 #include <stdint.h> | 10 #include <stdint.h> |
| 10 | 11 |
| 11 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 14 #include "ui/gfx/buffer_types.h" | 15 #include "ui/gfx/buffer_types.h" |
| 15 #include "ui/gfx/generic_shared_memory_id.h" | 16 #include "ui/gfx/generic_shared_memory_id.h" |
| 16 #include "ui/gl/gl_image.h" | 17 #include "ui/gl/gl_image.h" |
| 17 | 18 |
| 18 #if defined(__OBJC__) | 19 #if defined(__OBJC__) |
| 19 @class CALayer; | 20 @class CALayer; |
| 20 #else | 21 #else |
| 21 typedef void* CALayer; | 22 typedef void* CALayer; |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace gl { | 25 namespace gl { |
| 25 | 26 |
| 26 class GL_EXPORT GLImageIOSurface : public GLImage { | 27 class GL_EXPORT GLImageIOSurface : public GLImage { |
| 27 public: | 28 public: |
| 28 GLImageIOSurface(const gfx::Size& size, unsigned internalformat); | 29 GLImageIOSurface(const gfx::Size& size, unsigned internalformat); |
| 29 | 30 |
| 31 // IOSurfaces that come from hardware decode can be erased when the |
| 32 // CVPixelBufferRef they were created from is destroyed. Set |cv_pixel_buffer| |
| 33 // to the IOSurface's CVPixelBufferRef if one exists and nullptr otherwise. |
| 30 bool Initialize(IOSurfaceRef io_surface, | 34 bool Initialize(IOSurfaceRef io_surface, |
| 35 CVPixelBufferRef cv_pixel_buffer, |
| 31 gfx::GenericSharedMemoryId io_surface_id, | 36 gfx::GenericSharedMemoryId io_surface_id, |
| 32 gfx::BufferFormat format); | 37 gfx::BufferFormat format); |
| 33 | 38 |
| 34 // Overridden from GLImage: | 39 // Overridden from GLImage: |
| 35 void Destroy(bool have_context) override; | 40 void Destroy(bool have_context) override; |
| 36 gfx::Size GetSize() override; | 41 gfx::Size GetSize() override; |
| 37 unsigned GetInternalFormat() override; | 42 unsigned GetInternalFormat() override; |
| 38 bool BindTexImage(unsigned target) override; | 43 bool BindTexImage(unsigned target) override; |
| 39 void ReleaseTexImage(unsigned target) override {} | 44 void ReleaseTexImage(unsigned target) override {} |
| 40 bool CopyTexImage(unsigned target) override; | 45 bool CopyTexImage(unsigned target) override; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 | 64 |
| 60 protected: | 65 protected: |
| 61 ~GLImageIOSurface() override; | 66 ~GLImageIOSurface() override; |
| 62 | 67 |
| 63 private: | 68 private: |
| 64 const gfx::Size size_; | 69 const gfx::Size size_; |
| 65 const unsigned internalformat_; | 70 const unsigned internalformat_; |
| 66 gfx::BufferFormat format_; | 71 gfx::BufferFormat format_; |
| 67 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; | 72 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; |
| 68 gfx::GenericSharedMemoryId io_surface_id_; | 73 gfx::GenericSharedMemoryId io_surface_id_; |
| 74 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; |
| 69 base::ThreadChecker thread_checker_; | 75 base::ThreadChecker thread_checker_; |
| 70 | 76 |
| 71 // GL state to support 420v IOSurface conversion to RGB. | 77 // GL state to support 420v IOSurface conversion to RGB. |
| 72 unsigned framebuffer_ = 0; | 78 unsigned framebuffer_ = 0; |
| 73 unsigned vertex_shader_ = 0; | 79 unsigned vertex_shader_ = 0; |
| 74 unsigned fragment_shader_ = 0; | 80 unsigned fragment_shader_ = 0; |
| 75 unsigned program_ = 0; | 81 unsigned program_ = 0; |
| 76 int size_location_ = -1; | 82 int size_location_ = -1; |
| 77 unsigned vertex_buffer_ = 0; | 83 unsigned vertex_buffer_ = 0; |
| 78 unsigned yuv_textures_[2] = {}; | 84 unsigned yuv_textures_[2] = {}; |
| 79 | 85 |
| 80 DISALLOW_COPY_AND_ASSIGN(GLImageIOSurface); | 86 DISALLOW_COPY_AND_ASSIGN(GLImageIOSurface); |
| 81 }; | 87 }; |
| 82 | 88 |
| 83 } // namespace gl | 89 } // namespace gl |
| 84 | 90 |
| 85 #endif // UI_GL_GL_IMAGE_IO_SURFACE_H_ | 91 #endif // UI_GL_GL_IMAGE_IO_SURFACE_H_ |
| OLD | NEW |