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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 329 GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 void TextureGL::Draw(const ui::TextureDrawParams& params) { | 333 void TextureGL::Draw(const ui::TextureDrawParams& params) { |
| 334 DCHECK(compositor_->program_swizzle()); | 334 DCHECK(compositor_->program_swizzle()); |
| 335 Draw(params, gfx::Rect(0, 0, size_.width(), size_.height())); | 335 Draw(params, gfx::Rect(0, 0, size_.width(), size_.height())); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void TextureGL::Draw(const ui::TextureDrawParams& params, | 338 void TextureGL::Draw(const ui::TextureDrawParams& params, |
| 339 const gfx::Rect& clip_bounds) { | 339 const gfx::Rect& clip_bounds_in_texture) { |
| 340 DCHECK(compositor_->program_swizzle()); | 340 DCHECK(compositor_->program_swizzle()); |
| 341 DrawInternal(*compositor_->program_swizzle(), params, clip_bounds); | 341 DrawInternal(*compositor_->program_swizzle(), params, clip_bounds_in_texture); |
| 342 } | 342 } |
| 343 void TextureGL::DrawInternal(const ui::TextureProgramGL& program, | 343 void TextureGL::DrawInternal(const ui::TextureProgramGL& program, |
| 344 const ui::TextureDrawParams& params, | 344 const ui::TextureDrawParams& params, |
| 345 const gfx::Rect& clip_bounds) { | 345 const gfx::Rect& clip_bounds_in_texture) { |
| 346 // clip clip_bounds_in_layer to size of texture | |
|
sky
2011/08/17 15:53:57
-> Clip clip_bounds_in_texture to current size.
| |
| 347 gfx::Rect clip_bounds = clip_bounds_in_texture.Intersect( | |
| 348 gfx::Rect(gfx::Point(0, 0), size_)); | |
| 349 | |
| 346 if (params.blend) | 350 if (params.blend) |
| 347 glEnable(GL_BLEND); | 351 glEnable(GL_BLEND); |
| 348 else | 352 else |
| 349 glDisable(GL_BLEND); | 353 glDisable(GL_BLEND); |
| 350 | 354 |
| 351 program.Use(); | 355 program.Use(); |
| 352 | 356 |
| 353 glActiveTexture(GL_TEXTURE0); | 357 glActiveTexture(GL_TEXTURE0); |
| 354 glUniform1i(program.u_tex_loc(), 0); | 358 glUniform1i(program.u_tex_loc(), 0); |
| 355 glBindTexture(GL_TEXTURE_2D, texture_id_); | 359 glBindTexture(GL_TEXTURE_2D, texture_id_); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 // on this thread long enough to perform the GL bindings. | 503 // on this thread long enough to perform the GL bindings. |
| 500 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. | 504 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. |
| 501 base::ThreadRestrictions::ScopedAllowIO allow_io; | 505 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 502 if (gfx::GLSurface::InitializeOneOff() && | 506 if (gfx::GLSurface::InitializeOneOff() && |
| 503 gfx::GetGLImplementation() != gfx::kGLImplementationNone) | 507 gfx::GetGLImplementation() != gfx::kGLImplementationNone) |
| 504 return new CompositorGL(widget, size); | 508 return new CompositorGL(widget, size); |
| 505 return NULL; | 509 return NULL; |
| 506 } | 510 } |
| 507 | 511 |
| 508 } // namespace ui | 512 } // namespace ui |
| OLD | NEW |