Bug 810501: Get buffer offset from ThebesLayer when composing with hwc. r=cjones a=blocking-basecamp

This commit is contained in:
Diego Wilson 2013-01-10 11:51:43 +01:00
parent 96040234fe
commit 0e864b60c7
3 changed files with 33 additions and 20 deletions

View File

@ -10,6 +10,7 @@
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/TimeStamp.h"
#include "nsPoint.h"
#ifdef XP_WIN
#include <windows.h>
@ -435,12 +436,20 @@ enum LayerRenderStateFlags {
};
struct LayerRenderState {
LayerRenderState() : mSurface(nullptr), mFlags(0)
LayerRenderState() : mSurface(nullptr), mFlags(0), mHasOwnOffset(false)
{}
LayerRenderState(SurfaceDescriptor* aSurface, uint32_t aFlags = 0)
: mSurface(aSurface)
, mFlags(aFlags)
, mHasOwnOffset(false)
{}
LayerRenderState(SurfaceDescriptor* aSurface, nsIntPoint aOffset, uint32_t aFlags = 0)
: mSurface(aSurface)
, mFlags(aFlags)
, mOffset(aOffset)
, mHasOwnOffset(true)
{}
bool YFlipped() const
@ -451,6 +460,8 @@ struct LayerRenderState {
SurfaceDescriptor* mSurface;
uint32_t mFlags;
nsIntPoint mOffset;
bool mHasOwnOffset;
};
/**

View File

@ -98,8 +98,8 @@ public:
bool Initialised() { return mInitialised; }
protected:
virtual nsIntPoint GetOriginOffset() = 0;
protected:
GLContext* gl() const { return mOGLLayer->gl(); }
@ -343,7 +343,6 @@ public:
return mTexImage ? mTexImage->GetBackingSurface() : nullptr;
}
protected:
virtual nsIntPoint GetOriginOffset() {
return BufferRect().TopLeft() - BufferRotation();
}
@ -366,6 +365,10 @@ public:
virtual PaintState BeginPaint(ContentType aContentType,
uint32_t aFlags);
virtual nsIntPoint GetOriginOffset() {
return mBufferRect.TopLeft() - mBufferRotation;
}
protected:
enum XSide {
@ -376,10 +379,6 @@ protected:
};
nsIntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide);
virtual nsIntPoint GetOriginOffset() {
return mBufferRect.TopLeft() - mBufferRotation;
}
private:
nsIntRect mBufferRect;
nsIntPoint mBufferRotation;
@ -947,7 +946,6 @@ public:
return mBufferRotation;
}
protected:
virtual nsIntPoint GetOriginOffset() {
return mBufferRect.TopLeft() - mBufferRotation;
}
@ -1156,7 +1154,7 @@ ShadowThebesLayerOGL::GetRenderState()
}
uint32_t flags = (mBuffer->Rotation() != nsIntPoint()) ?
LAYER_RENDER_STATE_BUFFER_ROTATION : 0;
return LayerRenderState(&mBufferDescriptor, flags);
return LayerRenderState(&mBufferDescriptor, mBuffer->GetOriginOffset(), flags);
}
bool

View File

@ -174,13 +174,13 @@ HwcComposer2D::GetRotation()
* Sets hwc layer rectangles required for hwc composition
*
* @param aVisible Input. Layer's unclipped visible rectangle
* The origin is the layer's buffer
* The origin is the top-left corner of the layer
* @param aTransform Input. Layer's transformation matrix
* It transforms from layer space to screen space
* @param aClip Input. A clipping rectangle.
* The origin is the top-left corner of the screen
* @param aBufferRect Input. The layer's buffer bounds
* The origin is the buffer itself and hence always (0,0)
* The origin is the top-left corner of the layer
* @param aSurceCrop Output. Area of the source to consider,
* the origin is the top-left corner of the buffer
* @param aVisibleRegionScreen Output. Visible region in screen space.
@ -207,9 +207,7 @@ PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
gfxMatrix inverse(aTransform);
inverse.Invert();
gfxRect crop = inverse.TransformBounds(visibleRectScreen);
// Map to buffer space
crop -= visibleRect.TopLeft();
gfxRect bufferRect(aBufferRect);
//clip to buffer size
crop.IntersectRect(crop, aBufferRect);
crop.RoundOut();
@ -219,11 +217,13 @@ PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
return false;
}
//propagate buffer clipping back to visible rect
visibleRectScreen = aTransform.TransformBounds(crop + visibleRect.TopLeft());
visibleRectScreen = aTransform.TransformBounds(crop);
visibleRectScreen.RoundOut();
// Map from layer space to buffer space
crop -= aBufferRect.TopLeft();
aSourceCrop->left = crop.x;
aSourceCrop->top = crop.y;
aSourceCrop->right = crop.x + crop.width;
@ -326,11 +326,15 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
nsIntRect bufferRect;
if (fillColor) {
bufferRect = nsIntRect(0, 0, visibleRect.width,
visibleRect.height);
bufferRect = nsIntRect(visibleRect);
} else {
bufferRect = nsIntRect(0, 0, int(buffer->getWidth()),
int(buffer->getHeight()));
if(state.mHasOwnOffset) {
bufferRect = nsIntRect(state.mOffset.x, state.mOffset.y,
int(buffer->getWidth()), int(buffer->getHeight()));
} else {
bufferRect = nsIntRect(visibleRect.x, visibleRect.y,
int(buffer->getWidth()), int(buffer->getHeight()));
}
}
hwc_layer_t& hwcLayer = mList->hwLayers[current];