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

Side by Side Diff: ui/gfx/compositor/compositor_gl.cc

Issue 7273073: Animated Rotation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Moved screen rotation code under touch; use lock object to disable painting Created 9 years, 3 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 // for CompositorGL::SchedulePaint
8 #include <gtk/gtk.h>
9 #include <gdk/gdkx.h>
10
7 #include "base/basictypes.h" 11 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
9 #include "base/logging.h" 13 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
12 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
13 #include "third_party/skia/include/core/SkDevice.h" 17 #include "third_party/skia/include/core/SkDevice.h"
14 #include "third_party/skia/include/core/SkMatrix.h" 18 #include "third_party/skia/include/core/SkMatrix.h"
15 #include "third_party/skia/include/core/SkRect.h" 19 #include "third_party/skia/include/core/SkRect.h"
16 #include "third_party/skia/include/core/SkScalar.h" 20 #include "third_party/skia/include/core/SkScalar.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 glEnableVertexAttribArray(program.a_pos_loc()); 426 glEnableVertexAttribArray(program.a_pos_loc());
423 glEnableVertexAttribArray(program.a_tex_loc()); 427 glEnableVertexAttribArray(program.a_tex_loc());
424 428
425 glUniformMatrix4fv(program.u_mat_loc(), 1, GL_FALSE, m); 429 glUniformMatrix4fv(program.u_mat_loc(), 1, GL_FALSE, m);
426 430
427 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 431 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
428 } 432 }
429 433
430 CompositorGL::CompositorGL(gfx::AcceleratedWidget widget, 434 CompositorGL::CompositorGL(gfx::AcceleratedWidget widget,
431 const gfx::Size& size) 435 const gfx::Size& size)
432 : size_(size), 436 : widget_(widget),
437 size_(size),
433 started_(false) { 438 started_(false) {
434 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); 439 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget);
435 gl_context_ = SharedResources::GetInstance()-> 440 gl_context_ = SharedResources::GetInstance()->
436 CreateContext(gl_surface_.get()); 441 CreateContext(gl_surface_.get());
437 gl_context_->MakeCurrent(gl_surface_.get()); 442 gl_context_->MakeCurrent(gl_surface_.get());
438 glColorMask(true, true, true, true); 443 glColorMask(true, true, true, true);
439 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 444 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
440 } 445 }
441 446
442 CompositorGL::~CompositorGL() { 447 CompositorGL::~CompositorGL() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 DCHECK(started_); 488 DCHECK(started_);
484 gl_surface_->SwapBuffers(); 489 gl_surface_->SwapBuffers();
485 started_ = false; 490 started_ = false;
486 } 491 }
487 492
488 void CompositorGL::Blur(const gfx::Rect& bounds) { 493 void CompositorGL::Blur(const gfx::Rect& bounds) {
489 NOTIMPLEMENTED(); 494 NOTIMPLEMENTED();
490 } 495 }
491 496
492 void CompositorGL::SchedulePaint() { 497 void CompositorGL::SchedulePaint() {
493 // TODO: X doesn't provide coalescing of regions, its left to the toolkit. 498 // TODO(vollick) Remove or ifdef the gdk/gtk code.
494 NOTIMPLEMENTED(); 499 GdkDisplay* display = gdk_display_get_default();
500 GdkWindow* window = gdk_window_lookup_for_display(display, widget_);
501 if (window == NULL)
502 return;
503 gpointer data = NULL;
504 gdk_window_get_user_data(window, &data);
505 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data);
506 if (widget && GTK_IS_WIDGET(widget) && GTK_WIDGET_DRAWABLE(widget))
507 gtk_widget_queue_draw_area(widget, 0, 0, size_.width(), size_.height());
495 } 508 }
496 509
497 void CompositorGL::OnWidgetSizeChanged(const gfx::Size& size) { 510 void CompositorGL::OnWidgetSizeChanged(const gfx::Size& size) {
498 size_ = size; 511 size_ = size;
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 // The following line of code exists soley to disable IO restrictions 517 // The following line of code exists soley to disable IO restrictions
505 // on this thread long enough to perform the GL bindings. 518 // on this thread long enough to perform the GL bindings.
506 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. 519 // TODO(wjmaclean) Remove this when GL initialisation cleaned up.
507 base::ThreadRestrictions::ScopedAllowIO allow_io; 520 base::ThreadRestrictions::ScopedAllowIO allow_io;
508 if (gfx::GLSurface::InitializeOneOff() && 521 if (gfx::GLSurface::InitializeOneOff() &&
509 gfx::GetGLImplementation() != gfx::kGLImplementationNone) 522 gfx::GetGLImplementation() != gfx::kGLImplementationNone)
510 return new CompositorGL(widget, size); 523 return new CompositorGL(widget, size);
511 return NULL; 524 return NULL;
512 } 525 }
513 526
514 } // namespace ui 527 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698