summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-21 06:37:11 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-21 06:37:11 +0000
commitfcd0e4ca7e092ac95c7c1be190ef3ec64acb810a (patch)
tree7f7b25524d2ec7deb000c3438ea3f957335104e2
parente1d028a53f424b059ca492ab0066df2d2e31fe54 (diff)
downloadchromium_src-fcd0e4ca7e092ac95c7c1be190ef3ec64acb810a.zip
chromium_src-fcd0e4ca7e092ac95c7c1be190ef3ec64acb810a.tar.gz
chromium_src-fcd0e4ca7e092ac95c7c1be190ef3ec64acb810a.tar.bz2
Add GL_BGRA8_EXT to supported GpuMemoryBuffer formats.
BUG=321789 Review URL: https://codereview.chromium.org/76913008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236420 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/resources/image_raster_worker_pool.cc3
-rw-r--r--cc/resources/resource_provider.cc5
-rw-r--r--content/common/gpu/client/gpu_memory_buffer_impl.cc4
-rw-r--r--ui/gl/gl_image_shm.cc84
4 files changed, 68 insertions, 28 deletions
diff --git a/cc/resources/image_raster_worker_pool.cc b/cc/resources/image_raster_worker_pool.cc
index e665837..8c3a06b 100644
--- a/cc/resources/image_raster_worker_pool.cc
+++ b/cc/resources/image_raster_worker_pool.cc
@@ -155,8 +155,7 @@ void ImageRasterWorkerPool::ScheduleTasks(RasterTask::Queue* queue) {
}
ResourceFormat ImageRasterWorkerPool::GetResourceFormat() const {
- // Only format supported by CHROMIUM_map_image
- return RGBA_8888;
+ return resource_provider()->best_texture_format();
}
void ImageRasterWorkerPool::OnRasterTasksFinished() {
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 61ed04a..a6c59cc 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -1736,9 +1736,10 @@ void ResourceProvider::AcquireImage(ResourceId id) {
resource->allocated = true;
WebGraphicsContext3D* context3d = Context3d();
DCHECK(context3d);
- DCHECK_EQ(RGBA_8888, resource->format);
resource->image_id = context3d->createImageCHROMIUM(
- resource->size.width(), resource->size.height(), GL_RGBA8_OES);
+ resource->size.width(),
+ resource->size.height(),
+ TextureToStorageFormat(resource->format));
DCHECK(resource->image_id);
}
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc
index e5f6bc5..e27e260 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc
@@ -56,8 +56,8 @@ gfx::GpuMemoryBufferHandle GpuMemoryBufferImpl::GetHandle() const {
// static
bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) {
- // GL_RGBA8_OES is the only supported format at the moment.
switch (internalformat) {
+ case GL_BGRA8_EXT:
case GL_RGBA8_OES:
return true;
default:
@@ -67,8 +67,8 @@ bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) {
// static
size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) {
- // GL_RGBA_OES has 4 bytes per pixel.
switch (internalformat) {
+ case GL_BGRA8_EXT:
case GL_RGBA8_OES:
return 4;
default:
diff --git a/ui/gl/gl_image_shm.cc b/ui/gl/gl_image_shm.cc
index 5b182eb..8b20552 100644
--- a/ui/gl/gl_image_shm.cc
+++ b/ui/gl/gl_image_shm.cc
@@ -10,11 +10,61 @@
namespace gfx {
+namespace {
+
+bool ValidFormat(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ case GL_RGBA8_OES:
+ return true;
+ default:
+ return false;
+ }
+}
+
+GLenum TextureFormat(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ return GL_BGRA_EXT;
+ case GL_RGBA8_OES:
+ return GL_RGBA;
+ default:
+ NOTREACHED();
+ return 0;
+ }
+}
+
+GLenum DataFormat(unsigned internalformat) {
+ return TextureFormat(internalformat);
+}
+
+GLenum DataType(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ case GL_RGBA8_OES:
+ return GL_UNSIGNED_BYTE;
+ default:
+ NOTREACHED();
+ return 0;
+ }
+}
+
+GLenum BytesPerPixel(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ case GL_RGBA8_OES:
+ return 4;
+ default:
+ NOTREACHED();
+ return 0;
+ }
+}
+
+} // namespace
+
GLImageShm::GLImageShm(gfx::Size size, unsigned internalformat)
: size_(size),
internalformat_(internalformat) {
- // GL_RGBA8_OES is currently the only supported internalformat.
- DCHECK_EQ(static_cast<GLenum>(GL_RGBA8_OES), internalformat);
}
GLImageShm::~GLImageShm() {
@@ -22,6 +72,11 @@ GLImageShm::~GLImageShm() {
}
bool GLImageShm::Initialize(gfx::GpuMemoryBufferHandle buffer) {
+ if (!ValidFormat(internalformat_)) {
+ DVLOG(0) << "Invalid format: " << internalformat_;
+ return false;
+ }
+
if (!base::SharedMemory::IsHandleValid(buffer.handle))
return false;
@@ -50,24 +105,9 @@ gfx::Size GLImageShm::GetSize() {
bool GLImageShm::BindTexImage() {
TRACE_EVENT0("gpu", "GLImageShm::BindTexImage");
DCHECK(shared_memory_);
+ DCHECK(ValidFormat(internalformat_));
- GLenum internalformat;
- GLenum format;
- GLenum type;
- int bytes_per_pixel;
- switch (internalformat_) {
- case GL_RGBA8_OES:
- internalformat = GL_RGBA;
- format = GL_RGBA;
- type = GL_UNSIGNED_BYTE;
- bytes_per_pixel = 4;
- break;
- default:
- DVLOG(0) << "Invalid format: " << internalformat_;
- return false;
- }
-
- size_t size = size_.GetArea() * bytes_per_pixel;
+ size_t size = size_.GetArea() * BytesPerPixel(internalformat_);
DCHECK(!shared_memory_->memory());
if (!shared_memory_->Map(size)) {
DVLOG(0) << "Failed to map shared memory.";
@@ -77,12 +117,12 @@ bool GLImageShm::BindTexImage() {
DCHECK(shared_memory_->memory());
glTexImage2D(GL_TEXTURE_2D,
0, // mip level
- internalformat,
+ TextureFormat(internalformat_),
size_.width(),
size_.height(),
0, // border
- format,
- type,
+ DataFormat(internalformat_),
+ DataType(internalformat_),
shared_memory_->memory());
shared_memory_->Unmap();