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

Side by Side Diff: media/gpu/dxva_picture_buffer_win.h

Issue 2859723002: Copy NV12 picture buffers on demand on the main thread. (Closed)
Patch Set: change comment Created 3 years, 6 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
« no previous file with comments | « media/base/media_switches.cc ('k') | media/gpu/dxva_picture_buffer_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_ 5 #ifndef MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_
6 #define MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_ 6 #define MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_
7 7
8 #include <d3d11.h> 8 #include <d3d11.h>
9 #include <d3d9.h> 9 #include <d3d9.h>
10 #include <mfidl.h> 10 #include <mfidl.h>
(...skipping 30 matching lines...) Expand all
41 // client. 41 // client.
42 // The dest_surface parameter contains the decoded bits. 42 // The dest_surface parameter contains the decoded bits.
43 virtual bool CopyOutputSampleDataToPictureBuffer( 43 virtual bool CopyOutputSampleDataToPictureBuffer(
44 DXVAVideoDecodeAccelerator* decoder, 44 DXVAVideoDecodeAccelerator* decoder,
45 IDirect3DSurface9* dest_surface, 45 IDirect3DSurface9* dest_surface,
46 ID3D11Texture2D* dx11_texture, 46 ID3D11Texture2D* dx11_texture,
47 int input_buffer_id); 47 int input_buffer_id);
48 48
49 bool available() const { return state_ == UNUSED; } 49 bool available() const { return state_ == UNUSED; }
50 State state() const { return state_; } 50 State state() const { return state_; }
51 const PictureBuffer& picture_buffer() const { return picture_buffer_; }
51 52
52 int id() const { return picture_buffer_.id(); } 53 int id() const { return picture_buffer_.id(); }
53 54
54 gfx::Size size() const { return picture_buffer_.size(); } 55 gfx::Size size() const { return picture_buffer_.size(); }
55 void set_bound(); 56 void set_bound();
56 57
57 scoped_refptr<gl::GLImage> gl_image() { return gl_image_; } 58 scoped_refptr<gl::GLImage> gl_image() { return gl_image_; }
58 59
59 const gfx::ColorSpace& color_space() const { return color_space_; } 60 const gfx::ColorSpace& color_space() const { return color_space_; }
60 void set_color_space(const gfx::ColorSpace& color_space) { 61 void set_color_space(const gfx::ColorSpace& color_space) {
61 color_space_ = color_space; 62 color_space_ = color_space;
62 } 63 }
63 64
64 // Returns true if these could in theory be used as an overlay. May 65 // Returns true if these could in theory be used as an overlay. May
65 // still be drawn using GL depending on the scene and precise hardware 66 // still be drawn using GL depending on the scene and precise hardware
66 // support. 67 // support.
67 virtual bool AllowOverlay() const = 0; 68 virtual bool AllowOverlay() const = 0;
68 69
70 // Returns true if BindSampleToTexture should be used. Otherwise
71 // CopyOutputSampleDataToPicture should be used.
72 virtual bool CanBindSamples() const = 0;
73
69 bool waiting_to_reuse() const { return state_ == WAITING_TO_REUSE; } 74 bool waiting_to_reuse() const { return state_ == WAITING_TO_REUSE; }
70 virtual gl::GLFence* reuse_fence(); 75 virtual gl::GLFence* reuse_fence();
71 76
72 // Called when the source surface |src_surface| is copied to the destination 77 // Called when the source surface |src_surface| is copied to the destination
73 // |dest_surface| 78 // |dest_surface|
74 virtual bool CopySurfaceComplete(IDirect3DSurface9* src_surface, 79 virtual bool CopySurfaceComplete(IDirect3DSurface9* src_surface,
75 IDirect3DSurface9* dest_surface); 80 IDirect3DSurface9* dest_surface);
76 virtual bool BindSampleToTexture(base::win::ScopedComPtr<IMFSample> sample); 81 virtual bool BindSampleToTexture(DXVAVideoDecodeAccelerator* decoder,
82 base::win::ScopedComPtr<IMFSample> sample);
77 83
78 protected: 84 protected:
79 explicit DXVAPictureBuffer(const PictureBuffer& buffer); 85 explicit DXVAPictureBuffer(const PictureBuffer& buffer);
80 86
81 State state_ = UNUSED; 87 State state_ = UNUSED;
82 PictureBuffer picture_buffer_; 88 PictureBuffer picture_buffer_;
83 gfx::ColorSpace color_space_; 89 gfx::ColorSpace color_space_;
84 scoped_refptr<gl::GLImage> gl_image_; 90 scoped_refptr<gl::GLImage> gl_image_;
85 91
86 DISALLOW_COPY_AND_ASSIGN(DXVAPictureBuffer); 92 DISALLOW_COPY_AND_ASSIGN(DXVAPictureBuffer);
(...skipping 14 matching lines...) Expand all
101 bool ReusePictureBuffer() override; 107 bool ReusePictureBuffer() override;
102 void ResetReuseFence() override; 108 void ResetReuseFence() override;
103 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder, 109 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder,
104 IDirect3DSurface9* dest_surface, 110 IDirect3DSurface9* dest_surface,
105 ID3D11Texture2D* dx11_texture, 111 ID3D11Texture2D* dx11_texture,
106 int input_buffer_id) override; 112 int input_buffer_id) override;
107 gl::GLFence* reuse_fence() override; 113 gl::GLFence* reuse_fence() override;
108 bool CopySurfaceComplete(IDirect3DSurface9* src_surface, 114 bool CopySurfaceComplete(IDirect3DSurface9* src_surface,
109 IDirect3DSurface9* dest_surface) override; 115 IDirect3DSurface9* dest_surface) override;
110 bool AllowOverlay() const override; 116 bool AllowOverlay() const override;
117 bool CanBindSamples() const override;
111 118
112 protected: 119 protected:
113 EGLSurface decoding_surface_; 120 EGLSurface decoding_surface_;
114 121
115 std::unique_ptr<gl::GLFence> reuse_fence_; 122 std::unique_ptr<gl::GLFence> reuse_fence_;
116 123
117 HANDLE texture_share_handle_; 124 HANDLE texture_share_handle_;
118 base::win::ScopedComPtr<IDirect3DTexture9> decoding_texture_; 125 base::win::ScopedComPtr<IDirect3DTexture9> decoding_texture_;
119 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; 126 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_;
120 127
(...skipping 21 matching lines...) Expand all
142 }; 149 };
143 150
144 // Shares the decoded texture with ANGLE without copying by using an EGL stream. 151 // Shares the decoded texture with ANGLE without copying by using an EGL stream.
145 class EGLStreamPictureBuffer : public DXVAPictureBuffer { 152 class EGLStreamPictureBuffer : public DXVAPictureBuffer {
146 public: 153 public:
147 explicit EGLStreamPictureBuffer(const PictureBuffer& buffer); 154 explicit EGLStreamPictureBuffer(const PictureBuffer& buffer);
148 ~EGLStreamPictureBuffer() override; 155 ~EGLStreamPictureBuffer() override;
149 156
150 bool Initialize(); 157 bool Initialize();
151 bool ReusePictureBuffer() override; 158 bool ReusePictureBuffer() override;
152 bool BindSampleToTexture(base::win::ScopedComPtr<IMFSample> sample) override; 159 bool BindSampleToTexture(DXVAVideoDecodeAccelerator* decoder,
160 base::win::ScopedComPtr<IMFSample> sample) override;
153 bool AllowOverlay() const override; 161 bool AllowOverlay() const override;
162 bool CanBindSamples() const override;
154 163
155 private: 164 private:
156 EGLStreamKHR stream_; 165 EGLStreamKHR stream_;
166
167 base::win::ScopedComPtr<IMFSample> current_d3d_sample_;
168 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_;
169 };
170
171 // Shares the decoded texture with ANGLE without copying by using an EGL stream.
172 class EGLStreamDelayedCopyPictureBuffer : public DXVAPictureBuffer {
173 public:
174 explicit EGLStreamDelayedCopyPictureBuffer(const PictureBuffer& buffer);
175 ~EGLStreamDelayedCopyPictureBuffer() override;
176
177 bool Initialize(const DXVAVideoDecodeAccelerator& decoder);
178 bool ReusePictureBuffer() override;
179 bool BindSampleToTexture(DXVAVideoDecodeAccelerator* decoder,
180 base::win::ScopedComPtr<IMFSample> sample) override;
181 bool AllowOverlay() const override;
182 bool CanBindSamples() const override;
183
184 private:
185 EGLStreamKHR stream_;
157 186
158 base::win::ScopedComPtr<IMFSample> current_d3d_sample_; 187 base::win::ScopedComPtr<IMFSample> current_d3d_sample_;
159 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; 188 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_;
160 }; 189 };
161 190
162 // Creates an NV12 texture and copies to it, then shares that with ANGLE. 191 // Creates an NV12 texture and copies to it, then shares that with ANGLE.
163 class EGLStreamCopyPictureBuffer : public DXVAPictureBuffer { 192 class EGLStreamCopyPictureBuffer : public DXVAPictureBuffer {
164 public: 193 public:
165 explicit EGLStreamCopyPictureBuffer(const PictureBuffer& buffer); 194 explicit EGLStreamCopyPictureBuffer(const PictureBuffer& buffer);
166 ~EGLStreamCopyPictureBuffer() override; 195 ~EGLStreamCopyPictureBuffer() override;
167 196
168 bool Initialize(const DXVAVideoDecodeAccelerator& decoder); 197 bool Initialize(const DXVAVideoDecodeAccelerator& decoder);
169 bool ReusePictureBuffer() override; 198 bool ReusePictureBuffer() override;
170 199
171 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder, 200 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder,
172 IDirect3DSurface9* dest_surface, 201 IDirect3DSurface9* dest_surface,
173 ID3D11Texture2D* dx11_texture, 202 ID3D11Texture2D* dx11_texture,
174 int input_buffer_id) override; 203 int input_buffer_id) override;
175 bool CopySurfaceComplete(IDirect3DSurface9* src_surface, 204 bool CopySurfaceComplete(IDirect3DSurface9* src_surface,
176 IDirect3DSurface9* dest_surface) override; 205 IDirect3DSurface9* dest_surface) override;
177 bool AllowOverlay() const override; 206 bool AllowOverlay() const override;
207 bool CanBindSamples() const override;
178 208
179 private: 209 private:
180 EGLStreamKHR stream_; 210 EGLStreamKHR stream_;
181 211
182 // This ID3D11Texture2D interface pointer is used to hold a reference to the 212 // This ID3D11Texture2D interface pointer is used to hold a reference to the
183 // MFT decoder texture during the course of a copy operation. This reference 213 // MFT decoder texture during the course of a copy operation. This reference
184 // is released when the copy completes. 214 // is released when the copy completes.
185 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; 215 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_;
186 216
187 base::win::ScopedComPtr<IDXGIKeyedMutex> egl_keyed_mutex_; 217 base::win::ScopedComPtr<IDXGIKeyedMutex> egl_keyed_mutex_;
188 base::win::ScopedComPtr<IDXGIKeyedMutex> dx11_keyed_mutex_; 218 base::win::ScopedComPtr<IDXGIKeyedMutex> dx11_keyed_mutex_;
189 219
190 HANDLE texture_share_handle_; 220 HANDLE texture_share_handle_;
191 // This is the texture (created on ANGLE's device) that will be put in the 221 // This is the texture (created on ANGLE's device) that will be put in the
192 // EGLStream. 222 // EGLStream.
193 base::win::ScopedComPtr<ID3D11Texture2D> angle_copy_texture_; 223 base::win::ScopedComPtr<ID3D11Texture2D> angle_copy_texture_;
194 // This is another copy of that shared resource that will be copied to from 224 // This is another copy of that shared resource that will be copied to from
195 // the decoder. 225 // the decoder.
196 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; 226 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_;
197 227
198 // This is the last value that was used to release the keyed mutex. 228 // This is the last value that was used to release the keyed mutex.
199 uint64_t keyed_mutex_value_ = 0; 229 uint64_t keyed_mutex_value_ = 0;
200 }; 230 };
201 231
202 } // namespace media 232 } // namespace media
203 233
204 #endif // MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_ 234 #endif // MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_
OLDNEW
« no previous file with comments | « media/base/media_switches.cc ('k') | media/gpu/dxva_picture_buffer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698