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

Side by Side Diff: ui/gl/gl_image_dxgi.h

Issue 2968503003: Allow presenting DXGI share handles as overlays. (Closed)
Patch Set: fix keyed mutex usage Created 3 years, 5 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/gpu/dxva_picture_buffer_win.cc ('k') | ui/gl/gl_image_dxgi.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 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
43 base::win::ScopedComPtr<ID3D11Texture2D> texture() { return texture_; }
44 size_t level() const { return level_; }
45 base::win::ScopedComPtr<IDXGIKeyedMutex> keyed_mutex() {
46 return keyed_mutex_;
47 }
48
49 protected:
50 ~GLImageDXGIBase() override;
51
52 gfx::Size size_;
53
54 base::win::ScopedComPtr<ID3D11Texture2D> texture_;
55 base::win::ScopedComPtr<IDXGIKeyedMutex> keyed_mutex_;
56 size_t level_ = 0;
57 };
58
59 class GL_EXPORT GLImageDXGI : public GLImageDXGIBase {
60 public:
61 GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream);
62
63 // GLImage implementation.
64 bool BindTexImage(unsigned target) override;
65
42 void SetTexture(const base::win::ScopedComPtr<ID3D11Texture2D>& texture, 66 void SetTexture(const base::win::ScopedComPtr<ID3D11Texture2D>& texture,
43 size_t level); 67 size_t level);
44 68
45 base::win::ScopedComPtr<ID3D11Texture2D> texture() { return texture_; }
46 size_t level() const { return level_; }
47
48 protected: 69 protected:
49 ~GLImageDXGI() override; 70 ~GLImageDXGI() override;
50 71
51 gfx::Size size_;
52
53 EGLStreamKHR stream_; 72 EGLStreamKHR stream_;
54
55 base::win::ScopedComPtr<ID3D11Texture2D> texture_;
56 size_t level_ = 0;
57 }; 73 };
58 74
59 // This copies to a new texture on bind. 75 // This copies to a new texture on bind.
60 class GL_EXPORT CopyingGLImageDXGI : public GLImageDXGI { 76 class GL_EXPORT CopyingGLImageDXGI : public GLImageDXGI {
61 public: 77 public:
62 CopyingGLImageDXGI(const base::win::ScopedComPtr<ID3D11Device>& d3d11_device, 78 CopyingGLImageDXGI(const base::win::ScopedComPtr<ID3D11Device>& d3d11_device,
63 const gfx::Size& size, 79 const gfx::Size& size,
64 EGLStreamKHR stream); 80 EGLStreamKHR stream);
65 81
66 bool Initialize(); 82 bool Initialize();
(...skipping 12 matching lines...) Expand all
79 bool copied_ = false; 95 bool copied_ = false;
80 96
81 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; 97 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_;
82 base::win::ScopedComPtr<ID3D11VideoContext> video_context_; 98 base::win::ScopedComPtr<ID3D11VideoContext> video_context_;
83 base::win::ScopedComPtr<ID3D11VideoProcessor> d3d11_processor_; 99 base::win::ScopedComPtr<ID3D11VideoProcessor> d3d11_processor_;
84 base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator> enumerator_; 100 base::win::ScopedComPtr<ID3D11VideoProcessorEnumerator> enumerator_;
85 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; 101 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
86 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_; 102 base::win::ScopedComPtr<ID3D11Texture2D> decoder_copy_texture_;
87 base::win::ScopedComPtr<ID3D11VideoProcessorOutputView> output_view_; 103 base::win::ScopedComPtr<ID3D11VideoProcessorOutputView> output_view_;
88 }; 104 };
105
106 class GL_EXPORT GLImageDXGIHandle : public GLImageDXGIBase {
107 public:
108 GLImageDXGIHandle(const gfx::Size& size,
109 base::win::ScopedHandle handle,
110 uint32_t level);
111
112 bool Initialize();
113
114 protected:
115 ~GLImageDXGIHandle() override;
116
117 base::win::ScopedHandle handle_;
118 };
89 } 119 }
OLDNEW
« no previous file with comments | « media/gpu/dxva_picture_buffer_win.cc ('k') | ui/gl/gl_image_dxgi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698