summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 22:06:15 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 22:06:15 +0000
commitb9363b2794c6f287be68eebb361117cdfbf060ca (patch)
tree74408c31f3920ae183663b0f16e633349805798e /chrome/gpu
parentc8c9712650efaa201c97ad6ff4edb6aa092dfd17 (diff)
downloadchromium_src-b9363b2794c6f287be68eebb361117cdfbf060ca.zip
chromium_src-b9363b2794c6f287be68eebb361117cdfbf060ca.tar.gz
chromium_src-b9363b2794c6f287be68eebb361117cdfbf060ca.tar.bz2
Added EGL based GLContext.
Python script to generate code to dynamically bind to GL functions (native GL, OSMesa, EGL or mock GL for unit tests). This replaces GLEW because GLEW doesn't bind to the GLES dialect of GL. Moved the mock GL code into app/gfx/gl. Updated the GPU code and AcceleratedSurface to use the new GL bindings. TEST=trybots BUG=none Review URL: http://codereview.chromium.org/2134006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r--chrome/gpu/gpu_backing_store_glx.cc62
-rw-r--r--chrome/gpu/gpu_backing_store_glx_context.cc31
-rw-r--r--chrome/gpu/gpu_main.cc7
-rw-r--r--chrome/gpu/gpu_video_layer_glx.cc6
-rw-r--r--chrome/gpu/gpu_view_x.cc28
5 files changed, 68 insertions, 66 deletions
diff --git a/chrome/gpu/gpu_backing_store_glx.cc b/chrome/gpu/gpu_backing_store_glx.cc
index 5f022cc..1c91a641 100644
--- a/chrome/gpu/gpu_backing_store_glx.cc
+++ b/chrome/gpu/gpu_backing_store_glx.cc
@@ -4,8 +4,7 @@
#include "chrome/gpu/gpu_backing_store_glx.h"
-#include <GL/glew.h>
-
+#include "app/gfx/gl/gl_bindings.h"
#include "app/surface/transport_dib.h"
#include "base/scoped_ptr.h"
#include "chrome/common/gpu_messages.h"
@@ -31,7 +30,8 @@ GpuBackingStoreGLX::GpuBackingStoreGLX(GpuViewX* view,
glGenTextures(1, &texture_id_);
glBindTexture(GL_TEXTURE_2D, texture_id_);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ // TODO(apatrick): This function are not available in GLES2.
+ // glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
@@ -92,28 +92,33 @@ void GpuBackingStoreGLX::OnScrollBackingStore(int dx, int dy,
// Set up the the tranform so we can paint exact pixels to the screen, with
// (0, 0) at the bottom left.
- float w = static_cast<float>(size_.width());
- float h = static_cast<float>(size_.height());
+ // TODO(apatrick): Commenting out because these variables were only used by
+ // code that is now commented out.
+ // float w = static_cast<float>(size_.width());
+ // float h = static_cast<float>(size_.height());
glViewport(0, 0, size_.width(), size_.height());
- glLoadIdentity();
- glOrtho(0.0, w, 0.0, h, -1.0, 1.0);
+
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glLoadIdentity();
+ // glOrtho(0.0, w, 0.0, h, -1.0, 1.0);
// Paint the non-scrolled background of the page. Note that we try to avoid
// this if the entire thing is scrolling, which is a common case.
if (view_size != clip_rect.size()) {
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(0.0, 0.0);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glBegin(GL_QUADS);
+ // glTexCoord2f(0.0f, 0.0f);
+ // glVertex2f(0.0, 0.0);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(0.0, h);
+ // glTexCoord2f(0.0f, 1.0f);
+ // glVertex2f(0.0, h);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f(w, h);
+ // glTexCoord2f(1.0f, 1.0f);
+ // glVertex2f(w, h);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f(w, 0.0);
- glEnd();
+ // glTexCoord2f(1.0f, 0.0f);
+ // glVertex2f(w, 0.0);
+ // glEnd();
}
// Constrain the painting to only the area we're scrolling. Compute the clip
@@ -126,20 +131,21 @@ void GpuBackingStoreGLX::OnScrollBackingStore(int dx, int dy,
gl_clip_rect.width(), gl_clip_rect.height());
// Paint the offset texture.
- glTranslatef(static_cast<float>(dx), static_cast<float>(dy), 0.0f);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(0.0, 0.0);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glTranslatef(static_cast<float>(dx), static_cast<float>(dy), 0.0f);
+ // glBegin(GL_QUADS);
+ // glTexCoord2f(0.0f, 0.0f);
+ // glVertex2f(0.0, 0.0);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(0.0, h);
+ // glTexCoord2f(0.0f, 1.0f);
+ // glVertex2f(0.0, h);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f(w, h);
+ // glTexCoord2f(1.0f, 1.0f);
+ // glVertex2f(w, h);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f(w, 0.0);
- glEnd();
+ // glTexCoord2f(1.0f, 0.0f);
+ // glVertex2f(w, 0.0);
+ // glEnd();
glDisable(GL_SCISSOR_TEST);
glBindTexture(GL_TEXTURE_2D, 0);
diff --git a/chrome/gpu/gpu_backing_store_glx_context.cc b/chrome/gpu/gpu_backing_store_glx_context.cc
index 96c6917..ea70651 100644
--- a/chrome/gpu/gpu_backing_store_glx_context.cc
+++ b/chrome/gpu/gpu_backing_store_glx_context.cc
@@ -4,13 +4,12 @@
#include "chrome/gpu/gpu_backing_store_glx_context.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "app/x11_util.h"
#include "base/scoped_ptr.h"
#include "chrome/gpu/gpu_thread.h"
// Must be last.
-#include <GL/glew.h>
-#include <GL/glxew.h>
#include <X11/Xutil.h>
GpuBackingStoreGLXContext::GpuBackingStoreGLXContext(GpuThread* gpu_thread)
@@ -30,7 +29,7 @@ GpuBackingStoreGLXContext::~GpuBackingStoreGLXContext() {
}
if (frame_buffer_for_scrolling_)
- glDeleteFramebuffers(1, &frame_buffer_for_scrolling_);
+ glDeleteFramebuffersEXT(1, &frame_buffer_for_scrolling_);
if (context_)
glXDestroyContext(gpu_thread_->display(), context_);
@@ -43,8 +42,8 @@ GLXContext GpuBackingStoreGLXContext::BindContext(XID window_id) {
if (!context_)
return NULL;
if (!previous_window_id_ || previous_window_id_ != window_id) {
- bool success = ::glXMakeCurrent(gpu_thread_->display(), window_id,
- context_);
+ bool success = glXMakeCurrent(gpu_thread_->display(), window_id,
+ context_);
DCHECK(success);
}
previous_window_id_ = window_id;
@@ -52,18 +51,16 @@ GLXContext GpuBackingStoreGLXContext::BindContext(XID window_id) {
}
tried_to_init_ = true;
- int attrib_list[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
+ int attrib_list[] = { GLX_RGBA, GLX_DOUBLEBUFFER, 0 };
scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info(
- ::glXChooseVisual(gpu_thread_->display(), 0, attrib_list));
+ glXChooseVisual(gpu_thread_->display(), 0, attrib_list));
if (!visual_info.get())
return NULL;
- context_ = ::glXCreateContext(gpu_thread_->display(), visual_info.get(),
- NULL, True);
- bool success = ::glXMakeCurrent(gpu_thread_->display(), window_id, context_);
+ context_ = glXCreateContext(gpu_thread_->display(), visual_info.get(),
+ NULL, True);
+ bool success = glXMakeCurrent(gpu_thread_->display(), window_id, context_);
DCHECK(success);
- glewInit();
- glewInitGL2Hack(); // Work around for I915. See gpu_video_layer_glx.cc.
return context_;
}
@@ -95,13 +92,13 @@ bool GpuBackingStoreGLXContext::BindTextureForScrolling(
}
if (!frame_buffer_for_scrolling_)
- glGenFramebuffers(1, &frame_buffer_for_scrolling_);
- glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer_for_scrolling_);
+ glGenFramebuffersEXT(1, &frame_buffer_for_scrolling_);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, frame_buffer_for_scrolling_);
is_frame_buffer_bound_ = true;
// Release our color attachment.
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- temp_scroll_texture_id_, 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ temp_scroll_texture_id_, 0);
DCHECK(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) ==
GL_FRAMEBUFFER_COMPLETE_EXT);
@@ -113,7 +110,7 @@ unsigned int GpuBackingStoreGLXContext::SwapTextureForScrolling(
const gfx::Size& old_size) {
// Unbind the framebuffer, which we expect to be bound.
DCHECK(is_frame_buffer_bound_);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
is_frame_buffer_bound_ = false;
DCHECK(temp_scroll_texture_id_);
diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc
index c6c4aee..2e248ab 100644
--- a/chrome/gpu/gpu_main.cc
+++ b/chrome/gpu/gpu_main.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/gfx/gl/gl_implementation.h"
#include "base/message_loop.h"
#include "build/build_config.h"
#include "chrome/common/chrome_constants.h"
@@ -17,9 +18,6 @@
#if defined(OS_WIN)
#include "app/win_util.h"
-#elif defined(GPU_USE_GLX)
-#include <dlfcn.h>
-#include <GL/glxew.h>
#endif
// Main function for starting the Gpu process.
@@ -40,8 +38,7 @@ int GpuMain(const MainFunctionParams& parameters) {
#if defined(OS_WIN)
win_util::ScopedCOMInitializer com_initializer;
#elif defined(GPU_USE_GLX)
- dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
- glxewInit();
+ gfx::InitializeGLBindings(gfx::kGLImplementationDesktopGL);
#endif
GpuProcess gpu_process;
diff --git a/chrome/gpu/gpu_video_layer_glx.cc b/chrome/gpu/gpu_video_layer_glx.cc
index 21e1bc1..d0578ad 100644
--- a/chrome/gpu/gpu_video_layer_glx.cc
+++ b/chrome/gpu/gpu_video_layer_glx.cc
@@ -4,8 +4,7 @@
#include "chrome/gpu/gpu_video_layer_glx.h"
-#include <GL/glew.h>
-
+#include "app/gfx/gl/gl_bindings.h"
#include "chrome/common/gpu_messages.h"
#include "chrome/gpu/gpu_thread.h"
#include "chrome/gpu/gpu_view_x.h"
@@ -107,7 +106,8 @@ GpuVideoLayerGLX::GpuVideoLayerGLX(GpuViewX* view,
view_->BindContext(); // Must do this before issuing OpenGl.
- glMatrixMode(GL_MODELVIEW);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glMatrixMode(GL_MODELVIEW);
// Create 3 textures, one for each plane, and bind them to different
// texture units.
diff --git a/chrome/gpu/gpu_view_x.cc b/chrome/gpu/gpu_view_x.cc
index b4c0f10..d9fd9d7 100644
--- a/chrome/gpu/gpu_view_x.cc
+++ b/chrome/gpu/gpu_view_x.cc
@@ -4,6 +4,7 @@
#include "chrome/gpu/gpu_view_x.h"
+#include "app/gfx/gl/gl_bindings.h"
#include "base/scoped_ptr.h"
#include "chrome/common/gpu_messages.h"
#include "chrome/gpu/gpu_backing_store_glx.h"
@@ -13,7 +14,6 @@
// X stuff must be last since it does "#define Status int" which messes up some
// of the header files we indirectly pull in.
-#include <GL/glxew.h>
#include <X11/Xutil.h>
GpuViewX::GpuViewX(GpuThread* gpu_thread,
@@ -63,8 +63,9 @@ void GpuViewX::Repaint() {
glViewport(0, 0, size.width(), size.height());
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glMatrixMode(GL_MODELVIEW);
+ // glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, backing_store_->texture_id());
@@ -72,19 +73,20 @@ void GpuViewX::Repaint() {
// TODO(brettw) use vertex buffers.
// TODO(brettw) make this so we use the texture size rather than the whole
// area size so we don't stretch bitmaps.
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(-1.0, 1.0);
+ // TODO(apatrick): These functions are not available in GLES2.
+ // glBegin(GL_QUADS);
+ // glTexCoord2f(0.0f, 0.0f);
+ // glVertex2f(-1.0, 1.0);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(-1.0, -1.0);
+ // glTexCoord2f(0.0f, 1.0f);
+ // glVertex2f(-1.0, -1.0);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f(1.0, -1.0);
+ // glTexCoord2f(1.0f, 1.0f);
+ // glVertex2f(1.0, -1.0);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f(1.0, 1.0);
- glEnd();
+ // glTexCoord2f(1.0f, 0.0f);
+ // glVertex2f(1.0, 1.0);
+ // glEnd();
DCHECK(glGetError() == GL_NO_ERROR);
if (video_layer_.get()) {