OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/gpu/media/rendering_helper.h" | 5 #include "content/common/gpu/media/rendering_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/stringize_macros.h" | 10 #include "base/strings/stringize_macros.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 glUniform1i(glGetUniformLocation(program_, "tex_flip"), 0); | 464 glUniform1i(glGetUniformLocation(program_, "tex_flip"), 0); |
465 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); | 465 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); |
466 GLSetViewPort(area); | 466 GLSetViewPort(area); |
467 RenderTexture(texture_target, texture_id); | 467 RenderTexture(texture_target, texture_id); |
468 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); | 468 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
469 ++frame_count_; | 469 ++frame_count_; |
470 } | 470 } |
471 | 471 |
472 void RenderingHelper::RenderTexture(uint32 texture_target, uint32 texture_id) { | 472 void RenderingHelper::RenderTexture(uint32 texture_target, uint32 texture_id) { |
473 // Unbound texture samplers default to (0, 0, 0, 1). Use this fact to switch | 473 // The ExternalOES sampler is bound to GL_TEXTURE1 and the Texture2D sampler |
474 // between GL_TEXTURE_2D and GL_TEXTURE_EXTERNAL_OES as appopriate. | 474 // is bound to GL_TEXTURE0. |
475 if (texture_target == GL_TEXTURE_2D) { | 475 if (texture_target == GL_TEXTURE_2D) { |
476 glActiveTexture(GL_TEXTURE0 + 0); | 476 glActiveTexture(GL_TEXTURE0 + 0); |
477 glBindTexture(GL_TEXTURE_2D, texture_id); | 477 } else if (texture_target == GL_TEXTURE_EXTERNAL_OES) { |
478 glActiveTexture(GL_TEXTURE0 + 1); | 478 glActiveTexture(GL_TEXTURE0 + 1); |
479 glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); | |
480 } else if (texture_target == GL_TEXTURE_EXTERNAL_OES) { | |
481 glActiveTexture(GL_TEXTURE0 + 0); | |
482 glBindTexture(GL_TEXTURE_2D, 0); | |
483 glActiveTexture(GL_TEXTURE0 + 1); | |
484 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id); | |
485 } | 479 } |
486 | 480 glBindTexture(texture_target, texture_id); |
487 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 481 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
| 482 glBindTexture(texture_target, 0); |
488 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 483 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
489 } | 484 } |
490 | 485 |
491 void RenderingHelper::DeleteTexture(uint32 texture_id) { | 486 void RenderingHelper::DeleteTexture(uint32 texture_id) { |
492 glDeleteTextures(1, &texture_id); | 487 glDeleteTextures(1, &texture_id); |
493 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 488 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
494 } | 489 } |
495 | 490 |
496 NativeContextType RenderingHelper::GetGLContext() { return gl_context_; } | 491 NativeContextType RenderingHelper::GetGLContext() { return gl_context_; } |
497 | 492 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 } | 583 } |
589 | 584 |
590 #if GL_VARIANT_GLX | 585 #if GL_VARIANT_GLX |
591 glXSwapBuffers(x_display_, x_window_); | 586 glXSwapBuffers(x_display_, x_window_); |
592 #else // EGL | 587 #else // EGL |
593 eglSwapBuffers(gl_display_, gl_surface_); | 588 eglSwapBuffers(gl_display_, gl_surface_); |
594 CHECK_EQ(static_cast<int>(eglGetError()), EGL_SUCCESS); | 589 CHECK_EQ(static_cast<int>(eglGetError()), EGL_SUCCESS); |
595 #endif | 590 #endif |
596 } | 591 } |
597 } // namespace content | 592 } // namespace content |
OLD | NEW |