diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 20f8ca6bd8c7..9ff59c9d7d5d 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -246,7 +246,7 @@ GLContextEGL::GLContextEGL( mHwc = HwcComposer2D::GetInstance(); MOZ_ASSERT(!mHwc->Initialized()); - if (mHwc->Init(EGL_DISPLAY(), mSurface)) { + if (mHwc->Init(EGL_DISPLAY(), mSurface, this)) { NS_WARNING("HWComposer initialization failed!"); mHwc = nullptr; } diff --git a/widget/gonk/HwcComposer2D.cpp b/widget/gonk/HwcComposer2D.cpp index b984499499aa..b2a83141f548 100644 --- a/widget/gonk/HwcComposer2D.cpp +++ b/widget/gonk/HwcComposer2D.cpp @@ -69,6 +69,7 @@ static StaticRefPtr sInstance; HwcComposer2D::HwcComposer2D() : mHwc(nullptr) , mList(nullptr) + , mGLContext(nullptr) , mMaxLayerCount(0) , mColorFill(false) , mRBSwapSupport(false) @@ -85,7 +86,7 @@ HwcComposer2D::~HwcComposer2D() { } int -HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur) +HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur, gl::GLContext* aGLContext) { MOZ_ASSERT(!Initialized()); @@ -123,6 +124,7 @@ HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur) mDpy = dpy; mSur = sur; + mGLContext = aGLContext; return 0; } @@ -583,6 +585,13 @@ HwcComposer2D::TryHwComposition() // GPU or partial OVERLAY Composition return false; } else if (blitComposite) { + // Some EGLSurface implementations require glClear() on blit composition. + // See bug 1029856. + if (mGLContext) { + mGLContext->MakeCurrent(); + mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0); + mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT); + } // BLIT Composition, flip FB target GetGonkDisplay()->UpdateFBSurface(mDpy, mSur); FramebufferSurface* fbsurface = (FramebufferSurface*)(GetGonkDisplay()->GetFBSurface()); diff --git a/widget/gonk/HwcComposer2D.h b/widget/gonk/HwcComposer2D.h index 825124f5caaf..927004f5556f 100644 --- a/widget/gonk/HwcComposer2D.h +++ b/widget/gonk/HwcComposer2D.h @@ -29,6 +29,10 @@ namespace mozilla { +namespace gl { + class GLContext; +} + namespace layers { class ContainerLayer; class Layer; @@ -69,7 +73,7 @@ public: HwcComposer2D(); virtual ~HwcComposer2D(); - int Init(hwc_display_t aDisplay, hwc_surface_t aSurface); + int Init(hwc_display_t aDisplay, hwc_surface_t aSurface, gl::GLContext* aGLContext); bool Initialized() const { return mHwc; } @@ -98,6 +102,7 @@ private: HwcList* mList; hwc_display_t mDpy; hwc_surface_t mSur; + gl::GLContext* mGLContext; nsIntRect mScreenRect; int mMaxLayerCount; bool mColorFill;