From 7e20c213c55cb433389cdd131a635ff12a688304 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 2 Apr 2012 15:15:08 -0400 Subject: [PATCH] Bug 740560 - [Azure] Add Factory::CreateDrawTargetForData. r=Bas,gw280 --- gfx/2d/Factory.cpp | 27 +++++++++++++++++++++++++++ gfx/thebes/gfxPlatform.cpp | 10 ++++++++++ gfx/thebes/gfxPlatform.h | 4 ++++ 3 files changed, 41 insertions(+) diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 9deb21acc3fd..fbe7a480a97a 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -132,6 +132,33 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor return NULL; } +TemporaryRef +Factory::CreateDrawTargetForData(BackendType aBackend, + unsigned char *aData, + const IntSize &aSize, + int32_t aStride, + SurfaceFormat aFormat) +{ + switch (aBackend) { +#ifdef USE_SKIA + case BACKEND_SKIA: + { + RefPtr newTarget; + newTarget = new DrawTargetSkia(); + newTarget->Init(aData, aSize, aStride, aFormat); + return newTarget; + } +#endif + default: + gfxDebug() << "Invalid draw target type specified."; + return NULL; + } + + gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize; + // Failed + return NULL; +} + TemporaryRef Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize) { diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index afe6387d148c..f6286e26ae2b 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -647,6 +647,16 @@ gfxPlatform::CreateOffscreenDrawTarget(const IntSize& aSize, SurfaceFormat aForm } } +RefPtr +gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat) +{ + BackendType backend; + if (!SupportsAzure(backend)) { + return NULL; + } + return Factory::CreateDrawTargetForData(backend, aData, aSize, aStride, aFormat); +} + nsresult gfxPlatform::GetFontList(nsIAtom *aLangGroup, const nsACString& aGenericFamily, diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 6d05e50f0a4a..fdbd32e7e64b 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -208,6 +208,10 @@ public: virtual mozilla::RefPtr CreateOffscreenDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat); + virtual mozilla::RefPtr + CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize, + int32_t aStride, mozilla::gfx::SurfaceFormat aFormat); + virtual bool SupportsAzure(mozilla::gfx::BackendType& aBackend) { return false; } void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {