Commit c30b19f8 authored by owenlin@chromium.org's avatar owenlin@chromium.org

The program crashed if the platform didn't support GL_TEXTURE_EXTERNAL_OES at all.

Since only one of GL_TEXTURE_2D and GL_TEXTURE_EXTERNAL_OES would be used. Switch active texture according to the target type and unbound the texture after use.
    
BUG=chromium:383414
TEST=Run the unittest on link and peach-pit

Review URL: https://codereview.chromium.org/324253005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277977 0039d316-1c4b-4281-b951-d872f2087c98
parent 04e35188
...@@ -457,21 +457,16 @@ void RenderingHelper::RenderThumbnail(uint32 texture_target, ...@@ -457,21 +457,16 @@ void RenderingHelper::RenderThumbnail(uint32 texture_target,
} }
void RenderingHelper::RenderTexture(uint32 texture_target, uint32 texture_id) { void RenderingHelper::RenderTexture(uint32 texture_target, uint32 texture_id) {
// Unbound texture samplers default to (0, 0, 0, 1). Use this fact to switch // The ExternalOES sampler is bound to GL_TEXTURE1 and the Texture2D sampler
// between GL_TEXTURE_2D and GL_TEXTURE_EXTERNAL_OES as appopriate. // is bound to GL_TEXTURE0.
if (texture_target == GL_TEXTURE_2D) { if (texture_target == GL_TEXTURE_2D) {
glActiveTexture(GL_TEXTURE0 + 0); glActiveTexture(GL_TEXTURE0 + 0);
glBindTexture(GL_TEXTURE_2D, texture_id);
glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
} else if (texture_target == GL_TEXTURE_EXTERNAL_OES) { } else if (texture_target == GL_TEXTURE_EXTERNAL_OES) {
glActiveTexture(GL_TEXTURE0 + 0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0 + 1); glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
} }
glBindTexture(texture_target, texture_id);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindTexture(texture_target, 0);
CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment