Bug 970007 - Fix incorrect colorformat when using CairoSurface. r=gal r=bas

This commit is contained in:
peter chang 2014-04-14 20:51:00 +02:00
parent d05cab9748
commit fc8c3c2db9
5 changed files with 11 additions and 11 deletions

View File

@ -1032,7 +1032,7 @@ public:
*/
static bool CheckSurfaceSize(const IntSize &sz, int32_t limit = 0);
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize);
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
static TemporaryRef<SourceSurface>
CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,

View File

@ -1157,12 +1157,12 @@ DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFo
}
bool
DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize)
DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
{
mContext = cairo_create(aSurface);
mSurface = aSurface;
mSize = aSize;
mFormat = CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
mFormat = aFormat ? *aFormat : CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
if (mFormat == SurfaceFormat::B8G8R8A8 ||
mFormat == SurfaceFormat::R8G8B8A8) {
@ -1218,10 +1218,10 @@ DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFor
}
bool
DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize)
DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
{
cairo_surface_reference(aSurface);
return InitAlreadyReferenced(aSurface, aSize);
return InitAlreadyReferenced(aSurface, aSize, aFormat);
}
bool

View File

@ -156,7 +156,7 @@ public:
virtual void *GetNativeSurface(NativeSurfaceType aType);
bool Init(cairo_surface_t* aSurface, const IntSize& aSize);
bool Init(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
bool Init(const IntSize& aSize, SurfaceFormat aFormat);
bool Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
@ -175,8 +175,7 @@ public:
private: // methods
// Init cairo surface without doing a cairo_surface_reference() call.
bool InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize);
bool InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr);
enum DrawPatternType { DRAW_FILL, DRAW_STROKE };
void DrawPattern(const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,

View File

@ -618,14 +618,14 @@ Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHintin
#endif
TemporaryRef<DrawTarget>
Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize)
Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
{
RefPtr<DrawTarget> retVal;
#ifdef USE_CAIRO
RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
if (newTarget->Init(aSurface, aSize)) {
if (newTarget->Init(aSurface, aSize, aFormat)) {
retVal = newTarget;
}

View File

@ -575,7 +575,8 @@ cairo_user_data_key_t kDrawTarget;
RefPtr<DrawTarget>
gfxPlatform::CreateDrawTargetForSurface(gfxASurface *aSurface, const IntSize& aSize)
{
RefPtr<DrawTarget> drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), aSize);
SurfaceFormat format = Optimal2DFormatForContent(aSurface->GetContentType());
RefPtr<DrawTarget> drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), aSize, &format);
aSurface->SetData(&kDrawTarget, drawTarget, nullptr);
return drawTarget;
}