Bug 881460 - Drawing color of CrystallSkull is not correct in master. r=vlad, r=nrc

This commit is contained in:
Peter Chang 2013-06-11 18:14:33 +08:00
Родитель 69879c8fd4
Коммит 2873f7a1dd
5 изменённых файлов: 44 добавлений и 10 удалений

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

@ -66,7 +66,9 @@ enum MaskType {
// by other surfaces we will need a more generic LayerRenderState.
enum LayerRenderStateFlags {
LAYER_RENDER_STATE_Y_FLIPPED = 1 << 0,
LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1
LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1,
// Notify Composer2D to swap the RB pixels of gralloc buffer
LAYER_RENDER_STATE_FORMAT_RB_SWAP = 1 << 2
};
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
@ -93,6 +95,9 @@ struct LayerRenderState {
bool BufferRotated() const
{ return mFlags & LAYER_RENDER_STATE_BUFFER_ROTATION; }
bool FormatRBSwapped() const
{ return mFlags & LAYER_RENDER_STATE_FORMAT_RB_SWAP; }
#endif
void SetOffset(const nsIntPoint& aOffset)

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

@ -81,8 +81,9 @@ public:
{
LayerRenderState result = mTextureHost->GetRenderState();
result.mFlags = (mBufferRotation != nsIntPoint()) ?
LAYER_RENDER_STATE_BUFFER_ROTATION : 0;
if (mBufferRotation != nsIntPoint()) {
result.mFlags |= LAYER_RENDER_STATE_BUFFER_ROTATION;
}
result.SetOffset(GetOriginOffset());
return result;
}

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

@ -709,6 +709,7 @@ GrallocTextureHostOGL::GrallocTextureHostOGL()
: mCompositor(nullptr)
, mTextureTarget(0)
, mEGLImage(0)
, mIsRBSwapped(false)
{
}
@ -762,8 +763,10 @@ GrallocTextureHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
const SurfaceDescriptorGralloc& desc = aImage.get_SurfaceDescriptorGralloc();
mGraphicBuffer = GrallocBufferActor::GetFrom(desc);
mIsRBSwapped = desc.isRBSwapped();
mFormat = SurfaceFormatForAndroidPixelFormat(mGraphicBuffer->getPixelFormat(),
desc.isRBSwapped());
mIsRBSwapped);
mTextureTarget = TextureTargetForAndroidPixelFormat(mGraphicBuffer->getPixelFormat());
DeleteTextures();
@ -860,9 +863,25 @@ LayerRenderState
GrallocTextureHostOGL::GetRenderState()
{
if (mBuffer && IsSurfaceDescriptorValid(*mBuffer)) {
uint32_t flags = mFlags & NeedsYFlip ? LAYER_RENDER_STATE_Y_FLIPPED : 0;
/*
* The 32 bit format of gralloc buffer is created as RGBA8888 or RGBX888 by default.
* For software rendering (non-GL rendering), the content is drawn with BGRA
* or BGRX. Therefore, we need to pass the RBSwapped flag for HW composer to swap format.
*
* For GL rendering content, the content format is RGBA or RGBX which is the same as
* the pixel format of gralloc buffer and no need for the RBSwapped flag.
*/
if (mIsRBSwapped) {
flags |= LAYER_RENDER_STATE_FORMAT_RB_SWAP;
}
return LayerRenderState(mGraphicBuffer.get(),
mBuffer->get_SurfaceDescriptorGralloc().size(),
mFlags & NeedsYFlip ? LAYER_RENDER_STATE_Y_FLIPPED : 0);
flags);
}
return LayerRenderState();

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

@ -652,6 +652,8 @@ private:
android::sp<android::GraphicBuffer> mGraphicBuffer;
GLenum mTextureTarget;
EGLImage mEGLImage;
//Set when the composer needs to swap RB pixels of gralloc buffer
bool mIsRBSwapped;
};
#endif

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

@ -53,7 +53,10 @@ enum {
// Draw a solid color rectangle
// The color should be set on the transform member of the hwc_layer_t struct
// The expected format is a 32 bit ABGR with 8 bits per component
HWC_COLOR_FILL = 0x8
HWC_COLOR_FILL = 0x8,
// Swap the RB pixels of gralloc buffer, like RGBA<->BGRA or RGBX<->BGRX
// The flag will be set inside LayerRenderState
HWC_FORMAT_RB_SWAP = 0x40
};
namespace mozilla {
@ -302,7 +305,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
float opacity = aLayer->GetEffectiveOpacity();
if (opacity < 1) {
LOGD("Layer has planar semitransparency which is unsupported");
LOGD("%s Layer has planar semitransparency which is unsupported", aLayer->Name());
return false;
}
@ -312,7 +315,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
aClip,
&clip))
{
LOGD("Clip rect is empty. Skip layer");
LOGD("%s Clip rect is empty. Skip layer", aLayer->Name());
return true;
}
@ -349,12 +352,12 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
if (aLayer->AsColorLayer() && mColorFill) {
fillColor = true;
} else {
LOGD("Layer doesn't have a gralloc buffer");
LOGD("%s Layer doesn't have a gralloc buffer", aLayer->Name());
return false;
}
}
if (state.BufferRotated()) {
LOGD("Layer has a rotated buffer");
LOGD("%s Layer has a rotated buffer", aLayer->Name());
return false;
}
@ -405,6 +408,10 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
hwcLayer.compositionType = HWC_USE_COPYBIT;
if (!fillColor) {
if (state.FormatRBSwapped()) {
hwcLayer.flags |= HWC_FORMAT_RB_SWAP;
}
gfxMatrix rotation = transform * aGLWorldTransform;
// Compute fuzzy equal like PreservesAxisAlignedRectangles()
if (fabs(rotation.xx) < 1e-6) {