Commit 3173af0d authored by John Bauman's avatar John Bauman Committed by Commit Bot

Allow putting D3D11VDA picture buffers into overlays.

Bug: 678800
Change-Id: If3bd8d215c2bf85e31472b73e4f6ffd7c13750cd

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Change-Id: If3bd8d215c2bf85e31472b73e4f6ffd7c13750cd
Reviewed-on: https://chromium-review.googlesource.com/578382Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: John Bauman <jbauman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488443}
parent 0825547d
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/gfx/color_space.h" #include "ui/gfx/color_space.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_image_dxgi.h"
#include "ui/gl/gl_surface_egl.h" #include "ui/gl/gl_surface_egl.h"
#include "ui/gl/scoped_binders.h" #include "ui/gl/scoped_binders.h"
...@@ -61,6 +62,8 @@ bool D3D11PictureBuffer::Init( ...@@ -61,6 +62,8 @@ bool D3D11PictureBuffer::Init(
}; };
stream_ = eglCreateStreamKHR(egl_display, stream_attributes); stream_ = eglCreateStreamKHR(egl_display, stream_attributes);
RETURN_ON_FAILURE(!!stream_, "Could not create stream", false); RETURN_ON_FAILURE(!!stream_, "Could not create stream", false);
gl_image_ =
make_scoped_refptr(new gl::GLImageDXGI(picture_buffer_.size(), stream_));
gl::ScopedActiveTexture texture0(GL_TEXTURE0); gl::ScopedActiveTexture texture0(GL_TEXTURE0);
gl::ScopedTextureBinder texture0_binder( gl::ScopedTextureBinder texture0_binder(
GL_TEXTURE_EXTERNAL_OES, picture_buffer_.service_texture_ids()[0]); GL_TEXTURE_EXTERNAL_OES, picture_buffer_.service_texture_ids()[0]);
...@@ -100,6 +103,10 @@ bool D3D11PictureBuffer::Init( ...@@ -100,6 +103,10 @@ bool D3D11PictureBuffer::Init(
RETURN_ON_FAILURE(result, "Could not post texture", false); RETURN_ON_FAILURE(result, "Could not post texture", false);
result = eglStreamConsumerAcquireKHR(egl_display, stream_); result = eglStreamConsumerAcquireKHR(egl_display, stream_);
RETURN_ON_FAILURE(result, "Could not post acquire stream", false); RETURN_ON_FAILURE(result, "Could not post acquire stream", false);
gl::GLImageDXGI* gl_image_dxgi =
static_cast<gl::GLImageDXGI*>(gl_image_.get());
gl_image_dxgi->SetTexture(texture, level_);
return true; return true;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "media/video/picture.h" #include "media/video/picture.h"
#include "third_party/angle/include/EGL/egl.h" #include "third_party/angle/include/EGL/egl.h"
#include "third_party/angle/include/EGL/eglext.h" #include "third_party/angle/include/EGL/eglext.h"
#include "ui/gl/gl_image.h"
namespace media { namespace media {
class D3D11H264Accelerator; class D3D11H264Accelerator;
...@@ -38,6 +39,7 @@ class D3D11PictureBuffer { ...@@ -38,6 +39,7 @@ class D3D11PictureBuffer {
bool in_picture_use() const { return in_picture_use_; } bool in_picture_use() const { return in_picture_use_; }
void set_in_client_use(bool use) { in_client_use_ = use; } void set_in_client_use(bool use) { in_client_use_ = use; }
void set_in_picture_use(bool use) { in_picture_use_ = use; } void set_in_picture_use(bool use) { in_picture_use_ = use; }
scoped_refptr<gl::GLImage> gl_image() const { return gl_image_; }
private: private:
friend class D3D11H264Accelerator; friend class D3D11H264Accelerator;
...@@ -49,6 +51,7 @@ class D3D11PictureBuffer { ...@@ -49,6 +51,7 @@ class D3D11PictureBuffer {
size_t level_; size_t level_;
base::win::ScopedComPtr<ID3D11VideoDecoderOutputView> output_view_; base::win::ScopedComPtr<ID3D11VideoDecoderOutputView> output_view_;
EGLStreamKHR stream_; EGLStreamKHR stream_;
scoped_refptr<gl::GLImage> gl_image_;
DISALLOW_COPY_AND_ASSIGN(D3D11PictureBuffer); DISALLOW_COPY_AND_ASSIGN(D3D11PictureBuffer);
}; };
......
...@@ -33,12 +33,13 @@ namespace media { ...@@ -33,12 +33,13 @@ namespace media {
} \ } \
} while (0) } while (0)
D3D11VideoDecodeAccelerator::D3D11VideoDecodeAccelerator( D3D11VideoDecodeAccelerator::D3D11VideoDecodeAccelerator(
const GetGLContextCallback& get_gl_context_cb, const GetGLContextCallback& get_gl_context_cb,
const MakeGLContextCurrentCallback& make_context_current_cb) const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb)
: get_gl_context_cb_(get_gl_context_cb), : get_gl_context_cb_(get_gl_context_cb),
make_context_current_cb_(make_context_current_cb) {} make_context_current_cb_(make_context_current_cb),
bind_image_cb_(bind_image_cb) {}
D3D11VideoDecodeAccelerator::~D3D11VideoDecodeAccelerator() {} D3D11VideoDecodeAccelerator::~D3D11VideoDecodeAccelerator() {}
...@@ -189,6 +190,13 @@ void D3D11VideoDecodeAccelerator::AssignPictureBuffers( ...@@ -189,6 +190,13 @@ void D3D11VideoDecodeAccelerator::AssignPictureBuffers(
picture_buffers_.push_back( picture_buffers_.push_back(
base::MakeUnique<D3D11PictureBuffer>(buffers[i], i)); base::MakeUnique<D3D11PictureBuffer>(buffers[i], i));
picture_buffers_[i]->Init(video_device_, out_texture, decoder_guid_); picture_buffers_[i]->Init(video_device_, out_texture, decoder_guid_);
for (uint32_t client_id : buffers[i].client_texture_ids()) {
// The picture buffer handles the actual binding of its contents to
// texture ids. This call just causes the texture manager to hold a
// reference to the GLImage as long as either texture exists.
bind_image_cb_.Run(client_id, GL_TEXTURE_EXTERNAL_OES,
picture_buffers_[i]->gl_image(), true);
}
} }
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&D3D11VideoDecodeAccelerator::DoDecode, FROM_HERE, base::Bind(&D3D11VideoDecodeAccelerator::DoDecode,
...@@ -245,7 +253,7 @@ void D3D11VideoDecodeAccelerator::OutputResult(D3D11PictureBuffer* buffer, ...@@ -245,7 +253,7 @@ void D3D11VideoDecodeAccelerator::OutputResult(D3D11PictureBuffer* buffer,
size_t input_buffer_id) { size_t input_buffer_id) {
buffer->set_in_client_use(true); buffer->set_in_client_use(true);
Picture picture(buffer->picture_buffer().id(), input_buffer_id, Picture picture(buffer->picture_buffer().id(), input_buffer_id,
gfx::Rect(0, 0), gfx::ColorSpace(), false); gfx::Rect(0, 0), gfx::ColorSpace(), true);
client_->PictureReady(picture); client_->PictureReady(picture);
} }
} // namespace media } // namespace media
...@@ -25,7 +25,8 @@ class MEDIA_GPU_EXPORT D3D11VideoDecodeAccelerator ...@@ -25,7 +25,8 @@ class MEDIA_GPU_EXPORT D3D11VideoDecodeAccelerator
public: public:
D3D11VideoDecodeAccelerator( D3D11VideoDecodeAccelerator(
const GetGLContextCallback& get_gl_context_cb, const GetGLContextCallback& get_gl_context_cb,
const MakeGLContextCurrentCallback& make_context_current_cb); const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb);
~D3D11VideoDecodeAccelerator() override; ~D3D11VideoDecodeAccelerator() override;
...@@ -54,6 +55,7 @@ class MEDIA_GPU_EXPORT D3D11VideoDecodeAccelerator ...@@ -54,6 +55,7 @@ class MEDIA_GPU_EXPORT D3D11VideoDecodeAccelerator
Client* client_; Client* client_;
GetGLContextCallback get_gl_context_cb_; GetGLContextCallback get_gl_context_cb_;
MakeGLContextCurrentCallback make_context_current_cb_; MakeGLContextCurrentCallback make_context_current_cb_;
BindGLImageCallback bind_image_cb_;
base::win::ScopedComPtr<ID3D11Device> device_; base::win::ScopedComPtr<ID3D11Device> device_;
base::win::ScopedComPtr<ID3D11DeviceContext> device_context_; base::win::ScopedComPtr<ID3D11DeviceContext> device_context_;
base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; base::win::ScopedComPtr<ID3D11VideoDevice> video_device_;
......
...@@ -172,8 +172,8 @@ GpuVideoDecodeAcceleratorFactory::CreateD3D11VDA( ...@@ -172,8 +172,8 @@ GpuVideoDecodeAcceleratorFactory::CreateD3D11VDA(
return decoder; return decoder;
if (base::win::GetVersion() >= base::win::VERSION_WIN8) { if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
DVLOG(0) << "Initializing D3D11 HW decoder for windows."; DVLOG(0) << "Initializing D3D11 HW decoder for windows.";
decoder.reset(new D3D11VideoDecodeAccelerator(get_gl_context_cb_, decoder.reset(new D3D11VideoDecodeAccelerator(
make_context_current_cb_)); get_gl_context_cb_, make_context_current_cb_, bind_image_cb_));
} }
return decoder; return decoder;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment