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

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

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

Powered by Google App Engine
This is Rietveld 408576698