Permalink
Browse files

Bug 776217: Support gecko-implemented screen rotation with omtc. r=roc

  • Loading branch information...
1 parent 37fac12 commit 397c1414d78a66ce22a308c0e12f138576deb046 @joneschrisg joneschrisg committed Jul 24, 2012
@@ -22,6 +22,7 @@
#include "BasicThebesLayer.h"
#include "BasicContainerLayer.h"
#include "mozilla/Preferences.h"
+#include "nsIWidget.h"
using namespace mozilla::gfx;
@@ -132,7 +133,8 @@ BasicLayerManager::~BasicLayerManager()
void
BasicLayerManager::SetDefaultTarget(gfxContext* aContext,
- BufferMode aDoubleBuffering)
+ BufferMode aDoubleBuffering,
+ ScreenRotation aRotation)
{
NS_ASSERTION(!InTransaction(),
"Must set default target outside transaction");
@@ -922,7 +924,7 @@ BasicLayerManager::CreateReadbackLayer()
}
BasicShadowLayerManager::BasicShadowLayerManager(nsIWidget* aWidget) :
- BasicLayerManager(aWidget)
+ BasicLayerManager(aWidget), mTargetRotation(ROTATION_0)
{
MOZ_COUNT_CTOR(BasicShadowLayerManager);
}
@@ -943,6 +945,18 @@ BasicShadowLayerManager::GetMaxTextureSize() const
}
void
+BasicShadowLayerManager::SetDefaultTarget(gfxContext* aContext,
+ BufferMode aDoubleBuffering,
+ ScreenRotation aRotation)
+{
+ BasicLayerManager::SetDefaultTarget(aContext, aDoubleBuffering, aRotation);
+ mTargetRotation = aRotation;
+ if (mWidget) {
+ mTargetBounds = mWidget->GetNaturalBounds();
+ }
+}
+
+void
BasicShadowLayerManager::SetRoot(Layer* aLayer)
{
if (mRoot != aLayer) {
@@ -981,7 +995,7 @@ BasicShadowLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
// don't signal a new transaction to ShadowLayerForwarder. Carry on adding
// to the previous transaction.
if (HasShadowManager()) {
- ShadowLayerForwarder::BeginTransaction();
+ ShadowLayerForwarder::BeginTransaction(mTargetBounds, mTargetRotation);
// If we have a non-default target, we need to let our shadow manager draw
// to it. This will happen at the end of the transaction.
@@ -10,11 +10,11 @@
#include "gfxContext.h"
#include "gfxCachedTempSurface.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "mozilla/WidgetUtils.h"
#include "nsAutoRef.h"
#include "nsThreadUtils.h"
-#include "mozilla/layers/ShadowLayers.h"
-
class nsIWidget;
namespace mozilla {
@@ -80,7 +80,8 @@ class THEBES_API BasicLayerManager :
BUFFER_NONE,
BUFFER_BUFFERED
};
- void SetDefaultTarget(gfxContext* aContext, BufferMode aDoubleBuffering);
+ virtual void SetDefaultTarget(gfxContext* aContext, BufferMode aDoubleBuffering,
+ ScreenRotation aRotation);
gfxContext* GetDefaultTarget() { return mDefaultTarget; }
nsIWidget* GetRetainerWidget() { return mWidget; }
@@ -221,6 +222,8 @@ class BasicShadowLayerManager : public BasicLayerManager,
virtual PRInt32 GetMaxTextureSize() const;
+ virtual void SetDefaultTarget(gfxContext* aContext, BufferMode aDoubleBuffering,
+ ScreenRotation aRotation) MOZ_OVERRIDE;
virtual void BeginTransactionWithTarget(gfxContext* aTarget);
virtual bool EndEmptyTransaction();
virtual void EndTransaction(DrawThebesLayerCallback aCallback,
@@ -261,11 +264,20 @@ class BasicShadowLayerManager : public BasicLayerManager,
*/
void ForwardTransaction();
+ // The bounds of |mTarget| in device pixels.
+ nsIntRect mTargetBounds;
+
+ LayerRefArray mKeepAlive;
+
+ // Sometimes we draw to targets that don't natively support
+ // landscape/portrait orientation. When we need to implement that
+ // ourselves, |mTargetRotation| describes the induced transform we
+ // need to apply when compositing content to our target.
+ ScreenRotation mTargetRotation;
+
// Used to repeat the transaction right away (to avoid rebuilding
// a display list) to support progressive drawing.
bool mRepeatTransaction;
-
- LayerRefArray mKeepAlive;
};
class BasicShadowableThebesLayer;
@@ -20,6 +20,7 @@
#include "ReadbackLayerD3D10.h"
#include "ImageLayerD3D10.h"
#include "mozilla/layers/PLayerChild.h"
+#include "mozilla/WidgetUtils.h"
#include "../d3d9/Nv3DVUtils.h"
@@ -729,7 +730,8 @@ LayerManagerD3D10::Render()
if (mTarget) {
PaintToTarget();
} else if (mBackBuffer) {
- ShadowLayerForwarder::BeginTransaction();
+ ShadowLayerForwarder::BeginTransaction(mWidget->GetNaturalBounds(),
+ ROTATION_0);
nsIntRect contentRect = nsIntRect(0, 0, rect.width, rect.height);
if (!mRootForShadowTree) {
@@ -422,6 +422,13 @@ CompositorParent::Composite()
RenderTraceLayers(aLayer, "0000");
+ if (LAYERS_OPENGL == mLayerManager->GetBackendType() &&
+ !mTargetConfig.naturalBounds().IsEmpty()) {
+ LayerManagerOGL* lm = static_cast<LayerManagerOGL*>(mLayerManager.get());
+ lm->SetWorldTransform(
+ ComputeGLTransformForRotation(mTargetConfig.naturalBounds(),
+ mTargetConfig.rotation()));
+ }
mLayerManager->EndEmptyTransaction();
#ifdef COMPOSITOR_PERFORMANCE_WARNING
@@ -694,8 +701,10 @@ CompositorParent::SyncViewportInfo(const nsIntRect& aDisplayPort,
void
CompositorParent::ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
+ const TargetConfig& aTargetConfig,
bool isFirstPaint)
{
+ mTargetConfig = aTargetConfig;
mIsFirstPaint = mIsFirstPaint || isFirstPaint;
mLayersUpdated = true;
Layer* root = aLayerTree->GetRoot();
@@ -898,6 +907,7 @@ class CrossProcessCompositorParent : public PCompositorParent,
virtual bool DeallocPLayers(PLayersParent* aLayers) MOZ_OVERRIDE;
virtual void ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
+ const TargetConfig& aTargetConfig,
bool isFirstPaint) MOZ_OVERRIDE;
private:
@@ -997,8 +1007,10 @@ CrossProcessCompositorParent::DeallocPLayers(PLayersParent* aLayers)
}
void
-CrossProcessCompositorParent::ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
- bool isFirstPaint)
+CrossProcessCompositorParent::ShadowLayersUpdated(
+ ShadowLayersParent* aLayerTree,
+ const TargetConfig& aTargetConfig,
+ bool isFirstPaint)
{
uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);
@@ -70,6 +70,7 @@ class CompositorParent : public PCompositorParent,
virtual bool RecvResume() MOZ_OVERRIDE;
virtual void ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
+ const TargetConfig& aTargetConfig,
bool isFirstPaint) MOZ_OVERRIDE;
void Destroy();
@@ -227,6 +228,7 @@ class CompositorParent : public PCompositorParent,
nsRefPtr<LayerManager> mLayerManager;
nsIWidget* mWidget;
+ TargetConfig mTargetConfig;
CancelableTask *mCurrentCompositeTask;
TimeStamp mLastCompose;
#ifdef COMPOSITOR_PERFORMANCE_WARNING
@@ -6,12 +6,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include LayersSurfaces;
+using mozilla::ScreenRotation;
include protocol PCompositor;
include protocol PGrallocBuffer;
include protocol PLayer;
include protocol PRenderFrame;
include "gfxipc/ShadowLayerUtils.h";
+include "mozilla/WidgetUtils.h";
/**
* The layers protocol is spoken between thread contexts that manage
@@ -24,6 +26,11 @@ include "gfxipc/ShadowLayerUtils.h";
namespace mozilla {
namespace layers {
+struct TargetConfig {
+ nsIntRect naturalBounds;
+ ScreenRotation rotation;
+};
+
// Create a shadow layer for |layer|
struct OpCreateThebesLayer { PLayer layer; };
struct OpCreateContainerLayer { PLayer layer; };
@@ -191,7 +198,7 @@ parent:
// The isFirstPaint flag can be used to indicate that this is the first update
// for a particular document.
- sync Update(Edit[] cset, bool isFirstPaint)
+ sync Update(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint)
returns (EditReply[] reply);
// Composite the layer tree to the given surface, and return the surface.
@@ -200,7 +207,7 @@ parent:
// We don't need to send a sync transaction if
// no transaction operate require a swap.
- async UpdateNoSwap(Edit[] cset, bool isFirstPaint);
+ async UpdateNoSwap(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint);
async __delete__();
};
@@ -11,6 +11,7 @@
#include "IPC/IPCMessageUtils.h"
#include "Layers.h"
#include "GLContext.h"
+#include "mozilla/WidgetUtils.h"
#if defined(MOZ_ENABLE_D3D10_LAYER)
# include "mozilla/layers/ShadowLayerUtilsD3D10.h"
@@ -107,6 +108,13 @@ struct ParamTraits<mozilla::layers::MagicGrallocBufferHandle> {
};
#endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORGRALLOC)
-}
+template <>
+struct ParamTraits<mozilla::ScreenRotation>
+ : public EnumSerializer<mozilla::ScreenRotation,
+ mozilla::ROTATION_0,
+ mozilla::ROTATION_COUNT>
+{};
+
+} // namespace IPC
#endif // IPC_ShadowLayerUtils_h
@@ -41,7 +41,12 @@ class Transaction
, mOpen(false)
{}
- void Begin() { mOpen = true; }
+ void Begin(const nsIntRect& aTargetBounds, ScreenRotation aRotation)
+ {
+ mOpen = true;
+ mTargetBounds = aTargetBounds;
+ mTargetRotation = aRotation;
+ }
void AddEdit(const Edit& aEdit)
{
@@ -92,6 +97,8 @@ class Transaction
EditVector mPaints;
BufferArray mDyingBuffers;
ShadowableLayerSet mMutants;
+ nsIntRect mTargetBounds;
+ ScreenRotation mTargetRotation;
bool mSwapRequired;
private:
@@ -123,11 +130,12 @@ ShadowLayerForwarder::~ShadowLayerForwarder()
}
void
-ShadowLayerForwarder::BeginTransaction()
+ShadowLayerForwarder::BeginTransaction(const nsIntRect& aTargetBounds,
+ ScreenRotation aRotation)
{
NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
NS_ABORT_IF_FALSE(mTxn->Finished(), "uncommitted txn?");
- mTxn->Begin();
+ mTxn->Begin(aTargetBounds, aRotation);
}
static PLayerChild*
@@ -325,13 +333,16 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
cset.AppendElements(&mTxn->mPaints.front(), mTxn->mPaints.size());
}
+ TargetConfig targetConfig(mTxn->mTargetBounds, mTxn->mTargetRotation);
+
MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
PlatformSyncBeforeUpdate();
if (mTxn->mSwapRequired) {
MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
RenderTraceScope rendertrace3("Forward Transaction", "000093");
- if (!mShadowManager->SendUpdate(cset, mIsFirstPaint, aReplies)) {
+ if (!mShadowManager->SendUpdate(cset, targetConfig, mIsFirstPaint,
+ aReplies)) {
MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
return false;
}
@@ -340,7 +351,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
// assumes that aReplies is empty (DEBUG assertion)
MOZ_LAYERS_LOG(("[LayersForwarder] sending no swap transaction..."));
RenderTraceScope rendertrace3("Forward NoSwap Transaction", "000093");
- if (!mShadowManager->SendUpdateNoSwap(cset, mIsFirstPaint)) {
+ if (!mShadowManager->SendUpdateNoSwap(cset, targetConfig, mIsFirstPaint)) {
MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
return false;
}
@@ -14,6 +14,7 @@
#include "ImageLayers.h"
#include "LayersBackend.h"
#include "mozilla/ipc/SharedMemory.h"
+#include "mozilla/WidgetUtils.h"
class gfxSharedImageSurface;
@@ -116,7 +117,8 @@ class ShadowLayerForwarder
* Begin recording a transaction to be forwarded atomically to a
* ShadowLayerManager.
*/
- void BeginTransaction();
+ void BeginTransaction(const nsIntRect& aTargetBounds,
+ ScreenRotation aRotation);
/**
* The following methods may only be called after BeginTransaction()
@@ -10,13 +10,14 @@
namespace mozilla {
namespace layers {
+class TargetConfig;
class ShadowLayersParent;
class ShadowLayersManager
{
public:
virtual void ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
- // FIXME nuke this
+ const TargetConfig& aTargetConfig,
bool isFirstPaint) = 0;
};
@@ -119,16 +119,18 @@ ShadowLayersParent::Destroy()
/* virtual */
bool
ShadowLayersParent::RecvUpdateNoSwap(const InfallibleTArray<Edit>& cset,
- const bool& isFirstPaint)
+ const TargetConfig& targetConfig,
+ const bool& isFirstPaint)
{
InfallibleTArray<EditReply> noReplies;
- bool success = RecvUpdate(cset, isFirstPaint, &noReplies);
+ bool success = RecvUpdate(cset, targetConfig, isFirstPaint, &noReplies);
NS_ABORT_IF_FALSE(noReplies.Length() == 0, "RecvUpdateNoSwap requires a sync Update to carry Edits");
return success;
}
bool
ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
+ const TargetConfig& targetConfig,
const bool& isFirstPaint,
InfallibleTArray<EditReply>* reply)
{
@@ -417,7 +419,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
// other's buffer contents.
ShadowLayerManager::PlatformSyncBeforeReplyUpdate();
- mShadowLayersManager->ShadowLayersUpdated(this, isFirstPaint);
+ mShadowLayersManager->ShadowLayersUpdated(this, targetConfig, isFirstPaint);
#ifdef COMPOSITOR_PERFORMANCE_WARNING
int compositeTime = (int)(mozilla::TimeStamp::Now() - updateStart).ToMilliseconds();
Oops, something went wrong.

0 comments on commit 397c141

Please sign in to comment.