| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/compositor/compositor.h" | 5 #include "ui/gfx/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <GL/gl.h> | 7 #include <GL/gl.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 t.ConcatScale(2.0f/window_size.width(), 2.0f/window_size.height()); | 159 t.ConcatScale(2.0f/window_size.width(), 2.0f/window_size.height()); |
| 160 | 160 |
| 161 DCHECK(compositor_->program()); | 161 DCHECK(compositor_->program()); |
| 162 glUseProgram(compositor_->program()); | 162 glUseProgram(compositor_->program()); |
| 163 | 163 |
| 164 glActiveTexture(GL_TEXTURE0); | 164 glActiveTexture(GL_TEXTURE0); |
| 165 glUniform1i(compositor_->u_tex_loc(), 0); | 165 glUniform1i(compositor_->u_tex_loc(), 0); |
| 166 glBindTexture(GL_TEXTURE_2D, texture_id_); | 166 glBindTexture(GL_TEXTURE_2D, texture_id_); |
| 167 | 167 |
| 168 GLfloat m[16]; | 168 GLfloat m[16]; |
| 169 const SkMatrix& matrix = t.matrix(); | 169 t.matrix().asColMajorf(m); |
| 170 | |
| 171 // Convert 3x3 view transform matrix (row major) into 4x4 GL matrix (column | |
| 172 // major). Assume 2-D rotations/translations restricted to XY plane. | |
| 173 | |
| 174 m[ 0] = matrix[0]; | |
| 175 m[ 1] = matrix[3]; | |
| 176 m[ 2] = 0; | |
| 177 m[ 3] = matrix[6]; | |
| 178 | |
| 179 m[ 4] = matrix[1]; | |
| 180 m[ 5] = matrix[4]; | |
| 181 m[ 6] = 0; | |
| 182 m[ 7] = matrix[7]; | |
| 183 | |
| 184 m[ 8] = 0; | |
| 185 m[ 9] = 0; | |
| 186 m[10] = 1; | |
| 187 m[11] = 0; | |
| 188 | |
| 189 m[12] = matrix[2]; | |
| 190 m[13] = matrix[5]; | |
| 191 m[14] = 0; | |
| 192 m[15] = matrix[8]; | |
| 193 | 170 |
| 194 const GLfloat vertices[] = { -1., -1., +0., +0., +1., | 171 const GLfloat vertices[] = { -1., -1., +0., +0., +1., |
| 195 +1., -1., +0., +1., +1., | 172 +1., -1., +0., +1., +1., |
| 196 +1., +1., +0., +1., +0., | 173 +1., +1., +0., +1., +0., |
| 197 -1., +1., +0., +0., +0. }; | 174 -1., +1., +0., +0., +0. }; |
| 198 | 175 |
| 199 glVertexAttribPointer(compositor_->a_pos_loc(), 3, GL_FLOAT, | 176 glVertexAttribPointer(compositor_->a_pos_loc(), 3, GL_FLOAT, |
| 200 GL_FALSE, 5 * sizeof(GLfloat), vertices); | 177 GL_FALSE, 5 * sizeof(GLfloat), vertices); |
| 201 glVertexAttribPointer(compositor_->a_tex_loc(), 2, GL_FLOAT, | 178 glVertexAttribPointer(compositor_->a_tex_loc(), 2, GL_FLOAT, |
| 202 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]); | 179 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // on this thread long enough to perform the GL bindings. | 352 // on this thread long enough to perform the GL bindings. |
| 376 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. | 353 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. |
| 377 base::ThreadRestrictions::ScopedAllowIO allow_io; | 354 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 378 if (gfx::GLSurface::InitializeOneOff() && | 355 if (gfx::GLSurface::InitializeOneOff() && |
| 379 gfx::GetGLImplementation() != gfx::kGLImplementationNone) | 356 gfx::GetGLImplementation() != gfx::kGLImplementationNone) |
| 380 return new glHidden::CompositorGL(widget); | 357 return new glHidden::CompositorGL(widget); |
| 381 return NULL; | 358 return NULL; |
| 382 } | 359 } |
| 383 | 360 |
| 384 } // namespace ui | 361 } // namespace ui |
| OLD | NEW |