mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 970007 - Fix incorrect colorformat when using CairoSurface. r=gal r=bas
This commit is contained in:
parent
d05cab9748
commit
fc8c3c2db9
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user