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

Side by Side Diff: content/common/gpu/media/va_surface.h

Issue 817023005: Reland: Refactor Vaapi video decoder/encoder in preparation of Freon support (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years 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 // This file contains the definition of VASurface class, used for decoding by 5 // This file contains the definition of VASurface class, used for decoding by
6 // VaapiVideoDecodeAccelerator and VaapiH264Decoder. 6 // VaapiVideoDecodeAccelerator and VaapiH264Decoder.
7 7
8 #ifndef CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_ 8 #ifndef CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_
9 #define CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_ 9 #define CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_
10 10
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h"
11 #include "third_party/libva/va/va.h" 14 #include "third_party/libva/va/va.h"
15 #include "ui/gfx/size.h"
12 16
13 namespace content { 17 namespace content {
14 18
15 // A VA-API-specific decode surface used by VaapiH264Decoder to decode into 19 // A VA-API-specific decode surface used by VaapiH264Decoder to decode into
16 // and use as reference for decoding other surfaces. It is also handed by the 20 // and use as reference for decoding other surfaces. It is also handed by the
17 // decoder to VaapiVideoDecodeAccelerator when the contents of the surface are 21 // decoder to VaapiVideoDecodeAccelerator when the contents of the surface are
18 // ready and should be displayed. VAVDA converts the surface contents into an 22 // ready and should be displayed. VAVDA converts the surface contents into an
19 // X Pixmap bound to a texture for display and releases its reference to it. 23 // X/Drm Pixmap bound to a texture for display and releases its reference to it.
20 // Decoder releases its references to the surface when it's done decoding and 24 // Decoder releases its references to the surface when it's done decoding and
21 // using it as reference. Note that a surface may still be used for reference 25 // using it as reference. Note that a surface may still be used for reference
22 // after it's been sent to output and also after it is no longer used by VAVDA. 26 // after it's been sent to output and also after it is no longer used by VAVDA.
23 // Thus, the surface can be in use by both VAVDA and the Decoder at the same 27 // Thus, the surface can be in use by both VAVDA and the Decoder at the same
24 // time, or by either of them, with the restriction that VAVDA will never get 28 // time, or by either of them, with the restriction that VAVDA will never get
25 // the surface until the contents are ready, and it is guaranteed that the 29 // the surface until the contents are ready, and it is guaranteed that the
26 // contents will not change after that. 30 // contents will not change after that.
27 // When both the decoder and VAVDA release their references to the surface, 31 // When both the decoder and VAVDA release their references to the surface,
28 // it is freed and the release callback is executed to put the surface back 32 // it is freed and the release callback is executed to put the surface back
29 // into available surfaces pool, which is managed externally. 33 // into available surfaces pool, which is managed externally.
(...skipping 19 matching lines...) Expand all
49 // | DecodeSurface is used for decoding, putting data into associated VASurface. 53 // | DecodeSurface is used for decoding, putting data into associated VASurface.
50 // | | 54 // | |
51 // | |--------------------------------------------------+ 55 // | |--------------------------------------------------+
52 // | | | 56 // | | |
53 // | v v 57 // | v v
54 // | DecodeSurface is to be output. VaapiH264Decoder uses the 58 // | DecodeSurface is to be output. VaapiH264Decoder uses the
55 // | VaapiH264Decoder passes the associated DecodeSurface and associated 59 // | VaapiH264Decoder passes the associated DecodeSurface and associated
56 // | VASurface to VaapiVideoDecodeAccelerator, VASurface as reference for 60 // | VASurface to VaapiVideoDecodeAccelerator, VASurface as reference for
57 // | which stores it (taking a ref) on decoding more frames. 61 // | which stores it (taking a ref) on decoding more frames.
58 // | pending_output_cbs_ queue until an output | 62 // | pending_output_cbs_ queue until an output |
59 // | TFPPicture becomes available. v 63 // | VaapiPicture becomes available. v
60 // | | Once the DecodeSurface is not 64 // | | Once the DecodeSurface is not
61 // | | needed as reference anymore, 65 // | | needed as reference anymore,
62 // | v it is released, releasing the 66 // | v it is released, releasing the
63 // | A TFPPicture becomes available after associated VASurface reference. 67 // | A VaapiPicture becomes available after associated VASurface reference.
64 // | the client of VVDA returns | 68 // | the client of VVDA returns |
65 // | a PictureBuffer associated with it. VVDA | 69 // | a PictureBuffer associated with it. VVDA |
66 // | puts the contents of the VASurface into | 70 // | puts the contents of the VASurface into |
67 // | it and releases the reference to VASurface. | 71 // | it and releases the reference to VASurface. |
68 // | | | 72 // | | |
69 // | '---------------------------------------' 73 // | '---------------------------------------'
70 // | | 74 // | |
71 // | v 75 // | v
72 // | Neither VVDA nor VHD hold a reference to VASurface. VASurface is released, 76 // | Neither VVDA nor VHD hold a reference to VASurface. VASurface is released,
73 // | ReleaseCB gets called in its destructor, which puts the associated 77 // | ReleaseCB gets called in its destructor, which puts the associated
74 // | VASurfaceID back onto VVDA::available_va_surfaces_. 78 // | VASurfaceID back onto VVDA::available_va_surfaces_.
75 // | | 79 // | |
76 // '-------------------------------------| 80 // '-------------------------------------|
77 // | 81 // |
78 // v 82 // v
79 // VaapiWrapper frees VASurfaceID. 83 // VaapiWrapper frees VASurfaceID.
80 // 84 //
81 class CONTENT_EXPORT VASurface : public base::RefCountedThreadSafe<VASurface> { 85 class CONTENT_EXPORT VASurface : public base::RefCountedThreadSafe<VASurface> {
82 public: 86 public:
83 // Provided by user, will be called when all references to the surface 87 // Provided by user, will be called when all references to the surface
84 // are released. 88 // are released.
85 typedef base::Callback<void(VASurfaceID)> ReleaseCB; 89 typedef base::Callback<void(VASurfaceID)> ReleaseCB;
86 90
87 VASurface(VASurfaceID va_surface_id, const ReleaseCB& release_cb); 91 VASurface(VASurfaceID va_surface_id,
92 const gfx::Size& size,
93 const ReleaseCB& release_cb);
88 94
89 VASurfaceID id() { 95 VASurfaceID id() {
90 return va_surface_id_; 96 return va_surface_id_;
91 } 97 }
92 98
99 const gfx::Size& size() const { return size_; }
100
93 private: 101 private:
94 friend class base::RefCountedThreadSafe<VASurface>; 102 friend class base::RefCountedThreadSafe<VASurface>;
95 ~VASurface(); 103 ~VASurface();
96 104
97 const VASurfaceID va_surface_id_; 105 const VASurfaceID va_surface_id_;
106 gfx::Size size_;
98 ReleaseCB release_cb_; 107 ReleaseCB release_cb_;
99 108
100 DISALLOW_COPY_AND_ASSIGN(VASurface); 109 DISALLOW_COPY_AND_ASSIGN(VASurface);
101 }; 110 };
102 111
103 } // namespace content 112 } // namespace content
104 113
105 #endif // CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_ 114 #endif // CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698