Bug 1220629 - Part 6: Implement PushLayer/PopLayer API in several wrapper DT types. r=jrmuizel

--HG--
extra : rebase_source : 5a421568fa20b23d7ceef71eb58014e29dbc1c76
This commit is contained in:
Bas Schouten 2016-01-06 00:23:33 +01:00
Родитель b5ed4b63ba
Коммит 12b9a82473
6 изменённых файлов: 63 добавлений и 2 удалений

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

@ -776,6 +776,9 @@ DrawTargetD2D1::PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
PushedLayer pushedLayer;
pushedLayer.mClipsArePushed = false;
pushedLayer.mIsOpaque = aOpaque;
pushedLayer.mOldPermitSubpixelAA = mPermitSubpixelAA;
mPermitSubpixelAA = aOpaque;
mDC->CreateCommandList(getter_AddRefs(pushedLayer.mCurrentList));
mPushedLayers.push_back(pushedLayer);
@ -788,6 +791,8 @@ DrawTargetD2D1::PopLayer()
MOZ_ASSERT(CurrentLayer().mPushedClips.size() == 0);
RefPtr<ID2D1CommandList> list = CurrentLayer().mCurrentList;
mPermitSubpixelAA = CurrentLayer().mOldPermitSubpixelAA;
mPushedLayers.pop_back();
mDC->SetTarget(CurrentTarget());

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

@ -243,13 +243,14 @@ private:
// List of pushed layers.
struct PushedLayer
{
PushedLayer() : mClipsArePushed(false), mIsOpaque(false) {}
PushedLayer() : mClipsArePushed(false), mIsOpaque(false), mOldPermitSubpixelAA(false) {}
std::vector<PushedClip> mPushedClips;
RefPtr<ID2D1CommandList> mCurrentList;
// True if the current clip stack is pushed to the CurrentTarget().
bool mClipsArePushed;
bool mIsOpaque;
bool mOldPermitSubpixelAA;
};
std::vector<PushedLayer> mPushedLayers;
PushedLayer& CurrentLayer()

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

@ -15,6 +15,11 @@ class DualSurface
public:
inline explicit DualSurface(SourceSurface *aSurface)
{
if (!aSurface) {
mA = mB = nullptr;
return;
}
if (aSurface->GetType() != SurfaceType::DUAL_DT) {
mA = mB = aSurface;
return;
@ -181,6 +186,16 @@ DrawTargetDual::Mask(const Pattern &aSource, const Pattern &aMask, const DrawOpt
mB->Mask(*source.mB, *mask.mB, aOptions);
}
void
DrawTargetDual::PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
const Matrix& aMaskTransform, const IntRect& aBounds,
bool aCopyBackground)
{
DualSurface mask(aMask);
mA->PushLayer(aOpaque, aOpacity, mask.mA, aMaskTransform, aBounds, aCopyBackground);
mB->PushLayer(aOpaque, aOpacity, mask.mB, aMaskTransform, aBounds, aCopyBackground);
}
already_AddRefed<DrawTarget>
DrawTargetDual::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{

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

@ -54,6 +54,7 @@ public:
FORWARD_FUNCTION1(PushClip, const Path *, aPath)
FORWARD_FUNCTION1(PushClipRect, const Rect &, aRect)
FORWARD_FUNCTION(PopClip)
FORWARD_FUNCTION(PopLayer)
FORWARD_FUNCTION1(ClearRect, const Rect &, aRect)
virtual void SetTransform(const Matrix &aTransform) override {
@ -104,7 +105,13 @@ public:
const GlyphRenderingOptions *aRenderingOptions) override;
virtual void Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions) override;
virtual void PushLayer(bool aOpaque, Float aOpacity,
SourceSurface* aMask,
const Matrix& aMaskTransform,
const IntRect& aBounds = IntRect(),
bool aCopyBackground = false) override;
virtual already_AddRefed<SourceSurface>
CreateSourceSurfaceFromData(unsigned char *aData,
const IntSize &aSize,
@ -155,6 +162,8 @@ public:
{
return true;
}
virtual bool IsCurrentGroupOpaque() override { return mA->IsCurrentGroupOpaque(); }
private:
RefPtr<DrawTarget> mA;

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

@ -305,5 +305,29 @@ DrawTargetTiled::Fill(const Path* aPath, const Pattern& aPattern, const DrawOpti
}
}
void
DrawTargetTiled::PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
const Matrix& aMaskTransform, const IntRect& aBounds,
bool aCopyBackground)
{
// XXX - not sure this is what we want or whether we want to continue drawing to a larger
// intermediate surface, that would require tweaking the code in here a little though.
for (size_t i = 0; i < mTiles.size(); i++) {
IntRect bounds = aBounds;
bounds.MoveBy(-mTiles[i].mTileOrigin);
mTiles[i].mDrawTarget->PushLayer(aOpaque, aOpacity, aMask, aMaskTransform, aBounds);
}
}
void
DrawTargetTiled::PopLayer()
{
// XXX - not sure this is what we want or whether we want to continue drawing to a larger
// intermediate surface, that would require tweaking the code in here a little though.
for (size_t i = 0; i < mTiles.size(); i++) {
mTiles[i].mDrawTarget->PopLayer();
}
}
} // namespace gfx
} // namespace mozilla

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

@ -103,6 +103,13 @@ public:
virtual void PushClip(const Path *aPath) override;
virtual void PushClipRect(const Rect &aRect) override;
virtual void PopClip() override;
virtual void PushLayer(bool aOpaque, Float aOpacity,
SourceSurface* aMask,
const Matrix& aMaskTransform,
const IntRect& aBounds = IntRect(),
bool aCopyBackground = false) override;
virtual void PopLayer() override;
virtual void SetTransform(const Matrix &aTransform) override;