Bug 1209812 (part 6) - Convert all gfxImageFormat values to SurfaceFormat equivalents. r=jrmuizel.

This patch:

- Makes the following substitutions (plus necessary namespace qualifiers:

    gfxImageFormat::ARGB32      --> SurfaceFormat::A8R8G8B8_UINT32
    gfxImageFormat::RGB24       --> SurfaceFormat::X8R8G8B8_UINT32
    gfxImageFormat::A8          --> SurfaceFormat::A8
    gfxImageFormat::RGB16_565   --> SurfaceFormat::R5G6B5_UINT16
    gfxImageFormat::Unknown     --> SurfaceFormat::UNKNOWN

- Changes gfxImageFormat to be a typedef to gfx::SurfaceFormat. This will be
  removed soon.

- Removes gfxCairoFormatToImageFormat() and gfxImageFormatToCairoFormat() and
  replace calls to them with CairoFormatToGfxFormat() and
  GfxFormatToCairoFormat().

- Removes ParamTraits<gfxImageFormat>.

- Add namespace qualifiers to SurfaceFormat instances where necessary.
This commit is contained in:
Nicholas Nethercote 2016-01-07 20:57:38 -08:00
parent 8138ef566d
commit 56a7e0fc70
48 changed files with 160 additions and 189 deletions

View File

@ -395,7 +395,7 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
if (aImage->GetFormat() == ImageFormat::PLANAR_YCBCR) {
nsTArray<uint8_t> data;
layers::PlanarYCbCrImage* ycbcrImage = static_cast<layers::PlanarYCbCrImage*> (aImage);
gfxImageFormat format = gfxImageFormat::ARGB32;
gfxImageFormat format = SurfaceFormat::A8R8G8B8_UINT32;
uint32_t stride = GetAlignedStride<16>(aSize.width * 4);
size_t length = BufferSizeFromStrideAndHeight(stride, aSize.height);
data.SetCapacity(length);

View File

@ -5423,7 +5423,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
uint32_t copyWidth = dirtyRect.Width();
uint32_t copyHeight = dirtyRect.Height();
RefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfx::IntSize(copyWidth, copyHeight),
gfxImageFormat::ARGB32,
SurfaceFormat::A8R8G8B8_UINT32,
false);
if (!imgsurf || imgsurf->CairoStatus()) {
return NS_ERROR_FAILURE;

View File

@ -367,7 +367,7 @@ AndroidMediaReader::ImageBufferCallback::operator()(size_t aWidth, size_t aHeigh
case MPAPI::RGB565:
image = mozilla::layers::CreateSharedRGBImage(mImageContainer,
nsIntSize(aWidth, aHeight),
gfxImageFormat::RGB16_565);
SurfaceFormat::R5G6B5_UINT16);
if (!image) {
NS_WARNING("Could not create rgb image");
return nullptr;

View File

@ -244,7 +244,7 @@ MediaEngineTabVideoSource::Draw() {
}
}
gfxImageFormat format = gfxImageFormat::RGB24;
gfxImageFormat format = SurfaceFormat::X8R8G8B8_UINT32;
uint32_t stride = gfxASurface::FormatStrideForWidth(format, size.width);
if (mDataSize < static_cast<size_t>(stride * size.height)) {

View File

@ -2922,7 +2922,7 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
aFrameRect.height != pluginSurface->Height()) {
pluginSurface = new gfxImageSurface(gfx::IntSize(aFrameRect.width, aFrameRect.height),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
if (!pluginSurface)
return;
}

View File

@ -3067,15 +3067,15 @@ PluginInstanceChild::CreateOptSurface(void)
// Use an opaque surface unless we're transparent and *don't* have
// a background to source from.
gfxImageFormat format =
(mIsTransparent && !mBackground) ? gfxImageFormat::ARGB32 :
gfxImageFormat::RGB24;
(mIsTransparent && !mBackground) ? SurfaceFormat::A8R8G8B8_UINT32 :
SurfaceFormat::X8R8G8B8_UINT32;
#ifdef MOZ_X11
Display* dpy = mWsInfo.display;
Screen* screen = DefaultScreenOfDisplay(dpy);
if (format == gfxImageFormat::RGB24 &&
if (format == SurfaceFormat::X8R8G8B8_UINT32 &&
DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
format = gfxImageFormat::RGB16_565;
format = SurfaceFormat::R5G6B5_UINT16;
}
if (mSurfaceType == gfxSurfaceType::Xlib) {
@ -3517,7 +3517,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
gfxImageSurface* surfaceAsImage =
static_cast<gfxImageSurface*>(aSurface);
useSurfaceSubimageForBlack =
(surfaceAsImage->Format() == gfxImageFormat::ARGB32);
(surfaceAsImage->Format() == SurfaceFormat::A8R8G8B8_UINT32);
// If we're going to use a subimage, nudge the rect so that we
// can use optimal alpha recovery. If we're not using a
// subimage, the temporaries should automatically get
@ -3536,7 +3536,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
gfxPoint deviceOffset = -targetRect.TopLeft();
// We always use a temporary "white image"
whiteImage = new gfxImageSurface(targetSize, gfxImageFormat::RGB24);
whiteImage = new gfxImageSurface(targetSize, SurfaceFormat::X8R8G8B8_UINT32);
if (whiteImage->CairoStatus()) {
return;
}
@ -3577,7 +3577,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
blackImage = surface->GetSubimage(targetRect);
} else {
blackImage = new gfxImageSurface(targetSize,
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
}
// Paint onto black background

View File

@ -1214,7 +1214,7 @@ PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
gfxSharedImageSurface::CreateUnsafe(
this,
mozilla::gfx::IntSize(aSize.width, aSize.height),
gfxImageFormat::RGB24);
mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
return !!mBackground;
#else
return false;

View File

@ -342,6 +342,9 @@ enum class JobStatus {
} // namespace gfx
} // namespace mozilla
// XXX: temporary
typedef mozilla::gfx::SurfaceFormat gfxImageFormat;
#if defined(XP_WIN) && defined(MOZ_GFX)
#ifdef GFX2D_INTERNAL
#define GFX2D_API __declspec(dllexport)

View File

@ -58,10 +58,10 @@ public:
/**
* Read the image data contained in aTexture, and return it as an ImageSurface.
* If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned.
* If GL_RGBA is given as the format, a SurfaceFormat::A8R8G8B8_UINT32 surface is returned.
* Not implemented yet:
* If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned.
* If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned.
* If GL_RGB is given as the format, a SurfaceFormat::X8R8G8B8_UINT32 surface is returned.
* If GL_LUMINANCE is given as the format, a SurfaceFormat::A8 surface is returned.
*
* THIS IS EXPENSIVE. It is ridiculously expensive. Only do this
* if you absolutely positively must, and never in any performance

View File

@ -212,7 +212,7 @@ protected:
TextureImage(const gfx::IntSize& aSize,
GLenum aWrapMode, ContentType aContentType,
Flags aFlags = NoFlags,
ImageFormat aImageFormat = gfxImageFormat::Unknown);
ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
// Protected destructor, to discourage deletion outside of Release():
virtual ~TextureImage() {}
@ -248,7 +248,7 @@ public:
ContentType aContentType,
GLContext* aContext,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
virtual void BindTexture(GLenum aTextureUnit);
@ -298,7 +298,7 @@ public:
gfx::IntSize aSize,
TextureImage::ContentType,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
~TiledTextureImage();
void DumpDiv();
virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion);
@ -348,7 +348,7 @@ CreateBasicTextureImage(GLContext* aGL,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
TextureImage::Flags aFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
/**
* Return a valid, allocated TextureImage of |aSize| with
@ -373,7 +373,7 @@ CreateTextureImage(GLContext* gl,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
} // namespace gl
} // namespace mozilla

View File

@ -29,7 +29,7 @@ SharedSurface_GLXDrawable::Create(GLContext* prodGL,
UniquePtr<SharedSurface_GLXDrawable> ret;
Display* display = DefaultXDisplay();
Screen* screen = XDefaultScreenOfDisplay(display);
Visual* visual = gfxXlibSurface::FindVisual(screen, gfxImageFormat::ARGB32);
Visual* visual = gfxXlibSurface::FindVisual(screen, gfx::SurfaceFormat::A8R8G8B8_UINT32);
RefPtr<gfxXlibSurface> surf = gfxXlibSurface::Create(screen, visual, size);
if (!deallocateClient)

View File

@ -24,7 +24,7 @@ public:
ContentType aContentType,
GLContext* aContext,
TextureImage::Flags aFlags = TextureImage::NoFlags,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = gfx::SurfaceFormat::UNKNOWN);
~TextureImageCGL();

View File

@ -22,7 +22,7 @@ public:
GLContext* aContext,
Flags aFlags = TextureImage::NoFlags,
TextureState aTextureState = Created,
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
TextureImage::ImageFormat aImageFormat = SurfaceFormat::UNKNOWN);
virtual ~TextureImageEGL();

View File

@ -229,14 +229,6 @@ struct ParamTraits<mozilla::layers::ScaleMode>
mozilla::layers::ScaleMode::SENTINEL>
{};
template <>
struct ParamTraits<gfxImageFormat>
: public ContiguousEnumSerializer<
gfxImageFormat,
gfxImageFormat::ARGB32,
gfxImageFormat::Unknown>
{};
template <>
struct ParamTraits<mozilla::gfx::AttributeName>
: public ContiguousEnumSerializer<
@ -287,8 +279,8 @@ struct ParamTraits<mozilla::layers::DiagnosticTypes>
template <>
struct ParamTraits<mozilla::PixelFormat>
: public EnumSerializer<mozilla::PixelFormat,
gfxImageFormat::ARGB32,
gfxImageFormat::Unknown>
SurfaceFormat::A8R8G8B8_UINT32,
SurfaceFormat::UNKNOWN>
{};
*/

View File

@ -43,7 +43,7 @@ SharedDIBSurface::InitSurface(uint32_t aWidth, uint32_t aHeight,
long stride = long(aWidth * SharedDIB::kBytesPerPixel);
unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
gfxImageFormat format = aTransparent ? gfxImageFormat::ARGB32 : gfxImageFormat::RGB24;
gfxImageFormat format = aTransparent ? SurfaceFormat::A8R8G8B8_UINT32 : SurfaceFormat::X8R8G8B8_UINT32;
gfxImageSurface::InitWithData(data, IntSize(aWidth, aHeight),
stride, format);

View File

@ -378,7 +378,7 @@ ImageContainer::NotifyCompositeInternal(const ImageCompositeNotification& aNotif
PlanarYCbCrImage::PlanarYCbCrImage()
: Image(nullptr, ImageFormat::PLANAR_YCBCR)
, mOffscreenFormat(gfxImageFormat::Unknown)
, mOffscreenFormat(SurfaceFormat::UNKNOWN)
, mBufferSize(0)
{
}
@ -480,7 +480,7 @@ RecyclingPlanarYCbCrImage::SetData(const Data &aData)
gfxImageFormat
PlanarYCbCrImage::GetOffscreenFormat()
{
return mOffscreenFormat == gfxImageFormat::Unknown ?
return mOffscreenFormat == SurfaceFormat::UNKNOWN ?
gfxPlatform::GetPlatform()->GetOffscreenFormat() :
mOffscreenFormat;
}

View File

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ImageDataSerializer.h"
#include <string.h> // for memcpy
#include "gfx2DGlue.h" // for SurfaceFormatToImageFormat
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc

View File

@ -789,7 +789,7 @@ Transform(const gfxImageSurface* aDest,
gfxPoint aDestOffset)
{
IntSize destSize = aDest->GetSize();
pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormat::ARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == SurfaceFormat::A8R8G8B8_UINT32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
destSize.width,
destSize.height,
(uint32_t*)aDest->Data(),
@ -865,7 +865,7 @@ Transform3D(RefPtr<SourceSurface> aSource,
RefPtr<gfxASurface> dest = aDest->CurrentSurface();
RefPtr<gfxImageSurface> destImage = new gfxImageSurface(IntSize(aDestRect.width,
aDestRect.height),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
gfxPoint offset = aDestRect.TopLeft();
// Include a translation to the correct origin.

View File

@ -31,9 +31,9 @@ CreateSharedRGBImage(ImageContainer *aImageContainer,
gfx::IntSize aSize,
gfxImageFormat aImageFormat)
{
NS_ASSERTION(aImageFormat == gfxImageFormat::ARGB32 ||
aImageFormat == gfxImageFormat::RGB24 ||
aImageFormat == gfxImageFormat::RGB16_565,
NS_ASSERTION(aImageFormat == gfx::SurfaceFormat::A8R8G8B8_UINT32 ||
aImageFormat == gfx::SurfaceFormat::X8R8G8B8_UINT32 ||
aImageFormat == gfx::SurfaceFormat::R5G6B5_UINT16,
"RGB formats supported only");
if (!aImageContainer) {

View File

@ -115,7 +115,7 @@ CompositorOGL::CreateContext()
if (!context && gfxEnv::LayersPreferOffscreen()) {
SurfaceCaps caps = SurfaceCaps::ForRGB();
caps.preserve = false;
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == gfxImageFormat::RGB16_565;
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == SurfaceFormat::R5G6B5_UINT16;
context = GLContextProvider::CreateOffscreen(mSurfaceSize,
caps, CreateContextFlags::REQUIRE_COMPAT_PROFILE);

View File

@ -213,9 +213,9 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
TEST(Layers, TextureSerialization) {
// the test is run on all the following image formats
gfxImageFormat formats[3] = {
gfxImageFormat::ARGB32,
gfxImageFormat::RGB24,
gfxImageFormat::A8,
SurfaceFormat::A8R8G8B8_UINT32,
SurfaceFormat::X8R8G8B8_UINT32,
SurfaceFormat::A8,
};
for (int f = 0; f < 3; ++f) {
@ -240,9 +240,9 @@ TEST(Layers, TextureSerialization) {
}
TEST(Layers, TextureYCbCrSerialization) {
RefPtr<gfxImageSurface> ySurface = new gfxImageSurface(IntSize(400,300), gfxImageFormat::A8);
RefPtr<gfxImageSurface> cbSurface = new gfxImageSurface(IntSize(200,150), gfxImageFormat::A8);
RefPtr<gfxImageSurface> crSurface = new gfxImageSurface(IntSize(200,150), gfxImageFormat::A8);
RefPtr<gfxImageSurface> ySurface = new gfxImageSurface(IntSize(400,300), SurfaceFormat::A8);
RefPtr<gfxImageSurface> cbSurface = new gfxImageSurface(IntSize(200,150), SurfaceFormat::A8);
RefPtr<gfxImageSurface> crSurface = new gfxImageSurface(IntSize(200,150), SurfaceFormat::A8);
SetupSurface(ySurface.get());
SetupSurface(cbSurface.get());
SetupSurface(crSurface.get());

View File

@ -44,7 +44,7 @@ TestNewSurface () {
int failures = 0;
int destroyed = 0;
RefPtr<gfxASurface> s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), gfxImageFormat::ARGB32);
RefPtr<gfxASurface> s = new gfxImageSurface (mozilla::gfx::IntSize(10, 10), SurfaceFormat::A8R8G8B8_UINT32);
cairo_surface_t *cs = s->CairoSurface();
cairo_surface_set_user_data (cs, &destruction_key, &destroyed, SurfaceDestroyNotifier);

View File

@ -80,31 +80,31 @@ inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
{
switch (aFormat) {
case SurfaceFormat::B8G8R8A8:
return gfxImageFormat::ARGB32;
return SurfaceFormat::A8R8G8B8_UINT32;
case SurfaceFormat::B8G8R8X8:
return gfxImageFormat::RGB24;
return SurfaceFormat::X8R8G8B8_UINT32;
case SurfaceFormat::R5G6B5_UINT16:
return gfxImageFormat::RGB16_565;
return SurfaceFormat::R5G6B5_UINT16;
case SurfaceFormat::A8:
return gfxImageFormat::A8;
return SurfaceFormat::A8;
default:
return gfxImageFormat::Unknown;
return SurfaceFormat::UNKNOWN;
}
}
inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
{
switch (aFormat) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return SurfaceFormat::B8G8R8A8;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return SurfaceFormat::B8G8R8X8;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return SurfaceFormat::R5G6B5_UINT16;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return SurfaceFormat::A8;
default:
case gfxImageFormat::Unknown:
case SurfaceFormat::UNKNOWN:
return SurfaceFormat::B8G8R8A8;
}
}

View File

@ -344,7 +344,7 @@ already_AddRefed<gfxImageSurface>
gfxASurface::GetAsReadableARGB32ImageSurface()
{
RefPtr<gfxImageSurface> imgSurface = GetAsImageSurface();
if (!imgSurface || imgSurface->Format() != gfxImageFormat::ARGB32) {
if (!imgSurface || imgSurface->Format() != SurfaceFormat::A8R8G8B8_UINT32) {
imgSurface = CopyToARGB32ImageSurface();
}
return imgSurface.forget();
@ -359,7 +359,7 @@ gfxASurface::CopyToARGB32ImageSurface()
const IntSize size = GetSize();
RefPtr<gfxImageSurface> imgSurface =
new gfxImageSurface(size, gfxImageFormat::ARGB32);
new gfxImageSurface(size, SurfaceFormat::A8R8G8B8_UINT32);
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height));
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this);
@ -425,7 +425,7 @@ gfxASurface::CheckSurfaceSize(const IntSize& sz, int32_t limit)
int32_t
gfxASurface::FormatStrideForWidth(gfxImageFormat format, int32_t width)
{
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
return cairo_format_stride_for_width(cformat, (int)width);
}
@ -463,15 +463,15 @@ gfxContentType
gfxASurface::ContentFromFormat(gfxImageFormat format)
{
switch (format) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return gfxContentType::COLOR_ALPHA;
case gfxImageFormat::RGB24:
case gfxImageFormat::RGB16_565:
case SurfaceFormat::X8R8G8B8_UINT32:
case SurfaceFormat::R5G6B5_UINT16:
return gfxContentType::COLOR;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return gfxContentType::ALPHA;
case gfxImageFormat::Unknown:
case SurfaceFormat::UNKNOWN:
default:
return gfxContentType::COLOR;
}
@ -504,12 +504,12 @@ int32_t
gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
{
switch (format) {
case gfxImageFormat::ARGB32:
case gfxImageFormat::RGB24:
case SurfaceFormat::A8R8G8B8_UINT32:
case SurfaceFormat::X8R8G8B8_UINT32:
return 4;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return 2;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return 1;
default:
NS_WARNING("Unknown byte per pixel value for Image format");
@ -667,15 +667,15 @@ gfxASurface::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
gfxASurface::BytesPerPixel(gfxImageFormat aImageFormat)
{
switch (aImageFormat) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return 4;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return 4;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return 2;
case gfxImageFormat::A8:
case SurfaceFormat::A8:
return 1;
case gfxImageFormat::Unknown:
case SurfaceFormat::UNKNOWN:
default:
NS_NOTREACHED("Not really sure what you want me to say here");
return 0;

View File

@ -17,10 +17,10 @@ gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
mozilla::gfx::IntSize size = blackSurf->GetSize();
if (size != whiteSurf->GetSize() ||
(blackSurf->Format() != gfxImageFormat::ARGB32 &&
blackSurf->Format() != gfxImageFormat::RGB24) ||
(whiteSurf->Format() != gfxImageFormat::ARGB32 &&
whiteSurf->Format() != gfxImageFormat::RGB24))
(blackSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
blackSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ||
(whiteSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
whiteSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32))
return false;
#ifdef MOZILLA_MAY_SUPPORT_SSE2

View File

@ -33,10 +33,10 @@ gfxAlphaRecovery::RecoverAlphaSSE2(gfxImageSurface* blackSurf,
mozilla::gfx::IntSize size = blackSurf->GetSize();
if (size != whiteSurf->GetSize() ||
(blackSurf->Format() != gfxImageFormat::ARGB32 &&
blackSurf->Format() != gfxImageFormat::RGB24) ||
(whiteSurf->Format() != gfxImageFormat::ARGB32 &&
whiteSurf->Format() != gfxImageFormat::RGB24))
(blackSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
blackSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ||
(whiteSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
whiteSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32))
return false;
blackSurf->Flush();
@ -140,7 +140,7 @@ ByteAlignment(int32_t aAlignToLog2, int32_t aX, int32_t aY=0, int32_t aStride=1)
gfxAlphaRecovery::AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect,
gfxImageSurface* aSurface)
{
NS_ASSERTION(gfxImageFormat::ARGB32 == aSurface->Format(),
NS_ASSERTION(mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 == aSurface->Format(),
"Thebes grew support for non-ARGB32 COLOR_ALPHA?");
static const int32_t kByteAlignLog2 = GoodAlignmentLog2();
static const int32_t bpp = 4;

View File

@ -101,11 +101,11 @@ gfxAndroidPlatform::gfxAndroidPlatform()
RegisterStrongMemoryReporter(new FreetypeReporter());
mOffscreenFormat = GetScreenDepth() == 16
? gfxImageFormat::RGB16_565
: gfxImageFormat::RGB24;
? SurfaceFormat::R5G6B5_UINT16
: SurfaceFormat::X8R8G8B8_UINT32;
if (gfxPrefs::AndroidRGB16Force()) {
mOffscreenFormat = gfxImageFormat::RGB16_565;
mOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
}
#ifdef MOZ_WIDGET_GONK

View File

@ -12,6 +12,7 @@
#include "cairo.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "gfx2DGlue.h"
#include <algorithm>
@ -21,7 +22,7 @@ using namespace mozilla::gfx;
gfxImageSurface::gfxImageSurface()
: mSize(0, 0),
mOwnsData(false),
mFormat(gfxImageFormat::Unknown),
mFormat(SurfaceFormat::UNKNOWN),
mStride(0)
{
}
@ -37,7 +38,7 @@ gfxImageSurface::InitFromSurface(cairo_surface_t *csurf)
mSize.width = cairo_image_surface_get_width(csurf);
mSize.height = cairo_image_surface_get_height(csurf);
mData = cairo_image_surface_get_data(csurf);
mFormat = gfxCairoFormatToImageFormat(cairo_image_surface_get_format(csurf));
mFormat = CairoFormatToGfxFormat(cairo_image_surface_get_format(csurf));
mOwnsData = false;
mStride = cairo_image_surface_get_stride(csurf);
@ -71,7 +72,7 @@ gfxImageSurface::InitWithData(unsigned char *aData, const IntSize& aSize,
if (!CheckSurfaceSize(aSize))
MakeInvalid();
cairo_format_t cformat = gfxImageFormatToCairoFormat(mFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
cairo_surface_t *surface =
cairo_image_surface_create_for_data((unsigned char*)mData,
cformat,
@ -141,7 +142,7 @@ gfxImageSurface::AllocateAndInit(long aStride, int32_t aMinimalAllocation,
mOwnsData = true;
cairo_format_t cformat = gfxImageFormatToCairoFormat(mFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
cairo_surface_t *surface =
cairo_image_surface_create_for_data((unsigned char*)mData,
cformat,
@ -169,7 +170,7 @@ gfxImageSurface::gfxImageSurface(cairo_surface_t *csurf)
mSize.width = cairo_image_surface_get_width(csurf);
mSize.height = cairo_image_surface_get_height(csurf);
mData = cairo_image_surface_get_data(csurf);
mFormat = gfxCairoFormatToImageFormat(cairo_image_surface_get_format(csurf));
mFormat = CairoFormatToGfxFormat(cairo_image_surface_get_format(csurf));
mOwnsData = false;
mStride = cairo_image_surface_get_stride(csurf);
@ -187,13 +188,13 @@ gfxImageSurface::ComputeStride(const IntSize& aSize, gfxImageFormat aFormat)
{
long stride;
if (aFormat == gfxImageFormat::ARGB32)
if (aFormat == SurfaceFormat::A8R8G8B8_UINT32)
stride = aSize.width * 4;
else if (aFormat == gfxImageFormat::RGB24)
else if (aFormat == SurfaceFormat::X8R8G8B8_UINT32)
stride = aSize.width * 4;
else if (aFormat == gfxImageFormat::RGB16_565)
else if (aFormat == SurfaceFormat::R5G6B5_UINT16)
stride = aSize.width * 2;
else if (aFormat == gfxImageFormat::A8)
else if (aFormat == SurfaceFormat::A8)
stride = aSize.width;
else {
NS_WARNING("Unknown format specified to gfxImageSurface!");
@ -249,10 +250,10 @@ static bool
FormatsAreCompatible(gfxImageFormat a1, gfxImageFormat a2)
{
if (a1 != a2 &&
!(a1 == gfxImageFormat::ARGB32 &&
a2 == gfxImageFormat::RGB24) &&
!(a1 == gfxImageFormat::RGB24 &&
a2 == gfxImageFormat::ARGB32)) {
!(a1 == SurfaceFormat::A8R8G8B8_UINT32 &&
a2 == SurfaceFormat::X8R8G8B8_UINT32) &&
!(a1 == SurfaceFormat::X8R8G8B8_UINT32 &&
a2 == SurfaceFormat::A8R8G8B8_UINT32)) {
return false;
}
@ -348,9 +349,9 @@ gfxImageSurface::GetSubimage(const gfxRect& aRect)
(Stride() * (int)r.Y()) +
(int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
if (format == gfxImageFormat::ARGB32 &&
if (format == SurfaceFormat::A8R8G8B8_UINT32 &&
GetOpaqueRect().Contains(aRect)) {
format = gfxImageFormat::RGB24;
format = SurfaceFormat::X8R8G8B8_UINT32;
}
RefPtr<gfxSubimageSurface> image =

View File

@ -577,7 +577,7 @@ gfxPlatform::Init()
gPlatform->mScreenReferenceSurface =
gPlatform->CreateOffscreenSurface(IntSize(1, 1),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
if (!gPlatform->mScreenReferenceSurface) {
NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
}
@ -1864,11 +1864,11 @@ gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
switch (aContent) {
case gfxContentType::COLOR:
switch (GetOffscreenFormat()) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return mozilla::gfx::SurfaceFormat::B8G8R8A8;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return mozilla::gfx::SurfaceFormat::B8G8R8X8;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return mozilla::gfx::SurfaceFormat::R5G6B5_UINT16;
default:
NS_NOTREACHED("unknown gfxImageFormat for gfxContentType::COLOR");
@ -1891,12 +1891,12 @@ gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
case gfxContentType::COLOR:
return GetOffscreenFormat();
case gfxContentType::ALPHA:
return gfxImageFormat::A8;
return SurfaceFormat::A8;
case gfxContentType::COLOR_ALPHA:
return gfxImageFormat::ARGB32;
return SurfaceFormat::A8R8G8B8_UINT32;
default:
NS_NOTREACHED("unknown gfxContentType");
return gfxImageFormat::ARGB32;
return SurfaceFormat::A8R8G8B8_UINT32;
}
}

View File

@ -536,7 +536,7 @@ public:
virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent);
virtual gfxImageFormat GetOffscreenFormat()
{ return gfxImageFormat::RGB24; }
{ return mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32; }
/**
* Returns a logger if one is available and logging is enabled

View File

@ -365,10 +365,10 @@ gfxPlatformGtk::GetOffscreenFormat()
// Make sure there is a screen
GdkScreen *screen = gdk_screen_get_default();
if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
return gfxImageFormat::RGB16_565;
return SurfaceFormat::R5G6B5_UINT16;
}
return gfxImageFormat::RGB24;
return SurfaceFormat::X8R8G8B8_UINT32;
}
void gfxPlatformGtk::FontsPrefsChanged(const char *aPref)

View File

@ -21,7 +21,7 @@ gfxQPainterSurface::gfxQPainterSurface(QPainter *painter)
gfxQPainterSurface::gfxQPainterSurface(const mozilla::gfx::IntSize& size, gfxImageFormat format)
{
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *csurf =
cairo_qt_surface_create_with_qimage(cformat, size.width, size.height);
mPainter = cairo_qt_surface_get_qpainter (csurf);

View File

@ -46,7 +46,7 @@ using namespace mozilla::gfx;
gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nullptr;
static gfxImageFormat sOffscreenFormat = gfxImageFormat::RGB24;
static gfxImageFormat sOffscreenFormat = SurfaceFormat::X8R8G8B8_UINT32;
gfxQtPlatform::gfxQtPlatform()
{
@ -55,7 +55,7 @@ gfxQtPlatform::gfxQtPlatform()
int32_t depth = GetScreenDepth();
if (depth == 16) {
sOffscreenFormat = gfxImageFormat::RGB16_565;
sOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
}
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);

View File

@ -6,6 +6,7 @@
#include "gfxQuartzSurface.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "cairo-quartz.h"
@ -26,7 +27,7 @@ gfxQuartzSurface::gfxQuartzSurface(const gfxSize& desiredSize, gfxImageFormat fo
unsigned int width = static_cast<unsigned int>(mSize.width);
unsigned int height = static_cast<unsigned int>(mSize.height);
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create(cformat, width, height);
mCGContext = cairo_quartz_surface_get_cg_context (surf);
@ -109,7 +110,7 @@ gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
unsigned int width = static_cast<unsigned int>(mSize.width);
unsigned int height = static_cast<unsigned int>(mSize.height);
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create_for_data
(data, cformat, width, height, stride);
@ -132,7 +133,7 @@ gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
if (!CheckSurfaceSize(aSize))
MakeInvalid();
cairo_format_t cformat = gfxImageFormatToCairoFormat(format);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create_for_data
(data, cformat, aSize.width, aSize.height, stride);

View File

@ -44,34 +44,6 @@ enum class gfxBreakPriority {
eNormalBreak
};
/**
* The format for an image surface. For all formats with alpha data, 0
* means transparent, 1 or 255 means fully opaque.
*
* XXX: it's vital that the values here match the values in cairo_format_t,
* otherwise gfxCairoFormatToImageFormat() and gfxImageFormatToCairoFormat()
* won't work.
*/
enum class gfxImageFormat {
ARGB32 = 0, ///< ARGB data in native endianness, using premultiplied alpha
RGB24 = 1, ///< xRGB data in native endianness
A8 = 2, ///< Only an alpha channel
RGB16_565 = 4, ///< RGB_565 data in native endianness
Unknown
};
// XXX: temporary
// This works because the gfxImageFormat enum is defined so as to match the
// cairo_format_t enum.
#define gfxCairoFormatToImageFormat(aFormat) \
((gfxImageFormat)aFormat)
// XXX: temporary
// This works because the gfxImageFormat enum is defined so as to match the
// cairo_format_t enum.
#define gfxImageFormatToCairoFormat(aFormat) \
((cairo_format_t)aFormat)
enum class gfxSurfaceType {
Image,
PDF,

View File

@ -789,11 +789,11 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext,
gfxUtils::ImageFormatToDepth(gfxImageFormat aFormat)
{
switch (aFormat) {
case gfxImageFormat::ARGB32:
case SurfaceFormat::A8R8G8B8_UINT32:
return 32;
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return 24;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return 16;
default:
break;
@ -985,7 +985,7 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
bool prescale = aSuggestedSize.width > 0 && aSuggestedSize.height > 0 &&
aSuggestedSize != aData.mPicSize;
if (aSuggestedFormat == gfxImageFormat::RGB16_565) {
if (aSuggestedFormat == SurfaceFormat::R5G6B5_UINT16) {
#if defined(HAVE_YCBCR_TO_RGB565)
if (prescale &&
!IsScaleYCbCrToRGB565Fast(aData.mPicX,
@ -1005,14 +1005,14 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
}
#else
// yuv2rgb16 function not available
aSuggestedFormat = gfxImageFormat::RGB24;
aSuggestedFormat = SurfaceFormat::X8R8G8B8_UINT32;
#endif
}
else if (aSuggestedFormat != gfxImageFormat::RGB24) {
else if (aSuggestedFormat != SurfaceFormat::X8R8G8B8_UINT32) {
// No other formats are currently supported.
aSuggestedFormat = gfxImageFormat::RGB24;
aSuggestedFormat = SurfaceFormat::X8R8G8B8_UINT32;
}
if (aSuggestedFormat == gfxImageFormat::RGB24) {
if (aSuggestedFormat == SurfaceFormat::X8R8G8B8_UINT32) {
/* ScaleYCbCrToRGB32 does not support a picture offset, nor 4:4:4 data.
See bugs 639415 and 640073. */
if (aData.mPicX != 0 || aData.mPicY != 0 || yuvtype == YV24)
@ -1045,7 +1045,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
// Convert from YCbCr to RGB now, scaling the image if needed.
if (aDestSize != aData.mPicSize) {
#if defined(HAVE_YCBCR_TO_RGB565)
if (aDestFormat == gfxImageFormat::RGB16_565) {
if (aDestFormat == SurfaceFormat::R5G6B5_UINT16) {
ScaleYCbCrToRGB565(aData.mYChannel,
aData.mCbChannel,
aData.mCrChannel,
@ -1079,7 +1079,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
FILTER_BILINEAR);
} else { // no prescale
#if defined(HAVE_YCBCR_TO_RGB565)
if (aDestFormat == gfxImageFormat::RGB16_565) {
if (aDestFormat == SurfaceFormat::R5G6B5_UINT16) {
ConvertYCbCrToRGB565(aData.mYChannel,
aData.mCbChannel,
aData.mCrChannel,
@ -1092,7 +1092,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
aData.mCbCrStride,
aStride,
yuvtype);
} else // aDestFormat != gfxImageFormat::RGB16_565
} else // aDestFormat != SurfaceFormat::R5G6B5_UINT16
#endif
ConvertYCbCrToRGB32(aData.mYChannel,
aData.mCbChannel,

View File

@ -49,7 +49,7 @@ public:
* If aDestSurface is given, it must have identical format, dimensions, and
* stride as the source.
*
* If the source is not gfxImageFormat::ARGB32, no operation is performed. If
* If the source is not SurfaceFormat::A8R8G8B8_UINT32, no operation is performed. If
* aDestSurface is given, the data is copied over.
*/
static bool PremultiplyDataSurface(DataSourceSurface* srcSurf,
@ -137,7 +137,7 @@ public:
/**
* Helper function for ConvertYCbCrToRGB that finds the
* RGB buffer size and format for given YCbCrImage.
* @param aSuggestedFormat will be set to gfxImageFormat::RGB24
* @param aSuggestedFormat will be set to SurfaceFormat::X8R8G8B8_UINT32
* if the desired format is not supported.
* @param aSuggestedSize will be set to the picture size from aData
* if either the suggested size was {0,0}

View File

@ -6,6 +6,7 @@
#include "gfxWindowsSurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "mozilla/gfx/Logging.h"
#include "cairo.h"
@ -59,7 +60,7 @@ gfxWindowsSurface::gfxWindowsSurface(const mozilla::gfx::IntSize& realSize, gfxI
if (!CheckSurfaceSize(size))
MakeInvalid(size);
cairo_format_t cformat = gfxImageFormatToCairoFormat(imageFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(imageFormat);
cairo_surface_t *surf =
cairo_win32_surface_create_with_dib(cformat, size.width, size.height);
@ -80,7 +81,7 @@ gfxWindowsSurface::gfxWindowsSurface(HDC dc, const mozilla::gfx::IntSize& realSi
if (!CheckSurfaceSize(size))
MakeInvalid(size);
cairo_format_t cformat = gfxImageFormatToCairoFormat(imageFormat);
cairo_format_t cformat = GfxFormatToCairoFormat(imageFormat);
cairo_surface_t *surf =
cairo_win32_surface_create_with_ddb(dc, cformat,
size.width, size.height);
@ -89,7 +90,8 @@ gfxWindowsSurface::gfxWindowsSurface(HDC dc, const mozilla::gfx::IntSize& realSi
if (mSurfaceValid) {
// DDBs will generally only use 3 bytes per pixel when RGB24
int bytesPerPixel = ((imageFormat == gfxImageFormat::RGB24) ? 3 : 4);
int bytesPerPixel =
((imageFormat == mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ? 3 : 4);
RecordMemoryUsed(size.width * size.height * bytesPerPixel + sizeof(gfxWindowsSurface));
}
@ -143,7 +145,7 @@ gfxWindowsSurface::CreateSimilarSurface(gfxContentType aContent,
// have a DIB.
gfxImageFormat gformat =
gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
cairo_format_t cformat = gfxImageFormatToCairoFormat(gformat);
cairo_format_t cformat = GfxFormatToCairoFormat(gformat);
surface = cairo_win32_surface_create_with_dib(cformat, aSize.width,
aSize.height);
} else {

View File

@ -35,12 +35,12 @@ public:
// Create a DIB surface
gfxWindowsSurface(const mozilla::gfx::IntSize& size,
gfxImageFormat imageFormat = gfxImageFormat::RGB24);
gfxImageFormat imageFormat = mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
// Create a DDB surface; dc may be nullptr to use the screen DC
gfxWindowsSurface(HDC dc,
const mozilla::gfx::IntSize& size,
gfxImageFormat imageFormat = gfxImageFormat::RGB24);
gfxImageFormat imageFormat = mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
gfxWindowsSurface(cairo_surface_t *csurf);

View File

@ -13,6 +13,7 @@
#include "cairo-xlib.h"
#include "cairo-xlib-xrender.h"
#include "mozilla/gfx/BorrowedContext.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "gfx2DGlue.h"
using namespace mozilla;
@ -352,7 +353,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget,
} else if (cairoTargetType == CAIRO_SURFACE_TYPE_IMAGE || drawTarget) {
gfxImageFormat imageFormat =
drawTarget ? SurfaceFormatToImageFormat(drawTarget->GetFormat()) :
gfxCairoFormatToImageFormat(cairo_image_surface_get_format(cairoTarget));
CairoFormatToGfxFormat(cairo_image_surface_get_format(cairoTarget));
target_visual = gfxXlibSurface::FindVisual(screen, imageFormat);
Display *dpy = DisplayOfScreen(screen);
if (target_visual) {
@ -389,7 +390,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget,
supportsAlternateScreen ? target_screen : screen;
Visual *argbVisual =
gfxXlibSurface::FindVisual(visualScreen,
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
if (argbVisual) {
visual = argbVisual;
screen = visualScreen;
@ -399,7 +400,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget,
// No advantage in using the target screen.
Visual *rgb24Visual =
gfxXlibSurface::FindVisual(screen,
gfxImageFormat::RGB24);
SurfaceFormat::X8R8G8B8_UINT32);
if (rgb24Visual) {
visual = rgb24Visual;
}
@ -596,7 +597,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
}
RefPtr<gfxImageSurface> blackImage =
CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::ARGB32);
CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::A8R8G8B8_UINT32);
cairo_t* tmpCtx = cairo_create(tempXlibSurface);
cairo_set_source_rgba(tmpCtx, 1.0, 1.0, 1.0, 1.0);
@ -605,7 +606,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
cairo_destroy(tmpCtx);
DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft());
RefPtr<gfxImageSurface> whiteImage =
CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::RGB24);
CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::X8R8G8B8_UINT32);
if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS &&
whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) {

View File

@ -504,25 +504,25 @@ gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format)
int depth;
unsigned long red_mask, green_mask, blue_mask;
switch (format) {
case gfxImageFormat::ARGB32:
case gfx::SurfaceFormat::A8R8G8B8_UINT32:
depth = 32;
red_mask = 0xff0000;
green_mask = 0xff00;
blue_mask = 0xff;
break;
case gfxImageFormat::RGB24:
case gfx::SurfaceFormat::X8R8G8B8_UINT32:
depth = 24;
red_mask = 0xff0000;
green_mask = 0xff00;
blue_mask = 0xff;
break;
case gfxImageFormat::RGB16_565:
case gfx::SurfaceFormat::R5G6B5_UINT16:
depth = 16;
red_mask = 0xf800;
green_mask = 0x7e0;
blue_mask = 0x1f;
break;
case gfxImageFormat::A8:
case gfx::SurfaceFormat::A8:
default:
return nullptr;
}
@ -551,11 +551,11 @@ XRenderPictFormat*
gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
{
switch (format) {
case gfxImageFormat::ARGB32:
case gfx::SurfaceFormat::A8R8G8B8_UINT32:
return XRenderFindStandardFormat (dpy, PictStandardARGB32);
case gfxImageFormat::RGB24:
case gfx::SurfaceFormat::X8R8G8B8_UINT32:
return XRenderFindStandardFormat (dpy, PictStandardRGB24);
case gfxImageFormat::RGB16_565: {
case gfx::SurfaceFormat::R5G6B5_UINT16: {
// PictStandardRGB16_565 is not standard Xrender format
// we should try to find related visual
// and find xrender format by visual
@ -564,7 +564,7 @@ gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
return nullptr;
return XRenderFindVisualFormat(dpy, visual);
}
case gfxImageFormat::A8:
case gfx::SurfaceFormat::A8:
return XRenderFindStandardFormat (dpy, PictStandardA8);
default:
break;

View File

@ -135,7 +135,7 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
aData.mCbCrStride,
aStride,
yuvtype);
} else // aDestFormat != gfxImageFormat::RGB16_565
} else // aDestFormat != SurfaceFormat::R5G6B5_UINT16
#endif
ConvertYCbCrToRGB32(aData.mYChannel, //
aData.mCbChannel,

View File

@ -391,9 +391,9 @@ uint32_t
AndroidGraphicBuffer::GetAndroidFormat(gfxImageFormat aFormat)
{
switch (aFormat) {
case gfxImageFormat::RGB24:
case SurfaceFormat::X8R8G8B8_UINT32:
return HAL_PIXEL_FORMAT_RGBX_8888;
case gfxImageFormat::RGB16_565:
case SurfaceFormat::R5G6B5_UINT16:
return HAL_PIXEL_FORMAT_RGB_565;
default:
return 0;

View File

@ -157,7 +157,7 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
CGContextScaleCTM(context, 1.0, -1.0);
newSurface = new gfxQuartzSurface(context, gfxSize(width, height));
} else {
newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), gfxImageFormat::ARGB32);
newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), SurfaceFormat::A8R8G8B8_UINT32);
}
if (!newSurface)

View File

@ -86,7 +86,7 @@ nsDeviceContextSpecProxy::GetSurfaceForPrinter(gfxASurface** aSurface)
RefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
CreateOffscreenSurface(mozilla::gfx::IntSize(width, height),
gfxImageFormat::ARGB32);
SurfaceFormat::A8R8G8B8_UINT32);
surface.forget(aSurface);
return NS_OK;

View File

@ -357,7 +357,7 @@ TaskbarPreview::UpdateTooltip() {
void
TaskbarPreview::DrawBitmap(uint32_t width, uint32_t height, bool isPreview) {
nsresult rv;
RefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfx::IntSize(width, height), gfxImageFormat::ARGB32);
RefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfx::IntSize(width, height), gfx::SurfaceFormat::A8R8G8B8_UINT32);
nsCOMPtr<nsIDocShell> shell = do_QueryReferent(mDocShell);

View File

@ -6939,7 +6939,7 @@ void nsWindow::ResizeTranslucentWindow(int32_t aNewWidth, int32_t aNewHeight, bo
return;
RefPtr<gfxWindowsSurface> newSurface =
new gfxWindowsSurface(IntSize(aNewWidth, aNewHeight), gfxImageFormat::ARGB32);
new gfxWindowsSurface(IntSize(aNewWidth, aNewHeight), SurfaceFormat::A8R8G8B8_UINT32);
mTransparentSurface = newSurface;
mMemoryDC = newSurface->GetDC();
}

View File

@ -354,7 +354,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
targetSurfaceImage = new gfxImageSurface(sSharedSurfaceData.get(),
surfaceSize,
surfaceSize.width * 4,
gfxImageFormat::RGB24);
SurfaceFormat::X8R8G8B8_UINT32);
if (targetSurfaceImage && !targetSurfaceImage->CairoStatus()) {
targetSurfaceImage->SetDeviceOffset(gfxPoint(-ps.rcPaint.left, -ps.rcPaint.top));