Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: ui/gl/gl_image_shm.cc

Issue 20017005: gpu: Refactor GpuMemoryBuffer framework for multi-process support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_image_shm.h ('k') | ui/gl/gl_image_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_shm.cc
diff --git a/ui/gl/gl_image_shm.cc b/ui/gl/gl_image_shm.cc
index 14ed8364721e7d70146037e38b8bc91849fd1f2f..78e816496fba7af8057d8d75c082cc8775238b08 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();
« no previous file with comments | « ui/gl/gl_image_shm.h ('k') | ui/gl/gl_image_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698