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

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

Issue 2981713002: Revert of Allow presenting DXGI share handles as overlays. (Closed)
Patch Set: 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
9 #include "third_party/khronos/EGL/egl.h" 7 #include "third_party/khronos/EGL/egl.h"
10 #include "third_party/khronos/EGL/eglext.h" 8 #include "third_party/khronos/EGL/eglext.h"
11 #include "ui/gl/gl_angle_util_win.h"
12 #include "ui/gl/gl_bindings.h" 9 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_image.h" 10 #include "ui/gl/gl_image.h"
14 #include "ui/gl/gl_surface_egl.h" 11 #include "ui/gl/gl_surface_egl.h"
15 12
16 namespace gl { 13 namespace gl {
17 14
18 GLImageDXGIBase::GLImageDXGIBase(const gfx::Size& size) : size_(size) {} 15 GLImageDXGI::GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream)
16 : size_(size), stream_(stream) {}
19 17
20 // static 18 // static
21 GLImageDXGIBase* GLImageDXGIBase::FromGLImage(GLImage* image) { 19 GLImageDXGI* GLImageDXGI::FromGLImage(GLImage* image) {
22 if (!image || image->GetType() != Type::DXGI_IMAGE) 20 if (!image || image->GetType() != Type::DXGI_IMAGE)
23 return nullptr; 21 return nullptr;
24 return static_cast<GLImageDXGIBase*>(image); 22 return static_cast<GLImageDXGI*>(image);
25 } 23 }
26 24
27 gfx::Size GLImageDXGIBase::GetSize() { 25 gfx::Size GLImageDXGI::GetSize() {
28 return size_; 26 return size_;
29 } 27 }
30 28
31 unsigned GLImageDXGIBase::GetInternalFormat() { 29 unsigned GLImageDXGI::GetInternalFormat() {
32 return GL_BGRA_EXT; 30 return GL_BGRA_EXT;
33 } 31 }
34 32
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
74 bool GLImageDXGI::BindTexImage(unsigned target) { 33 bool GLImageDXGI::BindTexImage(unsigned target) {
75 return true; 34 return true;
76 } 35 }
77 36
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
78 void GLImageDXGI::SetTexture( 67 void GLImageDXGI::SetTexture(
79 const base::win::ScopedComPtr<ID3D11Texture2D>& texture, 68 const base::win::ScopedComPtr<ID3D11Texture2D>& texture,
80 size_t level) { 69 size_t level) {
81 texture_ = texture; 70 texture_ = texture;
82 level_ = level; 71 level_ = level;
83 } 72 }
84 73
85 GLImageDXGI::~GLImageDXGI() { 74 GLImageDXGI::~GLImageDXGI() {
86 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); 75 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay();
87 eglDestroyStreamKHR(egl_display, stream_); 76 eglDestroyStreamKHR(egl_display, stream_);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (FAILED(hr)) { 185 if (FAILED(hr)) {
197 DLOG(ERROR) << "Failed to process video"; 186 DLOG(ERROR) << "Failed to process video";
198 return false; 187 return false;
199 } 188 }
200 copied_ = true; 189 copied_ = true;
201 return true; 190 return true;
202 } 191 }
203 192
204 CopyingGLImageDXGI::~CopyingGLImageDXGI() {} 193 CopyingGLImageDXGI::~CopyingGLImageDXGI() {}
205 194
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 return true;
232 }
233
234 GLImageDXGIHandle::~GLImageDXGIHandle() {}
235
236 } // namespace gl 195 } // 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