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

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

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 | « ui/gl/gl_image_dxgi.h ('k') | no next file » | 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 "ui/gl/gl_image_dxgi.h" 5 #include "ui/gl/gl_image_dxgi.h"
6 6
7 #include <d3d11_1.h>
8
7 #include "third_party/khronos/EGL/egl.h" 9 #include "third_party/khronos/EGL/egl.h"
8 #include "third_party/khronos/EGL/eglext.h" 10 #include "third_party/khronos/EGL/eglext.h"
11 #include "ui/gl/gl_angle_util_win.h"
9 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/gl_image.h" 13 #include "ui/gl/gl_image.h"
11 #include "ui/gl/gl_surface_egl.h" 14 #include "ui/gl/gl_surface_egl.h"
12 15
13 namespace gl { 16 namespace gl {
14 17
15 GLImageDXGI::GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream) 18 GLImageDXGIBase::GLImageDXGIBase(const gfx::Size& size) : size_(size) {}
16 : size_(size), stream_(stream) {}
17 19
18 // static 20 // static
19 GLImageDXGI* GLImageDXGI::FromGLImage(GLImage* image) { 21 GLImageDXGIBase* GLImageDXGIBase::FromGLImage(GLImage* image) {
20 if (!image || image->GetType() != Type::DXGI_IMAGE) 22 if (!image || image->GetType() != Type::DXGI_IMAGE)
21 return nullptr; 23 return nullptr;
22 return static_cast<GLImageDXGI*>(image); 24 return static_cast<GLImageDXGIBase*>(image);
23 } 25 }
24 26
25 gfx::Size GLImageDXGI::GetSize() { 27 gfx::Size GLImageDXGIBase::GetSize() {
26 return size_; 28 return size_;
27 } 29 }
28 30
29 unsigned GLImageDXGI::GetInternalFormat() { 31 unsigned GLImageDXGIBase::GetInternalFormat() {
30 return GL_BGRA_EXT; 32 return GL_BGRA_EXT;
31 } 33 }
32 34
35 bool GLImageDXGIBase::BindTexImage(unsigned target) {
36 return false;
37 }
38
39 void GLImageDXGIBase::ReleaseTexImage(unsigned target) {}
40
41 bool GLImageDXGIBase::CopyTexImage(unsigned target) {
42 return false;
43 }
44
45 bool GLImageDXGIBase::CopyTexSubImage(unsigned target,
46 const gfx::Point& offset,
47 const gfx::Rect& rect) {
48 return false;
49 }
50
51 bool GLImageDXGIBase::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
52 int z_order,
53 gfx::OverlayTransform transform,
54 const gfx::Rect& bounds_rect,
55 const gfx::RectF& crop_rect) {
56 return false;
57 }
58
59 void GLImageDXGIBase::Flush() {}
60
61 void GLImageDXGIBase::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
62 uint64_t process_tracing_id,
63 const std::string& dump_name) {}
64
65 GLImage::Type GLImageDXGIBase::GetType() const {
66 return Type::DXGI_IMAGE;
67 }
68
69 GLImageDXGIBase::~GLImageDXGIBase() {}
70
71 GLImageDXGI::GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream)
72 : GLImageDXGIBase(size), stream_(stream) {}
73
33 bool GLImageDXGI::BindTexImage(unsigned target) { 74 bool GLImageDXGI::BindTexImage(unsigned target) {
34 return true; 75 return true;
35 } 76 }
36 77
37 void GLImageDXGI::ReleaseTexImage(unsigned target) {}
38
39 bool GLImageDXGI::CopyTexImage(unsigned target) {
40 return false;
41 }
42
43 bool GLImageDXGI::CopyTexSubImage(unsigned target,
44 const gfx::Point& offset,
45 const gfx::Rect& rect) {
46 return false;
47 }
48
49 bool GLImageDXGI::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
50 int z_order,
51 gfx::OverlayTransform transform,
52 const gfx::Rect& bounds_rect,
53 const gfx::RectF& crop_rect) {
54 return false;
55 }
56
57 void GLImageDXGI::Flush() {}
58
59 void GLImageDXGI::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
60 uint64_t process_tracing_id,
61 const std::string& dump_name) {}
62
63 GLImage::Type GLImageDXGI::GetType() const {
64 return Type::DXGI_IMAGE;
65 }
66
67 void GLImageDXGI::SetTexture( 78 void GLImageDXGI::SetTexture(
68 const base::win::ScopedComPtr<ID3D11Texture2D>& texture, 79 const base::win::ScopedComPtr<ID3D11Texture2D>& texture,
69 size_t level) { 80 size_t level) {
70 texture_ = texture; 81 texture_ = texture;
71 level_ = level; 82 level_ = level;
72 } 83 }
73 84
74 GLImageDXGI::~GLImageDXGI() { 85 GLImageDXGI::~GLImageDXGI() {
75 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); 86 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay();
76 eglDestroyStreamKHR(egl_display, stream_); 87 eglDestroyStreamKHR(egl_display, stream_);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (FAILED(hr)) { 196 if (FAILED(hr)) {
186 DLOG(ERROR) << "Failed to process video"; 197 DLOG(ERROR) << "Failed to process video";
187 return false; 198 return false;
188 } 199 }
189 copied_ = true; 200 copied_ = true;
190 return true; 201 return true;
191 } 202 }
192 203
193 CopyingGLImageDXGI::~CopyingGLImageDXGI() {} 204 CopyingGLImageDXGI::~CopyingGLImageDXGI() {}
194 205
206 GLImageDXGIHandle::GLImageDXGIHandle(const gfx::Size& size,
207 base::win::ScopedHandle handle,
208 uint32_t level)
209 : GLImageDXGIBase(size), handle_(std::move(handle)) {
210 level_ = level;
211 }
212
213 bool GLImageDXGIHandle::Initialize() {
214 base::win::ScopedComPtr<ID3D11Device> d3d11_device =
215 QueryD3D11DeviceObjectFromANGLE();
216 if (!d3d11_device)
217 return false;
218
219 base::win::ScopedComPtr<ID3D11Device1> d3d11_device1;
220 if (FAILED(d3d11_device.CopyTo(d3d11_device1.GetAddressOf())))
221 return false;
222
223 if (FAILED(d3d11_device1->OpenSharedResource1(
224 handle_.Get(), IID_PPV_ARGS(texture_.GetAddressOf())))) {
225 return false;
226 }
227 D3D11_TEXTURE2D_DESC desc;
228 texture_->GetDesc(&desc);
229 if (desc.Format != DXGI_FORMAT_NV12 || desc.ArraySize <= level_)
230 return false;
231 if (FAILED(texture_.CopyTo(keyed_mutex_.GetAddressOf())))
232 return false;
233 return true;
234 }
235
236 GLImageDXGIHandle::~GLImageDXGIHandle() {}
237
195 } // namespace gl 238 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_dxgi.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698