| 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 "base/win/scoped_handle.h" |
| 8 #include "ui/gl/gl_export.h" | 9 #include "ui/gl/gl_export.h" |
| 9 #include "ui/gl/gl_image.h" | 10 #include "ui/gl/gl_image.h" |
| 10 | 11 |
| 11 typedef void* EGLStreamKHR; | 12 typedef void* EGLStreamKHR; |
| 12 | 13 |
| 13 namespace gl { | 14 namespace gl { |
| 14 | 15 |
| 15 class GL_EXPORT GLImageDXGI : public GLImage { | 16 class GL_EXPORT GLImageDXGIBase : public GLImage { |
| 16 public: | 17 public: |
| 17 GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream); | 18 GLImageDXGIBase(const gfx::Size& size); |
| 18 | 19 |
| 19 // Safe downcast. Returns nullptr on failure. | 20 // Safe downcast. Returns nullptr on failure. |
| 20 static GLImageDXGI* FromGLImage(GLImage* image); | 21 static GLImageDXGIBase* FromGLImage(GLImage* image); |
| 21 | 22 |
| 22 // GLImage implementation. | 23 // GLImage implementation. |
| 23 gfx::Size GetSize() override; | 24 gfx::Size GetSize() override; |
| 24 unsigned GetInternalFormat() override; | 25 unsigned GetInternalFormat() override; |
| 25 bool BindTexImage(unsigned target) override; | 26 bool BindTexImage(unsigned target) override; |
| 26 void ReleaseTexImage(unsigned target) override; | 27 void ReleaseTexImage(unsigned target) override; |
| 27 bool CopyTexImage(unsigned target) override; | 28 bool CopyTexImage(unsigned target) override; |
| 28 bool CopyTexSubImage(unsigned target, | 29 bool CopyTexSubImage(unsigned target, |
| 29 const gfx::Point& offset, | 30 const gfx::Point& offset, |
| 30 const gfx::Rect& rect) override; | 31 const gfx::Rect& rect) override; |
| 31 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 32 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 32 int z_order, | 33 int z_order, |
| 33 gfx::OverlayTransform transform, | 34 gfx::OverlayTransform transform, |
| 34 const gfx::Rect& bounds_rect, | 35 const gfx::Rect& bounds_rect, |
| 35 const gfx::RectF& crop_rect) override; | 36 const gfx::RectF& crop_rect) override; |
| 36 void Flush() override; | 37 void Flush() override; |
| 37 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 38 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 38 uint64_t process_tracing_id, | 39 uint64_t process_tracing_id, |
| 39 const std::string& dump_name) override; | 40 const std::string& dump_name) override; |
| 40 Type GetType() const override; | 41 Type GetType() const override; |
| 41 | 42 |
| 42 void SetTexture(const base::win::ScopedComPtr<ID3D11Texture2D>& texture, | |
| 43 size_t level); | |
| 44 | |
| 45 base::win::ScopedComPtr<ID3D11Texture2D> texture() { return texture_; } | 43 base::win::ScopedComPtr<ID3D11Texture2D> texture() { return texture_; } |
| 46 size_t level() const { return level_; } | 44 size_t level() const { return level_; } |
| 47 | 45 |
| 48 protected: | 46 protected: |
| 49 ~GLImageDXGI() override; | 47 ~GLImageDXGIBase() override; |
| 50 | 48 |
| 51 gfx::Size size_; | 49 gfx::Size size_; |
| 52 | 50 |
| 53 EGLStreamKHR stream_; | |
| 54 | |
| 55 base::win::ScopedComPtr<ID3D11Texture2D> texture_; | 51 base::win::ScopedComPtr<ID3D11Texture2D> texture_; |
| 56 size_t level_ = 0; | 52 size_t level_ = 0; |
| 57 }; | 53 }; |
| 58 | 54 |
| 55 class GL_EXPORT GLImageDXGI : public GLImageDXGIBase { |
| 56 public: |
| 57 GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream); |
| 58 |
| 59 // GLImage implementation. |
| 60 bool BindTexImage(unsigned target) override; |
| 61 |
| 62 void SetTexture(const base::win::ScopedComPtr<ID3D11Texture2D>& texture, |
| 63 size_t level); |
| 64 |
| 65 protected: |
| 66 ~GLImageDXGI() override; |
| 67 |
| 68 EGLStreamKHR stream_; |
| 69 }; |
| 70 |
| 59 // This copies to a new texture on bind. | 71 // This copies to a new texture on bind. |
| 60 class GL_EXPORT CopyingGLImageDXGI : public GLImageDXGI { | 72 class GL_EXPORT CopyingGLImageDXGI : public GLImageDXGI { |
| 61 public: | 73 public: |
| 62 CopyingGLImageDXGI(const base::win::ScopedComPtr<ID3D11Device>& d3d11_device, | 74 CopyingGLImageDXGI(const base::win::ScopedComPtr<ID3D11Device>& d3d11_device, |
| 63 const gfx::Size& size, | 75 const gfx::Size& size, |
| 64 EGLStreamKHR stream); | 76 EGLStreamKHR stream); |
| 65 | 77 |
| 66 bool Initialize(); | 78 bool Initialize(); |
| 67 bool InitializeVideoProcessor( | 79 bool InitializeVideoProcessor( |
| 68 const base::win::ScopedComPtr<ID3D11VideoProcessor>& video_processor, | 80 const base::win::ScopedComPtr<ID3D11VideoProcessor>& video_processor, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 bool copied_ = false; | 91 bool copied_ = false; |
| 80 | 92 |
| 81 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; | 93 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; |
| 82 base::win::ScopedComPtr<ID3D11VideoContext> video_context_; | 94 base::win::ScopedComPtr<ID3D11VideoContext> video_context_; |
| 83 base::win::ScopedComPtr<ID3D11VideoProcessor> d3d11_processor_; | 95 base::win::ScopedComPtr<ID3D11VideoProcessor> d3d11_processor_; |
| 84 base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator> enumerator_; | 96 base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator> enumerator_; |
| 85 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; | 97 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; |
| 86 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; | 98 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; |
| 87 base::win::ScopedComPtr<ID3D11VideoProcessorOutputView> output_view_; | 99 base::win::ScopedComPtr<ID3D11VideoProcessorOutputView> output_view_; |
| 88 }; | 100 }; |
| 101 |
| 102 class GL_EXPORT GLImageDXGIHandle : public GLImageDXGIBase { |
| 103 public: |
| 104 GLImageDXGIHandle(const gfx::Size& size, |
| 105 base::win::ScopedHandle handle, |
| 106 uint32_t level); |
| 107 |
| 108 bool Initialize(); |
| 109 |
| 110 protected: |
| 111 ~GLImageDXGIHandle() override; |
| 112 |
| 113 base::win::ScopedHandle handle_; |
| 114 }; |
| 89 } | 115 } |
| OLD | NEW |