Commit ae6d39b6 authored by Kevin Chen's avatar Kevin Chen
Browse files

Bug 1361574 - Restore texture after creating the video texture; r=sotaro

MozReview-Commit-ID: 1XAPVwW8zv3

--HG--
extra : rebase_source : ee6358a3d7a262281bcd1e4049509c44646428a9
parent e8fed618
Loading
Loading
Loading
Loading
+41 −37
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@
#ifdef USE_SKIA
#include "SurfaceTypes.h"
#include "GLBlitHelper.h"
#include "ScopedGLHelpers.h"
#endif

using mozilla::gl::GLContext;
@@ -5232,13 +5233,14 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
      return;
    }

    {
      gl->MakeCurrent();
      GLuint videoTexture = 0;
      gl->fGenTextures(1, &videoTexture);
      // skiaGL expect upload on drawing, and uses texture 0 for texturing,
      // so we must active texture 0 and bind the texture for it.
      gl->fActiveTexture(LOCAL_GL_TEXTURE0);
    gl->fBindTexture(LOCAL_GL_TEXTURE_2D, videoTexture);
      const gl::ScopedBindTexture scopeBindTexture(gl, videoTexture);

      gl->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGB, srcImage->GetSize().width, srcImage->GetSize().height, 0, LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_SHORT_5_6_5, nullptr);
      gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
@@ -5272,6 +5274,8 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
      } else {
        gl->fDeleteTextures(1, &videoTexture);
      }
    }

    srcImage = nullptr;

    if (mCanvasElement) {