Bug 916116 - Avoid some code duplication in Gralloc textures. r=sotaro

This commit is contained in:
Nicolas Silva 2013-09-17 15:29:19 +02:00
Родитель 5105ebac1e
Коммит fbfc359172
4 изменённых файлов: 25 добавлений и 12 удалений

Просмотреть файл

@ -117,8 +117,7 @@ void GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit)
MOZ_ASSERT(gl());
gl()->MakeCurrent();
mQuirks->SetCompositor(mCompositor);
GLuint tex = static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
GLuint tex = GetGLTexture();
GLuint textureTarget = GetTextureTarget();
gl()->fActiveTexture(aTextureUnit);
@ -179,8 +178,7 @@ GrallocTextureSourceOGL::SetCompositableQuirks(CompositableQuirks* aQuirks)
DeallocateDeviceData();
gl()->MakeCurrent();
mQuirks->SetCompositor(mCompositor);
GLuint tex = static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
GLuint tex = GetGLTexture();
GLuint textureTarget = GetTextureTarget();
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
@ -310,8 +308,7 @@ GrallocTextureSourceOGL::GetAsSurface() {
MOZ_ASSERT(gl());
gl()->MakeCurrent();
mQuirks->SetCompositor(mCompositor);
GLuint tex = static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
GLuint tex = GetGLTexture();
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(GetTextureTarget(), tex);
if (!mEGLImage) {
@ -326,6 +323,13 @@ GrallocTextureSourceOGL::GetAsSurface() {
return surf.forget();
}
GLuint
GrallocTextureSourceOGL::GetGLTexture()
{
mQuirks->SetCompositor(mCompositor);
return static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
}
void
GrallocTextureHostOGL::SetCompositableQuirks(CompositableQuirks* aQuirks)
{

Просмотреть файл

@ -62,6 +62,8 @@ public:
already_AddRefed<gfxImageSurface> GetAsSurface();
GLuint GetGLTexture();
protected:
CompositorOGL* mCompositor;
android::sp<android::GraphicBuffer> mGraphicBuffer;

Просмотреть файл

@ -1123,8 +1123,7 @@ GrallocDeprecatedTextureHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImag
mIsRBSwapped);
mTextureTarget = TextureTargetForAndroidPixelFormat(mGraphicBuffer->getPixelFormat());
mQuirks->SetCompositor(mCompositor);
GLuint tex = static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
GLuint tex = GetGLTexture();
// delete old EGLImage
DeleteTextures();
@ -1162,8 +1161,7 @@ void GrallocDeprecatedTextureHostOGL::BindTexture(GLenum aTextureUnit)
MOZ_ASSERT(gl());
gl()->MakeCurrent();
mQuirks->SetCompositor(mCompositor);
GLuint tex = static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
GLuint tex = GetGLTexture();
gl()->fActiveTexture(aTextureUnit);
gl()->fBindTexture(mTextureTarget, tex);
@ -1242,6 +1240,14 @@ GrallocDeprecatedTextureHostOGL::GetRenderState()
return LayerRenderState();
}
GLuint
GrallocDeprecatedTextureHostOGL::GetGLTexture()
{
mQuirks->SetCompositor(mCompositor);
return static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
}
#endif // MOZ_WIDGET_GONK
already_AddRefed<gfxImageSurface>
@ -1299,8 +1305,7 @@ already_AddRefed<gfxImageSurface>
GrallocDeprecatedTextureHostOGL::GetAsSurface() {
gl()->MakeCurrent();
mQuirks->SetCompositor(mCompositor);
GLuint tex = static_cast<CompositableQuirksGonkOGL*>(mQuirks.get())->GetTexture();
GLuint tex = GetGLTexture();
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(mTextureTarget, tex);
if (!mEGLImage) {

Просмотреть файл

@ -920,6 +920,8 @@ public:
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
GLuint GetGLTexture();
private:
gl::GLContext* gl() const;