Bug 1010584 - Part 1: Introduce RenderTargetPixel. r=mwoodrow

This commit is contained in:
Benoit Girard 2014-07-30 14:36:15 -04:00
Родитель d54b9ed617
Коммит 0d295d7249
13 изменённых файлов: 169 добавлений и 79 удалений

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

@ -104,30 +104,32 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
aFlashCounter);
}
gfx::Rect
Compositor::ClipRectInLayersCoordinates(gfx::Rect aClip) const {
gfx::Rect result;
aClip = aClip + GetCurrentRenderTarget()->GetOrigin();
gfx::IntSize destSize = GetWidgetSize();
RenderTargetRect
Compositor::ClipRectInLayersCoordinates(RenderTargetIntRect aClip) const {
RenderTargetRect result;
aClip = aClip + RenderTargetIntPoint(GetCurrentRenderTarget()->GetOrigin().x,
GetCurrentRenderTarget()->GetOrigin().y);
RenderTargetIntSize destSize = RenderTargetIntSize(GetWidgetSize().width,
GetWidgetSize().height);
switch (mScreenRotation) {
case ROTATION_0:
result = aClip;
result = RenderTargetRect(aClip.x, aClip.y, aClip.width, aClip.height);
break;
case ROTATION_90:
result = gfx::Rect(aClip.y,
destSize.width - aClip.x - aClip.width,
aClip.height, aClip.width);
result = RenderTargetRect(aClip.y,
destSize.width - aClip.x - aClip.width,
aClip.height, aClip.width);
break;
case ROTATION_270:
result = gfx::Rect(destSize.height - aClip.y - aClip.height,
aClip.x,
aClip.height, aClip.width);
result = RenderTargetRect(destSize.height - aClip.y - aClip.height,
aClip.x,
aClip.height, aClip.width);
break;
case ROTATION_180:
result = gfx::Rect(destSize.width - aClip.x - aClip.width,
destSize.height - aClip.y - aClip.height,
aClip.width, aClip.height);
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)

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

@ -498,7 +498,7 @@ public:
// at the OS level rather than in Gecko.
// In addition, the clip rect needs to be offset by the rendering origin.
// This becomes important if intermediate surfaces are used.
gfx::Rect ClipRectInLayersCoordinates(gfx::Rect aClip) const;
RenderTargetRect ClipRectInLayersCoordinates(RenderTargetIntRect aClip) const;
protected:
void DrawDiagnosticsInternal(DiagnosticFlags aFlags,

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

@ -601,8 +601,8 @@ Layer::MayResample()
AncestorLayerMayChangeTransform(this);
}
nsIntRect
Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
RenderTargetIntRect
Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect,
const gfx::Matrix* aWorldTransform)
{
ContainerLayer* container = GetParent();
@ -610,24 +610,25 @@ Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
// Establish initial clip rect: it's either the one passed in, or
// if the parent has an intermediate surface, it's the extents of that surface.
nsIntRect currentClip;
RenderTargetIntRect currentClip;
if (container->UseIntermediateSurface()) {
currentClip.SizeTo(container->GetIntermediateSurfaceRect().Size());
} else {
currentClip = aCurrentScissorRect;
}
const nsIntRect *clipRect = GetEffectiveClipRect();
if (!clipRect)
if (!GetEffectiveClipRect()) {
return currentClip;
if (clipRect->IsEmpty()) {
// We might have a non-translation transform in the container so we can't
// use the code path below.
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
}
nsIntRect scissor = *clipRect;
const RenderTargetIntRect clipRect = RenderTargetPixel::FromUntyped(*GetEffectiveClipRect());
if (clipRect.IsEmpty()) {
// We might have a non-translation transform in the container so we can't
// use the code path below.
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
}
RenderTargetIntRect scissor = clipRect;
if (!container->UseIntermediateSurface()) {
gfx::Matrix matrix;
DebugOnly<bool> is2D = container->GetEffectiveTransform().Is2D(&matrix);
@ -637,23 +638,29 @@ Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height);
gfxRect trScissor = gfx::ThebesRect(matrix.TransformBounds(r));
trScissor.Round();
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissor)) {
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
nsIntRect tmp;
if (!gfxUtils::GfxRectToIntRect(trScissor, &tmp)) {
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
}
scissor = RenderTargetPixel::FromUntyped(tmp);
// Find the nearest ancestor with an intermediate surface
do {
container = container->GetParent();
} while (container && !container->UseIntermediateSurface());
}
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();
if (!gfxUtils::GfxRectToIntRect(ThebesRect(trScissor), &scissor))
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
nsIntRect tmp;
if (!gfxUtils::GfxRectToIntRect(ThebesRect(trScissor), &tmp)) {
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
}
scissor = RenderTargetPixel::FromUntyped(tmp);
}
return currentClip.Intersect(scissor);
}
@ -756,6 +763,16 @@ Layer::ComputeEffectiveTransformForMaskLayer(const Matrix4x4& aTransformToSurfac
}
}
RenderTargetRect
Layer::TransformRectToRenderTarget(const LayerIntRect& aRect)
{
LayerRect rect(aRect);
RenderTargetRect quad = RenderTargetRect::FromUnknown(
GetEffectiveTransform().TransformBounds(
LayerPixel::ToUnknown(rect)));
return quad;
}
ContainerLayer::ContainerLayer(LayerManager* aManager, void* aImplData)
: Layer(aManager, aImplData),
mFirstChild(nullptr),

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

@ -1388,8 +1388,8 @@ public:
* by aWorldTransform before being combined with aCurrentScissorRect, if
* aWorldTransform is non-null.
*/
nsIntRect CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
const gfx::Matrix* aWorldTransform);
RenderTargetIntRect CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect,
const gfx::Matrix* aWorldTransform);
virtual const char* Name() const =0;
virtual LayerType GetType() const =0;
@ -1486,7 +1486,6 @@ public:
virtual LayerRenderState GetRenderState() { return LayerRenderState(); }
void Mutated()
{
mManager->Mutated(this);
@ -1502,6 +1501,8 @@ public:
*/
bool MayResample();
RenderTargetRect TransformRectToRenderTarget(const LayerIntRect& aRect);
protected:
Layer(LayerManager* aManager, void* aImplData);
@ -1813,12 +1814,15 @@ public:
/**
* Returns the rectangle covered by the intermediate surface,
* in this layer's coordinate system
* in this layer's coordinate system.
*
* NOTE: Since this layer has an intermediate surface it follows
* that LayerPixel == RenderTargetPixel
*/
nsIntRect GetIntermediateSurfaceRect()
RenderTargetIntRect GetIntermediateSurfaceRect()
{
NS_ASSERTION(mUseIntermediateSurface, "Must have intermediate surface");
return mVisibleRegion.GetBounds();
return RenderTargetPixel::FromUntyped(mVisibleRegion.GetBounds());
}
/**

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

@ -117,7 +117,7 @@ static gfx::Point GetScrollData(Layer* aLayer) {
return origin;
}
static void DrawLayerInfo(const nsIntRect& aClipRect,
static void DrawLayerInfo(const RenderTargetIntRect& aClipRect,
LayerManagerComposite* aManager,
Layer* aLayer)
{
@ -154,7 +154,7 @@ static LayerVelocityUserData* GetVelocityData(Layer* aLayer) {
return static_cast<LayerVelocityUserData*>(aLayer->GetUserData(key));
}
static void DrawVelGraph(const nsIntRect& aClipRect,
static void DrawVelGraph(const RenderTargetIntRect& aClipRect,
LayerManagerComposite* aManager,
Layer* aLayer) {
Compositor* compositor = aManager->GetCompositor();
@ -281,10 +281,10 @@ static void PrintUniformityInfo(Layer* aLayer)
/* all of the per-layer prepared data we need to maintain */
struct PreparedLayer
{
PreparedLayer(LayerComposite *aLayer, nsIntRect aClipRect, bool aRestoreVisibleRegion, nsIntRegion &aVisibleRegion) :
PreparedLayer(LayerComposite *aLayer, RenderTargetIntRect aClipRect, bool aRestoreVisibleRegion, nsIntRegion &aVisibleRegion) :
mLayer(aLayer), mClipRect(aClipRect), mRestoreVisibleRegion(aRestoreVisibleRegion), mSavedVisibleRegion(aVisibleRegion) {}
LayerComposite* mLayer;
nsIntRect mClipRect;
RenderTargetIntRect mClipRect;
bool mRestoreVisibleRegion;
nsIntRegion mSavedVisibleRegion;
};
@ -300,7 +300,7 @@ struct PreparedData
template<class ContainerT> void
ContainerPrepare(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect)
const RenderTargetIntRect& aClipRect)
{
aContainer->mPrepared = MakeUnique<PreparedData>();
@ -318,7 +318,7 @@ ContainerPrepare(ContainerT* aContainer,
continue;
}
nsIntRect clipRect = layerToRender->GetLayer()->
RenderTargetIntRect clipRect = layerToRender->GetLayer()->
CalculateScissorRect(aClipRect, &aManager->GetWorldTransform());
if (clipRect.IsEmpty()) {
continue;
@ -375,7 +375,7 @@ ContainerPrepare(ContainerT* aContainer,
// If we don't need a copy we can render to the intermediate now to avoid
// unecessary render target switching. This brings a big perf boost on mobile gpus.
RefPtr<CompositingRenderTarget> surface = CreateTemporaryTarget(aContainer, aManager);
RenderIntermediate(aContainer, aManager, aClipRect, surface);
RenderIntermediate(aContainer, aManager, RenderTargetPixel::ToUntyped(aClipRect), surface);
aContainer->mPrepared->mTmpTarget = surface;
}
}
@ -384,7 +384,7 @@ ContainerPrepare(ContainerT* aContainer,
template<class ContainerT> void
RenderLayers(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect)
const RenderTargetIntRect& aClipRect)
{
Compositor* compositor = aManager->GetCompositor();
@ -407,9 +407,10 @@ RenderLayers(ContainerT* aContainer,
EffectChain effectChain(aContainer);
effectChain.mPrimaryEffect = new EffectSolidColor(ToColor(color));
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
Compositor* compositor = aManager->GetCompositor();
compositor->DrawQuad(compositor->ClipRectInLayersCoordinates(clipRect),
clipRect, effectChain, opacity, Matrix4x4());
compositor->DrawQuad(
RenderTargetPixel::ToUnknown(
compositor->ClipRectInLayersCoordinates(aClipRect)),
clipRect, effectChain, opacity, Matrix4x4());
}
}
}
@ -417,7 +418,8 @@ RenderLayers(ContainerT* aContainer,
for (size_t i = 0u; i < aContainer->mPrepared->mLayers.Length(); i++) {
PreparedLayer& preparedData = aContainer->mPrepared->mLayers[i];
LayerComposite* layerToRender = preparedData.mLayer;
nsIntRect clipRect = preparedData.mClipRect;
const RenderTargetIntRect& clipRect = preparedData.mClipRect;
if (layerToRender->HasLayerBeenComposited()) {
// Composer2D will compose this layer so skip GPU composition
// this time & reset composition flag for next composition phase
@ -430,7 +432,7 @@ RenderLayers(ContainerT* aContainer,
layerToRender->SetClearRect(nsIntRect(0, 0, 0, 0));
}
} else {
layerToRender->RenderLayer(clipRect);
layerToRender->RenderLayer(RenderTargetPixel::ToUntyped(clipRect));
}
if (preparedData.mRestoreVisibleRegion) {
@ -508,7 +510,7 @@ RenderIntermediate(ContainerT* aContainer,
compositor->SetRenderTarget(surface);
// pre-render all of the layers into our temporary
RenderLayers(aContainer, aManager, aClipRect);
RenderLayers(aContainer, aManager, RenderTargetPixel::FromUntyped(aClipRect));
// Unbind the current surface and rebind the previous one.
compositor->SetRenderTarget(previousTarget);
}
@ -525,7 +527,8 @@ ContainerRender(ContainerT* aContainer,
if (!aContainer->mPrepared->mTmpTarget) {
// we needed to copy the background so we waited until now to render the intermediate
surface = CreateTemporaryTargetAndCopyFromBackground(aContainer, aManager);
RenderIntermediate(aContainer, aManager, aClipRect, surface);
RenderIntermediate(aContainer, aManager,
aClipRect, surface);
} else {
surface = aContainer->mPrepared->mTmpTarget;
}
@ -559,7 +562,7 @@ ContainerRender(ContainerT* aContainer,
aManager->GetCompositor()->DrawQuad(rect, clipRect, effectChain, opacity,
aContainer->GetEffectiveTransform());
} else {
RenderLayers(aContainer, aManager, aClipRect);
RenderLayers(aContainer, aManager, RenderTargetPixel::FromUntyped(aClipRect));
}
aContainer->mPrepared = nullptr;
@ -628,7 +631,7 @@ ContainerLayerComposite::RenderLayer(const nsIntRect& aClipRect)
}
void
ContainerLayerComposite::Prepare(const nsIntRect& aClipRect)
ContainerLayerComposite::Prepare(const RenderTargetIntRect& aClipRect)
{
ContainerPrepare(this, mCompositeManager, aClipRect);
}
@ -677,7 +680,7 @@ RefLayerComposite::RenderLayer(const nsIntRect& aClipRect)
}
void
RefLayerComposite::Prepare(const nsIntRect& aClipRect)
RefLayerComposite::Prepare(const RenderTargetIntRect& aClipRect)
{
ContainerPrepare(this, mCompositeManager, aClipRect);
}

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

@ -27,15 +27,15 @@ class ContainerLayerComposite : public ContainerLayer,
template<class ContainerT>
friend void ContainerPrepare(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect);
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void ContainerRender(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect);
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void RenderLayers(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect);
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void RenderIntermediate(ContainerT* aContainer,
LayerManagerComposite* aManager,
@ -45,12 +45,12 @@ class ContainerLayerComposite : public ContainerLayer,
friend RefPtr<CompositingRenderTarget>
CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect);
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend RefPtr<CompositingRenderTarget>
CreateTemporaryTarget(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect);
const RenderTargetIntRect& aClipRect);
public:
explicit ContainerLayerComposite(LayerManagerComposite *aManager);
@ -67,7 +67,7 @@ public:
LayerComposite* GetFirstChildComposite();
virtual void RenderLayer(const nsIntRect& aClipRect) MOZ_OVERRIDE;
virtual void Prepare(const nsIntRect& aClipRect) MOZ_OVERRIDE;
virtual void Prepare(const RenderTargetIntRect& aClipRect) MOZ_OVERRIDE;
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) MOZ_OVERRIDE
{
@ -91,7 +91,7 @@ class RefLayerComposite : public RefLayer,
template<class ContainerT>
friend void ContainerPrepare(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect);
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void ContainerRender(ContainerT* aContainer,
LayerManagerComposite* aManager,
@ -131,7 +131,7 @@ public:
LayerComposite* GetFirstChildComposite();
virtual void RenderLayer(const nsIntRect& aClipRect) MOZ_OVERRIDE;
virtual void Prepare(const nsIntRect& aClipRect) MOZ_OVERRIDE;
virtual void Prepare(const RenderTargetIntRect& aClipRect) MOZ_OVERRIDE;
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) MOZ_OVERRIDE
{

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

@ -565,7 +565,7 @@ LayerManagerComposite::Render()
}
// Render our layers.
RootLayer()->Prepare(clipRect);
RootLayer()->Prepare(RenderTargetPixel::FromUntyped(clipRect));
RootLayer()->RenderLayer(clipRect);
if (!mRegionToClear.IsEmpty()) {

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

@ -336,8 +336,9 @@ public:
* This allows us on to avoid framebuffer switches in the middle of our render
* which is inefficient. This must be called before RenderLayer.
*/
virtual void Prepare(const nsIntRect& aClipRect) {}
virtual void Prepare(const RenderTargetIntRect& aClipRect) {}
// TODO: This should also take RenderTargetIntRect like Prepare.
virtual void RenderLayer(const nsIntRect& aClipRect) = 0;
virtual bool SetCompositableHost(CompositableHost*)

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

@ -117,6 +117,7 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
mBuffer->GetLayer() == this,
"buffer is corrupted");
const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
#ifdef MOZ_DUMP_PAINTING
@ -132,8 +133,6 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
AddBlendModeEffect(effectChain);
const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
mBuffer->SetPaintWillResample(MayResample());
mBuffer->Composite(effectChain,

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

@ -424,10 +424,11 @@ TiledContentHost::RenderTile(const TileHost& aTile,
}
nsIntRect screenBounds = aScreenRegion.GetBounds();
Rect quad(screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height);
quad = aTransform.TransformBounds(quad);
Rect layerQuad(screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height);
RenderTargetRect quad = RenderTargetRect::FromUnknown(aTransform.TransformBounds(layerQuad));
if (!quad.Intersects(mCompositor->ClipRectInLayersCoordinates(aClipRect))) {
if (!quad.Intersects(mCompositor->ClipRectInLayersCoordinates(
RenderTargetIntRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height)))) {
return;
}

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

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

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

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

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

@ -21,14 +21,17 @@ namespace mozilla {
template <typename T>
struct IsPixel : FalseType {};
// See struct decleration for a description of each unit type
struct CSSPixel;
struct LayoutDevicePixel;
struct LayerPixel;
struct RenderTargetPixel;
struct ScreenPixel;
template<> struct IsPixel<CSSPixel> : TrueType {};
template<> struct IsPixel<LayoutDevicePixel> : TrueType {};
template<> struct IsPixel<LayerPixel> : TrueType {};
template<> struct IsPixel<RenderTargetPixel> : TrueType {};
template<> struct IsPixel<ScreenPixel> : TrueType {};
typedef gfx::CoordTyped<CSSPixel> CSSCoord;
@ -66,6 +69,15 @@ typedef gfx::IntMarginTyped<LayerPixel> LayerIntMargin;
typedef gfx::CoordTyped<ScreenPixel> ScreenCoord;
typedef gfx::IntCoordTyped<ScreenPixel> ScreenIntCoord;
typedef gfx::PointTyped<RenderTargetPixel> RenderTargetPoint;
typedef gfx::IntPointTyped<RenderTargetPixel> RenderTargetIntPoint;
typedef gfx::SizeTyped<RenderTargetPixel> RenderTargetSize;
typedef gfx::IntSizeTyped<RenderTargetPixel> RenderTargetIntSize;
typedef gfx::RectTyped<RenderTargetPixel> RenderTargetRect;
typedef gfx::IntRectTyped<RenderTargetPixel> RenderTargetIntRect;
typedef gfx::MarginTyped<RenderTargetPixel> RenderTargetMargin;
typedef gfx::IntMarginTyped<RenderTargetPixel> RenderTargetIntMargin;
typedef gfx::PointTyped<ScreenPixel> ScreenPoint;
typedef gfx::IntPointTyped<ScreenPixel> ScreenIntPoint;
typedef gfx::SizeTyped<ScreenPixel> ScreenSize;
@ -76,16 +88,18 @@ typedef gfx::MarginTyped<ScreenPixel> ScreenMargin;
typedef gfx::IntMarginTyped<ScreenPixel> ScreenIntMargin;
typedef gfx::ScaleFactor<CSSPixel, LayoutDevicePixel> CSSToLayoutDeviceScale;
typedef gfx::ScaleFactor<LayoutDevicePixel, CSSPixel> LayoutDeviceToCSSScale;
typedef gfx::ScaleFactor<CSSPixel, LayerPixel> CSSToLayerScale;
typedef gfx::ScaleFactor<LayerPixel, CSSPixel> LayerToCSSScale;
typedef gfx::ScaleFactor<CSSPixel, ScreenPixel> CSSToScreenScale;
typedef gfx::ScaleFactor<ScreenPixel, CSSPixel> ScreenToCSSScale;
typedef gfx::ScaleFactor<LayoutDevicePixel, CSSPixel> LayoutDeviceToCSSScale;
typedef gfx::ScaleFactor<LayoutDevicePixel, LayerPixel> LayoutDeviceToLayerScale;
typedef gfx::ScaleFactor<LayerPixel, LayoutDevicePixel> LayerToLayoutDeviceScale;
typedef gfx::ScaleFactor<LayoutDevicePixel, ScreenPixel> LayoutDeviceToScreenScale;
typedef gfx::ScaleFactor<ScreenPixel, LayoutDevicePixel> ScreenToLayoutDeviceScale;
typedef gfx::ScaleFactor<LayerPixel, CSSPixel> LayerToCSSScale;
typedef gfx::ScaleFactor<LayerPixel, LayoutDevicePixel> LayerToLayoutDeviceScale;
typedef gfx::ScaleFactor<LayerPixel, RenderTargetPixel> LayerToRenderTargetScale;
typedef gfx::ScaleFactor<LayerPixel, ScreenPixel> LayerToScreenScale;
typedef gfx::ScaleFactor<RenderTargetPixel, ScreenPixel> RenderTargetToScreenScale;
typedef gfx::ScaleFactor<ScreenPixel, CSSPixel> ScreenToCSSScale;
typedef gfx::ScaleFactor<ScreenPixel, LayoutDevicePixel> ScreenToLayoutDeviceScale;
typedef gfx::ScaleFactor<ScreenPixel, LayerPixel> ScreenToLayerScale;
/*
@ -215,6 +229,55 @@ struct LayerPixel {
static nsIntRect ToUntyped(const LayerIntRect& aRect) {
return nsIntRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static gfx::IntRect ToUnknown(const LayerIntRect& aRect) {
return gfx::IntRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static gfx::Rect ToUnknown(const LayerRect& aRect) {
return gfx::Rect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static LayerIntRect FromUntyped(const nsIntRect& aRect) {
return LayerIntRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static LayerIntPoint FromUntyped(const nsIntPoint& aPoint) {
return LayerIntPoint(aPoint.x, aPoint.y);
}
};
/*
* Layers are always composited to a render target. This unit
* represents one pixel in the render target. Note that for the
* root render target RenderTargetPixel == ScreenPixel. Also
* any ContainerLayer providing an intermediate surface will
* have RenderTargetPixel == LayerPixel.
*/
struct RenderTargetPixel {
static nsIntPoint ToUntyped(const RenderTargetIntPoint& aPoint) {
return nsIntPoint(aPoint.x, aPoint.y);
}
static nsIntRect ToUntyped(const RenderTargetIntRect& aRect) {
return nsIntRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static gfx::IntRect ToUnknown(const RenderTargetIntRect& aRect) {
return gfx::IntRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static gfx::Rect ToUnknown(const RenderTargetRect& aRect) {
return gfx::Rect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static RenderTargetRect FromUnknown(const gfx::Rect& aRect) {
return RenderTargetRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
static RenderTargetIntRect FromUntyped(const nsIntRect& aRect) {
return RenderTargetIntRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
};
/*