Chromium Code Reviews| 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(CompositorOwner* owner, |
| 445 const gfx::Size& size) | 445 const gfx::Size& size) |
| 446 : Compositor(size), | 446 : Compositor(owner, size), |
| 447 started_(false) { | 447 started_(false) { |
| 448 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); | 448 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, |
| 449 owner->GetAcceleratedWidget()); | |
| 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() { |
| 457 gl_context_ = NULL; | 458 gl_context_ = NULL; |
| 458 } | 459 } |
| (...skipping 28 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 owner()->PaintNow(); |
|
sadrul
2011/09/06 17:27:05
This will actually be a PostTask
| |
| 498 NOTIMPLEMENTED(); | |
| 499 } | 499 } |
| 500 | 500 |
| 501 // static | 501 // static |
| 502 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, | 502 Compositor* Compositor::Create(CompositorOwner* owner, |
| 503 const gfx::Size& size) { | 503 const gfx::Size& size) { |
| 504 if (SharedResources::GetInstance() == NULL) | 504 if (SharedResources::GetInstance() == NULL) |
| 505 return NULL; | 505 return NULL; |
| 506 else | 506 else |
| 507 return new CompositorGL(widget, size); | 507 return new CompositorGL(owner, size); |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace ui | 510 } // namespace ui |
| OLD | NEW |