OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 gfx::Size size() const { return picture_buffer_.size(); } | 54 gfx::Size size() const { return picture_buffer_.size(); } |
55 void set_bound(); | 55 void set_bound(); |
56 | 56 |
57 scoped_refptr<gl::GLImage> gl_image() { return gl_image_; } | 57 scoped_refptr<gl::GLImage> gl_image() { return gl_image_; } |
58 | 58 |
59 const gfx::ColorSpace& color_space() const { return color_space_; } | 59 const gfx::ColorSpace& color_space() const { return color_space_; } |
60 void set_color_space(const gfx::ColorSpace& color_space) { | 60 void set_color_space(const gfx::ColorSpace& color_space) { |
61 color_space_ = color_space; | 61 color_space_ = color_space; |
62 } | 62 } |
63 | 63 |
| 64 // 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 // support. |
| 67 virtual bool AllowOverlay() const = 0; |
| 68 |
64 bool waiting_to_reuse() const { return state_ == WAITING_TO_REUSE; } | 69 bool waiting_to_reuse() const { return state_ == WAITING_TO_REUSE; } |
65 virtual gl::GLFence* reuse_fence(); | 70 virtual gl::GLFence* reuse_fence(); |
66 | 71 |
67 // Called when the source surface |src_surface| is copied to the destination | 72 // Called when the source surface |src_surface| is copied to the destination |
68 // |dest_surface| | 73 // |dest_surface| |
69 virtual bool CopySurfaceComplete(IDirect3DSurface9* src_surface, | 74 virtual bool CopySurfaceComplete(IDirect3DSurface9* src_surface, |
70 IDirect3DSurface9* dest_surface); | 75 IDirect3DSurface9* dest_surface); |
71 virtual bool BindSampleToTexture(base::win::ScopedComPtr<IMFSample> sample); | 76 virtual bool BindSampleToTexture(base::win::ScopedComPtr<IMFSample> sample); |
72 | 77 |
73 protected: | 78 protected: |
(...skipping 21 matching lines...) Expand all Loading... |
95 | 100 |
96 bool ReusePictureBuffer() override; | 101 bool ReusePictureBuffer() override; |
97 void ResetReuseFence() override; | 102 void ResetReuseFence() override; |
98 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder, | 103 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder, |
99 IDirect3DSurface9* dest_surface, | 104 IDirect3DSurface9* dest_surface, |
100 ID3D11Texture2D* dx11_texture, | 105 ID3D11Texture2D* dx11_texture, |
101 int input_buffer_id) override; | 106 int input_buffer_id) override; |
102 gl::GLFence* reuse_fence() override; | 107 gl::GLFence* reuse_fence() override; |
103 bool CopySurfaceComplete(IDirect3DSurface9* src_surface, | 108 bool CopySurfaceComplete(IDirect3DSurface9* src_surface, |
104 IDirect3DSurface9* dest_surface) override; | 109 IDirect3DSurface9* dest_surface) override; |
| 110 bool AllowOverlay() const override; |
105 | 111 |
106 protected: | 112 protected: |
107 EGLSurface decoding_surface_; | 113 EGLSurface decoding_surface_; |
108 | 114 |
109 std::unique_ptr<gl::GLFence> reuse_fence_; | 115 std::unique_ptr<gl::GLFence> reuse_fence_; |
110 | 116 |
111 HANDLE texture_share_handle_; | 117 HANDLE texture_share_handle_; |
112 base::win::ScopedComPtr<IDirect3DTexture9> decoding_texture_; | 118 base::win::ScopedComPtr<IDirect3DTexture9> decoding_texture_; |
113 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; | 119 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; |
114 | 120 |
(...skipping 22 matching lines...) Expand all Loading... |
137 | 143 |
138 // Shares the decoded texture with ANGLE without copying by using an EGL stream. | 144 // Shares the decoded texture with ANGLE without copying by using an EGL stream. |
139 class EGLStreamPictureBuffer : public DXVAPictureBuffer { | 145 class EGLStreamPictureBuffer : public DXVAPictureBuffer { |
140 public: | 146 public: |
141 explicit EGLStreamPictureBuffer(const PictureBuffer& buffer); | 147 explicit EGLStreamPictureBuffer(const PictureBuffer& buffer); |
142 ~EGLStreamPictureBuffer() override; | 148 ~EGLStreamPictureBuffer() override; |
143 | 149 |
144 bool Initialize(); | 150 bool Initialize(); |
145 bool ReusePictureBuffer() override; | 151 bool ReusePictureBuffer() override; |
146 bool BindSampleToTexture(base::win::ScopedComPtr<IMFSample> sample) override; | 152 bool BindSampleToTexture(base::win::ScopedComPtr<IMFSample> sample) override; |
| 153 bool AllowOverlay() const override; |
147 | 154 |
148 private: | 155 private: |
149 EGLStreamKHR stream_; | 156 EGLStreamKHR stream_; |
150 | 157 |
151 base::win::ScopedComPtr<IMFSample> current_d3d_sample_; | 158 base::win::ScopedComPtr<IMFSample> current_d3d_sample_; |
152 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; | 159 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; |
153 }; | 160 }; |
154 | 161 |
155 // Creates an NV12 texture and copies to it, then shares that with ANGLE. | 162 // Creates an NV12 texture and copies to it, then shares that with ANGLE. |
156 class EGLStreamCopyPictureBuffer : public DXVAPictureBuffer { | 163 class EGLStreamCopyPictureBuffer : public DXVAPictureBuffer { |
157 public: | 164 public: |
158 explicit EGLStreamCopyPictureBuffer(const PictureBuffer& buffer); | 165 explicit EGLStreamCopyPictureBuffer(const PictureBuffer& buffer); |
159 ~EGLStreamCopyPictureBuffer() override; | 166 ~EGLStreamCopyPictureBuffer() override; |
160 | 167 |
161 bool Initialize(const DXVAVideoDecodeAccelerator& decoder); | 168 bool Initialize(const DXVAVideoDecodeAccelerator& decoder); |
162 bool ReusePictureBuffer() override; | 169 bool ReusePictureBuffer() override; |
163 | 170 |
164 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder, | 171 bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder, |
165 IDirect3DSurface9* dest_surface, | 172 IDirect3DSurface9* dest_surface, |
166 ID3D11Texture2D* dx11_texture, | 173 ID3D11Texture2D* dx11_texture, |
167 int input_buffer_id) override; | 174 int input_buffer_id) override; |
168 bool CopySurfaceComplete(IDirect3DSurface9* src_surface, | 175 bool CopySurfaceComplete(IDirect3DSurface9* src_surface, |
169 IDirect3DSurface9* dest_surface) override; | 176 IDirect3DSurface9* dest_surface) override; |
| 177 bool AllowOverlay() const override; |
170 | 178 |
171 private: | 179 private: |
172 EGLStreamKHR stream_; | 180 EGLStreamKHR stream_; |
173 | 181 |
174 // This ID3D11Texture2D interface pointer is used to hold a reference to the | 182 // This ID3D11Texture2D interface pointer is used to hold a reference to the |
175 // MFT decoder texture during the course of a copy operation. This reference | 183 // MFT decoder texture during the course of a copy operation. This reference |
176 // is released when the copy completes. | 184 // is released when the copy completes. |
177 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; | 185 base::win::ScopedComPtr<ID3D11Texture2D> dx11_decoding_texture_; |
178 | 186 |
179 base::win::ScopedComPtr<IDXGIKeyedMutex> egl_keyed_mutex_; | 187 base::win::ScopedComPtr<IDXGIKeyedMutex> egl_keyed_mutex_; |
180 base::win::ScopedComPtr<IDXGIKeyedMutex> dx11_keyed_mutex_; | 188 base::win::ScopedComPtr<IDXGIKeyedMutex> dx11_keyed_mutex_; |
181 | 189 |
182 HANDLE texture_share_handle_; | 190 HANDLE texture_share_handle_; |
183 // This is the texture (created on ANGLE's device) that will be put in the | 191 // This is the texture (created on ANGLE's device) that will be put in the |
184 // EGLStream. | 192 // EGLStream. |
185 base::win::ScopedComPtr<ID3D11Texture2D> angle_copy_texture_; | 193 base::win::ScopedComPtr<ID3D11Texture2D> angle_copy_texture_; |
186 // This is another copy of that shared resource that will be copied to from | 194 // This is another copy of that shared resource that will be copied to from |
187 // the decoder. | 195 // the decoder. |
188 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; | 196 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; |
189 | 197 |
190 // This is the last value that was used to release the keyed mutex. | 198 // This is the last value that was used to release the keyed mutex. |
191 uint64_t keyed_mutex_value_ = 0; | 199 uint64_t keyed_mutex_value_ = 0; |
192 }; | 200 }; |
193 | 201 |
194 } // namespace media | 202 } // namespace media |
195 | 203 |
196 #endif // MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_ | 204 #endif // MEDIA_GPU_DXVA_PICTURE_BUFFER_WIN_H_ |
OLD | NEW |