Commit 82c4d847 authored by marcheu@chromium.org's avatar marcheu@chromium.org

OMX: Make context current before using EGLImage functions.

Otherwise we might be on a different context and that triggers invalid drawable
errors.

BUG=none
TEST=by hand, open an html5 video, reload it a bunch of times, close it,
TEST=check for no weird invalid drawable error messages.

Change-Id: Icc20efa35daf988edb1ecb2cb572e5b484719b35


Review URL: https://chromiumcodereview.appspot.com/10837199

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150991 0039d316-1c4b-4281-b951-d872f2087c98
parent 65293828
...@@ -174,7 +174,8 @@ void GpuVideoDecodeAccelerator::Initialize( ...@@ -174,7 +174,8 @@ void GpuVideoDecodeAccelerator::Initialize(
video_decode_accelerator_.reset(new OmxVideoDecodeAccelerator( video_decode_accelerator_.reset(new OmxVideoDecodeAccelerator(
gfx::GLSurfaceEGL::GetHardwareDisplay(), gfx::GLSurfaceEGL::GetHardwareDisplay(),
stub_->decoder()->GetGLContext()->GetHandle(), stub_->decoder()->GetGLContext()->GetHandle(),
this)); this,
make_context_current_));
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
gfx::GLContextGLX* glx_context = gfx::GLContextGLX* glx_context =
static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext());
......
...@@ -91,7 +91,8 @@ bool OmxVideoDecodeAccelerator::pre_sandbox_init_done_ = false; ...@@ -91,7 +91,8 @@ bool OmxVideoDecodeAccelerator::pre_sandbox_init_done_ = false;
OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
EGLDisplay egl_display, EGLContext egl_context, EGLDisplay egl_display, EGLContext egl_context,
media::VideoDecodeAccelerator::Client* client) media::VideoDecodeAccelerator::Client* client,
const base::Callback<bool(void)>& make_context_current)
: message_loop_(MessageLoop::current()), : message_loop_(MessageLoop::current()),
component_handle_(NULL), component_handle_(NULL),
weak_this_(base::AsWeakPtr(this)), weak_this_(base::AsWeakPtr(this)),
...@@ -106,6 +107,7 @@ OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( ...@@ -106,6 +107,7 @@ OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
output_buffers_at_component_(0), output_buffers_at_component_(0),
egl_display_(egl_display), egl_display_(egl_display),
egl_context_(egl_context), egl_context_(egl_context),
make_context_current_(make_context_current),
client_(client), client_(client),
codec_(UNKNOWN), codec_(UNKNOWN),
h264_profile_(OMX_VIDEO_AVCProfileMax), h264_profile_(OMX_VIDEO_AVCProfileMax),
...@@ -334,6 +336,9 @@ void OmxVideoDecodeAccelerator::AssignPictureBuffers( ...@@ -334,6 +336,9 @@ void OmxVideoDecodeAccelerator::AssignPictureBuffers(
DCHECK_EQ(fake_output_buffers_.size(), 0U); DCHECK_EQ(fake_output_buffers_.size(), 0U);
DCHECK_EQ(pictures_.size(), 0U); DCHECK_EQ(pictures_.size(), 0U);
if (!make_context_current_.Run())
return;
for (size_t i = 0; i < buffers.size(); ++i) { for (size_t i = 0; i < buffers.size(); ++i) {
EGLImageKHR egl_image = EGLImageKHR egl_image =
texture_to_egl_image_translator_->TranslateToEglImage( texture_to_egl_image_translator_->TranslateToEglImage(
...@@ -707,6 +712,10 @@ void OmxVideoDecodeAccelerator::FreeOutputBuffers() { ...@@ -707,6 +712,10 @@ void OmxVideoDecodeAccelerator::FreeOutputBuffers() {
DCHECK_EQ(message_loop_, MessageLoop::current()); DCHECK_EQ(message_loop_, MessageLoop::current());
// Calls to OMX to free buffers. // Calls to OMX to free buffers.
OMX_ERRORTYPE result; OMX_ERRORTYPE result;
if (!make_context_current_.Run())
return;
for (OutputPictureById::iterator it = pictures_.begin(); for (OutputPictureById::iterator it = pictures_.begin();
it != pictures_.end(); ++it) { it != pictures_.end(); ++it) {
OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header; OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header;
......
...@@ -38,8 +38,10 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : ...@@ -38,8 +38,10 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator :
public media::VideoDecodeAccelerator { public media::VideoDecodeAccelerator {
public: public:
// Does not take ownership of |client| which must outlive |*this|. // Does not take ownership of |client| which must outlive |*this|.
OmxVideoDecodeAccelerator(EGLDisplay egl_display, EGLContext egl_context, OmxVideoDecodeAccelerator(
media::VideoDecodeAccelerator::Client* client); EGLDisplay egl_display, EGLContext egl_context,
media::VideoDecodeAccelerator::Client* client,
const base::Callback<bool(void)>& make_context_current);
virtual ~OmxVideoDecodeAccelerator(); virtual ~OmxVideoDecodeAccelerator();
// media::VideoDecodeAccelerator implementation. // media::VideoDecodeAccelerator implementation.
...@@ -181,6 +183,7 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator : ...@@ -181,6 +183,7 @@ class CONTENT_EXPORT OmxVideoDecodeAccelerator :
// TODO(fischman,vrk): handle lost contexts? // TODO(fischman,vrk): handle lost contexts?
EGLDisplay egl_display_; EGLDisplay egl_display_;
EGLContext egl_context_; EGLContext egl_context_;
base::Callback<bool(void)> make_context_current_;
// Free input OpenMAX buffers that can be used to take bitstream from demuxer. // Free input OpenMAX buffers that can be used to take bitstream from demuxer.
std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_;
......
...@@ -310,7 +310,7 @@ GLRenderingVDAClient::~GLRenderingVDAClient() { ...@@ -310,7 +310,7 @@ GLRenderingVDAClient::~GLRenderingVDAClient() {
SetState(CS_DESTROYED); SetState(CS_DESTROYED);
} }
#if !defined(OS_WIN) && !defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY) #if !defined(OS_WIN) && !defined(OS_MACOSX)
static bool DoNothingReturnTrue() { return true; } static bool DoNothingReturnTrue() { return true; }
#endif #endif
...@@ -327,7 +327,8 @@ void GLRenderingVDAClient::CreateDecoder() { ...@@ -327,7 +327,8 @@ void GLRenderingVDAClient::CreateDecoder() {
new OmxVideoDecodeAccelerator( new OmxVideoDecodeAccelerator(
static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
static_cast<EGLContext>(rendering_helper_->GetGLContext()), static_cast<EGLContext>(rendering_helper_->GetGLContext()),
this)); this,
base::Bind(&DoNothingReturnTrue)));
#elif defined(ARCH_CPU_X86_FAMILY) #elif defined(ARCH_CPU_X86_FAMILY)
decoder_.reset(new VaapiVideoDecodeAccelerator( decoder_.reset(new VaapiVideoDecodeAccelerator(
static_cast<Display*>(rendering_helper_->GetGLDisplay()), static_cast<Display*>(rendering_helper_->GetGLDisplay()),
......
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