Bug 958375 - 6/9 - Make BackendType and NativeSurfaceType typed enums - r=Bas

Specifically:
  r=Bas for manual changes
  f=Bas for automatic changes
See attachments on the bug for the specific breakdown.
This commit is contained in:
Benoit Jacob 2014-01-10 14:06:16 -05:00
parent 78b03d8b63
commit ccaa35314d
57 changed files with 212 additions and 206 deletions

View File

@ -161,9 +161,9 @@ DrawTargetCG::GetType() const
// It may be worth spliting Bitmap and IOSurface DrawTarget
// into seperate classes.
if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
return BACKEND_COREGRAPHICS_ACCELERATED;
return BackendType::COREGRAPHICS_ACCELERATED;
} else {
return BACKEND_COREGRAPHICS;
return BackendType::COREGRAPHICS;
}
}
@ -390,9 +390,9 @@ class GradientStopsCG : public GradientStops
if (mGradient)
CGGradientRelease(mGradient);
}
// Will always report BACKEND_COREGRAPHICS, but it is compatible
// with BACKEND_COREGRAPHICS_ACCELERATED
BackendType GetBackendType() const { return BACKEND_COREGRAPHICS; }
// Will always report BackendType::COREGRAPHICS, but it is compatible
// with BackendType::COREGRAPHICS_ACCELERATED
BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
// XXX this should be a union
CGGradientRef mGradient;
std::vector<GradientStop> mStops;
@ -992,7 +992,7 @@ DrawTargetCG::Stroke(const Path *aPath, const Pattern &aPattern, const StrokeOpt
CGContextBeginPath(cg);
assert(aPath->GetBackendType() == BACKEND_COREGRAPHICS);
assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
const PathCG *cgPath = static_cast<const PathCG*>(aPath);
CGContextAddPath(cg, cgPath->GetPath());
@ -1020,7 +1020,7 @@ DrawTargetCG::Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions
{
MarkChanged();
assert(aPath->GetBackendType() == BACKEND_COREGRAPHICS);
assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
CGContextSaveGState(mCg);
@ -1281,7 +1281,7 @@ DrawTargetCG::Init(BackendType aType,
//XXX: we'd be better off reusing the Colorspace across draw targets
mColorSpace = CGColorSpaceCreateDeviceRGB();
if (aData == nullptr && aType != BACKEND_COREGRAPHICS_ACCELERATED) {
if (aData == nullptr && aType != BackendType::COREGRAPHICS_ACCELERATED) {
// XXX: Currently, Init implicitly clears, that can often be a waste of time
mData.Realloc(aStride * aSize.height);
aData = static_cast<unsigned char*>(mData);
@ -1290,7 +1290,7 @@ DrawTargetCG::Init(BackendType aType,
mSize = aSize;
if (aType == BACKEND_COREGRAPHICS_ACCELERATED) {
if (aType == BackendType::COREGRAPHICS_ACCELERATED) {
RefPtr<MacIOSurface> ioSurface = MacIOSurface::CreateIOSurface(aSize.width, aSize.height);
mCg = ioSurface->CreateIOSurfaceContext();
// If we don't have the symbol for 'CreateIOSurfaceContext' mCg will be null
@ -1299,7 +1299,7 @@ DrawTargetCG::Init(BackendType aType,
mFormat = SurfaceFormat::B8G8R8A8;
if (!mCg || aType == BACKEND_COREGRAPHICS) {
if (!mCg || aType == BackendType::COREGRAPHICS) {
int bitsPerComponent = 8;
CGBitmapInfo bitinfo;
@ -1344,7 +1344,7 @@ DrawTargetCG::Init(BackendType aType,
CGContextSetShouldSmoothFonts(mCg, GetPermitSubpixelAA());
if (aType == BACKEND_COREGRAPHICS_ACCELERATED) {
if (aType == BackendType::COREGRAPHICS_ACCELERATED) {
// The bitmap backend uses callac to clear, we can't do that without
// reading back the surface. This should trigger something equivilent
// to glClear.
@ -1428,8 +1428,8 @@ DrawTargetCG::CreatePathBuilder(FillRule aFillRule) const
void*
DrawTargetCG::GetNativeSurface(NativeSurfaceType aType)
{
if ((aType == NATIVE_SURFACE_CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP) ||
(aType == NATIVE_SURFACE_CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE)) {
if ((aType == NativeSurfaceType::CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP) ||
(aType == NativeSurfaceType::CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE)) {
return mCg;
} else {
return nullptr;
@ -1490,7 +1490,7 @@ DrawTargetCG::PushClip(const Path *aPath)
CGContextSaveGState(mCg);
CGContextBeginPath(mCg);
assert(aPath->GetBackendType() == BACKEND_COREGRAPHICS);
assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
const PathCG *cgPath = static_cast<const PathCG*>(aPath);
@ -1544,7 +1544,7 @@ DrawTargetCG::SetPermitSubpixelAA(bool aPermitSubpixelAA) {
CGContextRef
BorrowedCGContext::BorrowCGContextFromDrawTarget(DrawTarget *aDT)
{
if (aDT->GetType() == BACKEND_COREGRAPHICS || aDT->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
if (aDT->GetType() == BackendType::COREGRAPHICS || aDT->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
DrawTargetCG* cgDT = static_cast<DrawTargetCG*>(aDT);
cgDT->MarkChanged();

View File

@ -172,12 +172,12 @@ PatternIsCompatible(const Pattern& aPattern)
case PATTERN_LINEAR_GRADIENT:
{
const LinearGradientPattern& pattern = static_cast<const LinearGradientPattern&>(aPattern);
return pattern.mStops->GetBackendType() == BACKEND_CAIRO;
return pattern.mStops->GetBackendType() == BackendType::CAIRO;
}
case PATTERN_RADIAL_GRADIENT:
{
const RadialGradientPattern& pattern = static_cast<const RadialGradientPattern&>(aPattern);
return pattern.mStops->GetBackendType() == BACKEND_CAIRO;
return pattern.mStops->GetBackendType() == BackendType::CAIRO;
}
default:
return true;
@ -341,7 +341,7 @@ GfxPatternToCairoPattern(const Pattern& aPattern, Float aAlpha)
pat = cairo_pattern_create_linear(pattern.mBegin.x, pattern.mBegin.y,
pattern.mEnd.x, pattern.mEnd.y);
MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO);
MOZ_ASSERT(pattern.mStops->GetBackendType() == BackendType::CAIRO);
GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode()));
@ -364,7 +364,7 @@ GfxPatternToCairoPattern(const Pattern& aPattern, Float aAlpha)
pat = cairo_pattern_create_radial(pattern.mCenter1.x, pattern.mCenter1.y, pattern.mRadius1,
pattern.mCenter2.x, pattern.mCenter2.y, pattern.mRadius2);
MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO);
MOZ_ASSERT(pattern.mStops->GetBackendType() == BackendType::CAIRO);
GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode()));
@ -834,7 +834,7 @@ DrawTargetCairo::Stroke(const Path *aPath,
{
AutoPrepareForDrawing prep(this, mContext, aPath);
if (aPath->GetBackendType() != BACKEND_CAIRO)
if (aPath->GetBackendType() != BackendType::CAIRO)
return;
PathCairo* path = const_cast<PathCairo*>(static_cast<const PathCairo*>(aPath));
@ -850,7 +850,7 @@ DrawTargetCairo::Fill(const Path *aPath,
{
AutoPrepareForDrawing prep(this, mContext, aPath);
if (aPath->GetBackendType() != BACKEND_CAIRO)
if (aPath->GetBackendType() != BackendType::CAIRO)
return;
PathCairo* path = const_cast<PathCairo*>(static_cast<const PathCairo*>(aPath));
@ -968,7 +968,7 @@ DrawTargetCairo::MaskSurface(const Pattern &aSource,
void
DrawTargetCairo::PushClip(const Path *aPath)
{
if (aPath->GetBackendType() != BACKEND_CAIRO) {
if (aPath->GetBackendType() != BackendType::CAIRO) {
return;
}
@ -1107,7 +1107,7 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
TemporaryRef<SourceSurface>
DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
{
if (aSurface.mType == NATIVE_SURFACE_CAIRO_SURFACE) {
if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
IntSize size;
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
if (GetCairoSurfaceSize(surf, size)) {
@ -1240,10 +1240,10 @@ DrawTargetCairo::Init(unsigned char* aData, const IntSize &aSize, int32_t aStrid
void *
DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
{
if (aType == NATIVE_SURFACE_CAIRO_SURFACE) {
if (aType == NativeSurfaceType::CAIRO_SURFACE) {
return cairo_get_target(mContext);
}
if (aType == NATIVE_SURFACE_CAIRO_CONTEXT) {
if (aType == NativeSurfaceType::CAIRO_CONTEXT) {
return mContext;
}
@ -1290,7 +1290,7 @@ DrawTargetCairo::GetUserSpaceClip()
cairo_t*
BorrowedCairoContext::BorrowCairoContextFromDrawTarget(DrawTarget* aDT)
{
if (aDT->GetType() != BACKEND_CAIRO || aDT->IsDualDrawTarget()) {
if (aDT->GetType() != BackendType::CAIRO || aDT->IsDualDrawTarget()) {
return nullptr;
}
DrawTargetCairo* cairoDT = static_cast<DrawTargetCairo*>(aDT);
@ -1311,7 +1311,7 @@ void
BorrowedCairoContext::ReturnCairoContextToDrawTarget(DrawTarget* aDT,
cairo_t* aCairo)
{
if (aDT->GetType() != BACKEND_CAIRO || aDT->IsDualDrawTarget()) {
if (aDT->GetType() != BackendType::CAIRO || aDT->IsDualDrawTarget()) {
return;
}
DrawTargetCairo* cairoDT = static_cast<DrawTargetCairo*>(aDT);

View File

@ -41,7 +41,7 @@ class GradientStopsCairo : public GradientStops
return mExtendMode;
}
virtual BackendType GetBackendType() const { return BACKEND_CAIRO; }
virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
private:
std::vector<GradientStop> mStops;
@ -56,7 +56,7 @@ public:
DrawTargetCairo();
virtual ~DrawTargetCairo();
virtual BackendType GetType() const { return BACKEND_CAIRO; }
virtual BackendType GetType() const { return BackendType::CAIRO; }
virtual TemporaryRef<SourceSurface> Snapshot();
virtual IntSize GetSize();

View File

@ -907,7 +907,7 @@ DrawTargetD2D::Stroke(const Path *aPath,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions)
{
if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
if (aPath->GetBackendType() != BackendType::DIRECT2D) {
gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
return;
}
@ -936,7 +936,7 @@ DrawTargetD2D::Fill(const Path *aPath,
const Pattern &aPattern,
const DrawOptions &aOptions)
{
if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
if (aPath->GetBackendType() != BackendType::DIRECT2D) {
gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
return;
}
@ -1086,7 +1086,7 @@ DrawTargetD2D::Mask(const Pattern &aSource,
void
DrawTargetD2D::PushClip(const Path *aPath)
{
if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
if (aPath->GetBackendType() != BackendType::DIRECT2D) {
gfxDebug() << *this << ": Ignoring clipping call for incompatible path.";
return;
}
@ -1194,7 +1194,7 @@ DrawTargetD2D::OptimizeSourceSurface(SourceSurface *aSurface) const
TemporaryRef<SourceSurface>
DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
{
if (aSurface.mType != NATIVE_SURFACE_D3D10_TEXTURE) {
if (aSurface.mType != NativeSurfaceType::D3D10_TEXTURE) {
gfxDebug() << *this << ": Failure to create source surface from non-D3D10 texture native surface.";
return nullptr;
}
@ -1293,7 +1293,7 @@ DrawTargetD2D::CreateFilter(FilterType aType)
void*
DrawTargetD2D::GetNativeSurface(NativeSurfaceType aType)
{
if (aType != NATIVE_SURFACE_D3D10_TEXTURE) {
if (aType != NativeSurfaceType::D3D10_TEXTURE) {
return nullptr;
}

View File

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

View File

@ -285,7 +285,7 @@ DrawTargetD2D1::Stroke(const Path *aPath,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions)
{
if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
if (aPath->GetBackendType() != BackendType::DIRECT2D) {
gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
return;
}
@ -306,7 +306,7 @@ DrawTargetD2D1::Fill(const Path *aPath,
const Pattern &aPattern,
const DrawOptions &aOptions)
{
if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
if (aPath->GetBackendType() != BackendType::DIRECT2D) {
gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
return;
}
@ -430,7 +430,7 @@ DrawTargetD2D1::Mask(const Pattern &aSource,
void
DrawTargetD2D1::PushClip(const Path *aPath)
{
if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
if (aPath->GetBackendType() != BackendType::DIRECT2D) {
gfxDebug() << *this << ": Ignoring clipping call for incompatible path.";
return;
}

View File

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

View File

@ -49,7 +49,7 @@ public:
mRecorder->RecordEvent(RecordedGradientStopsDestruction(this));
}
virtual BackendType GetBackendType() const { return BACKEND_RECORDING; }
virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
RefPtr<GradientStops> mFinalGradientStops;
RefPtr<DrawEventRecorderPrivate> mRecorder;
@ -68,7 +68,7 @@ GetSourceSurface(SourceSurface *aSurface)
static GradientStops *
GetGradientStops(GradientStops *aStops)
{
if (aStops->GetBackendType() != BACKEND_RECORDING) {
if (aStops->GetBackendType() != BackendType::RECORDING) {
return aStops;
}
@ -265,7 +265,7 @@ DrawTargetRecording::StrokeLine(const Point &aBegin,
Path*
DrawTargetRecording::GetPathForPathRecording(const Path *aPath) const
{
if (aPath->GetBackendType() != BACKEND_RECORDING) {
if (aPath->GetBackendType() != BackendType::RECORDING) {
return nullptr;
}
@ -574,7 +574,7 @@ void
DrawTargetRecording::EnsureStored(const Path *aPath)
{
if (!mRecorder->HasStoredPath(aPath)) {
if (aPath->GetBackendType() != BACKEND_RECORDING) {
if (aPath->GetBackendType() != BackendType::RECORDING) {
gfxWarning() << "Cannot record this fill path properly!";
} else {
PathRecording *recPath = const_cast<PathRecording*>(static_cast<const PathRecording*>(aPath));

View File

@ -69,7 +69,7 @@ public:
}
}
BackendType GetBackendType() const { return BACKEND_SKIA; }
BackendType GetBackendType() const { return BackendType::SKIA; }
std::vector<SkColor> mColors;
std::vector<SkScalar> mPositions;
@ -495,7 +495,7 @@ DrawTargetSkia::Stroke(const Path *aPath,
{
MarkChanged();
MOZ_ASSERT(aPath, "Null path");
if (aPath->GetBackendType() != BACKEND_SKIA) {
if (aPath->GetBackendType() != BackendType::SKIA) {
return;
}
@ -549,7 +549,7 @@ DrawTargetSkia::Fill(const Path *aPath,
const DrawOptions &aOptions)
{
MarkChanged();
if (aPath->GetBackendType() != BACKEND_SKIA) {
if (aPath->GetBackendType() != BackendType::SKIA) {
return;
}
@ -866,7 +866,7 @@ DrawTargetSkia::ClearRect(const Rect &aRect)
void
DrawTargetSkia::PushClip(const Path *aPath)
{
if (aPath->GetBackendType() != BACKEND_SKIA) {
if (aPath->GetBackendType() != BackendType::SKIA) {
return;
}

View File

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

View File

@ -187,7 +187,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
RefPtr<DrawTarget> retVal;
switch (aBackend) {
#ifdef WIN32
case BACKEND_DIRECT2D:
case BackendType::DIRECT2D:
{
RefPtr<DrawTargetD2D> newTarget;
newTarget = new DrawTargetD2D();
@ -197,7 +197,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
break;
}
#ifdef USE_D2D1_1
case BACKEND_DIRECT2D1_1:
case BackendType::DIRECT2D1_1:
{
RefPtr<DrawTargetD2D1> newTarget;
newTarget = new DrawTargetD2D1();
@ -208,8 +208,8 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
}
#endif
#elif defined XP_MACOSX
case BACKEND_COREGRAPHICS:
case BACKEND_COREGRAPHICS_ACCELERATED:
case BackendType::COREGRAPHICS:
case BackendType::COREGRAPHICS_ACCELERATED:
{
RefPtr<DrawTargetCG> newTarget;
newTarget = new DrawTargetCG();
@ -220,7 +220,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
}
#endif
#ifdef USE_SKIA
case BACKEND_SKIA:
case BackendType::SKIA:
{
RefPtr<DrawTargetSkia> newTarget;
newTarget = new DrawTargetSkia();
@ -231,7 +231,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
}
#endif
#ifdef USE_CAIRO
case BACKEND_CAIRO:
case BackendType::CAIRO:
{
RefPtr<DrawTargetCairo> newTarget;
newTarget = new DrawTargetCairo();
@ -254,7 +254,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
if (!retVal) {
// Failed
gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
}
return retVal;
@ -277,7 +277,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
switch (aBackend) {
#ifdef USE_SKIA
case BACKEND_SKIA:
case BackendType::SKIA:
{
RefPtr<DrawTargetSkia> newTarget;
newTarget = new DrawTargetSkia();
@ -286,7 +286,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
}
#endif
#ifdef XP_MACOSX
case BACKEND_COREGRAPHICS:
case BackendType::COREGRAPHICS:
{
RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
if (newTarget->Init(aBackend, aData, aSize, aStride, aFormat))
@ -295,7 +295,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
}
#endif
#ifdef USE_CAIRO
case BACKEND_CAIRO:
case BackendType::CAIRO:
{
RefPtr<DrawTargetCairo> newTarget;
newTarget = new DrawTargetCairo();
@ -316,7 +316,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
}
if (!retVal) {
gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
}
return retVal;

View File

@ -128,7 +128,7 @@ D2D1_CHANNEL_SELECTOR D2DChannelSelector(uint32_t aMode)
TemporaryRef<ID2D1Image> GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface)
{
if (aDT->GetType() == BACKEND_DIRECT2D1_1) {
if (aDT->GetType() == BackendType::DIRECT2D1_1) {
return static_cast<DrawTargetD2D1*>(aDT)->GetImageForSurface(aSurface, EXTEND_CLAMP);
}
RefPtr<ID2D1Image> image;

View File

@ -988,7 +988,7 @@ FilterNodeTransformSoftware::Render(const IntRect& aRect)
}
RefPtr<DrawTarget> dt =
Factory::CreateDrawTarget(BACKEND_CAIRO, aRect.Size(), input->GetFormat());
Factory::CreateDrawTarget(BackendType::CAIRO, aRect.Size(), input->GetFormat());
if (!dt) {
return nullptr;
}

View File

@ -20,7 +20,7 @@ public:
: mStopCollection(aStopCollection)
{}
virtual BackendType GetBackendType() const { return BACKEND_DIRECT2D; }
virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
private:
friend class DrawTargetD2D;

View File

@ -69,9 +69,9 @@ public:
}
virtual ~PathCG() { CGPathRelease(mPath); }
// Paths will always return BACKEND_COREGRAPHICS, but note that they
// are compatible with BACKEND_COREGRAPHICS_ACCELERATED backend.
virtual BackendType GetBackendType() const { return BACKEND_COREGRAPHICS; }
// Paths will always return BackendType::COREGRAPHICS, but note that they
// are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,

View File

@ -52,7 +52,7 @@ public:
PathCairo(cairo_t *aContext);
~PathCairo();
virtual BackendType GetBackendType() const { return BACKEND_CAIRO; }
virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,

View File

@ -68,7 +68,7 @@ public:
, mFillRule(aFillRule)
{}
virtual BackendType GetBackendType() const { return BACKEND_DIRECT2D; }
virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,

View File

@ -89,7 +89,7 @@ public:
~PathRecording();
virtual BackendType GetBackendType() const { return BACKEND_RECORDING; }
virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
FillRule aFillRule = FILL_WINDING) const;

View File

@ -52,7 +52,7 @@ public:
mPath.swap(aPath);
}
virtual BackendType GetBackendType() const { return BACKEND_SKIA; }
virtual BackendType GetBackendType() const { return BackendType::SKIA; }
virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,

View File

@ -17,9 +17,9 @@ using namespace std;
static std::string NameFromBackend(BackendType aType)
{
switch (aType) {
case BACKEND_NONE:
case BackendType::NONE:
return "None";
case BACKEND_DIRECT2D:
case BackendType::DIRECT2D:
return "Direct2D";
default:
return "Unknown";

View File

@ -79,17 +79,17 @@ TemporaryRef<Path>
ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
{
#ifdef USE_SKIA
if (aTarget->GetType() == BACKEND_SKIA) {
if (aTarget->GetType() == BackendType::SKIA) {
SkPath path = GetSkiaPathForGlyphs(aBuffer);
return new PathSkia(path, FILL_WINDING);
}
#endif
#ifdef USE_CAIRO
if (aTarget->GetType() == BACKEND_CAIRO) {
if (aTarget->GetType() == BackendType::CAIRO) {
MOZ_ASSERT(mScaledFont);
DrawTarget *dt = const_cast<DrawTarget*>(aTarget);
cairo_t *ctx = static_cast<cairo_t*>(dt->GetNativeSurface(NATIVE_SURFACE_CAIRO_CONTEXT));
cairo_t *ctx = static_cast<cairo_t*>(dt->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
bool isNewContext = !ctx;
if (!ctx) {
@ -128,14 +128,14 @@ void
ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint)
{
#ifdef USE_SKIA
if (aBackendType == BACKEND_SKIA) {
if (aBackendType == BackendType::SKIA) {
PathBuilderSkia *builder = static_cast<PathBuilderSkia*>(aBuilder);
builder->AppendPath(GetSkiaPathForGlyphs(aBuffer));
return;
}
#endif
#ifdef USE_CAIRO
if (aBackendType == BACKEND_CAIRO) {
if (aBackendType == BackendType::CAIRO) {
MOZ_ASSERT(mScaledFont);
PathBuilderCairo* builder = static_cast<PathBuilderCairo*>(aBuilder);

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() != BACKEND_DIRECT2D) {
if (aTarget->GetType() != BackendType::DIRECT2D) {
return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
}
@ -326,7 +326,7 @@ ScaledFontDWrite::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget
void
ScaledFontDWrite::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint)
{
if (aBackendType != BACKEND_DIRECT2D) {
if (aBackendType != BackendType::DIRECT2D) {
ScaledFontBase::CopyGlyphsToBuilder(aBuffer, aBuilder, aBackendType, aTransformHint);
return;
}

View File

@ -79,7 +79,7 @@ SkTypeface* ScaledFontMac::GetSkTypeface()
TemporaryRef<Path>
ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
{
if (aTarget->GetType() == BACKEND_COREGRAPHICS || aTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
if (aTarget->GetType() == BackendType::COREGRAPHICS || aTarget->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
CGMutablePathRef path = CGPathCreateMutable();
for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
@ -104,7 +104,7 @@ ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aT
void
ScaledFontMac::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint)
{
if (!(aBackendType == BACKEND_COREGRAPHICS || aBackendType == BACKEND_COREGRAPHICS_ACCELERATED)) {
if (!(aBackendType == BackendType::COREGRAPHICS || aBackendType == BackendType::COREGRAPHICS_ACCELERATED)) {
ScaledFontBase::CopyGlyphsToBuilder(aBuffer, aBuilder, aBackendType, aTransformHint);
return;
}

View File

@ -261,7 +261,7 @@ SourceSurfaceCGBitmapContext::SourceSurfaceCGBitmapContext(DrawTargetCG *aDrawTa
{
mDrawTarget = aDrawTarget;
mFormat = aDrawTarget->GetFormat();
mCg = (CGContextRef)aDrawTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT);
mCg = (CGContextRef)aDrawTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT);
if (!mCg)
abort();
@ -328,7 +328,7 @@ SourceSurfaceCGBitmapContext::~SourceSurfaceCGBitmapContext()
SourceSurfaceCGIOSurfaceContext::SourceSurfaceCGIOSurfaceContext(DrawTargetCG *aDrawTarget)
{
CGContextRef cg = (CGContextRef)aDrawTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT_ACCELERATED);
CGContextRef cg = (CGContextRef)aDrawTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT_ACCELERATED);
RefPtr<MacIOSurface> surf = MacIOSurface::IOSurfaceContextGetSurface(cg);

View File

@ -71,17 +71,16 @@ MOZ_BEGIN_ENUM_CLASS(FilterType)
UNPREMULTIPLY
MOZ_END_ENUM_CLASS(FilterType)
enum BackendType
{
BACKEND_NONE = 0,
BACKEND_DIRECT2D,
BACKEND_COREGRAPHICS,
BACKEND_COREGRAPHICS_ACCELERATED,
BACKEND_CAIRO,
BACKEND_SKIA,
BACKEND_RECORDING,
BACKEND_DIRECT2D1_1
};
MOZ_BEGIN_ENUM_CLASS(BackendType)
NONE = 0,
DIRECT2D,
COREGRAPHICS,
COREGRAPHICS_ACCELERATED,
CAIRO,
SKIA,
RECORDING,
DIRECT2D1_1
MOZ_END_ENUM_CLASS(BackendType)
enum FontType
{
@ -93,14 +92,13 @@ enum FontType
FONT_COREGRAPHICS
};
enum NativeSurfaceType
{
NATIVE_SURFACE_D3D10_TEXTURE,
NATIVE_SURFACE_CAIRO_SURFACE,
NATIVE_SURFACE_CAIRO_CONTEXT,
NATIVE_SURFACE_CGCONTEXT,
NATIVE_SURFACE_CGCONTEXT_ACCELERATED
};
MOZ_BEGIN_ENUM_CLASS(NativeSurfaceType)
D3D10_TEXTURE,
CAIRO_SURFACE,
CAIRO_CONTEXT,
CGCONTEXT,
CGCONTEXT_ACCELERATED
MOZ_END_ENUM_CLASS(NativeSurfaceType)
enum NativeFontType
{

View File

@ -19,10 +19,10 @@ TestBugs::TestBugs()
void
TestBugs::CairoClip918671()
{
RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BACKEND_CAIRO,
RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BackendType::CAIRO,
IntSize(100, 100),
SurfaceFormat::B8G8R8A8);
RefPtr<DrawTarget> ref = Factory::CreateDrawTarget(BACKEND_CAIRO,
RefPtr<DrawTarget> ref = Factory::CreateDrawTarget(BackendType::CAIRO,
IntSize(100, 100),
SurfaceFormat::B8G8R8A8);
// Create a path that extends around the center rect but doesn't intersect it.
@ -71,7 +71,7 @@ TestBugs::CairoClip918671()
void
TestBugs::PushPopClip950550()
{
RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BACKEND_CAIRO,
RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BackendType::CAIRO,
IntSize(500, 500),
SurfaceFormat::B8G8R8A8);
dt->PushClipRect(Rect(0, 0, 100, 100));

View File

@ -19,5 +19,5 @@ TestDrawTargetD2D::TestDrawTargetD2D()
Factory::SetDirect3D10Device(mDevice);
mDT = Factory::CreateDrawTarget(BACKEND_DIRECT2D, IntSize(DT_WIDTH, DT_HEIGHT), SurfaceFormat::B8G8R8A8);
mDT = Factory::CreateDrawTarget(BackendType::DIRECT2D, IntSize(DT_WIDTH, DT_HEIGHT), SurfaceFormat::B8G8R8A8);
}

View File

@ -411,7 +411,7 @@ static TemporaryRef<DataSourceSurface> YInvertImageSurface(DataSourceSurface* aS
aSurf->GetFormat(),
aSurf->Stride());
RefPtr<DrawTarget> dt =
Factory::CreateDrawTargetForData(BACKEND_CAIRO,
Factory::CreateDrawTargetForData(BackendType::CAIRO,
temp->GetData(),
temp->GetSize(),
temp->Stride(),

View File

@ -101,7 +101,7 @@ RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget,
// (to avoid flickering) but direct2d is ok since it defers rendering.
// We should try abstract this logic in a helper when we have other use
// cases.
if (aTarget->GetType() == BACKEND_DIRECT2D && aOperator == OP_SOURCE) {
if (aTarget->GetType() == BackendType::DIRECT2D && aOperator == OP_SOURCE) {
aOperator = OP_OVER;
if (mDTBuffer->GetFormat() == SurfaceFormat::B8G8R8A8) {
aTarget->ClearRect(ToRect(fillRect));

View File

@ -497,7 +497,7 @@ public:
// The type of draw target returned by LockDrawTarget.
virtual gfx::BackendType BackendType()
{
return gfx::BACKEND_NONE;
return gfx::BackendType::NONE;
}
virtual void ReleaseResources() {}
@ -590,7 +590,7 @@ public:
virtual gfx::DrawTarget* LockDrawTarget();
virtual gfx::BackendType BackendType() MOZ_OVERRIDE
{
return gfx::BACKEND_CAIRO;
return gfx::BackendType::CAIRO;
}
virtual void Unlock() MOZ_OVERRIDE;
virtual bool EnsureAllocated(gfx::IntSize aSize, gfxContentType aType) MOZ_OVERRIDE;

View File

@ -750,7 +750,7 @@ LayerManagerComposite::CreateDrawTarget(const IntSize &aSize,
aSize.width > 64 && aSize.height > 64 &&
gfxPlatformMac::GetPlatform()->UseAcceleratedCanvas();
if (useAcceleration) {
return Factory::CreateDrawTarget(BACKEND_COREGRAPHICS_ACCELERATED,
return Factory::CreateDrawTarget(BackendType::COREGRAPHICS_ACCELERATED,
aSize, aFormat);
}
#endif

View File

@ -77,7 +77,7 @@ CanvasLayerD3D10::Initialize(const Data& aData)
mDrawTarget = aData.mDrawTarget;
mNeedsYFlip = false;
mDataIsPremultiplied = true;
void *texture = mDrawTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE);
void *texture = mDrawTarget->GetNativeSurface(NativeSurfaceType::D3D10_TEXTURE);
if (texture) {
mTexture = static_cast<ID3D10Texture2D*>(texture);
@ -168,7 +168,7 @@ CanvasLayerD3D10::UpdateSurface()
DataSourceSurface* frameData = shareSurf->GetData();
// Scope for gfxContext, so it's destroyed before Unmap.
{
RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BackendType::CAIRO,
(uint8_t*)map.pData,
shareSurf->Size(),
map.RowPitch,

View File

@ -501,7 +501,7 @@ LayerManagerD3D10::CreateDrawTarget(const IntSize &aSize,
{
if ((aFormat != SurfaceFormat::B8G8R8A8 &&
aFormat != SurfaceFormat::B8G8R8X8) ||
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() != BACKEND_DIRECT2D) {
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() != BackendType::DIRECT2D) {
return LayerManager::CreateDrawTarget(aSize, aFormat);
}

View File

@ -235,7 +235,7 @@ public:
virtual gfx::DrawTarget* LockDrawTarget() MOZ_OVERRIDE;
virtual gfx::BackendType BackendType() MOZ_OVERRIDE
{
return gfx::BACKEND_DIRECT2D;
return gfx::BackendType::DIRECT2D;
}
virtual void Unlock() MOZ_OVERRIDE;

View File

@ -104,7 +104,7 @@ CanvasLayerD3D9::UpdateSurface()
DataSourceSurface* frameData = shareSurf->GetData();
// Scope for gfxContext, so it's destroyed early.
{
RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BackendType::CAIRO,
(uint8_t*)rect.pBits,
shareSurf->Size(),
rect.Pitch,

View File

@ -613,7 +613,7 @@ public:
virtual gfx::DrawTarget* LockDrawTarget() MOZ_OVERRIDE;
virtual gfx::BackendType BackendType() MOZ_OVERRIDE
{
return gfx::BACKEND_CAIRO;
return gfx::BackendType::CAIRO;
}
virtual void Unlock() MOZ_OVERRIDE;
@ -654,7 +654,7 @@ public:
virtual gfx::DrawTarget* LockDrawTarget() MOZ_OVERRIDE;
virtual gfx::BackendType BackendType() MOZ_OVERRIDE
{
return gfx::BACKEND_CAIRO;
return gfx::BackendType::CAIRO;
}
virtual void Unlock() MOZ_OVERRIDE;

View File

@ -480,7 +480,7 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode,
return;
nsRefPtr<gfxContext> context;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BACKEND_CAIRO)) {
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BackendType::CAIRO)) {
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(destinationSurface,
IntSize(destinationSurface->GetSize().width,

View File

@ -342,7 +342,7 @@ TemporaryRef<ScaledFont>
gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
{
NativeFont nativeFont;
if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
if (aTarget->GetType() == BackendType::CAIRO || aTarget->GetType() == BackendType::SKIA) {
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
nativeFont.mFont = aFont->GetCairoScaledFont();
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());

View File

@ -154,9 +154,9 @@ gfxContext::OriginalSurface()
return mSurface;
}
if (mOriginalDT && mOriginalDT->GetType() == BACKEND_CAIRO) {
if (mOriginalDT && mOriginalDT->GetType() == BackendType::CAIRO) {
cairo_surface_t *s =
(cairo_surface_t*)mOriginalDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE);
(cairo_surface_t*)mOriginalDT->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE);
if (s) {
mSurface = gfxASurface::Wrap(s);
return mSurface;
@ -181,9 +181,9 @@ gfxContext::CurrentSurface(gfxFloat *dx, gfxFloat *dy)
cairo_surface_get_device_offset(s, dx, dy);
return gfxASurface::Wrap(s);
} else {
if (mDT->GetType() == BACKEND_CAIRO) {
if (mDT->GetType() == BackendType::CAIRO) {
cairo_surface_t *s =
(cairo_surface_t*)mDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE);
(cairo_surface_t*)mDT->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE);
if (s) {
if (dx && dy) {
*dx = -CurrentState().deviceOffset.x;
@ -208,9 +208,9 @@ gfxContext::GetCairo()
return mCairo;
}
if (mDT->GetType() == BACKEND_CAIRO) {
if (mDT->GetType() == BackendType::CAIRO) {
cairo_t *ctx =
(cairo_t*)mDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_CONTEXT);
(cairo_t*)mDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT);
if (ctx) {
return ctx;
}

View File

@ -693,7 +693,7 @@ gfxDWriteFont::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
TemporaryRef<ScaledFont>
gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
{
bool wantCairo = aTarget->GetType() == BACKEND_CAIRO;
bool wantCairo = aTarget->GetType() == BackendType::CAIRO;
if (mAzureScaledFont && mAzureScaledFontIsCairo == wantCairo) {
return mAzureScaledFont;
}

View File

@ -2641,7 +2641,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
// The cairo DrawTarget backend uses the cairo_scaled_font directly
// and so has the font skew matrix applied already.
if (mScaledFont &&
dt->GetType() != BACKEND_CAIRO) {
dt->GetType() != BackendType::CAIRO) {
cairo_matrix_t matrix;
cairo_scaled_font_get_font_matrix(mScaledFont, &matrix);
if (matrix.xy != 0) {

View File

@ -44,7 +44,7 @@ struct GradientCacheKey : public PLDHashEntryHdr {
{
PLDHashNumber hash = 0;
FloatUint32 convert;
hash = AddToHash(hash, aKey->mBackendType);
hash = AddToHash(hash, int(aKey->mBackendType));
hash = AddToHash(hash, aKey->mExtend);
for (uint32_t i = 0; i < aKey->mStops.Length(); i++) {
hash = AddToHash(hash, aKey->mStops[i].color.ToABGR());

View File

@ -315,10 +315,10 @@ gfxPlatform::gfxPlatform()
"layers.draw-bigimage-borders",
false);
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
uint32_t contentMask = 1 << BACKEND_CAIRO;
InitBackendPrefs(canvasMask, BACKEND_CAIRO,
contentMask, BACKEND_CAIRO);
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
InitBackendPrefs(canvasMask, BackendType::CAIRO,
contentMask, BackendType::CAIRO);
}
gfxPlatform*
@ -762,7 +762,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
format != SurfaceFormat::A8) {
NativeSurface surf;
surf.mFormat = format;
surf.mType = NATIVE_SURFACE_D3D10_TEXTURE;
surf.mType = NativeSurfaceType::D3D10_TEXTURE;
surf.mSurface = static_cast<gfxD2DSurface*>(aSurface)->GetTexture();
mozilla::gfx::DrawTarget *dt = static_cast<mozilla::gfx::DrawTarget*>(aSurface->GetData(&kDrawTarget));
if (dt) {
@ -771,12 +771,12 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
} else
#endif
if (aSurface->CairoSurface() && aTarget->GetType() == BACKEND_CAIRO) {
if (aSurface->CairoSurface() && aTarget->GetType() == BackendType::CAIRO) {
// If this is an xlib cairo surface we don't want to fetch it into memory
// because this is a major slow down.
NativeSurface surf;
surf.mFormat = format;
surf.mType = NATIVE_SURFACE_CAIRO_SURFACE;
surf.mType = NativeSurfaceType::CAIRO_SURFACE;
surf.mSurface = aSurface->CairoSurface();
srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
@ -901,7 +901,7 @@ bool
gfxPlatform::UseAcceleratedSkiaCanvas()
{
return Preferences::GetBool("gfx.canvas.azure.accelerated", false) &&
mPreferredCanvasBackend == BACKEND_SKIA;
mPreferredCanvasBackend == BackendType::SKIA;
}
void
@ -940,9 +940,9 @@ gfxPlatform::InitializeSkiaCaches()
already_AddRefed<gfxASurface>
gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{
if (aTarget->GetType() == BACKEND_CAIRO) {
if (aTarget->GetType() == BackendType::CAIRO) {
cairo_surface_t* csurf =
static_cast<cairo_surface_t*>(aTarget->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE));
static_cast<cairo_surface_t*>(aTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
if (csurf) {
return gfxASurface::Wrap(csurf);
}
@ -987,7 +987,7 @@ gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSi
// now, but this might need to change in the future (using
// CreateOffscreenSurface() and CreateDrawTargetForSurface() for all
// backends).
if (aBackend == BACKEND_CAIRO) {
if (aBackend == BackendType::CAIRO) {
nsRefPtr<gfxASurface> surf = CreateOffscreenSurface(ThebesIntSize(aSize),
ContentForFormat(aFormat));
if (!surf || surf->CairoStatus()) {
@ -1003,10 +1003,10 @@ gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSi
RefPtr<DrawTarget>
gfxPlatform::CreateOffscreenCanvasDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
{
NS_ASSERTION(mPreferredCanvasBackend, "No backend.");
NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
RefPtr<DrawTarget> target = CreateDrawTargetForBackend(mPreferredCanvasBackend, aSize, aFormat);
if (target ||
mFallbackCanvasBackend == BACKEND_NONE) {
mFallbackCanvasBackend == BackendType::NONE) {
return target;
}
@ -1016,15 +1016,15 @@ gfxPlatform::CreateOffscreenCanvasDrawTarget(const IntSize& aSize, SurfaceFormat
RefPtr<DrawTarget>
gfxPlatform::CreateOffscreenContentDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
{
NS_ASSERTION(mContentBackend, "No backend.");
NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
return CreateDrawTargetForBackend(mContentBackend, aSize, aFormat);
}
RefPtr<DrawTarget>
gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat)
{
NS_ASSERTION(mContentBackend, "No backend.");
if (mContentBackend == BACKEND_CAIRO) {
NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
if (mContentBackend == BackendType::CAIRO) {
nsRefPtr<gfxImageSurface> image = new gfxImageSurface(aData, gfxIntSize(aSize.width, aSize.height), aStride, SurfaceFormatToImageFormat(aFormat));
return Factory::CreateDrawTargetForCairoSurface(image->CairoSurface(), aSize);
}
@ -1035,14 +1035,14 @@ gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize,
gfxPlatform::BackendTypeForName(const nsCString& aName)
{
if (aName.EqualsLiteral("cairo"))
return BACKEND_CAIRO;
return BackendType::CAIRO;
if (aName.EqualsLiteral("skia"))
return BACKEND_SKIA;
return BackendType::SKIA;
if (aName.EqualsLiteral("direct2d"))
return BACKEND_DIRECT2D;
return BackendType::DIRECT2D;
if (aName.EqualsLiteral("cg"))
return BACKEND_COREGRAPHICS;
return BACKEND_NONE;
return BackendType::COREGRAPHICS;
return BackendType::NONE;
}
nsresult
@ -1518,15 +1518,15 @@ gfxPlatform::InitBackendPrefs(uint32_t aCanvasBitmask, BackendType aCanvasDefaul
uint32_t aContentBitmask, BackendType aContentDefault)
{
mPreferredCanvasBackend = GetCanvasBackendPref(aCanvasBitmask);
if (!mPreferredCanvasBackend) {
if (mPreferredCanvasBackend == BackendType::NONE) {
mPreferredCanvasBackend = aCanvasDefault;
}
mFallbackCanvasBackend =
GetCanvasBackendPref(aCanvasBitmask & ~(1 << mPreferredCanvasBackend));
GetCanvasBackendPref(aCanvasBitmask & ~BackendTypeBit(mPreferredCanvasBackend));
mContentBackendBitmask = aContentBitmask;
mContentBackend = GetContentBackendPref(mContentBackendBitmask);
if (!mContentBackend) {
if (mContentBackend == BackendType::NONE) {
mContentBackend = aContentDefault;
}
}
@ -1553,12 +1553,12 @@ gfxPlatform::GetBackendPref(const char* aBackendPrefName, uint32_t &aBackendBitm
}
uint32_t allowedBackends = 0;
BackendType result = BACKEND_NONE;
BackendType result = BackendType::NONE;
for (uint32_t i = 0; i < backendList.Length(); ++i) {
BackendType type = BackendTypeForName(backendList[i]);
if ((1 << type) & aBackendBitmask) {
allowedBackends |= (1 << type);
if (result == BACKEND_NONE) {
if (BackendTypeBit(type) & aBackendBitmask) {
allowedBackends |= BackendTypeBit(type);
if (result == BackendType::NONE) {
result = type;
}
}

View File

@ -50,6 +50,12 @@ class DrawTarget;
class SourceSurface;
class ScaledFont;
class DrawEventRecorder;
inline uint32_t
BackendTypeBit(BackendType b)
{
return 1 << int(b);
}
}
}
@ -130,21 +136,21 @@ inline const char*
GetBackendName(mozilla::gfx::BackendType aBackend)
{
switch (aBackend) {
case mozilla::gfx::BACKEND_DIRECT2D:
case mozilla::gfx::BackendType::DIRECT2D:
return "direct2d";
case mozilla::gfx::BACKEND_COREGRAPHICS_ACCELERATED:
case mozilla::gfx::BackendType::COREGRAPHICS_ACCELERATED:
return "quartz accelerated";
case mozilla::gfx::BACKEND_COREGRAPHICS:
case mozilla::gfx::BackendType::COREGRAPHICS:
return "quartz";
case mozilla::gfx::BACKEND_CAIRO:
case mozilla::gfx::BackendType::CAIRO:
return "cairo";
case mozilla::gfx::BACKEND_SKIA:
case mozilla::gfx::BackendType::SKIA:
return "skia";
case mozilla::gfx::BACKEND_RECORDING:
case mozilla::gfx::BackendType::RECORDING:
return "recording";
case mozilla::gfx::BACKEND_DIRECT2D1_1:
case mozilla::gfx::BackendType::DIRECT2D1_1:
return "direct2d 1.1";
case mozilla::gfx::BACKEND_NONE:
case mozilla::gfx::BackendType::NONE:
return "none";
}
MOZ_CRASH("Incomplete switch");
@ -261,7 +267,7 @@ public:
* supported for content drawing.
*/
bool SupportsAzureContent() {
return GetContentBackend() != mozilla::gfx::BACKEND_NONE;
return GetContentBackend() != mozilla::gfx::BackendType::NONE;
}
/**
@ -274,7 +280,7 @@ public:
bool SupportsAzureContentForDrawTarget(mozilla::gfx::DrawTarget* aTarget);
bool SupportsAzureContentForType(mozilla::gfx::BackendType aType) {
return (1 << aType) & mContentBackendBitmask;
return BackendTypeBit(aType) & mContentBackendBitmask;
}
virtual bool UseAcceleratedSkiaCanvas();

View File

@ -62,10 +62,10 @@ gfxPlatformGtk::gfxPlatformGtk()
sUseXRender = mozilla::Preferences::GetBool("gfx.xrender.enabled");
#endif
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
uint32_t contentMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
InitBackendPrefs(canvasMask, BACKEND_CAIRO,
contentMask, BACKEND_CAIRO);
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
InitBackendPrefs(canvasMask, BackendType::CAIRO,
contentMask, BackendType::CAIRO);
}
gfxPlatformGtk::~gfxPlatformGtk()
@ -453,7 +453,7 @@ gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
{
NativeFont nativeFont;
if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
if (aTarget->GetType() == BackendType::CAIRO || aTarget->GetType() == BackendType::SKIA) {
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
nativeFont.mFont = aFont->GetCairoScaledFont();
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());

View File

@ -81,8 +81,8 @@ public:
bool UseXRender() {
#if defined(MOZ_X11)
if (GetContentBackend() != mozilla::gfx::BACKEND_NONE &&
GetContentBackend() != mozilla::gfx::BACKEND_CAIRO)
if (GetContentBackend() != mozilla::gfx::BackendType::NONE &&
GetContentBackend() != mozilla::gfx::BackendType::CAIRO)
return false;
return sUseXRender;

View File

@ -65,10 +65,12 @@ gfxPlatformMac::gfxPlatformMac()
DisableFontActivation();
mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA) | (1 << BACKEND_COREGRAPHICS);
uint32_t contentMask = (1 << BACKEND_COREGRAPHICS);
InitBackendPrefs(canvasMask, BACKEND_COREGRAPHICS,
contentMask, BACKEND_COREGRAPHICS);
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) |
BackendTypeBit(BackendType::SKIA) |
BackendTypeBit(BackendType::COREGRAPHICS);
uint32_t contentMask = BackendTypeBit(BackendType::COREGRAPHICS);
InitBackendPrefs(canvasMask, BackendType::COREGRAPHICS,
contentMask, BackendType::COREGRAPHICS);
}
gfxPlatformMac::~gfxPlatformMac()
@ -363,8 +365,8 @@ gfxPlatformMac::ReadAntiAliasingThreshold()
already_AddRefed<gfxASurface>
gfxPlatformMac::CreateThebesSurfaceAliasForDrawTarget_hack(mozilla::gfx::DrawTarget *aTarget)
{
if (aTarget->GetType() == BACKEND_COREGRAPHICS) {
CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT));
if (aTarget->GetType() == BackendType::COREGRAPHICS) {
CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
unsigned char* data = (unsigned char*)CGBitmapContextGetData(cg);
size_t bpp = CGBitmapContextGetBitsPerPixel(cg);
size_t stride = CGBitmapContextGetBytesPerRow(cg);
@ -384,7 +386,7 @@ gfxPlatformMac::CreateThebesSurfaceAliasForDrawTarget_hack(mozilla::gfx::DrawTar
already_AddRefed<gfxASurface>
gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{
if (aTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
if (aTarget->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
RefPtr<SourceSurface> source = aTarget->Snapshot();
RefPtr<DataSourceSurface> sourceData = source->GetDataSurface();
unsigned char* data = sourceData->GetData();
@ -394,8 +396,8 @@ gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageFormatARGB32);
cpy->CopyFrom(surf);
return cpy.forget();
} else if (aTarget->GetType() == BACKEND_COREGRAPHICS) {
CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT));
} else if (aTarget->GetType() == BackendType::COREGRAPHICS) {
CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
//XXX: it would be nice to have an implicit conversion from IntSize to gfxIntSize
IntSize intSize = aTarget->GetSize();

View File

@ -41,7 +41,7 @@ gfxQuartzNativeDrawing::BeginNativeDrawing()
if (!mContext->IsCairo()) {
DrawTarget *dt = mContext->GetDrawTarget();
if (dt->GetType() == BACKEND_COREGRAPHICS) {
if (dt->GetType() == BackendType::COREGRAPHICS) {
if (dt->IsDualDrawTarget()) {
IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
NSToIntFloor(mNativeRect.height * mBackingScale));
@ -49,7 +49,7 @@ gfxQuartzNativeDrawing::BeginNativeDrawing()
if (backingSize.IsEmpty())
return nullptr;
mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, SurfaceFormat::B8G8R8A8);
mDrawTarget = Factory::CreateDrawTarget(BackendType::COREGRAPHICS, backingSize, SurfaceFormat::B8G8R8A8);
Matrix transform;
transform.Scale(mBackingScale, mBackingScale);

View File

@ -184,7 +184,7 @@ bool
gfxWindowsNativeDrawing::IsDoublePass()
{
if (!mContext->IsCairo() &&
(mContext->GetDrawTarget()->GetType() != mozilla::gfx::BACKEND_CAIRO ||
(mContext->GetDrawTarget()->GetType() != mozilla::gfx::BackendType::CAIRO ||
mContext->GetDrawTarget()->IsDualDrawTarget())) {
return true;
}

View File

@ -493,15 +493,15 @@ gfxWindowsPlatform::UpdateRenderMode()
}
#endif
uint32_t canvasMask = 1 << BACKEND_CAIRO;
uint32_t contentMask = 1 << BACKEND_CAIRO;
BackendType defaultBackend = BACKEND_CAIRO;
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
BackendType defaultBackend = BackendType::CAIRO;
if (mRenderMode == RENDER_DIRECT2D) {
canvasMask |= 1 << BACKEND_DIRECT2D;
contentMask |= 1 << BACKEND_DIRECT2D;
defaultBackend = BACKEND_DIRECT2D;
canvasMask |= BackendTypeBit(BackendType::DIRECT2D);
contentMask |= BackendTypeBit(BackendType::DIRECT2D);
defaultBackend = BackendType::DIRECT2D;
} else {
canvasMask |= 1 << BACKEND_SKIA;
canvasMask |= BackendTypeBit(BackendType::SKIA);
}
InitBackendPrefs(canvasMask, defaultBackend,
contentMask, defaultBackend);
@ -695,7 +695,7 @@ gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
nativeFont.mType = NATIVE_FONT_DWRITE_FONT_FACE;
nativeFont.mFont = font->GetFontFace();
if (aTarget->GetType() == BACKEND_CAIRO) {
if (aTarget->GetType() == BackendType::CAIRO) {
return Factory::CreateScaledFontWithCairo(nativeFont,
font->GetAdjustedSize(),
font->GetCairoScaledFont());
@ -714,7 +714,7 @@ gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
GetObject(static_cast<gfxGDIFont*>(aFont)->GetHFONT(), sizeof(LOGFONT), &lf);
nativeFont.mFont = &lf;
if (aTarget->GetType() == BACKEND_CAIRO) {
if (aTarget->GetType() == BackendType::CAIRO) {
return Factory::CreateScaledFontWithCairo(nativeFont,
aFont->GetAdjustedSize(),
aFont->GetCairoScaledFont());
@ -727,14 +727,14 @@ already_AddRefed<gfxASurface>
gfxWindowsPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{
#ifdef XP_WIN
if (aTarget->GetType() == BACKEND_DIRECT2D) {
if (aTarget->GetType() == BackendType::DIRECT2D) {
if (!GetD2DDevice()) {
// We no longer have a D2D device, can't do this.
return nullptr;
}
RefPtr<ID3D10Texture2D> texture =
static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE));
static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NativeSurfaceType::D3D10_TEXTURE));
if (!texture) {
return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);

View File

@ -540,7 +540,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
Matrix dtTransform = drawTarget->GetTransform();
deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
cairoTarget = static_cast<cairo_surface_t*>
(drawTarget->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE));
(drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
}
cairo_surface_t* tempXlibSurface =

View File

@ -3518,7 +3518,7 @@ static bool ShouldDrawRectsSeparately(gfxContext* aContext, DrawRegionClip aClip
}
DrawTarget *dt = aContext->GetDrawTarget();
return dt->GetType() == BACKEND_DIRECT2D;
return dt->GetType() == BackendType::DIRECT2D;
}
static void DrawForcedBackgroundColor(gfxContext* aContext, Layer* aLayer, nscolor aBackgroundColor)

View File

@ -4856,7 +4856,7 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
if (wantImageSurface) {
IntSize size(imgWidth, imgHeight);
RefPtr<DataSourceSurface> output = Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BackendType::CAIRO,
output->GetData(),
size,
output->Stride(),

View File

@ -1818,7 +1818,7 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
}
nsRefPtr<gfxContext> context;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BACKEND_CAIRO)) {
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BackendType::CAIRO)) {
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf, IntSize(bufW, bufH));

View File

@ -2634,7 +2634,7 @@ RectTextureImage::BeginUpdate(const nsIntSize& aNewSize,
if (!mUpdateDrawTarget || mBufferSize != neededBufferSize) {
gfx::IntSize size(neededBufferSize.width, neededBufferSize.height);
mUpdateDrawTarget =
gfx::Factory::CreateDrawTarget(gfx::BACKEND_COREGRAPHICS, size,
gfx::Factory::CreateDrawTarget(gfx::BackendType::COREGRAPHICS, size,
gfx::SurfaceFormat::B8G8R8A8);
mBufferSize = neededBufferSize;
}
@ -3525,14 +3525,14 @@ NSEvent* gLastDragMouseDownEvent = nil;
targetSurface->SetAllowUseAsSource(false);
nsRefPtr<gfxContext> targetContext;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BACKEND_CAIRO)) {
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::CAIRO)) {
RefPtr<gfx::DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(targetSurface,
gfx::IntSize(backingSize.width,
backingSize.height));
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
targetContext = new gfxContext(dt);
} else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BACKEND_COREGRAPHICS)) {
} else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::COREGRAPHICS)) {
RefPtr<gfx::DrawTarget> dt =
gfx::Factory::CreateDrawTargetForCairoCGContext(aContext,
gfx::IntSize(backingSize.width,

View File

@ -2146,12 +2146,12 @@ nsWindow::OnExposeEvent(cairo_t *cr)
nsRefPtr<gfxContext> ctx;
if (gfxPlatform::GetPlatform()->
SupportsAzureContentForType(BACKEND_CAIRO)) {
SupportsAzureContentForType(BackendType::CAIRO)) {
IntSize intSize(surf->GetSize().width, surf->GetSize().height);
ctx = new gfxContext(gfxPlatform::GetPlatform()->
CreateDrawTargetForSurface(surf, intSize));
} else if (gfxPlatform::GetPlatform()->
SupportsAzureContentForType(BACKEND_SKIA) &&
SupportsAzureContentForType(BackendType::SKIA) &&
surf->GetType() != gfxSurfaceTypeImage) {
gfxImageSurface* imgSurf = static_cast<gfxImageSurface*>(surf);
SurfaceFormat format = ImageFormatToSurfaceFormat(imgSurf->Format());

View File

@ -387,7 +387,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
}
nsRefPtr<gfxContext> thebesContext;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(mozilla::gfx::BACKEND_CAIRO)) {
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(mozilla::gfx::BackendType::CAIRO)) {
RECT paintRect;
::GetClientRect(mWnd, &paintRect);
RefPtr<mozilla::gfx::DrawTarget> dt =