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

Side by Side Diff: ui/gfx/compositor/compositor_gl.cc

Issue 7044062: Use SkMatrix44 for the underlying implementation of ui::Transform (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: removed unused header in gl compositor Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 t.ConcatTranslate(-window_size.width()/2.0f, -window_size.height()/2.0f); 154 t.ConcatTranslate(-window_size.width()/2.0f, -window_size.height()/2.0f);
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 const SkMatrix44& matrix = t.matrix();
rjkroege 2011/06/10 17:52:14 Given Ganesh, there should be a single call into S
165
164 GLfloat m[16]; 166 GLfloat m[16];
165 const SkMatrix& matrix = t.matrix(); 167 for (int i = 0; i < 4; ++i) {
166 168 for (int j = 0; j < 4; ++j) {
167 // Convert 3x3 view transform matrix (row major) into 4x4 GL matrix (column 169 m[i + j * 4] = matrix.get(i, j);
168 // major). Assume 2-D rotations/translations restricted to XY plane. 170 }
169 171 }
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 172
190 const GLfloat vertices[] = { -1., -1., +0., +0., +1., 173 const GLfloat vertices[] = { -1., -1., +0., +0., +1.,
191 +1., -1., +0., +1., +1., 174 +1., -1., +0., +1., +1.,
192 +1., +1., +0., +1., +0., 175 +1., +1., +0., +1., +0.,
193 -1., +1., +0., +0., +0. }; 176 -1., +1., +0., +0., +0. };
194 177
195 glVertexAttribPointer(compositor_->a_pos_loc(), 3, GL_FLOAT, 178 glVertexAttribPointer(compositor_->a_pos_loc(), 3, GL_FLOAT,
196 GL_FALSE, 5 * sizeof(GLfloat), vertices); 179 GL_FALSE, 5 * sizeof(GLfloat), vertices);
197 glVertexAttribPointer(compositor_->a_tex_loc(), 2, GL_FLOAT, 180 glVertexAttribPointer(compositor_->a_tex_loc(), 2, GL_FLOAT,
198 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]); 181 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 406
424 // static 407 // static
425 Compositor* Compositor::Create(gfx::AcceleratedWidget widget) { 408 Compositor* Compositor::Create(gfx::AcceleratedWidget widget) {
426 if (gfx::GetGLImplementation() != gfx::kGLImplementationNone) 409 if (gfx::GetGLImplementation() != gfx::kGLImplementationNone)
427 return new CompositorGL(widget); 410 return new CompositorGL(widget);
428 return NULL; 411 return NULL;
429 } 412 }
430 #endif 413 #endif
431 414
432 } // namespace ui 415 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698