OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include <d3d11.h> | 5 #include <d3d11.h> |
6 | 6 |
7 #include "base/win/scoped_comptr.h" | 7 #include "base/win/scoped_comptr.h" |
8 #include "third_party/khronos/EGL/egl.h" | |
9 #include "third_party/khronos/EGL/eglext.h" | |
10 #include "ui/gl/gl_export.h" | 8 #include "ui/gl/gl_export.h" |
11 #include "ui/gl/gl_image.h" | 9 #include "ui/gl/gl_image.h" |
12 | 10 |
| 11 typedef void* EGLStreamKHR; |
| 12 |
13 namespace gl { | 13 namespace gl { |
14 | 14 |
15 class GL_EXPORT GLImageDXGI : public GLImage { | 15 class GL_EXPORT GLImageDXGI : public GLImage { |
16 public: | 16 public: |
17 GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream); | 17 GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream); |
18 | 18 |
19 // Safe downcast. Returns nullptr on failure. | 19 // Safe downcast. Returns nullptr on failure. |
20 static GLImageDXGI* FromGLImage(GLImage* image); | 20 static GLImageDXGI* FromGLImage(GLImage* image); |
21 | 21 |
22 // GLImage implementation. | 22 // GLImage implementation. |
(...skipping 18 matching lines...) Expand all Loading... |
41 | 41 |
42 void SetTexture(const base::win::ScopedComPtr<ID3D11Texture2D>& texture, | 42 void SetTexture(const base::win::ScopedComPtr<ID3D11Texture2D>& texture, |
43 size_t level); | 43 size_t level); |
44 | 44 |
45 base::win::ScopedComPtr<ID3D11Texture2D> texture() { return texture_; } | 45 base::win::ScopedComPtr<ID3D11Texture2D> texture() { return texture_; } |
46 size_t level() const { return level_; } | 46 size_t level() const { return level_; } |
47 | 47 |
48 protected: | 48 protected: |
49 ~GLImageDXGI() override; | 49 ~GLImageDXGI() override; |
50 | 50 |
51 private: | |
52 gfx::Size size_; | 51 gfx::Size size_; |
53 | 52 |
54 EGLStreamKHR stream_; | 53 EGLStreamKHR stream_; |
55 | 54 |
56 base::win::ScopedComPtr<ID3D11Texture2D> texture_; | 55 base::win::ScopedComPtr<ID3D11Texture2D> texture_; |
57 size_t level_ = 0; | 56 size_t level_ = 0; |
58 }; | 57 }; |
| 58 |
| 59 // This copies to a new texture on bind. |
| 60 class GL_EXPORT CopyingGLImageDXGI : public GLImageDXGI { |
| 61 public: |
| 62 CopyingGLImageDXGI(const base::win::ScopedComPtr<ID3D11Device>& d3d11_device, |
| 63 const gfx::Size& size, |
| 64 EGLStreamKHR stream); |
| 65 |
| 66 bool Initialize(); |
| 67 bool InitializeVideoProcessor( |
| 68 const base::win::ScopedComPtr<ID3D11VideoProcessor>& video_processor, |
| 69 const base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator>& |
| 70 enumerator); |
| 71 void UnbindFromTexture(); |
| 72 |
| 73 // GLImage implementation. |
| 74 bool BindTexImage(unsigned target) override; |
| 75 |
| 76 private: |
| 77 ~CopyingGLImageDXGI() override; |
| 78 |
| 79 bool copied_ = false; |
| 80 |
| 81 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; |
| 82 base::win::ScopedComPtr<ID3D11VideoContext> video_context_; |
| 83 base::win::ScopedComPtr<ID3D11VideoProcessor> d3d11_processor_; |
| 84 base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator> enumerator_; |
| 85 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; |
| 86 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; |
| 87 base::win::ScopedComPtr<ID3D11VideoProcessorOutputView> output_view_; |
| 88 }; |
59 } | 89 } |
OLD | NEW |