Bug 1064479. Redo how screen rotation is implemented on B2G/Layers. r=nical,mwoodrow

Currently we use a world transform on the LayerManager. This gets passed to the
screen render target which adjusts the gl transform to accomplish the rotation.
This causes a lot of the system to have to know about the transform.

Instead we can just bake the transform into the root layer's shadow transform.
Everything now mostly just works.

--HG--
extra : rebase_source : e0e170d191eef5887a2e6b17f71ac79037033006
This commit is contained in:
Jeff Muizelaar 2014-09-10 15:59:00 -04:00
parent c9d8b49279
commit 34032eed5e
30 changed files with 56 additions and 191 deletions

View File

@ -116,32 +116,7 @@ Compositor::ClipRectInLayersCoordinates(Layer* aLayer, RenderTargetIntRect aClip
RenderTargetRect result;
aClip = aClip + renderTargetOffset;
RenderTargetIntSize destSize = RenderTargetIntSize(GetWidgetSize().width,
GetWidgetSize().height);
switch (mScreenRotation) {
case ROTATION_0:
result = RenderTargetRect(aClip.x, aClip.y, aClip.width, aClip.height);
break;
case ROTATION_90:
result = RenderTargetRect(aClip.y,
destSize.width - aClip.x - aClip.width,
aClip.height, aClip.width);
break;
case ROTATION_270:
result = RenderTargetRect(destSize.height - aClip.y - aClip.height,
aClip.x,
aClip.height, aClip.width);
break;
case ROTATION_180:
result = RenderTargetRect(destSize.width - aClip.x - aClip.width,
destSize.height - aClip.y - aClip.height,
aClip.width, aClip.height);
break;
// ScreenRotation has a sentinel value, need to catch it in the switch
// statement otherwise the build fails (-WError)
default: {}
}
result = RenderTargetRect(aClip.x, aClip.y, aClip.width, aClip.height);
return result;
}

View File

@ -342,7 +342,6 @@ public:
*/
virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
const gfx::Rect* aClipRectIn,
const gfx::Matrix& aTransform,
const gfx::Rect& aRenderBounds,
gfx::Rect* aClipRectOut = nullptr,
gfx::Rect* aRenderBoundsOut = nullptr) = 0;
@ -373,11 +372,8 @@ public:
* target, usually the screen. Calling this method prepares the compositor to
* render using a different viewport (that is, size and transform), usually
* associated with a new render target.
* aWorldTransform is the transform from user space to the new viewport's
* coordinate space.
*/
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfx::Matrix& aWorldTransform) = 0;
virtual void PrepareViewport(const gfx::IntSize& aSize) = 0;
/**
* Whether textures created by this compositor can receive partial updates.

View File

@ -631,8 +631,7 @@ Layer::MayResample()
}
RenderTargetIntRect
Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect,
const gfx::Matrix* aWorldTransform)
Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect)
{
ContainerLayer* container = GetParent();
NS_ASSERTION(container, "This can't be called on the root!");
@ -681,15 +680,6 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect,
if (container) {
scissor.MoveBy(-container->GetIntermediateSurfaceRect().TopLeft());
} else if (aWorldTransform) {
gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height);
gfx::Rect trScissor = aWorldTransform->TransformBounds(r);
trScissor.Round();
nsIntRect tmp;
if (!gfxUtils::GfxRectToIntRect(ThebesRect(trScissor), &tmp)) {
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
}
scissor = RenderTargetPixel::FromUntyped(tmp);
}
return currentClip.Intersect(scissor);
}

View File

@ -1392,12 +1392,8 @@ public:
* nearest ancestor that has an intermediate surface, or relative to the root
* viewport if no ancestor has an intermediate surface, corresponding to the
* clip rect for this layer intersected with aCurrentScissorRect.
* If no ancestor has an intermediate surface, the clip rect is transformed
* by aWorldTransform before being combined with aCurrentScissorRect, if
* aWorldTransform is non-null.
*/
RenderTargetIntRect CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect,
const gfx::Matrix* aWorldTransform);
RenderTargetIntRect CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect);
virtual const char* Name() const =0;
virtual LayerType GetType() const =0;

View File

@ -385,7 +385,6 @@ BasicCompositor::ClearRect(const gfx::Rect& aRect)
void
BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
const gfx::Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const gfx::Rect& aRenderBounds,
gfx::Rect *aClipRectOut /* = nullptr */,
gfx::Rect *aRenderBoundsOut /* = nullptr */)

View File

@ -89,7 +89,6 @@ public:
virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
const gfx::Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const gfx::Rect& aRenderBounds,
gfx::Rect *aClipRectOut = nullptr,
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
@ -110,8 +109,7 @@ public:
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) { }
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE { }
virtual void PrepareViewport(const gfx::IntSize& aSize) MOZ_OVERRIDE { }
virtual const char* Name() const { return "Basic"; }

View File

@ -133,9 +133,6 @@ ClientLayerManager::SetDefaultTargetConfiguration(BufferMode aDoubleBuffering,
ScreenRotation aRotation)
{
mTargetRotation = aRotation;
if (mWidget) {
mTargetBounds = mWidget->GetNaturalBounds();
}
}
void
@ -201,10 +198,9 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
hal::GetCurrentScreenConfiguration(&currentConfig);
orientation = currentConfig.orientation();
}
nsIntRect clientBounds;
mWidget->GetClientBounds(clientBounds);
clientBounds.x = clientBounds.y = 0;
mForwarder->BeginTransaction(mTargetBounds, mTargetRotation, clientBounds, orientation);
nsIntRect targetBounds = mWidget->GetNaturalBounds();
targetBounds.x = targetBounds.y = 0;
mForwarder->BeginTransaction(targetBounds, mTargetRotation, orientation);
// If we're drawing on behalf of a context with async pan/zoom
// enabled, then the entire buffer of thebes layers might be

View File

@ -285,9 +285,6 @@ private:
void* aCallbackData,
EndTransactionFlags);
// The bounds of |mTarget| in device pixels.
nsIntRect mTargetBounds;
LayerRefArray mKeepAlive;
nsIWidget* mWidget;

View File

@ -74,7 +74,7 @@ WalkTheTree(Layer* aLayer,
dom::ScreenOrientation chromeOrientation = aTargetConfig.orientation();
dom::ScreenOrientation contentOrientation = state->mTargetConfig.orientation();
if (!IsSameDimension(chromeOrientation, contentOrientation) &&
ContentMightReflowOnOrientationChange(aTargetConfig.clientBounds())) {
ContentMightReflowOnOrientationChange(aTargetConfig.naturalBounds())) {
aReady = false;
}
}
@ -122,9 +122,9 @@ void
AsyncCompositionManager::ComputeRotation()
{
if (!mTargetConfig.naturalBounds().IsEmpty()) {
mLayerManager->SetWorldTransform(
mWorldTransform =
ComputeTransformForRotation(mTargetConfig.naturalBounds(),
mTargetConfig.rotation()));
mTargetConfig.rotation());
}
}
@ -958,6 +958,7 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
return false;
}
// NB: we must sample animations *before* sampling pan/zoom
// transforms.
bool wantNextFrame = SampleAnimations(root, aCurrentFrame);
@ -995,6 +996,13 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
}
}
LayerComposite* rootComposite = root->AsLayerComposite();
gfx::Matrix4x4 trans = rootComposite->GetShadowTransform();
trans *= gfx::Matrix4x4::From2D(mWorldTransform);
rootComposite->SetShadowTransform(trans);
return wantNextFrame;
}

View File

@ -204,6 +204,8 @@ private:
bool mLayersUpdated;
bool mReadyForCompose;
gfx::Matrix mWorldTransform;
};
class MOZ_STACK_CLASS AutoResolveRefLayers {

View File

@ -184,7 +184,7 @@ ContainerPrepare(ContainerT* aContainer,
}
RenderTargetIntRect clipRect = layerToRender->GetLayer()->
CalculateScissorRect(aClipRect, &aManager->GetWorldTransform());
CalculateScissorRect(aClipRect);
if (clipRect.IsEmpty()) {
continue;
}

View File

@ -601,14 +601,14 @@ LayerManagerComposite::Render()
composer2D = mCompositor->GetWidget()->GetComposer2D();
}
if (!mTarget && composer2D && composer2D->TryRender(mRoot, mWorldMatrix, mGeometryChanged)) {
if (!mTarget && composer2D && composer2D->TryRender(mRoot, mGeometryChanged)) {
if (mFPS) {
double fps = mFPS->mCompositionFps.AddFrameAndGetFps(TimeStamp::Now());
if (gfxPrefs::LayersDrawFPS()) {
printf_stderr("HWComposer: FPS is %g\n", fps);
}
}
mCompositor->EndFrameForExternalComposition(mWorldMatrix);
mCompositor->EndFrameForExternalComposition(Matrix());
// Reset the invalid region as compositing is done
mInvalidRegion.SetEmpty();
mLastFrameMissedHWC = false;
@ -643,12 +643,11 @@ LayerManagerComposite::Render()
if (mRoot->GetClipRect()) {
clipRect = *mRoot->GetClipRect();
WorldTransformRect(clipRect);
Rect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
mCompositor->BeginFrame(invalid, &rect, mWorldMatrix, bounds, nullptr, &actualBounds);
mCompositor->BeginFrame(invalid, &rect, bounds, nullptr, &actualBounds);
} else {
gfx::Rect rect;
mCompositor->BeginFrame(invalid, nullptr, mWorldMatrix, bounds, &rect, &actualBounds);
mCompositor->BeginFrame(invalid, nullptr, bounds, &rect, &actualBounds);
clipRect = nsIntRect(rect.x, rect.y, rect.width, rect.height);
}
@ -710,31 +709,6 @@ LayerManagerComposite::Render()
RecordFrame();
}
void
LayerManagerComposite::SetWorldTransform(const gfx::Matrix& aMatrix)
{
NS_ASSERTION(aMatrix.PreservesAxisAlignedRectangles(),
"SetWorldTransform only accepts matrices that satisfy PreservesAxisAlignedRectangles");
NS_ASSERTION(!aMatrix.HasNonIntegerScale(),
"SetWorldTransform only accepts matrices with integer scale");
mWorldMatrix = aMatrix;
}
gfx::Matrix&
LayerManagerComposite::GetWorldTransform(void)
{
return mWorldMatrix;
}
void
LayerManagerComposite::WorldTransformRect(nsIntRect& aRect)
{
gfx::Rect grect(aRect.x, aRect.y, aRect.width, aRect.height);
grect = mWorldMatrix.TransformBounds(grect);
aRect.SetRect(grect.X(), grect.Y(), grect.Width(), grect.Height());
}
static void
SubtractTransformedRegion(nsIntRegion& aRegion,
const nsIntRegion& aRegionToSubtract,

View File

@ -165,19 +165,6 @@ public:
virtual const char* Name() const MOZ_OVERRIDE { return ""; }
enum WorldTransforPolicy {
ApplyWorldTransform,
DontApplyWorldTransform
};
/**
* Setup World transform matrix.
* Transform will be ignored if it is not PreservesAxisAlignedRectangles
* or has non integer scale
*/
void SetWorldTransform(const gfx::Matrix& aMatrix);
gfx::Matrix& GetWorldTransform(void);
/**
* RAII helper class to add a mask effect with the compositable from aMaskLayer
* to the EffectChain aEffect and notify the compositable when we are done.
@ -292,7 +279,6 @@ private:
*/
void RenderDebugOverlay(const gfx::Rect& aBounds);
void WorldTransformRect(nsIntRect& aRect);
RefPtr<CompositingRenderTarget> PushGroupForLayerEffects();
void PopGroupForLayerEffects(RefPtr<CompositingRenderTarget> aPreviousTarget,
@ -313,7 +299,6 @@ private:
RefPtr<gfx::DrawTarget> mTarget;
nsIntRect mTargetBounds;
gfx::Matrix mWorldMatrix;
nsIntRegion mInvalidRegion;
UniquePtr<FPSState> mFPS;

View File

@ -158,7 +158,7 @@ ContainerLayerD3D10::RenderLayer()
}
nsIntRect scissorRect =
RenderTargetPixel::ToUntyped(layerToRender->GetLayer()->CalculateScissorRect(RenderTargetPixel::FromUntyped(oldScissor), nullptr));
RenderTargetPixel::ToUntyped(layerToRender->GetLayer()->CalculateScissorRect(RenderTargetPixel::FromUntyped(oldScissor)));
if (scissorRect.IsEmpty()) {
continue;
}

View File

@ -483,7 +483,7 @@ CompositorD3D11::SetRenderTarget(CompositingRenderTarget* aRenderTarget)
ID3D11RenderTargetView* view = newRT->mRTView;
mCurrentRT = newRT;
mContext->OMSetRenderTargets(1, &view, nullptr);
PrepareViewport(newRT->GetSize(), gfx::Matrix());
PrepareViewport(newRT->GetSize());
}
void
@ -738,7 +738,6 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
void
CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion,
const Rect* aClipRectIn,
const gfx::Matrix& aTransform,
const Rect& aRenderBounds,
Rect* aClipRectOut,
Rect* aRenderBoundsOut)
@ -816,8 +815,7 @@ CompositorD3D11::EndFrame()
}
void
CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
const gfx::Matrix& aWorldTransform)
CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize)
{
D3D11_VIEWPORT viewport;
viewport.MaxDepth = 1.0f;
@ -833,8 +831,6 @@ CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
viewMatrix.PreScale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.PreScale(1.0f, -1.0f);
viewMatrix = aWorldTransform * viewMatrix;
Matrix4x4 projection = Matrix4x4::From2D(viewMatrix);
projection._33 = 0.0f;

View File

@ -100,7 +100,6 @@ public:
*/
virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
const gfx::Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const gfx::Rect& aRenderBounds,
gfx::Rect *aClipRectOut = nullptr,
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
@ -125,8 +124,7 @@ public:
* Setup the viewport and projection matrix for rendering
* to a window of the given dimensions.
*/
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
virtual void PrepareViewport(const gfx::IntSize& aSize) MOZ_OVERRIDE;
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE { return true; }

View File

@ -194,7 +194,7 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget)
RefPtr<CompositingRenderTargetD3D9> oldRT = mCurrentRT;
mCurrentRT = static_cast<CompositingRenderTargetD3D9*>(aRenderTarget);
mCurrentRT->BindRenderTarget(device());
PrepareViewport(mCurrentRT->GetSize(), Matrix());
PrepareViewport(mCurrentRT->GetSize());
}
static DeviceManagerD3D9::ShaderMode
@ -599,7 +599,6 @@ CompositorD3D9::Ready()
void
CompositorD3D9::BeginFrame(const nsIntRegion& aInvalidRegion,
const Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const Rect& aRenderBounds,
Rect *aClipRectOut,
Rect *aRenderBoundsOut)
@ -662,8 +661,7 @@ CompositorD3D9::EndFrame()
}
void
CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize,
const Matrix &aWorldTransform)
CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize)
{
Matrix4x4 viewMatrix;
/*
@ -675,8 +673,6 @@ CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize,
viewMatrix._41 = -1.0f;
viewMatrix._42 = 1.0f;
viewMatrix = Matrix4x4::From2D(aWorldTransform) * viewMatrix;
HRESULT hr = device()->SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4);
if (FAILED(hr)) {

View File

@ -61,7 +61,6 @@ public:
virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
const gfx::Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const gfx::Rect& aRenderBounds,
gfx::Rect *aClipRectOut = nullptr,
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
@ -72,8 +71,7 @@ public:
virtual void AbortFrame() MOZ_OVERRIDE {}
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
virtual void PrepareViewport(const gfx::IntSize& aSize) MOZ_OVERRIDE;
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE{ return true; }

View File

@ -161,7 +161,7 @@ ContainerLayerD3D9::RenderLayer()
}
nsIntRect scissorRect =
RenderTargetPixel::ToUntyped(layerToRender->GetLayer()->CalculateScissorRect(RenderTargetPixel::FromUntyped(oldScissor), nullptr));
RenderTargetPixel::ToUntyped(layerToRender->GetLayer()->CalculateScissorRect(RenderTargetPixel::FromUntyped(oldScissor)));
if (scissorRect.IsEmpty()) {
continue;
}

View File

@ -801,7 +801,7 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
// Instruct the LayerManager to update its render bounds now. Since all the orientation
// change, dimension change would be done at the stage, update the size here is free of
// race condition.
mLayerManager->UpdateRenderBounds(aTargetConfig.clientBounds());
mLayerManager->UpdateRenderBounds(aTargetConfig.naturalBounds());
mLayerManager->SetRegionToClear(aTargetConfig.clearRegion());
mCompositionManager->Updated(aIsFirstPaint, aTargetConfig);

View File

@ -49,7 +49,6 @@ namespace layers {
struct TargetConfig {
nsIntRect naturalBounds;
ScreenRotation rotation;
nsIntRect clientBounds;
ScreenOrientation orientation;
nsIntRegion clearRegion;
};

View File

@ -64,7 +64,7 @@ public:
{}
void Begin(const nsIntRect& aTargetBounds, ScreenRotation aRotation,
const nsIntRect& aClientBounds, dom::ScreenOrientation aOrientation)
dom::ScreenOrientation aOrientation)
{
mOpen = true;
mTargetBounds = aTargetBounds;
@ -76,7 +76,6 @@ public:
mRotationChanged = true;
}
mTargetRotation = aRotation;
mClientBounds = aClientBounds;
mTargetOrientation = aOrientation;
}
void MarkSyncTransaction()
@ -141,7 +140,6 @@ public:
ShadowableLayerSet mMutants;
nsIntRect mTargetBounds;
ScreenRotation mTargetRotation;
nsIntRect mClientBounds;
dom::ScreenOrientation mTargetOrientation;
bool mSwapRequired;
@ -186,12 +184,11 @@ ShadowLayerForwarder::~ShadowLayerForwarder()
void
ShadowLayerForwarder::BeginTransaction(const nsIntRect& aTargetBounds,
ScreenRotation aRotation,
const nsIntRect& aClientBounds,
dom::ScreenOrientation aOrientation)
{
NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
NS_ABORT_IF_FALSE(mTxn->Finished(), "uncommitted txn?");
mTxn->Begin(aTargetBounds, aRotation, aClientBounds, aOrientation);
mTxn->Begin(aTargetBounds, aRotation, aOrientation);
}
static PLayerChild*
@ -635,7 +632,6 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
TargetConfig targetConfig(mTxn->mTargetBounds,
mTxn->mTargetRotation,
mTxn->mClientBounds,
mTxn->mTargetOrientation,
aRegionToClear);

View File

@ -176,7 +176,6 @@ public:
*/
void BeginTransaction(const nsIntRect& aTargetBounds,
ScreenRotation aRotation,
const nsIntRect& aClientBounds,
mozilla::dom::ScreenOrientation aOrientation);
/**

View File

@ -49,17 +49,10 @@ public:
* composition and the render was successful. Return false to fall
* back on the GPU.
*
* |aWorldTransform| must be applied to |aRoot|'s subtree when
* rendering to the framebuffer. This is a global transform on the
* entire scene, defined in GL space. If the Composer2D
* implementation is unable to honor the transform, it should return
* false.
*
* Currently, when TryRender() returns true, the entire framebuffer
* must have been rendered.
*/
virtual bool TryRender(Layer* aRoot, const gfx::Matrix& aWorldTransform,
bool aGeometryChanged) = 0;
virtual bool TryRender(Layer* aRoot, bool aGeometryChanged) = 0;
};
} // namespace layers

View File

@ -56,7 +56,7 @@ CompositingRenderTargetOGL::BindRenderTarget()
}
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
mCompositor->PrepareViewport(mInitParams.mSize);
}
}
@ -92,7 +92,7 @@ CompositingRenderTargetOGL::InitializeImpl()
NS_ERROR(msg.get());
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
mCompositor->PrepareViewport(mInitParams.mSize);
mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height);
if (mInitParams.mInit == INIT_MODE_CLEAR) {
mGL->fClearColor(0.0, 0.0, 0.0, 0.0);

View File

@ -67,7 +67,6 @@ public:
GLuint aTexure, GLuint aFBO)
: CompositingRenderTarget(aOrigin)
, mInitParams()
, mTransform()
, mCompositor(aCompositor)
, mGL(aCompositor->gl())
, mTextureHandle(aTexure)
@ -82,12 +81,10 @@ public:
*/
static TemporaryRef<CompositingRenderTargetOGL>
RenderTargetForWindow(CompositorOGL* aCompositor,
const gfx::IntSize& aSize,
const gfx::Matrix& aTransform)
const gfx::IntSize& aSize)
{
RefPtr<CompositingRenderTargetOGL> result
= new CompositingRenderTargetOGL(aCompositor, gfx::IntPoint(0, 0), 0, 0);
result->mTransform = aTransform;
result->mInitParams = InitParams(aSize, 0, INIT_MODE_NONE);
result->mInitParams.mStatus = InitParams::INITIALIZED;
return result.forget();
@ -146,10 +143,6 @@ public:
return gfx::SurfaceFormat::UNKNOWN;
}
const gfx::Matrix& GetTransform() {
return mTransform;
}
#ifdef MOZ_DUMP_PAINTING
virtual TemporaryRef<gfx::DataSourceSurface> Dump(Compositor* aCompositor);
#endif
@ -162,7 +155,6 @@ private:
void InitializeImpl();
InitParams mInitParams;
gfx::Matrix mTransform;
CompositorOGL* mCompositor;
GLContext* mGL;
GLuint mTextureHandle;

View File

@ -567,8 +567,7 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
}
void
CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
const Matrix& aWorldTransform)
CompositorOGL::PrepareViewport(const gfx::IntSize& aSize)
{
// Set the viewport correctly.
mGLContext->fViewport(0, 0, aSize.width, aSize.height);
@ -579,9 +578,7 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
// drawing directly into the window's back buffer, so this keeps things
// looking correct.
// XXX: We keep track of whether the window size changed, so we could skip
// this update if it hadn't changed since the last call. We will need to
// track changes to aTransformPolicy and aWorldTransform for this to work
// though.
// this update if it hadn't changed since the last call.
// Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0,
// 2, 2) and flip the contents.
@ -600,8 +597,6 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
viewMatrix.PreTranslate(mRenderOffset.x, mRenderOffset.y);
}
viewMatrix = aWorldTransform * viewMatrix;
Matrix4x4 matrix3d = Matrix4x4::From2D(viewMatrix);
matrix3d._33 = 0.0f;
@ -705,7 +700,6 @@ CompositorOGL::ClearRect(const gfx::Rect& aRect)
void
CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
const Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const Rect& aRenderBounds,
Rect *aClipRectOut,
Rect *aRenderBoundsOut)
@ -723,7 +717,6 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
rect = gfx::Rect(aRenderBounds.x, aRenderBounds.y, aRenderBounds.width, aRenderBounds.height);
}
rect = aTransform.TransformBounds(rect);
if (aRenderBoundsOut) {
*aRenderBoundsOut = rect;
}
@ -758,8 +751,7 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
mCurrentRenderTarget =
CompositingRenderTargetOGL::RenderTargetForWindow(this,
IntSize(width, height),
aTransform);
IntSize(width, height));
mCurrentRenderTarget->BindRenderTarget();
#ifdef DEBUG
mWindowRenderTarget = mCurrentRenderTarget;
@ -1325,7 +1317,7 @@ CompositorOGL::EndFrame()
mWidget->GetBounds(rect);
}
RefPtr<DrawTarget> target = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(rect.width, rect.height), SurfaceFormat::B8G8R8A8);
CopyToTarget(target, nsIntPoint(), mCurrentRenderTarget->GetTransform());
CopyToTarget(target, nsIntPoint(), Matrix());
WriteSnapshotToDumpFile(this, target);
}
@ -1334,7 +1326,7 @@ CompositorOGL::EndFrame()
mFrameInProgress = false;
if (mTarget) {
CopyToTarget(mTarget, mTargetBounds.TopLeft(), mCurrentRenderTarget->GetTransform());
CopyToTarget(mTarget, mTargetBounds.TopLeft(), Matrix());
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
mCurrentRenderTarget = nullptr;
return;

View File

@ -236,8 +236,7 @@ public:
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE;
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
virtual void PrepareViewport(const gfx::IntSize& aSize) MOZ_OVERRIDE;
#ifdef MOZ_DUMP_PAINTING
@ -327,7 +326,6 @@ private:
*/
virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
const gfx::Rect *aClipRectIn,
const gfx::Matrix& aTransform,
const gfx::Rect& aRenderBounds,
gfx::Rect *aClipRectOut = nullptr,
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;

View File

@ -285,8 +285,7 @@ HwcComposer2D::setHwcGeometry(bool aGeometryChanged)
bool
HwcComposer2D::PrepareLayerList(Layer* aLayer,
const nsIntRect& aClip,
const Matrix& aParentTransform,
const Matrix& aGLWorldTransform)
const Matrix& aParentTransform)
{
// NB: we fall off this path whenever there are container layers
// that require intermediate surfaces. That means all the
@ -308,7 +307,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
#endif
nsIntRect clip;
if (!HwcUtils::CalculateClipRect(aParentTransform * aGLWorldTransform,
if (!HwcUtils::CalculateClipRect(aParentTransform,
aLayer->GetEffectiveClipRect(),
aClip,
&clip))
@ -344,7 +343,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
container->SortChildrenBy3DZOrder(children);
for (uint32_t i = 0; i < children.Length(); i++) {
if (!PrepareLayerList(children[i], clip, transform, aGLWorldTransform)) {
if (!PrepareLayerList(children[i], clip, transform)) {
return false;
}
}
@ -389,7 +388,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
hwc_rect_t sourceCrop, displayFrame;
if(!HwcUtils::PrepareLayerRects(visibleRect,
transform * aGLWorldTransform,
transform,
clip,
bufferRect,
state.YFlipped(),
@ -473,7 +472,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
// And ignore scaling.
//
// Reflection is applied before rotation
gfx::Matrix rotation = transform * aGLWorldTransform;
gfx::Matrix rotation = transform;
// Compute fuzzy zero like PreservesAxisAlignedRectangles()
if (fabs(rotation._11) < 1e-6) {
if (rotation._21 < 0) {
@ -578,7 +577,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
mVisibleRegions.push_back(HwcUtils::RectVector());
HwcUtils::RectVector* visibleRects = &(mVisibleRegions.back());
if(!HwcUtils::PrepareVisibleRegion(visibleRegion,
transform * aGLWorldTransform,
transform,
clip,
bufferRect,
visibleRects)) {
@ -871,14 +870,8 @@ HwcComposer2D::Reset()
bool
HwcComposer2D::TryRender(Layer* aRoot,
const gfx::Matrix& aGLWorldTransform,
bool aGeometryChanged)
{
if (!aGLWorldTransform.PreservesAxisAlignedRectangles()) {
LOGD("Render aborted. World transform has non-square angle rotation");
return false;
}
MOZ_ASSERT(Initialized());
if (mList) {
setHwcGeometry(aGeometryChanged);
@ -897,8 +890,7 @@ HwcComposer2D::TryRender(Layer* aRoot,
MOZ_ASSERT(mHwcLayerMap.IsEmpty());
if (!PrepareLayerList(aRoot,
mScreenRect,
gfx::Matrix(),
aGLWorldTransform))
gfx::Matrix()))
{
mHwcLayerMap.Clear();
LOGD("Render aborted. Nothing was drawn to the screen");

View File

@ -82,7 +82,7 @@ public:
// Returns TRUE if the container has been succesfully rendered
// Returns FALSE if the container cannot be fully rendered
// by this composer so nothing was rendered at all
bool TryRender(layers::Layer* aRoot, const gfx::Matrix& aGLWorldTransform,
bool TryRender(layers::Layer* aRoot,
bool aGeometryChanged) MOZ_OVERRIDE;
bool Render(EGLDisplay dpy, EGLSurface sur);
@ -100,7 +100,7 @@ private:
bool TryHwComposition();
bool ReallocLayerList();
bool PrepareLayerList(layers::Layer* aContainer, const nsIntRect& aClip,
const gfx::Matrix& aParentTransform, const gfx::Matrix& aGLWorldTransform);
const gfx::Matrix& aParentTransform);
void setCrop(HwcLayer* layer, hwc_rect_t srcCrop);
void setHwcGeometry(bool aGeometryChanged);
void SendtoLayerScope();