Bug 1034702 - Remove gfxPlatform::GetThebesSurfaceForDrawTarget(). r=Bas

This commit is contained in:
Jonathan Watt 2014-07-10 10:58:09 +01:00
parent 5b43b8c744
commit 26606a941a
6 changed files with 0 additions and 124 deletions

View File

@ -827,20 +827,6 @@ gfxPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
return scaledFont;
}
cairo_user_data_key_t kDrawSourceSurface;
static void
DataSourceSurfaceDestroy(void *dataSourceSurface)
{
static_cast<DataSourceSurface*>(dataSourceSurface)->Release();
}
cairo_user_data_key_t kDrawTargetForSurface;
static void
DataDrawTargetDestroy(void *aTarget)
{
static_cast<DrawTarget*>(aTarget)->Release();
}
bool
gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
{
@ -926,49 +912,6 @@ gfxPlatform::PurgeSkiaCache()
#endif
}
already_AddRefed<gfxASurface>
gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{
if (aTarget->GetBackendType() == BackendType::CAIRO) {
cairo_surface_t* csurf =
static_cast<cairo_surface_t*>(aTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
if (csurf) {
return gfxASurface::Wrap(csurf);
}
}
// The semantics of this part of the function are sort of weird. If we
// don't have direct support for the backend, we snapshot the first time
// and then return the snapshotted surface for the lifetime of the draw
// target. Sometimes it seems like this works out, but it seems like it
// might result in no updates ever.
RefPtr<SourceSurface> source = aTarget->Snapshot();
RefPtr<DataSourceSurface> data = source->GetDataSurface();
if (!data) {
return nullptr;
}
IntSize size = data->GetSize();
gfxImageFormat format = SurfaceFormatToImageFormat(data->GetFormat());
nsRefPtr<gfxASurface> surf =
new gfxImageSurface(data->GetData(), gfxIntSize(size.width, size.height),
data->Stride(), format);
if (surf->CairoStatus()) {
return nullptr;
}
surf->SetData(&kDrawSourceSurface, data.forget().drop(), DataSourceSurfaceDestroy);
// keep the draw target alive as long as we need its data
aTarget->AddRef();
surf->SetData(&kDrawTargetForSurface, aTarget, DataDrawTargetDestroy);
return surf.forget();
}
TemporaryRef<DrawTarget>
gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat)
{

View File

@ -222,9 +222,6 @@ public:
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
virtual already_AddRefed<gfxASurface>
GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
mozilla::TemporaryRef<DrawTarget>
CreateOffscreenContentDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);

View File

@ -380,35 +380,6 @@ gfxPlatformMac::ReadAntiAliasingThreshold()
return threshold;
}
already_AddRefed<gfxASurface>
gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{
if (aTarget->GetBackendType() == BackendType::COREGRAPHICS_ACCELERATED) {
RefPtr<SourceSurface> source = aTarget->Snapshot();
RefPtr<DataSourceSurface> sourceData = source->GetDataSurface();
unsigned char* data = sourceData->GetData();
nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(data, ThebesIntSize(sourceData->GetSize()), sourceData->Stride(),
gfxImageFormat::ARGB32);
// We could fix this by telling gfxImageSurface it owns data.
nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageFormat::ARGB32);
cpy->CopyFrom(surf);
return cpy.forget();
} else if (aTarget->GetBackendType() == BackendType::COREGRAPHICS) {
CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
//XXX: it would be nice to have an implicit conversion from IntSize to gfxIntSize
IntSize intSize = aTarget->GetSize();
gfxIntSize size(intSize.width, intSize.height);
nsRefPtr<gfxASurface> surf =
new gfxQuartzSurface(cg, size);
return surf.forget();
}
return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
}
bool
gfxPlatformMac::UseAcceleratedCanvas()
{

View File

@ -64,8 +64,6 @@ public:
// lower threshold on font anti-aliasing
uint32_t GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; }
virtual already_AddRefed<gfxASurface>
GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
private:
virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size);

View File

@ -647,37 +647,6 @@ gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
}
already_AddRefed<gfxASurface>
gfxWindowsPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{
#ifdef XP_WIN
if (aTarget->GetBackendType() == BackendType::DIRECT2D) {
if (!GetD2DDevice()) {
// We no longer have a D2D device, can't do this.
return nullptr;
}
RefPtr<ID3D10Texture2D> texture =
static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NativeSurfaceType::D3D10_TEXTURE));
if (!texture) {
return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
}
aTarget->Flush();
nsRefPtr<gfxASurface> surf =
new gfxD2DSurface(texture, ContentForFormat(aTarget->GetFormat()));
// shouldn't this hold a reference?
surf->SetData(&kDrawTarget, aTarget, nullptr);
return surf.forget();
}
#endif
return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
}
nsresult
gfxWindowsPlatform::GetFontList(nsIAtom *aLangGroup,
const nsACString& aGenericFamily,

View File

@ -130,8 +130,6 @@ public:
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
virtual already_AddRefed<gfxASurface>
GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
enum RenderMode {
/* Use GDI and windows surfaces */