diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 02:28:48 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 02:28:48 +0000 |
commit | 43f28f83bc268dea720843a2616058b64b3e8810 (patch) | |
tree | 3c3c4fc9c43dad15246fae82cb5b965e6b217281 /gpu/command_buffer/client | |
parent | 2d48004e1f2c8cecd015144c179f993d883aba9c (diff) | |
download | chromium_src-43f28f83bc268dea720843a2616058b64b3e8810.zip chromium_src-43f28f83bc268dea720843a2616058b64b3e8810.tar.gz chromium_src-43f28f83bc268dea720843a2616058b64b3e8810.tar.bz2 |
[GPU] Get GPU process running on the mac
Initial port of GPU process / plugin to Mac OS X. Uses new IOSurface
APIs and therefore currently runs only on 10.6. Alternate strategy
will need to be devised for 10.5.
Slight UI issues remain such as GPU plugins initially showing up in
the wrong place on the page. These will be fixed in follow-on bugs.
Minimal changes made to command buffer code to get it to compile on
Mac OS X. Commented out use of nested anonymous namespaces in
gles2_cmd_decoder.cc which were causing the linker to crash with a seg
fault.
Refactored gyp files so the OS test enabling the GPU plugin is in one
place, common.gypi, and other files test only the variable enable_gpu.
Slight change to gles2_demo_cc.cc to add some simple animation to
verify that updates from the GPU plugin are reaching the screen.
Changed Pepper test plugin to use 3D view by default and commented out
use of audio context because of recent issues.
TEST=none (ran Pepper Test Plugin with 3D view enabled)
BUG=http://crbug.com/25988
Review URL: http://codereview.chromium.org/558035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_cc.cc | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/gpu/command_buffer/client/gles2_demo_cc.cc b/gpu/command_buffer/client/gles2_demo_cc.cc index 0478e32..2544f42 100644 --- a/gpu/command_buffer/client/gles2_demo_cc.cc +++ b/gpu/command_buffer/client/gles2_demo_cc.cc @@ -5,6 +5,7 @@ // This file is here so other GLES2 related files can have a common set of // includes where appropriate. +#include <math.h> #include <GLES2/gl2.h> #include "gpu/command_buffer/client/gles2_demo_cc.h" @@ -13,8 +14,10 @@ namespace { GLuint g_texture = 0; int g_textureLoc = -1; GLuint g_programObject = 0; +GLuint g_worldMatrixLoc = 0; GLuint g_vbo = 0; GLsizei g_texCoordOffset = 0; +int g_angle = 0; void CheckGLError() { GLenum error = glGetError(); @@ -49,12 +52,14 @@ GLuint LoadShader(GLenum type, const char* shaderSrc) { void InitShaders() { static const char* vShaderStr = + "uniform mat4 worldMatrix;\n" "attribute vec3 g_Position;\n" "attribute vec2 g_TexCoord0;\n" "varying vec2 texCoord;\n" "void main()\n" "{\n" - " gl_Position = vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);\n" + " gl_Position = worldMatrix *\n" + " vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);\n" " texCoord = g_TexCoord0;\n" "}\n"; static const char* fShaderStr = @@ -94,6 +99,7 @@ void InitShaders() { return; } g_programObject = programObject; + g_worldMatrixLoc = glGetUniformLocation(g_programObject, "worldMatrix"); g_textureLoc = glGetUniformLocation(g_programObject, "tex"); glGenBuffers(1, &g_vbo); glBindBuffer(GL_ARRAY_BUFFER, g_vbo); @@ -124,7 +130,36 @@ void InitShaders() { CheckGLError(); } +#define PI 3.1415926535897932384626433832795f + void Draw() { + // TODO(kbr): base the angle on time rather than on ticks + g_angle = (g_angle + 1) % 360; + // Rotate about the Z axis + GLfloat rot_matrix[16]; + GLfloat cos_angle = cosf(static_cast<GLfloat>(g_angle) * PI / 180.0f); + GLfloat sin_angle = sinf(static_cast<GLfloat>(g_angle) * PI / 180.0f); + // OpenGL matrices are column-major + rot_matrix[0] = cos_angle; + rot_matrix[1] = sin_angle; + rot_matrix[2] = 0.0f; + rot_matrix[3] = 0.0f; + + rot_matrix[4] = -sin_angle; + rot_matrix[5] = cos_angle; + rot_matrix[6] = 0.0f; + rot_matrix[7] = 0.0f; + + rot_matrix[8] = 0.0f; + rot_matrix[9] = 0.0f; + rot_matrix[10] = 1.0f; + rot_matrix[11] = 0.0f; + + rot_matrix[12] = 0.0f; + rot_matrix[13] = 0.0f; + rot_matrix[14] = 0.0f; + rot_matrix[15] = 1.0f; + // Note: the viewport is automatically set up to cover the entire Canvas. // Clear the color buffer glClear(GL_COLOR_BUFFER_BIT); @@ -132,6 +167,9 @@ void Draw() { // Use the program object glUseProgram(g_programObject); CheckGLError(); + // Set up the model matrix + glUniformMatrix4fv(g_worldMatrixLoc, 1, GL_FALSE, rot_matrix); + // Load the vertex data glBindBuffer(GL_ARRAY_BUFFER, g_vbo); glEnableVertexAttribArray(0); |