Skip to content

Commit

Permalink
Bug 958375 - 4/9 - Make SurfaceFormat a typed enum - r=Bas
Browse files Browse the repository at this point in the history
Specifically:
  r=Bas for manual changes
  f=Bas for automatic changes
See attachments on the bug for the specific breakdown.
  • Loading branch information
Benoit Jacob committed Jan 10, 2014
1 parent d0616b0 commit a1e7c32
Show file tree
Hide file tree
Showing 84 changed files with 427 additions and 428 deletions.
12 changes: 6 additions & 6 deletions content/canvas/src/CanvasRenderingContext2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class AdjustedTarget

mTarget =
mCtx->mTarget->CreateShadowDrawTarget(IntSize(int32_t(mTempRect.width), int32_t(mTempRect.height)),
FORMAT_B8G8R8A8, mSigma);
SurfaceFormat::B8G8R8A8, mSigma);

if (!mTarget) {
// XXX - Deal with the situation where our temp size is too big to
Expand Down Expand Up @@ -1130,7 +1130,7 @@ CanvasRenderingContext2D::GetInputStream(const char *aMimeType,
SurfaceFormat
CanvasRenderingContext2D::GetSurfaceFormat() const
{
return mOpaque ? FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8;
return mOpaque ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
}

//
Expand Down Expand Up @@ -3394,7 +3394,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x,
} else if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
drawDT =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(ceil(sw), ceil(sh)),
FORMAT_B8G8R8A8);
SurfaceFormat::B8G8R8A8);
if (!drawDT) {
error.Throw(NS_ERROR_FAILURE);
return;
Expand Down Expand Up @@ -3434,7 +3434,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x,
mTarget->CreateSourceSurfaceFromData(img->Data(),
IntSize(size.width, size.height),
img->Stride(),
FORMAT_B8G8R8A8);
SurfaceFormat::B8G8R8A8);
} else {
RefPtr<SourceSurface> snapshot = drawDT->Snapshot();
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
Expand Down Expand Up @@ -3733,7 +3733,7 @@ CanvasRenderingContext2D::EnsureErrorTarget()
return;
}

RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), FORMAT_B8G8R8A8);
RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);
MOZ_ASSERT(errorTarget, "Failed to allocate the error target!");

sErrorTarget = errorTarget;
Expand Down Expand Up @@ -3879,7 +3879,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
}

RefPtr<SourceSurface> sourceSurface =
mTarget->CreateSourceSurfaceFromData(imgsurf->Data(), IntSize(w, h), imgsurf->Stride(), FORMAT_B8G8R8A8);
mTarget->CreateSourceSurfaceFromData(imgsurf->Data(), IntSize(w, h), imgsurf->Stride(), SurfaceFormat::B8G8R8A8);

// In certain scenarios, requesting larger than 8k image fails. Bug 803568
// covers the details of how to run into it, but the full detailed
Expand Down
8 changes: 4 additions & 4 deletions content/canvas/src/WebGLContextGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2689,16 +2689,16 @@ WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromE
// texture sources in the first place.

switch (data->GetFormat()) {
case FORMAT_B8G8R8A8:
case SurfaceFormat::B8G8R8A8:
*format = WebGLTexelFormat::BGRA8; // careful, our ARGB means BGRA
break;
case FORMAT_B8G8R8X8:
case SurfaceFormat::B8G8R8X8:
*format = WebGLTexelFormat::BGRX8; // careful, our RGB24 is not tightly packed. Whence BGRX8.
break;
case FORMAT_A8:
case SurfaceFormat::A8:
*format = WebGLTexelFormat::A8;
break;
case FORMAT_R5G6B5:
case SurfaceFormat::R5G6B5:
*format = WebGLTexelFormat::RGB565;
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions gfx/2d/DataSurfaceHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SurfaceToPackedBGRA(SourceSurface *aSurface)
}

SurfaceFormat format = data->GetFormat();
if (format != FORMAT_B8G8R8A8 && format != FORMAT_B8G8R8X8) {
if (format != SurfaceFormat::B8G8R8A8 && format != SurfaceFormat::B8G8R8X8) {
return nullptr;
}

Expand Down Expand Up @@ -68,7 +68,7 @@ SurfaceToPackedBGRA(SourceSurface *aSurface)
}
}

if (format == FORMAT_B8G8R8X8) {
if (format == SurfaceFormat::B8G8R8X8) {
// Convert BGRX to BGRA by setting a to 255.
ConvertBGRXToBGRA(reinterpret_cast<uint8_t *>(imageBuffer), size, size.width * sizeof(uint32_t));
}
Expand Down
16 changes: 8 additions & 8 deletions gfx/2d/DrawTargetCG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ DrawTargetCG::CopySurface(SourceSurface *aSurface,

// Quartz seems to copy A8 surfaces incorrectly if we don't initialize them
// to transparent first.
if (mFormat == FORMAT_A8) {
if (mFormat == SurfaceFormat::A8) {
CGContextClearRect(mCg, flippedRect);
}
CGContextDrawImage(mCg, flippedRect, subimage);
Expand Down Expand Up @@ -1297,21 +1297,21 @@ DrawTargetCG::Init(BackendType aType,
// and we will fallback to software below
}

mFormat = FORMAT_B8G8R8A8;
mFormat = SurfaceFormat::B8G8R8A8;

if (!mCg || aType == BACKEND_COREGRAPHICS) {
int bitsPerComponent = 8;

CGBitmapInfo bitinfo;
if (aFormat == FORMAT_A8) {
if (aFormat == SurfaceFormat::A8) {
if (mColorSpace)
CGColorSpaceRelease(mColorSpace);
mColorSpace = nullptr;
bitinfo = kCGImageAlphaOnly;
mFormat = FORMAT_A8;
mFormat = SurfaceFormat::A8;
} else {
bitinfo = kCGBitmapByteOrder32Host;
if (aFormat == FORMAT_B8G8R8X8) {
if (aFormat == SurfaceFormat::B8G8R8X8) {
bitinfo |= kCGImageAlphaNoneSkipFirst;
mFormat = aFormat;
} else {
Expand Down Expand Up @@ -1394,15 +1394,15 @@ DrawTargetCG::Init(CGContextRef cgContext, const IntSize &aSize)
// CGContextTranslateCTM(mCg, 0, mSize.height);
// CGContextScaleCTM(mCg, 1, -1);

mFormat = FORMAT_B8G8R8A8;
mFormat = SurfaceFormat::B8G8R8A8;
if (GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP) {
CGColorSpaceRef colorspace;
CGBitmapInfo bitinfo = CGBitmapContextGetBitmapInfo(mCg);
colorspace = CGBitmapContextGetColorSpace (mCg);
if (CGColorSpaceGetNumberOfComponents(colorspace) == 1) {
mFormat = FORMAT_A8;
mFormat = SurfaceFormat::A8;
} else if ((bitinfo & kCGBitmapAlphaInfoMask) == kCGImageAlphaNoneSkipFirst) {
mFormat = FORMAT_B8G8R8X8;
mFormat = SurfaceFormat::B8G8R8X8;
}
}

Expand Down
4 changes: 2 additions & 2 deletions gfx/2d/DrawTargetCairo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,8 @@ DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize&
mSize = aSize;
mFormat = CairoContentToGfxFormat(cairo_surface_get_content(aSurface));

if (mFormat == FORMAT_B8G8R8A8 ||
mFormat == FORMAT_R8G8B8A8) {
if (mFormat == SurfaceFormat::B8G8R8A8 ||
mFormat == SurfaceFormat::R8G8B8A8) {
SetPermitSubpixelAA(false);
} else {
SetPermitSubpixelAA(true);
Expand Down
14 changes: 7 additions & 7 deletions gfx/2d/DrawTargetD2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ DrawTargetD2D::CopySurface(SourceSurface *aSurface,
return;
}

if (aSurface->GetFormat() == FORMAT_A8) {
if (aSurface->GetFormat() == SurfaceFormat::A8) {
RefPtr<ID2D1SolidColorBrush> brush;
mRT->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White),
D2D1::BrushProperties(), byRef(brush));
Expand Down Expand Up @@ -995,7 +995,7 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
aaMode = aOptions.mAntialiasMode;
}

if (mFormat == FORMAT_B8G8R8A8 && mPermitSubpixelAA &&
if (mFormat == SurfaceFormat::B8G8R8A8 && mPermitSubpixelAA &&
aOptions.mCompositionOp == OP_OVER && aPattern.GetType() == PATTERN_COLOR &&
aaMode == AA_SUBPIXEL) {
if (FillGlyphsManual(font, aBuffer,
Expand Down Expand Up @@ -1026,7 +1026,7 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
}

if (d2dAAMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE &&
mFormat != FORMAT_B8G8R8X8) {
mFormat != SurfaceFormat::B8G8R8X8) {
d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
}

Expand Down Expand Up @@ -1487,7 +1487,7 @@ DrawTargetD2D::InitD2DRenderTarget()

mRT->BeginDraw();

if (mFormat == FORMAT_B8G8R8X8) {
if (mFormat == SurfaceFormat::B8G8R8X8) {
mRT->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE);
}

Expand Down Expand Up @@ -1639,7 +1639,7 @@ DrawTargetD2D::GetRTForOperation(CompositionOp aOperator, const Pattern &aPatter
return mRT;
}

mTempRT = CreateRTForTexture(mTempTexture, FORMAT_B8G8R8A8);
mTempRT = CreateRTForTexture(mTempTexture, SurfaceFormat::B8G8R8A8);

if (!mTempRT) {
return mRT;
Expand Down Expand Up @@ -1932,7 +1932,7 @@ DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aForm

D2D1_ALPHA_MODE alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;

if (aFormat == FORMAT_B8G8R8X8 && aTexture == mTexture) {
if (aFormat == SurfaceFormat::B8G8R8X8 && aTexture == mTexture) {
alphaMode = D2D1_ALPHA_MODE_IGNORE;
}

Expand Down Expand Up @@ -2043,7 +2043,7 @@ DrawTargetD2D::EnsureClipMaskTexture(IntRect *aBounds)
return;
}

RefPtr<ID2D1RenderTarget> rt = CreateRTForTexture(mCurrentClipMaskTexture, FORMAT_A8);
RefPtr<ID2D1RenderTarget> rt = CreateRTForTexture(mCurrentClipMaskTexture, SurfaceFormat::A8);

if (!rt) {
gfxWarning() << "Failed to create RT for ClipMask!";
Expand Down
4 changes: 2 additions & 2 deletions gfx/2d/DrawTargetD2D1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *aFont,
PrepareForDrawing(aOptions.mCompositionOp, aPattern);

bool forceClearType = false;
if (mFormat == FORMAT_B8G8R8A8 && mPermitSubpixelAA &&
if (mFormat == SurfaceFormat::B8G8R8A8 && mPermitSubpixelAA &&
aOptions.mCompositionOp == OP_OVER && aaMode == AA_SUBPIXEL) {
forceClearType = true;
}
Expand All @@ -378,7 +378,7 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *aFont,
}

if (d2dAAMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE &&
mFormat != FORMAT_B8G8R8X8 && !forceClearType) {
mFormat != SurfaceFormat::B8G8R8X8 && !forceClearType) {
d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
}

Expand Down
4 changes: 2 additions & 2 deletions gfx/2d/DrawTargetSkia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
{
SkAutoTUnref<SkDevice> device(new SkDevice(GfxFormatToSkiaConfig(aFormat),
aSize.width, aSize.height,
aFormat == FORMAT_B8G8R8X8));
aFormat == SurfaceFormat::B8G8R8X8));

SkBitmap bitmap = device->accessBitmap(true);
if (!bitmap.allocPixels()) {
Expand Down Expand Up @@ -817,7 +817,7 @@ void
DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat)
{
bool isOpaque = false;
if (aFormat == FORMAT_B8G8R8X8) {
if (aFormat == SurfaceFormat::B8G8R8X8) {
// We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
ConvertBGRXToBGRA(aData, aSize, aStride);
isOpaque = true;
Expand Down
Loading

0 comments on commit a1e7c32

Please sign in to comment.