diff options
8 files changed, 38 insertions, 67 deletions
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc index f164acc..0e2d14a 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc @@ -169,31 +169,25 @@ void GpuVideoDecodeAccelerator::Initialize( return; } DLOG(INFO) << "Initializing DXVA HW decoder for windows."; - scoped_ptr<DXVAVideoDecodeAccelerator> video_decoder( - new DXVAVideoDecodeAccelerator(this)); - video_decode_accelerator_ = video_decoder.Pass(); + video_decode_accelerator_.reset(new DXVAVideoDecodeAccelerator(this)); #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) - scoped_ptr<OmxVideoDecodeAccelerator> video_decoder( - new OmxVideoDecodeAccelerator(this)); - video_decoder->SetEglState( + video_decode_accelerator_.reset(new OmxVideoDecodeAccelerator( gfx::GLSurfaceEGL::GetHardwareDisplay(), - stub_->decoder()->GetGLContext()->GetHandle()); - video_decode_accelerator_ = video_decoder.Pass(); + stub_->decoder()->GetGLContext()->GetHandle(), + this)); #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) - scoped_ptr<VaapiVideoDecodeAccelerator> video_decoder( - new VaapiVideoDecodeAccelerator(this, make_context_current_)); gfx::GLContextGLX* glx_context = static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); GLXContext glx_context_handle = static_cast<GLXContext>(glx_context->GetHandle()); - video_decoder->SetGlxState(glx_context->display(), glx_context_handle); - video_decode_accelerator_ = video_decoder.Pass(); + video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator( + glx_context->display(), glx_context_handle, this, + make_context_current_)); #elif defined(OS_MACOSX) - scoped_ptr<MacVideoDecodeAccelerator> video_decoder( - new MacVideoDecodeAccelerator(this)); - video_decoder->SetCGLContext(static_cast<CGLContextObj>( - stub_->decoder()->GetGLContext()->GetHandle())); - video_decode_accelerator_ = video_decoder.Pass(); + video_decode_accelerator_.reset(new MacVideoDecodeAccelerator( + static_cast<CGLContextObj>( + stub_->decoder()->GetGLContext()->GetHandle()), + this)); #else NOTIMPLEMENTED() << "HW video decode acceleration not available."; NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); diff --git a/content/common/gpu/media/mac_video_decode_accelerator.h b/content/common/gpu/media/mac_video_decode_accelerator.h index 2aa3830..5985c9c 100644 --- a/content/common/gpu/media/mac_video_decode_accelerator.h +++ b/content/common/gpu/media/mac_video_decode_accelerator.h @@ -32,12 +32,10 @@ class CONTENT_EXPORT MacVideoDecodeAccelerator public base::NonThreadSafe { public: // Does not take ownership of |client| which must outlive |*this|. - MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); + MacVideoDecodeAccelerator(CGLContextObj cgl_context, + media::VideoDecodeAccelerator::Client* client); virtual ~MacVideoDecodeAccelerator(); - // Set the OpenGL context to use. - void SetCGLContext(CGLContextObj cgl_context); - // media::VideoDecodeAccelerator implementation. virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; diff --git a/content/common/gpu/media/mac_video_decode_accelerator.mm b/content/common/gpu/media/mac_video_decode_accelerator.mm index 7aa9c6c..94b6780 100644 --- a/content/common/gpu/media/mac_video_decode_accelerator.mm +++ b/content/common/gpu/media/mac_video_decode_accelerator.mm @@ -93,17 +93,12 @@ static bool BindImageToTexture(CGLContextObj context, } MacVideoDecodeAccelerator::MacVideoDecodeAccelerator( - media::VideoDecodeAccelerator::Client* client) + CGLContextObj cgl_context, media::VideoDecodeAccelerator::Client* client) : client_(client), - cgl_context_(NULL), + cgl_context_(cgl_context), did_build_config_record_(false) { } -void MacVideoDecodeAccelerator::SetCGLContext(CGLContextObj cgl_context) { - DCHECK(CalledOnValidThread()); - cgl_context_ = cgl_context; -} - bool MacVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile) { DCHECK(CalledOnValidThread()); diff --git a/content/common/gpu/media/omx_video_decode_accelerator.cc b/content/common/gpu/media/omx_video_decode_accelerator.cc index 1934a43..57fe2fd 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.cc +++ b/content/common/gpu/media/omx_video_decode_accelerator.cc @@ -98,6 +98,7 @@ static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) { error, ret_val) OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( + EGLDisplay egl_display, EGLContext egl_context, media::VideoDecodeAccelerator::Client* client) : message_loop_(MessageLoop::current()), component_handle_(NULL), @@ -111,6 +112,8 @@ OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( input_buffers_at_component_(0), output_port_(0), output_buffers_at_component_(0), + egl_display_(egl_display), + egl_context_(egl_context), client_(client), codec_(UNKNOWN), h264_profile_(OMX_VIDEO_AVCProfileMax), @@ -129,13 +132,6 @@ OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() { DCHECK(pictures_.empty()); } -void OmxVideoDecodeAccelerator::SetEglState( - EGLDisplay egl_display, EGLContext egl_context) { - DCHECK_EQ(message_loop_, MessageLoop::current()); - egl_display_ = egl_display; - egl_context_ = egl_context; -} - // This is to initialize the OMX data structures to default values. template <typename T> static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { diff --git a/content/common/gpu/media/omx_video_decode_accelerator.h b/content/common/gpu/media/omx_video_decode_accelerator.h index 9bfb886..60fc638 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.h +++ b/content/common/gpu/media/omx_video_decode_accelerator.h @@ -38,7 +38,8 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { public: // Does not take ownership of |client| which must outlive |*this|. - OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); + OmxVideoDecodeAccelerator(EGLDisplay egl_display, EGLContext egl_context, + media::VideoDecodeAccelerator::Client* client); virtual ~OmxVideoDecodeAccelerator(); // media::VideoDecodeAccelerator implementation. @@ -51,8 +52,6 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : void Reset() OVERRIDE; void Destroy() OVERRIDE; - void SetEglState(EGLDisplay egl_display, EGLContext egl_context); - base::WeakPtr<OmxVideoDecodeAccelerator> weak_this() { return weak_this_; } private: diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.cc b/content/common/gpu/media/vaapi_video_decode_accelerator.cc index 75fc61d..065f8e4 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.cc +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.cc @@ -52,9 +52,12 @@ void VaapiVideoDecodeAccelerator::NotifyError(Error error) { } VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( + Display* x_display, GLXContext glx_context, Client* client, const base::Callback<bool(void)>& make_context_current) - : make_context_current_(make_context_current), + : x_display_(x_display), + glx_context_(glx_context), + make_context_current_(make_context_current), state_(kUninitialized), input_ready_(&lock_), output_ready_(&lock_), @@ -96,15 +99,6 @@ bool VaapiVideoDecodeAccelerator::Initialize( return true; } -// TODO(posciak, fischman): try to move these to constructor parameters, -// but while removing SetEglState from OVDA as well for symmetry. -void VaapiVideoDecodeAccelerator::SetGlxState(Display* x_display, - GLXContext glx_context) { - DCHECK_EQ(message_loop_, MessageLoop::current()); - x_display_ = x_display; - glx_context_ = glx_context; -} - void VaapiVideoDecodeAccelerator::SyncAndNotifyPictureReady(int32 input_id, int32 output_id) { DCHECK_EQ(message_loop_, MessageLoop::current()); diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.h b/content/common/gpu/media/vaapi_video_decode_accelerator.h index 9fdffde..64a94d8 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.h +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.h @@ -41,6 +41,7 @@ class CONTENT_EXPORT VaapiVideoDecodeAccelerator : public media::VideoDecodeAccelerator { public: VaapiVideoDecodeAccelerator( + Display* x_display, GLXContext glx_context, Client* client, const base::Callback<bool(void)>& make_context_current); virtual ~VaapiVideoDecodeAccelerator(); @@ -55,9 +56,6 @@ class CONTENT_EXPORT VaapiVideoDecodeAccelerator : virtual void Reset() OVERRIDE; virtual void Destroy() OVERRIDE; - // Used by user of this class to pass X/GLX state. - void SetGlxState(Display* x_display, GLXContext glx_context); - private: // Ensure data has been synced with the output texture and notify // the client it is ready for displaying. diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc index a93e4f7..a86fb67 100644 --- a/content/common/gpu/media/video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc @@ -317,28 +317,25 @@ static bool DoNothingReturnTrue() { return true; } void GLRenderingVDAClient::CreateDecoder() { CHECK(decoder_deleted()); + CHECK(!decoder_.get()); #if defined(OS_WIN) - scoped_ptr<DXVAVideoDecodeAccelerator> decoder( - new DXVAVideoDecodeAccelerator(this)); + decoder_.reset(new DXVAVideoDecodeAccelerator(this)); #elif defined(OS_MACOSX) - scoped_ptr<MacVideoDecodeAccelerator> decoder( - new MacVideoDecodeAccelerator(this)); - decoder->SetCGLContext( - static_cast<CGLContextObj>(rendering_helper_->GetGLContext())); + decoder_.reset(new MacVideoDecodeAccelerator( + static_cast<CGLContextObj>(rendering_helper_->GetGLContext()), this)); #elif defined(ARCH_CPU_ARMEL) - scoped_ptr<OmxVideoDecodeAccelerator> decoder( - new OmxVideoDecodeAccelerator(this)); - decoder->SetEglState( - static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), - static_cast<EGLContext>(rendering_helper_->GetGLContext())); + decoder_.reset( + new OmxVideoDecodeAccelerator( + static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), + static_cast<EGLContext>(rendering_helper_->GetGLContext()), + this)); #elif defined(ARCH_CPU_X86_FAMILY) - scoped_ptr<VaapiVideoDecodeAccelerator> decoder( - new VaapiVideoDecodeAccelerator(this, base::Bind(&DoNothingReturnTrue))); - decoder->SetGlxState( + decoder_.reset(new VaapiVideoDecodeAccelerator( static_cast<Display*>(rendering_helper_->GetGLDisplay()), - static_cast<GLXContext>(rendering_helper_->GetGLContext())); + static_cast<GLXContext>(rendering_helper_->GetGLContext()), + this, base::Bind(&DoNothingReturnTrue))); #endif // OS_WIN - decoder_ = decoder.Pass(); + CHECK(decoder_.get()); SetState(CS_DECODER_SET); if (decoder_deleted()) return; |