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

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

Issue 1861923002: Mac h264: Retain CVPixelBuffer inside GLImageIOSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 #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 <IOSurface/IOSurface.h> 8 #include <IOSurface/IOSurface.h>
9 #include <CoreVideo/CVPixelBuffer.h>
Avi (use Gerrit) 2016/04/06 16:49:52 Alphabetical?
ccameron 2016/04/06 17:49:00 Oops -- done.
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
30 bool Initialize(IOSurfaceRef io_surface, 31 bool Initialize(IOSurfaceRef io_surface,
31 gfx::GenericSharedMemoryId io_surface_id, 32 gfx::GenericSharedMemoryId io_surface_id,
32 gfx::BufferFormat format); 33 gfx::BufferFormat format);
33 34
35 // IOSurfaces coming from video decode are wrapped in a CVPixelBuffer
36 // and may be discarded if the owning CVPixelBuffer is destroyed. This
37 // initialization will ensure that the CVPixelBuffer be retained for the
38 // lifetime of the GLImage.
39 bool InitializeWithCVPixelBuffer(CVPixelBufferRef cv_pixel_buffer,
40 gfx::GenericSharedMemoryId io_surface_id,
41 gfx::BufferFormat format);
42
34 // Overridden from GLImage: 43 // Overridden from GLImage:
35 void Destroy(bool have_context) override; 44 void Destroy(bool have_context) override;
36 gfx::Size GetSize() override; 45 gfx::Size GetSize() override;
37 unsigned GetInternalFormat() override; 46 unsigned GetInternalFormat() override;
38 bool BindTexImage(unsigned target) override; 47 bool BindTexImage(unsigned target) override;
39 void ReleaseTexImage(unsigned target) override {} 48 void ReleaseTexImage(unsigned target) override {}
40 bool CopyTexImage(unsigned target) override; 49 bool CopyTexImage(unsigned target) override;
41 bool CopyTexSubImage(unsigned target, 50 bool CopyTexSubImage(unsigned target,
42 const gfx::Point& offset, 51 const gfx::Point& offset,
43 const gfx::Rect& rect) override; 52 const gfx::Rect& rect) override;
44 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 53 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
45 int z_order, 54 int z_order,
46 gfx::OverlayTransform transform, 55 gfx::OverlayTransform transform,
47 const gfx::Rect& bounds_rect, 56 const gfx::Rect& bounds_rect,
48 const gfx::RectF& crop_rect) override; 57 const gfx::RectF& crop_rect) override;
49 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 58 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
50 uint64_t process_tracing_id, 59 uint64_t process_tracing_id,
51 const std::string& dump_name) override; 60 const std::string& dump_name) override;
52 61
53 gfx::GenericSharedMemoryId io_surface_id() const { return io_surface_id_; } 62 gfx::GenericSharedMemoryId io_surface_id() const { return io_surface_id_; }
54 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(); 63 base::ScopedCFTypeRef<IOSurfaceRef> io_surface();
64 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer();
55 65
56 static void SetLayerForWidget(gfx::AcceleratedWidget widget, CALayer* layer); 66 static void SetLayerForWidget(gfx::AcceleratedWidget widget, CALayer* layer);
57 67
58 static unsigned GetInternalFormatForTesting(gfx::BufferFormat format); 68 static unsigned GetInternalFormatForTesting(gfx::BufferFormat format);
59 69
60 protected: 70 protected:
61 ~GLImageIOSurface() override; 71 ~GLImageIOSurface() override;
62 72
63 private: 73 private:
64 const gfx::Size size_; 74 const gfx::Size size_;
65 const unsigned internalformat_; 75 const unsigned internalformat_;
66 gfx::BufferFormat format_; 76 gfx::BufferFormat format_;
67 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; 77 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
78 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_;
68 gfx::GenericSharedMemoryId io_surface_id_; 79 gfx::GenericSharedMemoryId io_surface_id_;
69 base::ThreadChecker thread_checker_; 80 base::ThreadChecker thread_checker_;
70 81
71 // GL state to support 420v IOSurface conversion to RGB. 82 // GL state to support 420v IOSurface conversion to RGB.
72 unsigned framebuffer_ = 0; 83 unsigned framebuffer_ = 0;
73 unsigned vertex_shader_ = 0; 84 unsigned vertex_shader_ = 0;
74 unsigned fragment_shader_ = 0; 85 unsigned fragment_shader_ = 0;
75 unsigned program_ = 0; 86 unsigned program_ = 0;
76 int size_location_ = -1; 87 int size_location_ = -1;
77 unsigned vertex_buffer_ = 0; 88 unsigned vertex_buffer_ = 0;
78 unsigned yuv_textures_[2] = {}; 89 unsigned yuv_textures_[2] = {};
79 90
80 DISALLOW_COPY_AND_ASSIGN(GLImageIOSurface); 91 DISALLOW_COPY_AND_ASSIGN(GLImageIOSurface);
81 }; 92 };
82 93
83 } // namespace gl 94 } // namespace gl
84 95
85 #endif // UI_GL_GL_IMAGE_IO_SURFACE_H_ 96 #endif // UI_GL_GL_IMAGE_IO_SURFACE_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/vt_video_decode_accelerator_mac.cc ('k') | ui/gl/gl_image_io_surface.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698