summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authorsheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 08:59:00 +0000
committersheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 08:59:00 +0000
commit3ecc1053b09adb0f0c32847e8901285339b34074 (patch)
treeccd73be429c31aac261fc95f93490261f46efb33 /content/common
parent50736a1f2b006d294baaf1f125bb453719b58c88 (diff)
downloadchromium_src-3ecc1053b09adb0f0c32847e8901285339b34074.zip
chromium_src-3ecc1053b09adb0f0c32847e8901285339b34074.tar.gz
chromium_src-3ecc1053b09adb0f0c32847e8901285339b34074.tar.bz2
Allow rendering from non-stream GL_TEXTURE_EXTERNAL_OES
Towards support for compositing from GL_TEXTURE_EXTERNAL_OES textures exported by other drivers into the GL stack. BUG=167417 TEST=local build, unittests, run on CrOS snow Review URL: https://codereview.chromium.org/24152009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225410 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/gpu/client/gpu_video_decode_accelerator_host.cc13
-rw-r--r--content/common/gpu/client/gpu_video_decode_accelerator_host.h6
-rw-r--r--content/common/gpu/gpu_messages.h7
-rw-r--r--content/common/gpu/media/exynos_video_decode_accelerator.cc19
-rw-r--r--content/common/gpu/media/gpu_video_decode_accelerator.cc51
-rw-r--r--content/common/gpu/media/gpu_video_decode_accelerator.h13
6 files changed, 62 insertions, 47 deletions
diff --git a/content/common/gpu/client/gpu_video_decode_accelerator_host.cc b/content/common/gpu/client/gpu_video_decode_accelerator_host.cc
index fcf36bf..403d296 100644
--- a/content/common/gpu/client/gpu_video_decode_accelerator_host.cc
+++ b/content/common/gpu/client/gpu_video_decode_accelerator_host.cc
@@ -103,15 +103,17 @@ void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers(
// Rearrange data for IPC command.
std::vector<int32> buffer_ids;
std::vector<uint32> texture_ids;
- std::vector<gfx::Size> sizes;
for (uint32 i = 0; i < buffers.size(); i++) {
const media::PictureBuffer& buffer = buffers[i];
+ if (buffer.size() != picture_buffer_dimensions_) {
+ OnErrorNotification(INVALID_ARGUMENT);
+ return;
+ }
texture_ids.push_back(buffer.texture_id());
buffer_ids.push_back(buffer.id());
- sizes.push_back(buffer.size());
}
Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers(
- decoder_route_id_, buffer_ids, texture_ids, sizes));
+ decoder_route_id_, buffer_ids, texture_ids));
}
void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer(
@@ -184,12 +186,13 @@ void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed(
void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer(
uint32 num_requested_buffers,
- const gfx::Size& buffer_size,
+ const gfx::Size& dimensions,
uint32 texture_target) {
DCHECK(CalledOnValidThread());
+ picture_buffer_dimensions_ = dimensions;
if (client_) {
client_->ProvidePictureBuffers(
- num_requested_buffers, buffer_size, texture_target);
+ num_requested_buffers, dimensions, texture_target);
}
}
diff --git a/content/common/gpu/client/gpu_video_decode_accelerator_host.h b/content/common/gpu/client/gpu_video_decode_accelerator_host.h
index ed67571..704584d 100644
--- a/content/common/gpu/client/gpu_video_decode_accelerator_host.h
+++ b/content/common/gpu/client/gpu_video_decode_accelerator_host.h
@@ -12,6 +12,7 @@
#include "content/common/gpu/client/command_buffer_proxy_impl.h"
#include "ipc/ipc_listener.h"
#include "media/video/video_decode_accelerator.h"
+#include "ui/gfx/size.h"
namespace content {
class GpuChannelHost;
@@ -55,7 +56,7 @@ class GpuVideoDecodeAcceleratorHost
void OnBitstreamBufferProcessed(int32 bitstream_buffer_id);
void OnProvidePictureBuffer(uint32 num_requested_buffers,
- const gfx::Size& buffer_size,
+ const gfx::Size& dimensions,
uint32 texture_target);
void OnDismissPictureBuffer(int32 picture_buffer_id);
void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id);
@@ -75,6 +76,9 @@ class GpuVideoDecodeAcceleratorHost
// Unowned reference to the CommandBufferProxyImpl that created us.
CommandBufferProxyImpl* impl_;
+ // Requested dimensions of the buffer, from ProvidePictureBuffers().
+ gfx::Size picture_buffer_dimensions_;
+
DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost);
};
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index b4e5be5..84598e6 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -659,10 +659,9 @@ IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderMsg_Decode,
// Sent from Renderer process to the GPU process to give the texture IDs for
// the textures the decoder will use for output.
-IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderMsg_AssignPictureBuffers,
- std::vector<int32>, /* Picture buffer ID */
- std::vector<uint32>, /* Texture ID */
- std::vector<gfx::Size>) /* Size */
+IPC_MESSAGE_ROUTED2(AcceleratedVideoDecoderMsg_AssignPictureBuffers,
+ std::vector<int32>, /* Picture buffer ID */
+ std::vector<uint32>) /* Texture ID */
// Send from Renderer process to the GPU process to recycle the given picture
// buffer for further decoding.
diff --git a/content/common/gpu/media/exynos_video_decode_accelerator.cc b/content/common/gpu/media/exynos_video_decode_accelerator.cc
index 36971f6..68d7129 100644
--- a/content/common/gpu/media/exynos_video_decode_accelerator.cc
+++ b/content/common/gpu/media/exynos_video_decode_accelerator.cc
@@ -241,8 +241,7 @@ ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator(
make_context_current_(make_context_current),
egl_display_(egl_display),
egl_context_(egl_context),
- video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {
-}
+ video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {}
ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() {
DCHECK(!decoder_thread_.IsRunning());
@@ -440,14 +439,6 @@ void ExynosVideoDecodeAccelerator::AssignPictureBuffers(
return;
}
- for (size_t i = 0; i < buffers.size(); ++i) {
- if (buffers[i].size() != frame_buffer_size_) {
- DLOG(ERROR) << "AssignPictureBuffers(): invalid buffer size";
- NOTIFY_ERROR(INVALID_ARGUMENT);
- return;
- }
- }
-
if (!make_context_current_.Run()) {
DLOG(ERROR) << "AssignPictureBuffers(): could not make context current";
NOTIFY_ERROR(PLATFORM_FAILURE);
@@ -464,12 +455,16 @@ void ExynosVideoDecodeAccelerator::AssignPictureBuffers(
Display* x_display = base::MessagePumpForUI::GetDefaultXDisplay();
gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_2D, 0);
for (size_t i = 0; i < pic_buffers_ref->picture_buffers.size(); ++i) {
+ DCHECK(buffers[i].size() == frame_buffer_size_);
PictureBufferArrayRef::PictureBufferRef& buffer =
pic_buffers_ref->picture_buffers[i];
// Create the X pixmap and then create an EGLImageKHR from it, so we can
// get dma_buf backing.
- Pixmap pixmap = XCreatePixmap(x_display, RootWindow(x_display, 0),
- buffers[i].size().width(), buffers[i].size().height(), 32);
+ Pixmap pixmap = XCreatePixmap(x_display,
+ RootWindow(x_display, 0),
+ frame_buffer_size_.width(),
+ frame_buffer_size_.height(),
+ 32);
if (!pixmap) {
DLOG(ERROR) << "AssignPictureBuffers(): could not create X pixmap";
NOTIFY_ERROR(PLATFORM_FAILURE);
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc
index 6b975f1..e180f06 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.cc
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -37,8 +37,6 @@
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gfx/size.h"
-using gpu::gles2::TextureManager;
-
namespace content {
static bool MakeDecoderContextCurrent(
@@ -166,6 +164,7 @@ void GpuVideoDecodeAccelerator::ProvidePictureBuffers(
DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers) "
<< "failed";
}
+ texture_dimensions_ = dimensions;
texture_target_ = texture_target;
}
@@ -277,7 +276,7 @@ void GpuVideoDecodeAccelerator::OnDecode(
base::SharedMemoryHandle handle, int32 id, uint32 size) {
DCHECK(video_decode_accelerator_.get());
if (id < 0) {
- DLOG(FATAL) << "BitstreamBuffer id " << id << " out of range";
+ DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range";
if (child_message_loop_->BelongsToCurrentThread()) {
NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
} else {
@@ -293,12 +292,10 @@ void GpuVideoDecodeAccelerator::OnDecode(
}
void GpuVideoDecodeAccelerator::OnAssignPictureBuffers(
- const std::vector<int32>& buffer_ids,
- const std::vector<uint32>& texture_ids,
- const std::vector<gfx::Size>& sizes) {
+ const std::vector<int32>& buffer_ids,
+ const std::vector<uint32>& texture_ids) {
DCHECK(stub_);
- if (buffer_ids.size() != texture_ids.size() ||
- buffer_ids.size() != sizes.size()) {
+ if (buffer_ids.size() != texture_ids.size()) {
NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
@@ -310,49 +307,65 @@ void GpuVideoDecodeAccelerator::OnAssignPictureBuffers(
std::vector<media::PictureBuffer> buffers;
for (uint32 i = 0; i < buffer_ids.size(); ++i) {
if (buffer_ids[i] < 0) {
- DLOG(FATAL) << "Buffer id " << buffer_ids[i] << " out of range";
+ DLOG(ERROR) << "Buffer id " << buffer_ids[i] << " out of range";
NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
gpu::gles2::TextureRef* texture_ref = texture_manager->GetTexture(
texture_ids[i]);
if (!texture_ref) {
- DLOG(FATAL) << "Failed to find texture id " << texture_ids[i];
+ DLOG(ERROR) << "Failed to find texture id " << texture_ids[i];
NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
gpu::gles2::Texture* info = texture_ref->texture();
if (info->target() != texture_target_) {
- DLOG(FATAL) << "Texture target mismatch for texture id "
+ DLOG(ERROR) << "Texture target mismatch for texture id "
<< texture_ids[i];
NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
- // GL_TEXTURE_EXTERNAL_OES textures have their dimensions defined by the
- // underlying EGLImage.
- if (texture_target_ != GL_TEXTURE_EXTERNAL_OES) {
+ if (texture_target_ == GL_TEXTURE_EXTERNAL_OES) {
+ // GL_TEXTURE_EXTERNAL_OES textures have their dimensions defined by the
+ // underlying EGLImage. Use |texture_dimensions_| for this size. The
+ // textures cannot be rendered to or cleared, so we set |cleared| true to
+ // skip clearing.
+ texture_manager->SetLevelInfo(texture_ref,
+ GL_TEXTURE_EXTERNAL_OES,
+ 0,
+ 0,
+ texture_dimensions_.width(),
+ texture_dimensions_.height(),
+ 1,
+ 0,
+ 0,
+ 0,
+ true);
+ } else {
+ // For other targets, texture dimensions should already be defined.
GLsizei width = 0, height = 0;
info->GetLevelSize(texture_target_, 0, &width, &height);
- if (width != sizes[i].width() || height != sizes[i].height()) {
- DLOG(FATAL) << "Size mismatch for texture id " << texture_ids[i];
+ if (width != texture_dimensions_.width() ||
+ height != texture_dimensions_.height()) {
+ DLOG(ERROR) << "Size mismatch for texture id " << texture_ids[i];
NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
}
if (!texture_manager->ClearRenderableLevels(command_decoder, texture_ref)) {
- DLOG(FATAL) << "Failed to Clear texture id " << texture_ids[i];
+ DLOG(ERROR) << "Failed to Clear texture id " << texture_ids[i];
NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
return;
}
uint32 service_texture_id;
if (!command_decoder->GetServiceTextureId(
texture_ids[i], &service_texture_id)) {
- DLOG(FATAL) << "Failed to translate texture!";
+ DLOG(ERROR) << "Failed to translate texture!";
NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
return;
}
buffers.push_back(media::PictureBuffer(
- buffer_ids[i], sizes[i], service_texture_id));
+ buffer_ids[i], texture_dimensions_, service_texture_id));
}
video_decode_accelerator_->AssignPictureBuffers(buffers);
}
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h
index 77946bc..e085c53 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.h
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.h
@@ -15,6 +15,7 @@
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "media/video/video_decode_accelerator.h"
+#include "ui/gfx/size.h"
namespace base {
class MessageLoopProxy;
@@ -70,12 +71,9 @@ class GpuVideoDecodeAccelerator
// Handlers for IPC messages.
void OnDecode(base::SharedMemoryHandle handle, int32 id, uint32 size);
- void OnAssignPictureBuffers(
- const std::vector<int32>& buffer_ids,
- const std::vector<uint32>& texture_ids,
- const std::vector<gfx::Size>& sizes);
- void OnReusePictureBuffer(
- int32 picture_buffer_id);
+ void OnAssignPictureBuffers(const std::vector<int32>& buffer_ids,
+ const std::vector<uint32>& texture_ids);
+ void OnReusePictureBuffer(int32 picture_buffer_id);
void OnFlush();
void OnReset();
void OnDestroy();
@@ -101,6 +99,9 @@ class GpuVideoDecodeAccelerator
// Returns false if failed.
base::Callback<bool(void)> make_context_current_;
+ // The texture dimensions as requested by ProvidePictureBuffers().
+ gfx::Size texture_dimensions_;
+
// The texture target as requested by ProvidePictureBuffers().
uint32 texture_target_;