Bug 953303 - HwcComposer2D should honor HWC_HINT_CLEAR_FB set by hwcomposer. r=ncameron

This commit is contained in:
Sushil Chauhan 2014-01-17 18:55:30 -08:00
parent 2b7046acaa
commit 0c00df9f0d
7 changed files with 43 additions and 0 deletions

View File

@ -304,6 +304,11 @@ public:
gfx::Float aOpacity, const gfx::Matrix4x4 &aTransform)
{ /* Should turn into pure virtual once implemented in D3D */ }
/*
* Clear aRect on FrameBuffer.
*/
virtual void clearFBRect(const gfx::Rect* aRect) { }
/**
* Start a new frame.
*

View File

@ -318,6 +318,12 @@ ContainerRender(ContainerT* aContainer,
// Composer2D will compose this layer so skip GPU composition
// this time & reset composition flag for next composition phase
layerToRender->SetLayerComposited(false);
if (layerToRender->GetClearFB()) {
// Clear layer's visible rect on FrameBuffer with transparent pixels
gfx::Rect aRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
compositor->clearFBRect(&aRect);
layerToRender->SetClearFB(false);
}
} else {
layerToRender->RenderLayer(clipRect);
}

View File

@ -764,6 +764,7 @@ LayerComposite::LayerComposite(LayerManagerComposite *aManager)
, mShadowTransformSetByAnimation(false)
, mDestroyed(false)
, mLayerComposited(false)
, mClearFB(false)
{ }
LayerComposite::~LayerComposite()

View File

@ -358,6 +358,11 @@ public:
mLayerComposited = value;
}
void SetClearFB(bool value)
{
mClearFB = value;
}
// These getters can be used anytime.
float GetShadowOpacity() { return mShadowOpacity; }
const nsIntRect* GetShadowClipRect() { return mUseShadowClipRect ? &mShadowClipRect : nullptr; }
@ -365,6 +370,7 @@ public:
const gfx3DMatrix& GetShadowTransform() { return mShadowTransform; }
bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; }
bool HasLayerBeenComposited() { return mLayerComposited; }
bool GetClearFB() { return mClearFB; }
protected:
gfx3DMatrix mShadowTransform;
@ -377,6 +383,7 @@ protected:
bool mShadowTransformSetByAnimation;
bool mDestroyed;
bool mLayerComposited;
bool mClearFB;
};

View File

@ -767,6 +767,18 @@ CalculatePOTSize(const IntSize& aSize, GLContext* gl)
return IntSize(NextPowerOfTwo(aSize.width), NextPowerOfTwo(aSize.height));
}
void
CompositorOGL::clearFBRect(const gfx::Rect* aRect)
{
if (!aRect) {
return;
}
ScopedScissorRect autoScissorRect(mGLContext, aRect->x, aRect->y, aRect->width, aRect->height);
mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
}
void
CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
const Rect *aClipRectIn,

View File

@ -252,6 +252,11 @@ private:
*/
bool mFrameInProgress;
/*
* Clear aRect on FrameBuffer.
*/
virtual void clearFBRect(const gfx::Rect* aRect);
/* Start a new frame. If aClipRectIn is null and aClipRectOut is non-null,
* sets *aClipRectOut to the screen dimensions.
*/

View File

@ -507,6 +507,13 @@ HwcComposer2D::TryHwComposition()
// Overlay Composition, set layer composition flag
// on mapped LayerComposite to skip GPU composition
mHwcLayerMap[k]->SetLayerComposited(true);
if (k && (mList->hwLayers[k].hints & HWC_HINT_CLEAR_FB) &&
(mList->hwLayers[k].blending == HWC_BLENDING_NONE)) {
// Clear visible rect on FB with transparent pixels.
// Never clear the 1st layer since we're guaranteed
// that FB is already cleared.
mHwcLayerMap[k]->SetClearFB(true);
}
break;
default:
break;