Bug 1027763, part 1 - Rename DrawTarget::GetType() to DrawTarget::GetBackendType() in Moz2D code. r=Bas

This commit is contained in:
Jonathan Watt 2014-06-19 21:35:33 +01:00
parent e99f6cd57d
commit 3480cabb15
17 changed files with 31 additions and 21 deletions

View File

@ -620,7 +620,10 @@ public:
DrawTarget() : mTransformDirty(false), mPermitSubpixelAA(false) {}
virtual ~DrawTarget() {}
virtual BackendType GetType() const = 0;
// Temporary - to be removed after Mozilla code uses GetBackendType()
BackendType GetType() const { return GetBackendType(); }
virtual BackendType GetBackendType() const = 0;
/**
* Returns a SourceSurface which is a snapshot of the current contents of the DrawTarget.
* Multiple calls to Snapshot() without any drawing operations in between will

View File

@ -156,7 +156,7 @@ DrawTargetCG::~DrawTargetCG()
}
BackendType
DrawTargetCG::GetType() const
DrawTargetCG::GetBackendType() const
{
// It may be worth spliting Bitmap and IOSurface DrawTarget
// into seperate classes.
@ -186,7 +186,7 @@ DrawTargetCG::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aForma
// XXX: in thebes we use CGLayers to do this kind of thing. It probably makes sense
// to add that in somehow, but at a higher level
RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
if (newTarget->Init(GetType(), aSize, aFormat)) {
if (newTarget->Init(GetBackendType(), aSize, aFormat)) {
return newTarget.forget();
}
return nullptr;
@ -1573,7 +1573,8 @@ DrawTargetCG::MarkChanged()
CGContextRef
BorrowedCGContext::BorrowCGContextFromDrawTarget(DrawTarget *aDT)
{
if (aDT->GetType() == BackendType::COREGRAPHICS || aDT->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
if (aDT->GetBackendType() == BackendType::COREGRAPHICS ||
aDT->GetBackendType() == BackendType::COREGRAPHICS_ACCELERATED) {
DrawTargetCG* cgDT = static_cast<DrawTargetCG*>(aDT);
cgDT->MarkChanged();

View File

@ -100,7 +100,7 @@ public:
DrawTargetCG();
virtual ~DrawTargetCG();
virtual BackendType GetType() const;
virtual BackendType GetBackendType() const;
virtual TemporaryRef<SourceSurface> Snapshot();
virtual void DrawSurface(SourceSurface *aSurface,

View File

@ -1330,7 +1330,8 @@ DrawTargetCairo::GetUserSpaceClip()
cairo_t*
BorrowedCairoContext::BorrowCairoContextFromDrawTarget(DrawTarget* aDT)
{
if (aDT->GetType() != BackendType::CAIRO || aDT->IsDualDrawTarget()) {
if (aDT->GetBackendType() != BackendType::CAIRO ||
aDT->IsDualDrawTarget()) {
return nullptr;
}
DrawTargetCairo* cairoDT = static_cast<DrawTargetCairo*>(aDT);
@ -1351,7 +1352,8 @@ void
BorrowedCairoContext::ReturnCairoContextToDrawTarget(DrawTarget* aDT,
cairo_t* aCairo)
{
if (aDT->GetType() != BackendType::CAIRO || aDT->IsDualDrawTarget()) {
if (aDT->GetBackendType() != BackendType::CAIRO ||
aDT->IsDualDrawTarget()) {
return;
}
DrawTargetCairo* cairoDT = static_cast<DrawTargetCairo*>(aDT);

View File

@ -58,7 +58,7 @@ public:
DrawTargetCairo();
virtual ~DrawTargetCairo();
virtual BackendType GetType() const { return BackendType::CAIRO; }
virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
virtual TemporaryRef<SourceSurface> Snapshot();
virtual IntSize GetSize();

View File

@ -47,7 +47,7 @@ public:
DrawTargetD2D();
virtual ~DrawTargetD2D();
virtual BackendType GetType() const { return BackendType::DIRECT2D; }
virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
virtual TemporaryRef<SourceSurface> Snapshot();
virtual IntSize GetSize() { return mSize; }

View File

@ -39,7 +39,7 @@ public:
DrawTargetD2D1();
virtual ~DrawTargetD2D1();
virtual BackendType GetType() const { return BackendType::DIRECT2D1_1; }
virtual BackendType GetBackendType() const { return BackendType::DIRECT2D1_1; }
virtual TemporaryRef<SourceSurface> Snapshot();
virtual IntSize GetSize() { return mSize; }

View File

@ -43,7 +43,7 @@ public:
mFormat = aA->GetFormat();
}
virtual BackendType GetType() const { return mA->GetType(); }
virtual BackendType GetBackendType() const { return mA->GetBackendType(); }
virtual TemporaryRef<SourceSurface> Snapshot() { return new SourceSurfaceDual(mA, mB); }
virtual IntSize GetSize() { return mA->GetSize(); }

View File

@ -225,7 +225,10 @@ DrawTargetRecording::DrawTargetRecording(DrawEventRecorder *aRecorder, DrawTarge
, mFinalDT(aDT)
{
RefPtr<SourceSurface> snapshot = aHasData ? mFinalDT->Snapshot() : nullptr;
mRecorder->RecordEvent(RecordedDrawTargetCreation(this, mFinalDT->GetType(), mFinalDT->GetSize(), mFinalDT->GetFormat(),
mRecorder->RecordEvent(RecordedDrawTargetCreation(this,
mFinalDT->GetBackendType(),
mFinalDT->GetSize(),
mFinalDT->GetFormat(),
aHasData, snapshot));
mFormat = mFinalDT->GetFormat();
}

View File

@ -19,7 +19,7 @@ public:
DrawTargetRecording(DrawEventRecorder *aRecorder, DrawTarget *aDT, bool aHasData = false);
~DrawTargetRecording();
virtual BackendType GetType() const { return mFinalDT->GetType(); }
virtual BackendType GetBackendType() const { return mFinalDT->GetBackendType(); }
virtual TemporaryRef<SourceSurface> Snapshot();

View File

@ -31,7 +31,7 @@ public:
DrawTargetSkia();
virtual ~DrawTargetSkia();
virtual BackendType GetType() const { return BackendType::SKIA; }
virtual BackendType GetBackendType() const { return BackendType::SKIA; }
virtual TemporaryRef<SourceSurface> Snapshot();
virtual IntSize GetSize() { return mSize; }
virtual void Flush();

View File

@ -26,7 +26,7 @@ DrawTargetTiled::Init(const TileSet& aTiles)
for (size_t i = 0; i < mTiles.size(); i++) {
if (mTiles[0].mDrawTarget->GetFormat() != mTiles[i].mDrawTarget->GetFormat() ||
mTiles[0].mDrawTarget->GetType() != mTiles[i].mDrawTarget->GetType()) {
mTiles[0].mDrawTarget->GetBackendType() != mTiles[i].mDrawTarget->GetBackendType()) {
return false;
}
uint32_t newXMost = max(mRect.XMost(),

View File

@ -21,7 +21,7 @@ public:
bool Init(const TileSet& mTiles);
virtual BackendType GetType() const { return mTiles[0].mDrawTarget->GetType(); }
virtual BackendType GetBackendType() const { return mTiles[0].mDrawTarget->GetBackendType(); }
virtual TemporaryRef<SourceSurface> Snapshot();
virtual IntSize GetSize() { return IntSize(mRect.XMost(), mRect.YMost()); }

View File

@ -128,7 +128,7 @@ D2D1_CHANNEL_SELECTOR D2DChannelSelector(uint32_t aMode)
TemporaryRef<ID2D1Image> GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface)
{
switch (aDT->GetType()) {
switch (aDT->GetBackendType()) {
case BackendType::DIRECT2D1_1:
return static_cast<DrawTargetD2D1*>(aDT)->GetImageForSurface(aSurface, ExtendMode::CLAMP);
case BackendType::DIRECT2D:

View File

@ -79,13 +79,13 @@ TemporaryRef<Path>
ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
{
#ifdef USE_SKIA
if (aTarget->GetType() == BackendType::SKIA) {
if (aTarget->GetBackendType() == BackendType::SKIA) {
SkPath path = GetSkiaPathForGlyphs(aBuffer);
return new PathSkia(path, FillRule::FILL_WINDING);
}
#endif
#ifdef USE_CAIRO
if (aTarget->GetType() == BackendType::CAIRO) {
if (aTarget->GetBackendType() == BackendType::CAIRO) {
MOZ_ASSERT(mScaledFont);
DrawTarget *dt = const_cast<DrawTarget*>(aTarget);

View File

@ -309,7 +309,7 @@ ScaledFontDWrite::ScaledFontDWrite(uint8_t *aData, uint32_t aSize,
TemporaryRef<Path>
ScaledFontDWrite::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
{
if (aTarget->GetType() != BackendType::DIRECT2D) {
if (aTarget->GetBackendType() != BackendType::DIRECT2D) {
return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
}

View File

@ -79,7 +79,8 @@ SkTypeface* ScaledFontMac::GetSkTypeface()
TemporaryRef<Path>
ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
{
if (aTarget->GetType() == BackendType::COREGRAPHICS || aTarget->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
if (aTarget->GetBackendType() == BackendType::COREGRAPHICS ||
aTarget->GetBackendType() == BackendType::COREGRAPHICS_ACCELERATED) {
CGMutablePathRef path = CGPathCreateMutable();
for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {