summaryrefslogtreecommitdiffstats
path: root/ui/gl/gl_image_shm.cc
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 17:31:00 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 17:31:00 +0000
commitbac37fd3e9ff7eca18bbb58bc4d2c9ce2e3218f1 (patch)
tree05742d172017dc99f882e138d8029f1f452d7704 /ui/gl/gl_image_shm.cc
parenta16a5a57b2c34fbc8c8d6c5a16936df423f897a5 (diff)
downloadchromium_src-bac37fd3e9ff7eca18bbb58bc4d2c9ce2e3218f1.zip
chromium_src-bac37fd3e9ff7eca18bbb58bc4d2c9ce2e3218f1.tar.gz
chromium_src-bac37fd3e9ff7eca18bbb58bc4d2c9ce2e3218f1.tar.bz2
gpu: Refactor GpuMemoryBuffer framework for multi-process support.
This removes the ImageFactory interface and adjusts the buffer allocation system for future multi-process support. Also includes proper plumbing of internalformat to GLImage implementation and makes sure the compositor is using the correct format. TEST=gpu_unittests --gtest_filter=MockGpuMemoryBufferTest.Lifecycle BUG=261649 Review URL: https://chromiumcodereview.appspot.com/20017005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl/gl_image_shm.cc')
-rw-r--r--ui/gl/gl_image_shm.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/ui/gl/gl_image_shm.cc b/ui/gl/gl_image_shm.cc
index 14ed836..78e8164 100644
--- a/ui/gl/gl_image_shm.cc
+++ b/ui/gl/gl_image_shm.cc
@@ -10,7 +10,11 @@
namespace gfx {
-GLImageShm::GLImageShm(gfx::Size size) : size_(size) {
+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() {
@@ -40,8 +44,23 @@ bool GLImageShm::BindTexImage() {
TRACE_EVENT0("gpu", "GLImageShm::BindTexImage");
DCHECK(shared_memory_);
- const int kBytesPerPixel = 4;
- size_t size = size_.GetArea() * kBytesPerPixel;
+ 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;
DCHECK(!shared_memory_->memory());
if (!shared_memory_->Map(size)) {
DVLOG(0) << "Failed to map shared memory.";
@@ -51,12 +70,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();