Bug 924679. Part 4: Add Factory::CreateSourceSurfaceForCairoSurface. r=mattwoodrow

--HG--
extra : rebase_source : 0c9187e8b9597e47e9d0d63d6da757db9a8c8a5c
This commit is contained in:
Robert O'Callahan 2013-10-25 23:25:40 +02:00
parent 9ff4985627
commit b3e3eccd1a
4 changed files with 34 additions and 0 deletions

View File

@ -937,6 +937,10 @@ public:
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize);
static TemporaryRef<SourceSurface>
CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,
SurfaceFormat aFormat);
static TemporaryRef<DrawTarget>
CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);

View File

@ -1061,6 +1061,20 @@ DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurf
return nullptr;
}
TemporaryRef<SourceSurface>
DrawTargetCairo::CreateSourceSurfaceForCairoSurface(cairo_surface_t *aSurface,
SurfaceFormat aFormat)
{
IntSize size;
if (GetCairoSurfaceSize(aSurface, size)) {
RefPtr<SourceSurfaceCairo> source =
new SourceSurfaceCairo(aSurface, size, aFormat);
return source;
}
return nullptr;
}
TemporaryRef<DrawTarget>
DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{

View File

@ -157,6 +157,10 @@ public:
static cairo_surface_t *GetDummySurface();
static TemporaryRef<SourceSurface>
CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,
SurfaceFormat aFormat);
private: // methods
// Init cairo surface without doing a cairo_surface_reference() call.
bool InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize);

View File

@ -554,6 +554,18 @@ Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSiz
return retVal;
}
TemporaryRef<SourceSurface>
Factory::CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface,
SurfaceFormat aFormat)
{
RefPtr<SourceSurface> retVal;
#ifdef USE_CAIRO
retVal = DrawTargetCairo::CreateSourceSurfaceForCairoSurface(aSurface, aFormat);
#endif
return retVal;
}
#ifdef XP_MACOSX
TemporaryRef<DrawTarget>
Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize)