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_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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 glVertexAttribPointer(program.a_tex_loc(), 2, GL_FLOAT, | 434 glVertexAttribPointer(program.a_tex_loc(), 2, GL_FLOAT, |
435 GL_FALSE, 2 * sizeof(GLfloat), texture_vertices); | 435 GL_FALSE, 2 * sizeof(GLfloat), texture_vertices); |
436 glEnableVertexAttribArray(program.a_pos_loc()); | 436 glEnableVertexAttribArray(program.a_pos_loc()); |
437 glEnableVertexAttribArray(program.a_tex_loc()); | 437 glEnableVertexAttribArray(program.a_tex_loc()); |
438 | 438 |
439 glUniformMatrix4fv(program.u_mat_loc(), 1, GL_FALSE, m); | 439 glUniformMatrix4fv(program.u_mat_loc(), 1, GL_FALSE, m); |
440 | 440 |
441 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); | 441 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
442 } | 442 } |
443 | 443 |
444 CompositorGL::CompositorGL(gfx::AcceleratedWidget widget, | 444 CompositorGL::CompositorGL(CompositorDelegate* delegate, |
| 445 gfx::AcceleratedWidget widget, |
445 const gfx::Size& size) | 446 const gfx::Size& size) |
446 : Compositor(size), | 447 : Compositor(delegate, size), |
447 started_(false) { | 448 started_(false) { |
448 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); | 449 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); |
449 gl_context_ = SharedResources::GetInstance()-> | 450 gl_context_ = SharedResources::GetInstance()-> |
450 CreateContext(gl_surface_.get()); | 451 CreateContext(gl_surface_.get()); |
451 gl_context_->MakeCurrent(gl_surface_.get()); | 452 gl_context_->MakeCurrent(gl_surface_.get()); |
452 glColorMask(true, true, true, true); | 453 glColorMask(true, true, true, true); |
453 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 454 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
454 } | 455 } |
455 | 456 |
456 CompositorGL::~CompositorGL() { | 457 CompositorGL::~CompositorGL() { |
(...skipping 30 matching lines...) Expand all Loading... |
487 DCHECK(started_); | 488 DCHECK(started_); |
488 gl_surface_->SwapBuffers(); | 489 gl_surface_->SwapBuffers(); |
489 started_ = false; | 490 started_ = false; |
490 } | 491 } |
491 | 492 |
492 void CompositorGL::Blur(const gfx::Rect& bounds) { | 493 void CompositorGL::Blur(const gfx::Rect& bounds) { |
493 NOTIMPLEMENTED(); | 494 NOTIMPLEMENTED(); |
494 } | 495 } |
495 | 496 |
496 void CompositorGL::SchedulePaint() { | 497 void CompositorGL::SchedulePaint() { |
497 // TODO: X doesn't provide coalescing of regions, its left to the toolkit. | 498 delegate()->ScheduleCompositorPaint(); |
498 NOTIMPLEMENTED(); | |
499 } | 499 } |
500 | 500 |
501 // static | 501 // static |
502 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, | 502 Compositor* Compositor::Create(CompositorDelegate* owner, |
| 503 gfx::AcceleratedWidget widget, |
503 const gfx::Size& size) { | 504 const gfx::Size& size) { |
504 if (SharedResources::GetInstance() == NULL) | 505 if (SharedResources::GetInstance() == NULL) |
505 return NULL; | 506 return NULL; |
506 else | 507 else |
507 return new CompositorGL(widget, size); | 508 return new CompositorGL(owner, widget, size); |
508 } | 509 } |
509 | 510 |
510 } // namespace ui | 511 } // namespace ui |
OLD | NEW |