Bug 1066664. Fix screenshot rotation. r=mwoodrow

This moves the screenshot (now-nonexistent) unrotation code from the opengl
compositor into ClientLayerManager.cpp
This commit is contained in:
Jeff Muizelaar
2014-09-30 16:20:48 -04:00
parent 09d560dd7e
commit 0f09ff4b36
3 changed files with 76 additions and 0 deletions

View File

@@ -443,7 +443,17 @@ ClientLayerManager::MakeSnapshotIfRequired()
}
if (mWidget) {
if (CompositorChild* remoteRenderer = GetRemoteRenderer()) {
// The compositor doesn't draw to a different sized surface
// when there's a rotation. Instead we rotate the result
// when drawing into dt
nsIntRect outerBounds;
mWidget->GetBounds(outerBounds);
nsIntRect bounds = ToOutsideIntRect(mShadowTarget->GetClipExtents());
if (mTargetRotation) {
bounds = RotateRect(bounds, outerBounds, mTargetRotation);
}
SurfaceDescriptor inSnapshot;
if (!bounds.IsEmpty() &&
mForwarder->AllocSurfaceDescriptor(bounds.Size().ToIntSize(),
@@ -452,11 +462,18 @@ ClientLayerManager::MakeSnapshotIfRequired()
remoteRenderer->SendMakeSnapshot(inSnapshot, bounds)) {
RefPtr<DataSourceSurface> surf = GetSurfaceForDescriptor(inSnapshot);
DrawTarget* dt = mShadowTarget->GetDrawTarget();
Rect dstRect(bounds.x, bounds.y, bounds.width, bounds.height);
Rect srcRect(0, 0, bounds.width, bounds.height);
gfx::Matrix rotate = ComputeTransformForUnRotation(outerBounds, mTargetRotation);
gfx::Matrix oldMatrix = dt->GetTransform();
dt->SetTransform(oldMatrix * rotate);
dt->DrawSurface(surf, dstRect, srcRect,
DrawSurfaceOptions(),
DrawOptions(1.0f, CompositionOp::OP_OVER));
dt->SetTransform(oldMatrix);
}
mForwarder->DestroySharedSurface(&inSnapshot);
}