зеркало из https://github.com/mozilla/gecko-dev.git
Bug 640082 - Part 3 - Add BindTexture functions to TextureImage. r=joe
This commit is contained in:
Родитель
30b3523f5d
Коммит
28ec02dbae
|
@ -210,14 +210,8 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
|
|||
}
|
||||
|
||||
// Bind textures.
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexImage->Texture());
|
||||
|
||||
if (mTexImageOnWhite) {
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE1);
|
||||
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexImageOnWhite->Texture());
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
}
|
||||
TextureImage::ScopedBindTexture(mTexImage, LOCAL_GL_TEXTURE0);
|
||||
TextureImage::ScopedBindTexture(mTexImageOnWhite, LOCAL_GL_TEXTURE1);
|
||||
|
||||
float xres = mLayer->GetXResolution();
|
||||
float yres = mLayer->GetYResolution();
|
||||
|
@ -295,7 +289,7 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
|
|||
// Restore defaults
|
||||
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -629,6 +629,14 @@ BasicTextureImage::EndUpdate()
|
|||
mTextureState = Valid;
|
||||
}
|
||||
|
||||
void
|
||||
BasicTextureImage::BindTexture(GLenum aTextureUnit)
|
||||
{
|
||||
mGLContext->fActiveTexture(aTextureUnit);
|
||||
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, Texture());
|
||||
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
BasicTextureImage::GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt)
|
||||
{
|
||||
|
|
|
@ -205,6 +205,31 @@ public:
|
|||
|
||||
virtual bool DirectUpdate(gfxASurface *aSurf, const nsIntRegion& aRegion) =0;
|
||||
|
||||
virtual void BindTexture(GLenum aTextureUnit) = 0;
|
||||
virtual void ReleaseTexture() {};
|
||||
|
||||
class ScopedBindTexture
|
||||
{
|
||||
public:
|
||||
ScopedBindTexture(TextureImage *aTexture, GLenum aTextureUnit) :
|
||||
mTexture(aTexture)
|
||||
{
|
||||
if (mTexture) {
|
||||
mTexture->BindTexture(aTextureUnit);
|
||||
}
|
||||
}
|
||||
|
||||
~ScopedBindTexture()
|
||||
{
|
||||
if (mTexture) {
|
||||
mTexture->ReleaseTexture();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
TextureImage *mTexture;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return this TextureImage's texture ID for use with GL APIs.
|
||||
* Callers are responsible for properly binding the texture etc.
|
||||
|
@ -302,6 +327,8 @@ public:
|
|||
Initialized, // Texture memory exists, but contents are invalid.
|
||||
Valid // Texture fully ready to use.
|
||||
};
|
||||
|
||||
virtual void BindTexture(GLenum aTextureUnit);
|
||||
|
||||
virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
|
||||
virtual void EndUpdate();
|
||||
|
|
|
@ -1266,6 +1266,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual void BindTexture(GLenum aTextureUnit)
|
||||
{
|
||||
mGLContext->fActiveTexture(aTextureUnit);
|
||||
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, Texture());
|
||||
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
}
|
||||
|
||||
virtual PRBool InUpdate() const { return !!mUpdateSurface; }
|
||||
|
||||
virtual void Resize(const nsIntSize& aSize)
|
||||
|
|
Загрузка…
Ссылка в новой задаче