Chromium Code Reviews| Index: ui/gl/gl_image_shm.cc |
| diff --git a/ui/gl/gl_image_shm.cc b/ui/gl/gl_image_shm.cc |
| index cbf7c17a335c9d14ac3fa27bc849d3209aae99e0..6304f7773da5d59d3c8b8efd8f36fdef30c09005 100644 |
| --- a/ui/gl/gl_image_shm.cc |
| +++ b/ui/gl/gl_image_shm.cc |
| @@ -10,7 +10,9 @@ |
| namespace gfx { |
| -GLImageShm::GLImageShm(gfx::Size size) : size_(size) { |
| +GLImageShm::GLImageShm(const gfx::Size& size, unsigned internalformat) |
| + : size_(size), |
| + internalformat_(internalformat) { |
| } |
| GLImageShm::~GLImageShm() { |
| @@ -40,8 +42,26 @@ bool GLImageShm::BindTexImage() { |
| TRACE_EVENT0("gpu", "GLImageShm::BindTexImage"); |
| DCHECK(shared_memory_); |
| - const int kBytesPerPixel = 4; |
| - size_t size = size_.GetArea() * kBytesPerPixel; |
| + GLenum format; |
| + GLenum type; |
| + int bytes_per_pixel; |
| + switch (internalformat_) { |
| + case GL_RGBA: |
| + format = GL_RGBA; |
| + type = GL_UNSIGNED_BYTE; |
| + bytes_per_pixel = 4; |
| + break; |
| + case GL_BGRA_EXT: |
| + format = GL_BGRA_EXT; |
| + type = GL_UNSIGNED_BYTE; |
| + bytes_per_pixel = 4; |
| + break; |
| + default: |
| + NOTREACHED(); |
|
piman
2013/08/01 21:19:30
nit: this comes from the (untrusted) client side.
reveman
2013/08/08 23:19:00
Good point. Fixed in latest patch.
|
| + return false; |
| + } |
| + |
| + size_t size = size_.GetArea() * bytes_per_pixel; |
| DCHECK(!shared_memory_->memory()); |
| if (!shared_memory_->Map(size)) { |
| DVLOG(0) << "Failed to map shared memory."; |
| @@ -51,12 +71,12 @@ bool GLImageShm::BindTexImage() { |
| DCHECK(shared_memory_->memory()); |
| glTexImage2D(GL_TEXTURE_2D, |
| 0, // mip level |
| - GL_RGBA, |
| + internalformat_, |
| size_.width(), |
| size_.height(), |
| 0, // border |
| - GL_RGBA, |
| - GL_UNSIGNED_BYTE, |
| + format, |
| + type, |
| shared_memory_->memory()); |
| shared_memory_->Unmap(); |