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" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "third_party/skia/include/core/SkDevice.h" | 13 #include "third_party/skia/include/core/SkDevice.h" |
| 14 #include "third_party/skia/include/core/SkMatrix.h" | 14 #include "third_party/skia/include/core/SkMatrix.h" |
| 15 #include "third_party/skia/include/core/SkRect.h" | 15 #include "third_party/skia/include/core/SkRect.h" |
| 16 #include "third_party/skia/include/core/SkScalar.h" | 16 #include "third_party/skia/include/core/SkScalar.h" |
|
jonathan.backer
2011/09/06 12:25:37
probably need to #include <X11/Xlib.h> --- must be
sadrul
2011/09/06 13:51:44
Done.
| |
| 17 #include "ui/base/x/x11_util.h" | |
| 17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 18 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 19 #include "ui/gfx/gl/gl_bindings.h" | 20 #include "ui/gfx/gl/gl_bindings.h" |
| 20 #include "ui/gfx/gl/gl_context.h" | 21 #include "ui/gfx/gl/gl_context.h" |
| 21 #include "ui/gfx/gl/gl_implementation.h" | 22 #include "ui/gfx/gl/gl_implementation.h" |
| 22 #include "ui/gfx/gl/gl_surface.h" | 23 #include "ui/gfx/gl/gl_surface.h" |
| 23 | 24 |
| 24 // Wraps a simple GL program for drawing textures to the screen. | 25 // Wraps a simple GL program for drawing textures to the screen. |
| 25 // Need the declaration before the subclasses in the anonymous namespace below. | 26 // Need the declaration before the subclasses in the anonymous namespace below. |
| 26 class ui::TextureProgramGL { | 27 class ui::TextureProgramGL { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 glEnableVertexAttribArray(program.a_tex_loc()); | 438 glEnableVertexAttribArray(program.a_tex_loc()); |
| 438 | 439 |
| 439 glUniformMatrix4fv(program.u_mat_loc(), 1, GL_FALSE, m); | 440 glUniformMatrix4fv(program.u_mat_loc(), 1, GL_FALSE, m); |
| 440 | 441 |
| 441 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); | 442 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
| 442 } | 443 } |
| 443 | 444 |
| 444 CompositorGL::CompositorGL(gfx::AcceleratedWidget widget, | 445 CompositorGL::CompositorGL(gfx::AcceleratedWidget widget, |
| 445 const gfx::Size& size) | 446 const gfx::Size& size) |
| 446 : Compositor(size), | 447 : Compositor(size), |
| 448 widget_(widget), | |
| 447 started_(false) { | 449 started_(false) { |
| 448 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); | 450 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); |
| 449 gl_context_ = SharedResources::GetInstance()-> | 451 gl_context_ = SharedResources::GetInstance()-> |
| 450 CreateContext(gl_surface_.get()); | 452 CreateContext(gl_surface_.get()); |
| 451 gl_context_->MakeCurrent(gl_surface_.get()); | 453 gl_context_->MakeCurrent(gl_surface_.get()); |
| 452 glColorMask(true, true, true, true); | 454 glColorMask(true, true, true, true); |
| 453 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 455 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 454 } | 456 } |
| 455 | 457 |
| 456 CompositorGL::~CompositorGL() { | 458 CompositorGL::~CompositorGL() { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 487 DCHECK(started_); | 489 DCHECK(started_); |
| 488 gl_surface_->SwapBuffers(); | 490 gl_surface_->SwapBuffers(); |
| 489 started_ = false; | 491 started_ = false; |
| 490 } | 492 } |
| 491 | 493 |
| 492 void CompositorGL::Blur(const gfx::Rect& bounds) { | 494 void CompositorGL::Blur(const gfx::Rect& bounds) { |
| 493 NOTIMPLEMENTED(); | 495 NOTIMPLEMENTED(); |
| 494 } | 496 } |
| 495 | 497 |
| 496 void CompositorGL::SchedulePaint() { | 498 void CompositorGL::SchedulePaint() { |
| 497 // TODO: X doesn't provide coalescing of regions, its left to the toolkit. | 499 Display* display = ui::GetXDisplay(); |
| 498 NOTIMPLEMENTED(); | 500 XEvent event; |
| 501 event.xexpose.type = Expose; | |
| 502 event.xexpose.serial = XNextRequest(display); | |
| 503 event.xexpose.send_event = true; | |
| 504 event.xexpose.display = display; | |
| 505 event.xexpose.window = widget_; | |
| 506 event.xexpose.x = 0; | |
| 507 event.xexpose.y = 0; | |
| 508 event.xexpose.width = size().width(); | |
| 509 event.xexpose.height = size().height(); | |
| 510 event.xexpose.count = 0; | |
| 511 XSendEvent(display, widget_, true, ExposureMask, &event); | |
| 499 } | 512 } |
| 500 | 513 |
| 501 // static | 514 // static |
| 502 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, | 515 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, |
| 503 const gfx::Size& size) { | 516 const gfx::Size& size) { |
| 504 if (SharedResources::GetInstance() == NULL) | 517 if (SharedResources::GetInstance() == NULL) |
| 505 return NULL; | 518 return NULL; |
| 506 else | 519 else |
| 507 return new CompositorGL(widget, size); | 520 return new CompositorGL(widget, size); |
| 508 } | 521 } |
| 509 | 522 |
| 510 } // namespace ui | 523 } // namespace ui |
| OLD | NEW |