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

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: Fixed a typo in a comment Created 9 years, 5 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_gl.h" 5 #include "ui/gfx/compositor/compositor_gl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 t.ConcatScale(1, -1); 266 t.ConcatScale(1, -1);
267 267
268 t.ConcatTransform(transform); // Add view transform. 268 t.ConcatTransform(transform); // Add view transform.
269 269
270 t.ConcatTranslate(0, -window_size.height()); 270 t.ConcatTranslate(0, -window_size.height());
271 t.ConcatScale(1, -1); 271 t.ConcatScale(1, -1);
272 t.ConcatTranslate(-window_size.width()/2.0f, -window_size.height()/2.0f); 272 t.ConcatTranslate(-window_size.width()/2.0f, -window_size.height()/2.0f);
273 t.ConcatScale(2.0f/window_size.width(), 2.0f/window_size.height()); 273 t.ConcatScale(2.0f/window_size.width(), 2.0f/window_size.height());
274 274
275 GLfloat m[16]; 275 GLfloat m[16];
276 const SkMatrix& matrix = t.matrix(); 276 t.matrix().asColMajorf(m);
277
278 // Convert 3x3 view transform matrix (row major) into 4x4 GL matrix (column
279 // major). Assume 2-D rotations/translations restricted to XY plane.
280
281 m[ 0] = matrix[0];
282 m[ 1] = matrix[3];
283 m[ 2] = 0;
284 m[ 3] = matrix[6];
285
286 m[ 4] = matrix[1];
287 m[ 5] = matrix[4];
288 m[ 6] = 0;
289 m[ 7] = matrix[7];
290
291 m[ 8] = 0;
292 m[ 9] = 0;
293 m[10] = 1;
294 m[11] = 0;
295
296 m[12] = matrix[2];
297 m[13] = matrix[5];
298 m[14] = 0;
299 m[15] = matrix[8];
300 277
301 static const GLfloat vertices[] = { -1., -1., +0., +0., +1., 278 static const GLfloat vertices[] = { -1., -1., +0., +0., +1.,
302 +1., -1., +0., +1., +1., 279 +1., -1., +0., +1., +1.,
303 +1., +1., +0., +1., +0., 280 +1., +1., +0., +1., +0.,
304 -1., +1., +0., +0., +0. }; 281 -1., +1., +0., +0., +0. };
305 282
306 glVertexAttribPointer(program.a_pos_loc(), 3, GL_FLOAT, 283 glVertexAttribPointer(program.a_pos_loc(), 3, GL_FLOAT,
307 GL_FALSE, 5 * sizeof(GLfloat), vertices); 284 GL_FALSE, 5 * sizeof(GLfloat), vertices);
308 glVertexAttribPointer(program.a_tex_loc(), 2, GL_FLOAT, 285 glVertexAttribPointer(program.a_tex_loc(), 2, GL_FLOAT,
309 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]); 286 GL_FALSE, 5 * sizeof(GLfloat), &vertices[3]);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // on this thread long enough to perform the GL bindings. 385 // on this thread long enough to perform the GL bindings.
409 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. 386 // TODO(wjmaclean) Remove this when GL initialisation cleaned up.
410 base::ThreadRestrictions::ScopedAllowIO allow_io; 387 base::ThreadRestrictions::ScopedAllowIO allow_io;
411 if (gfx::GLSurface::InitializeOneOff() && 388 if (gfx::GLSurface::InitializeOneOff() &&
412 gfx::GetGLImplementation() != gfx::kGLImplementationNone) 389 gfx::GetGLImplementation() != gfx::kGLImplementationNone)
413 return new CompositorGL(widget); 390 return new CompositorGL(widget);
414 return NULL; 391 return NULL;
415 } 392 }
416 393
417 } // namespace ui 394 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698