OLD | NEW |
---|---|
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 // This file contains an interface of output pictures for the Vaapi | 5 // This file contains an interface of output pictures for the Vaapi |
6 // video decoder. This is implemented by different window system | 6 // video decoder. This is implemented by different window system |
7 // (X11/Ozone) and used by VaapiVideoDecodeAccelerator to produce | 7 // (X11/Ozone) and used by VaapiVideoDecodeAccelerator to produce |
8 // output pictures. | 8 // output pictures. |
9 | 9 |
10 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_ | 10 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_ |
11 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_ | 11 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_ |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 | 18 |
19 namespace gl { | 19 namespace gl { |
20 class GLImage; | 20 class GLImage; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class VASurface; | 25 class VASurface; |
26 class VaapiWrapper; | 26 class VaapiWrapper; |
27 | 27 |
28 // Picture is native pixmap abstraction (X11/Ozone). | 28 // Picture is native pixmap abstraction (X11/Ozone). |
29 class VaapiPicture : public base::NonThreadSafe { | 29 class VaapiPicture : public base::NonThreadSafe, |
30 public base::RefCounted<VaapiPicture> { | |
Pawel Osciak
2015/11/16 04:24:35
This should likely be RefCountedThreadSafe.
william.xie1
2015/11/16 08:07:25
Done.
| |
30 public: | 31 public: |
31 virtual ~VaapiPicture() {} | 32 virtual ~VaapiPicture() {} |
32 | 33 |
33 // Try to allocate the underlying resources for the picture. | 34 // Try to allocate the underlying resources for the picture. |
34 virtual bool Initialize() = 0; | 35 virtual bool Initialize() = 0; |
35 | 36 |
36 int32 picture_buffer_id() const { return picture_buffer_id_; } | 37 int32 picture_buffer_id() const { return picture_buffer_id_; } |
37 uint32 texture_id() const { return texture_id_; } | 38 uint32 texture_id() const { return texture_id_; } |
38 const gfx::Size& size() const { return size_; } | 39 const gfx::Size& size() const { return size_; } |
39 | 40 |
40 virtual bool AllowOverlay() const; | 41 virtual bool AllowOverlay() const; |
41 | 42 |
42 // Returns the |GLImage|, if any, to bind to the texture. | 43 // Returns the |GLImage|, if any, to bind to the texture. |
43 virtual scoped_refptr<gl::GLImage> GetImageToBind() = 0; | 44 virtual scoped_refptr<gl::GLImage> GetImageToBind() = 0; |
44 | 45 |
45 // Downloads the |va_surface| into the picture, potentially scaling | 46 // Downloads the |va_surface| into the picture, potentially scaling |
46 // it if needed. | 47 // it if needed. |
47 virtual bool DownloadFromSurface( | 48 virtual bool DownloadFromSurface( |
48 const scoped_refptr<VASurface>& va_surface) = 0; | 49 const scoped_refptr<VASurface>& va_surface) = 0; |
49 | 50 |
50 // Create a VaapiPicture of |size| to be associated with | 51 // Create a VaapiPicture of |size| to be associated with |
51 // |picture_buffer_id| and bound to |texture_id|. | 52 // |picture_buffer_id| and bound to |texture_id|. |
52 // |make_context_current| is provided for the GL operations. | 53 // |make_context_current| is provided for the GL operations. |
53 static linked_ptr<VaapiPicture> CreatePicture( | 54 static scoped_refptr<VaapiPicture> CreatePicture( |
54 VaapiWrapper* vaapi_wrapper, | 55 scoped_refptr<VaapiWrapper> vaapi_wrapper, |
Pawel Osciak
2015/11/16 04:24:35
const&
william.xie1
2015/11/16 08:07:26
Done.
| |
55 const base::Callback<bool(void)> make_context_current, | 56 const base::Callback<bool(void)> make_context_current, |
56 int32 picture_buffer_id, | 57 int32 picture_buffer_id, |
57 uint32 texture_id, | 58 uint32 texture_id, |
58 const gfx::Size& size); | 59 const gfx::Size& size); |
59 | 60 |
60 // Get the texture target used to bind EGLImages (either | 61 // Get the texture target used to bind EGLImages (either |
61 // GL_TEXTURE_2D on X11 or GL_TEXTURE_EXTERNAL_OES on DRM). | 62 // GL_TEXTURE_2D on X11 or GL_TEXTURE_EXTERNAL_OES on DRM). |
62 static uint32 GetGLTextureTarget(); | 63 static uint32 GetGLTextureTarget(); |
63 | 64 |
64 protected: | 65 protected: |
65 VaapiPicture(int32 picture_buffer_id, | 66 VaapiPicture(int32 picture_buffer_id, |
66 uint32 texture_id, | 67 uint32 texture_id, |
67 const gfx::Size& size) | 68 const gfx::Size& size) |
68 : picture_buffer_id_(picture_buffer_id), | 69 : picture_buffer_id_(picture_buffer_id), |
69 texture_id_(texture_id), | 70 texture_id_(texture_id), |
70 size_(size) {} | 71 size_(size) {} |
71 | 72 |
72 private: | 73 private: |
73 int32 picture_buffer_id_; | 74 int32 picture_buffer_id_; |
74 uint32 texture_id_; | 75 uint32 texture_id_; |
75 gfx::Size size_; | 76 gfx::Size size_; |
76 | 77 |
77 DISALLOW_COPY_AND_ASSIGN(VaapiPicture); | 78 DISALLOW_COPY_AND_ASSIGN(VaapiPicture); |
78 }; | 79 }; |
79 | 80 |
80 } // namespace content | 81 } // namespace content |
81 | 82 |
82 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_ | 83 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_ |
OLD | NEW |