Bug 912944 - Handle different surface formats in Azure CG source surfaces. r=jrmuizel

This commit is contained in:
Markus Stange 2013-09-27 17:19:33 +02:00
parent 6a76d73090
commit 737fc61f80
2 changed files with 11 additions and 4 deletions

View File

@ -164,6 +164,7 @@ DataSourceSurfaceCG::InitFromData(unsigned char *aData,
void *data = malloc(aStride * aSize.height);
memcpy(data, aData, aStride * aSize.height);
mFormat = aFormat;
mImage = CreateCGImage(data, data, aSize, aStride, aFormat);
if (!mImage) {
@ -210,6 +211,7 @@ CGContextRef CreateBitmapContextForImage(CGImageRef image)
DataSourceSurfaceCG::DataSourceSurfaceCG(CGImageRef aImage)
{
mFormat = FORMAT_B8G8R8A8;
mImage = aImage;
mCg = CreateBitmapContextForImage(aImage);
if (mCg == nullptr) {
@ -250,6 +252,7 @@ DataSourceSurfaceCG::GetData()
SourceSurfaceCGBitmapContext::SourceSurfaceCGBitmapContext(DrawTargetCG *aDrawTarget)
{
mDrawTarget = aDrawTarget;
mFormat = aDrawTarget->GetFormat();
mCg = (CGContextRef)aDrawTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT);
if (!mCg)
abort();
@ -286,7 +289,7 @@ void SourceSurfaceCGBitmapContext::EnsureImage() const
if (!mData) abort();
mImage = CreateCGImage(info, mData, mSize, mStride, FORMAT_B8G8R8A8);
mImage = CreateCGImage(info, mData, mSize, mStride, mFormat);
}
}
@ -338,6 +341,7 @@ SourceSurfaceCGIOSurfaceContext::SourceSurfaceCGIOSurfaceContext(DrawTargetCG *a
RefPtr<MacIOSurface> surf = MacIOSurface::IOSurfaceContextGetSurface(cg);
mFormat = aDrawTarget->GetFormat();
mSize.width = surf->GetWidth();
mSize.height = surf->GetHeight();

View File

@ -53,7 +53,7 @@ public:
virtual SurfaceType GetType() const { return SURFACE_DATA; }
virtual IntSize GetSize() const;
virtual SurfaceFormat GetFormat() const { return FORMAT_B8G8R8A8; }
virtual SurfaceFormat GetFormat() const { return mFormat; }
CGImageRef GetImage() { return mImage; }
@ -70,6 +70,7 @@ public:
private:
CGContextRef mCg;
CGImageRef mImage;
SurfaceFormat mFormat;
//XXX: we don't need to store mData we can just get it from the CGContext
void *mData;
/* It might be better to just use the bitmap info from the CGImageRef to
@ -92,7 +93,7 @@ public:
virtual SurfaceType GetType() const { return SURFACE_COREGRAPHICS_CGCONTEXT; }
virtual IntSize GetSize() const;
virtual SurfaceFormat GetFormat() const { return FORMAT_B8G8R8A8; }
virtual SurfaceFormat GetFormat() const { return mFormat; }
CGImageRef GetImage() { EnsureImage(); return mImage; }
@ -110,6 +111,7 @@ private:
// The cycle is broken by DrawTargetWillChange
DrawTargetCG *mDrawTarget;
CGContextRef mCg;
SurfaceFormat mFormat;
mutable CGImageRef mImage;
@ -129,7 +131,7 @@ public:
virtual SurfaceType GetType() const { return SURFACE_COREGRAPHICS_CGCONTEXT; }
virtual IntSize GetSize() const;
virtual SurfaceFormat GetFormat() const { return FORMAT_B8G8R8A8; }
virtual SurfaceFormat GetFormat() const { return mFormat; }
CGImageRef GetImage() { EnsureImage(); return mImage; }
@ -143,6 +145,7 @@ private:
virtual void DrawTargetWillChange();
void EnsureImage() const;
SurfaceFormat mFormat;
mutable CGImageRef mImage;
MacIOSurface* mIOSurface;