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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_image_dxgi.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_dxgi.cc
diff --git a/ui/gl/gl_image_dxgi.cc b/ui/gl/gl_image_dxgi.cc
index a7ab19cf44df003c07a5ee0e6364fdfbbd05a200..df4bce797b84c25971edbb696f155544b3c911a3 100644
--- a/ui/gl/gl_image_dxgi.cc
+++ b/ui/gl/gl_image_dxgi.cc
@@ -4,66 +4,77 @@
#include "ui/gl/gl_image_dxgi.h"
+#include <d3d11_1.h>
+
#include "third_party/khronos/EGL/egl.h"
#include "third_party/khronos/EGL/eglext.h"
+#include "ui/gl/gl_angle_util_win.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_surface_egl.h"
namespace gl {
-GLImageDXGI::GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream)
- : size_(size), stream_(stream) {}
+GLImageDXGIBase::GLImageDXGIBase(const gfx::Size& size) : size_(size) {}
// static
-GLImageDXGI* GLImageDXGI::FromGLImage(GLImage* image) {
+GLImageDXGIBase* GLImageDXGIBase::FromGLImage(GLImage* image) {
if (!image || image->GetType() != Type::DXGI_IMAGE)
return nullptr;
- return static_cast<GLImageDXGI*>(image);
+ return static_cast<GLImageDXGIBase*>(image);
}
-gfx::Size GLImageDXGI::GetSize() {
+gfx::Size GLImageDXGIBase::GetSize() {
return size_;
}
-unsigned GLImageDXGI::GetInternalFormat() {
+unsigned GLImageDXGIBase::GetInternalFormat() {
return GL_BGRA_EXT;
}
-bool GLImageDXGI::BindTexImage(unsigned target) {
- return true;
+bool GLImageDXGIBase::BindTexImage(unsigned target) {
+ return false;
}
-void GLImageDXGI::ReleaseTexImage(unsigned target) {}
+void GLImageDXGIBase::ReleaseTexImage(unsigned target) {}
-bool GLImageDXGI::CopyTexImage(unsigned target) {
+bool GLImageDXGIBase::CopyTexImage(unsigned target) {
return false;
}
-bool GLImageDXGI::CopyTexSubImage(unsigned target,
- const gfx::Point& offset,
- const gfx::Rect& rect) {
+bool GLImageDXGIBase::CopyTexSubImage(unsigned target,
+ const gfx::Point& offset,
+ const gfx::Rect& rect) {
return false;
}
-bool GLImageDXGI::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
- int z_order,
- gfx::OverlayTransform transform,
- const gfx::Rect& bounds_rect,
- const gfx::RectF& crop_rect) {
+bool GLImageDXGIBase::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
+ int z_order,
+ gfx::OverlayTransform transform,
+ const gfx::Rect& bounds_rect,
+ const gfx::RectF& crop_rect) {
return false;
}
-void GLImageDXGI::Flush() {}
+void GLImageDXGIBase::Flush() {}
-void GLImageDXGI::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
- uint64_t process_tracing_id,
- const std::string& dump_name) {}
+void GLImageDXGIBase::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
+ uint64_t process_tracing_id,
+ const std::string& dump_name) {}
-GLImage::Type GLImageDXGI::GetType() const {
+GLImage::Type GLImageDXGIBase::GetType() const {
return Type::DXGI_IMAGE;
}
+GLImageDXGIBase::~GLImageDXGIBase() {}
+
+GLImageDXGI::GLImageDXGI(const gfx::Size& size, EGLStreamKHR stream)
+ : GLImageDXGIBase(size), stream_(stream) {}
+
+bool GLImageDXGI::BindTexImage(unsigned target) {
+ return true;
+}
+
void GLImageDXGI::SetTexture(
const base::win::ScopedComPtr<ID3D11Texture2D>& texture,
size_t level) {
@@ -192,4 +203,36 @@ bool CopyingGLImageDXGI::BindTexImage(unsigned target) {
CopyingGLImageDXGI::~CopyingGLImageDXGI() {}
+GLImageDXGIHandle::GLImageDXGIHandle(const gfx::Size& size,
+ base::win::ScopedHandle handle,
+ uint32_t level)
+ : GLImageDXGIBase(size), handle_(std::move(handle)) {
+ level_ = level;
+}
+
+bool GLImageDXGIHandle::Initialize() {
+ base::win::ScopedComPtr<ID3D11Device> d3d11_device =
+ QueryD3D11DeviceObjectFromANGLE();
+ if (!d3d11_device)
+ return false;
+
+ base::win::ScopedComPtr<ID3D11Device1> d3d11_device1;
+ if (FAILED(d3d11_device.CopyTo(d3d11_device1.GetAddressOf())))
+ return false;
+
+ if (FAILED(d3d11_device1->OpenSharedResource1(
+ handle_.Get(), IID_PPV_ARGS(texture_.GetAddressOf())))) {
+ return false;
+ }
+ D3D11_TEXTURE2D_DESC desc;
+ texture_->GetDesc(&desc);
+ if (desc.Format != DXGI_FORMAT_NV12 || desc.ArraySize <= level_)
+ return false;
+ if (FAILED(texture_.CopyTo(keyed_mutex_.GetAddressOf())))
+ return false;
+ return true;
+}
+
+GLImageDXGIHandle::~GLImageDXGIHandle() {}
+
} // namespace gl
« 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