| 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 // for CompositorGL::SchedulePaint | 7 // for CompositorGL::SchedulePaint |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <gdk/gdkx.h> | 9 #include <gdk/gdkx.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 17 #include "third_party/skia/include/core/SkDevice.h" | 17 #include "third_party/skia/include/core/SkDevice.h" |
| 18 #include "third_party/skia/include/core/SkMatrix.h" | 18 #include "third_party/skia/include/core/SkMatrix.h" |
| 19 #include "third_party/skia/include/core/SkRect.h" | 19 #include "third_party/skia/include/core/SkRect.h" |
| 20 #include "third_party/skia/include/core/SkScalar.h" | 20 #include "third_party/skia/include/core/SkScalar.h" |
| 21 #include "ui/gfx/point3.h" |
| 21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 22 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 23 #include "ui/gfx/gl/gl_bindings.h" | 24 #include "ui/gfx/gl/gl_bindings.h" |
| 24 #include "ui/gfx/gl/gl_context.h" | 25 #include "ui/gfx/gl/gl_context.h" |
| 25 #include "ui/gfx/gl/gl_implementation.h" | 26 #include "ui/gfx/gl/gl_implementation.h" |
| 26 #include "ui/gfx/gl/gl_surface.h" | 27 #include "ui/gfx/gl/gl_surface.h" |
| 27 | 28 |
| 28 // Wraps a simple GL program for drawing textures to the screen. | 29 // Wraps a simple GL program for drawing textures to the screen. |
| 29 // Need the declaration before the subclasses in the anonymous namespace below. | 30 // Need the declaration before the subclasses in the anonymous namespace below. |
| 30 class ui::TextureProgramGL { | 31 class ui::TextureProgramGL { |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 473 |
| 473 void CompositorGL::NotifyStart() { | 474 void CompositorGL::NotifyStart() { |
| 474 started_ = true; | 475 started_ = true; |
| 475 gl_context_->MakeCurrent(gl_surface_.get()); | 476 gl_context_->MakeCurrent(gl_surface_.get()); |
| 476 glViewport(0, 0, size_.width(), size_.height()); | 477 glViewport(0, 0, size_.width(), size_.height()); |
| 477 glColorMask(true, true, true, true); | 478 glColorMask(true, true, true, true); |
| 478 | 479 |
| 479 #if defined(DEBUG) | 480 #if defined(DEBUG) |
| 480 // Clear to 'psychedelic' purple to make it easy to spot un-rendered regions. | 481 // Clear to 'psychedelic' purple to make it easy to spot un-rendered regions. |
| 481 glClearColor(223.0 / 255, 0, 1, 1); | 482 glClearColor(223.0 / 255, 0, 1, 1); |
| 483 #else |
| 484 glClearColor(0, 0, 0, 0); |
| 485 #endif |
| 486 |
| 482 glClear(GL_COLOR_BUFFER_BIT); | 487 glClear(GL_COLOR_BUFFER_BIT); |
| 483 #endif | |
| 484 // Do not clear in release: root layer is responsible for drawing every pixel. | |
| 485 } | 488 } |
| 486 | 489 |
| 487 void CompositorGL::NotifyEnd() { | 490 void CompositorGL::NotifyEnd() { |
| 488 DCHECK(started_); | 491 DCHECK(started_); |
| 489 gl_surface_->SwapBuffers(); | 492 gl_surface_->SwapBuffers(); |
| 490 started_ = false; | 493 started_ = false; |
| 491 } | 494 } |
| 492 | 495 |
| 493 void CompositorGL::Blur(const gfx::Rect& bounds) { | 496 void CompositorGL::Blur(const gfx::Rect& bounds) { |
| 494 NOTIMPLEMENTED(); | 497 NOTIMPLEMENTED(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 516 // on this thread long enough to perform the GL bindings. | 519 // on this thread long enough to perform the GL bindings. |
| 517 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. | 520 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. |
| 518 base::ThreadRestrictions::ScopedAllowIO allow_io; | 521 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 519 if (gfx::GLSurface::InitializeOneOff() && | 522 if (gfx::GLSurface::InitializeOneOff() && |
| 520 gfx::GetGLImplementation() != gfx::kGLImplementationNone) | 523 gfx::GetGLImplementation() != gfx::kGLImplementationNone) |
| 521 return new CompositorGL(widget, size); | 524 return new CompositorGL(widget, size); |
| 522 return NULL; | 525 return NULL; |
| 523 } | 526 } |
| 524 | 527 |
| 525 } // namespace ui | 528 } // namespace ui |
| OLD | NEW |