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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 t.ConcatScale(2.0f/window_size.width(), 2.0f/window_size.height()); | 155 t.ConcatScale(2.0f/window_size.width(), 2.0f/window_size.height()); |
156 | 156 |
157 DCHECK(compositor_->program()); | 157 DCHECK(compositor_->program()); |
158 glUseProgram(compositor_->program()); | 158 glUseProgram(compositor_->program()); |
159 | 159 |
160 glActiveTexture(GL_TEXTURE0); | 160 glActiveTexture(GL_TEXTURE0); |
161 glUniform1i(compositor_->u_tex_loc(), 0); | 161 glUniform1i(compositor_->u_tex_loc(), 0); |
162 glBindTexture(GL_TEXTURE_2D, texture_id_); | 162 glBindTexture(GL_TEXTURE_2D, texture_id_); |
163 | 163 |
164 GLfloat m[16]; | 164 GLfloat m[16]; |
165 const SkMatrix& matrix = t.matrix(); | 165 transform.matrix().asColMajorf(m); |
166 | |
167 // Convert 3x3 view transform matrix (row major) into 4x4 GL matrix (column | |
168 // major). Assume 2-D rotations/translations restricted to XY plane. | |
169 | |
170 m[ 0] = matrix[0]; | |
171 m[ 1] = matrix[3]; | |
172 m[ 2] = 0; | |
173 m[ 3] = matrix[6]; | |
174 | |
175 m[ 4] = matrix[1]; | |
176 m[ 5] = matrix[4]; | |
177 m[ 6] = 0; | |
178 m[ 7] = matrix[7]; | |
179 | |
180 m[ 8] = 0; | |
181 m[ 9] = 0; | |
182 m[10] = 1; | |
183 m[11] = 0; | |
184 | |
185 m[12] = matrix[2]; | |
186 m[13] = matrix[5]; | |
187 m[14] = 0; | |
188 m[15] = matrix[8]; | |
189 | 166 |
190 const GLfloat vertices[] = { -1., -1., +0., +0., +1., | 167 const GLfloat vertices[] = { -1., -1., +0., +0., +1., |
191 +1., -1., +0., +1., +1., | 168 +1., -1., +0., +1., +1., |
192 +1., +1., +0., +1., +0., | 169 +1., +1., +0., +1., +0., |
193 -1., +1., +0., +0., +0. }; | 170 -1., +1., +0., +0., +0. }; |
194 | 171 |
195 glVertexAttribPointer(compositor_->a_pos_loc(), 3, GL_FLOAT, | 172 glVertexAttribPointer(compositor_->a_pos_loc(), 3, GL_FLOAT, |
196 GL_FALSE, 5 * sizeof(GLfloat), vertices); | 173 GL_FALSE, 5 * sizeof(GLfloat), vertices); |
197 glVertexAttribPointer(compositor_->a_tex_loc(), 2, GL_FLOAT, | 174 glVertexAttribPointer(compositor_->a_tex_loc(), 2, GL_FLOAT, |
198 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]); | 175 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // on this thread long enough to perform the GL bindings. | 343 // on this thread long enough to perform the GL bindings. |
367 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. | 344 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. |
368 base::ThreadRestrictions::ScopedAllowIO allow_io; | 345 base::ThreadRestrictions::ScopedAllowIO allow_io; |
369 gfx::GLSurface::InitializeOneOff(); | 346 gfx::GLSurface::InitializeOneOff(); |
370 if (gfx::GetGLImplementation() != gfx::kGLImplementationNone) | 347 if (gfx::GetGLImplementation() != gfx::kGLImplementationNone) |
371 return new glHidden::CompositorGL(widget); | 348 return new glHidden::CompositorGL(widget); |
372 return NULL; | 349 return NULL; |
373 } | 350 } |
374 | 351 |
375 } // namespace ui | 352 } // namespace ui |
OLD | NEW |