diff --git a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp index 7b3190a229f3..99a0207659aa 100644 --- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp @@ -988,13 +988,7 @@ PRUint8 (*nsCanvasRenderingContext2DAzure::sPremultiplyTable)[256] = nsnull; nsresult NS_NewCanvasRenderingContext2DAzure(nsIDOMCanvasRenderingContext2D** aResult) { -#ifdef XP_WIN - if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() != - gfxWindowsPlatform::RENDER_DIRECT2D || - !gfxWindowsPlatform::GetPlatform()->DWriteEnabled()) { - return NS_ERROR_NOT_AVAILABLE; - } -#elif !defined(XP_MACOSX) && !defined(ANDROID) +#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID) return NS_ERROR_NOT_AVAILABLE; #endif diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 3a21ca423748..6d0bb4ecd24e 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -46,6 +46,9 @@ #ifdef XP_MACOSX #include "ScaledFontMac.h" #endif +#ifdef WIN32 +#include "ScaledFontWin.h" +#endif #include "ScaledFontSkia.h" #endif @@ -124,6 +127,12 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz { return new ScaledFontMac(static_cast(aNativeFont.mFont), aSize); } +#endif +#ifdef WIN32 + case NATIVE_FONT_GDI_FONT_FACE: + { + return new ScaledFontWin(static_cast(aNativeFont.mFont), aSize); + } #endif case NATIVE_FONT_SKIA_FONT_FACE: { diff --git a/gfx/2d/Makefile.in b/gfx/2d/Makefile.in index 0c576474a67b..4cc2207b3f5c 100644 --- a/gfx/2d/Makefile.in +++ b/gfx/2d/Makefile.in @@ -107,9 +107,13 @@ CPPSRCS += \ SourceSurfaceD2DTarget.cpp \ PathD2D.cpp \ ScaledFontDWrite.cpp \ - $(NULL) - -DEFINES += -DWIN32 + SourceSurfaceSkia.cpp \ + DrawTargetSkia.cpp \ + PathSkia.cpp \ + ScaledFontSkia.cpp \ + ScaledFontWin.cpp \ + $(NULL) +DEFINES += -DWIN32 -DUSE_SKIA endif #ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) diff --git a/gfx/2d/ScaledFontWin.cpp b/gfx/2d/ScaledFontWin.cpp new file mode 100644 index 000000000000..d1614e42c214 --- /dev/null +++ b/gfx/2d/ScaledFontWin.cpp @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Corporation code. + * + * The Initial Developer of the Original Code is Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Marco Castelluccio + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "ScaledFontWin.h" +#include "skia/SkTypeface_win.h" + +namespace mozilla { +namespace gfx { + +ScaledFontWin::ScaledFontWin(gfxGDIFont* aFont, Float aSize) + : ScaledFontSkia(aSize) +{ + LOGFONT lf; + GetObject(aFont->GetHFONT(), sizeof(LOGFONT), &lf); + mTypeface = SkCreateTypefaceFromLOGFONT(lf); +} + +} +} diff --git a/gfx/2d/ScaledFontWin.h b/gfx/2d/ScaledFontWin.h new file mode 100644 index 000000000000..b9eccc07bafc --- /dev/null +++ b/gfx/2d/ScaledFontWin.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Corporation code. + * + * The Initial Developer of the Original Code is Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Marco Castelluccio + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef MOZILLA_GFX_SCALEDFONTWIN_H_ +#define MOZILLA_GFX_SCALEDFONTWIN_H_ + +#include "ScaledFontSkia.h" +#include "gfxGDIFont.h" + +namespace mozilla { +namespace gfx { + +class ScaledFontWin : public ScaledFontSkia +{ +public: + ScaledFontWin(gfxGDIFont* aFont, Float aSize); + + virtual FontType GetType() const { return FONT_GDI; } + +private: + friend class DrawTargetSkia; +}; + +} +} + +#endif /* MOZILLA_GFX_SCALEDFONTWIN_H_ */ diff --git a/gfx/2d/Tools.h b/gfx/2d/Tools.h index 13d166c0948e..9f503c0d2497 100644 --- a/gfx/2d/Tools.h +++ b/gfx/2d/Tools.h @@ -43,7 +43,7 @@ namespace mozilla { namespace gfx { -bool +static inline bool IsOperatorBoundByMask(CompositionOp aOp) { switch (aOp) { case OP_IN: diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index b15902ff1e29..122a9855338c 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -91,6 +91,7 @@ enum BackendType enum FontType { FONT_DWRITE, + FONT_GDI, FONT_MAC, FONT_SKIA }; @@ -103,6 +104,7 @@ enum NativeSurfaceType enum NativeFontType { NATIVE_FONT_DWRITE_FONT_FACE, + NATIVE_FONT_GDI_FONT_FACE, NATIVE_FONT_MAC_FONT_FACE, NATIVE_FONT_SKIA_FONT_FACE }; diff --git a/gfx/Makefile.in b/gfx/Makefile.in index 81d2740c3c24..9a8512957e69 100644 --- a/gfx/Makefile.in +++ b/gfx/Makefile.in @@ -50,7 +50,7 @@ endif DIRS += 2d ycbcr angle src qcms layers harfbuzz/src ots/src thebes ipc -ifeq (,$(filter-out cocoa android,$(MOZ_WIDGET_TOOLKIT))) +ifeq (,$(filter-out cocoa android windows,$(MOZ_WIDGET_TOOLKIT))) DIRS += skia endif diff --git a/gfx/layers/d3d9/CanvasLayerD3D9.cpp b/gfx/layers/d3d9/CanvasLayerD3D9.cpp index 5b7e6d22f8b9..a84c50a45245 100644 --- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp +++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp @@ -62,7 +62,11 @@ CanvasLayerD3D9::Initialize(const Data& aData) { NS_ASSERTION(mSurface == nsnull, "BasicCanvasLayer::Initialize called twice!"); - if (aData.mSurface) { + if (aData.mDrawTarget) { + mDrawTarget = aData.mDrawTarget; + mNeedsYFlip = false; + mDataIsPremultiplied = true; + } else if (aData.mSurface) { mSurface = aData.mSurface; NS_ASSERTION(aData.mGLContext == nsnull, "CanvasLayer can't have both surface and GLContext"); @@ -75,7 +79,7 @@ CanvasLayerD3D9::Initialize(const Data& aData) mDataIsPremultiplied = aData.mGLBufferIsPremultiplied; mNeedsYFlip = true; } else { - NS_ERROR("CanvasLayer created without mSurface or mGLContext?"); + NS_ERROR("CanvasLayer created without mSurface, mGLContext or mDrawTarget?"); } mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height); @@ -150,7 +154,7 @@ CanvasLayerD3D9::UpdateSurface() } delete [] destination; } - } else if (mSurface) { + } else { RECT r; r.left = mBounds.x; r.top = mBounds.y; @@ -166,11 +170,18 @@ CanvasLayerD3D9::UpdateSurface() D3DLOCKED_RECT lockedRect = textureLock.GetLockRect(); nsRefPtr sourceSurface; + nsRefPtr tempSurface; + if (mDrawTarget) { + tempSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget); + } + else { + tempSurface = mSurface; + } - if (mSurface->GetType() == gfxASurface::SurfaceTypeWin32) { - sourceSurface = mSurface->GetAsImageSurface(); - } else if (mSurface->GetType() == gfxASurface::SurfaceTypeImage) { - sourceSurface = static_cast(mSurface.get()); + if (tempSurface->GetType() == gfxASurface::SurfaceTypeWin32) { + sourceSurface = tempSurface->GetAsImageSurface(); + } else if (tempSurface->GetType() == gfxASurface::SurfaceTypeImage) { + sourceSurface = static_cast(tempSurface.get()); if (sourceSurface->Format() != gfxASurface::ImageFormatARGB32 && sourceSurface->Format() != gfxASurface::ImageFormatRGB24) { diff --git a/gfx/layers/d3d9/CanvasLayerD3D9.h b/gfx/layers/d3d9/CanvasLayerD3D9.h index e2a5ccb105fa..4379de8efd94 100644 --- a/gfx/layers/d3d9/CanvasLayerD3D9.h +++ b/gfx/layers/d3d9/CanvasLayerD3D9.h @@ -85,6 +85,7 @@ protected: nsRefPtr mSurface; nsRefPtr mGLContext; nsRefPtr mTexture; + RefPtr mDrawTarget; PRUint32 mCanvasFramebuffer; diff --git a/gfx/skia/Makefile.in b/gfx/skia/Makefile.in index 3c89a59777da..a73404b659d7 100644 --- a/gfx/skia/Makefile.in +++ b/gfx/skia/Makefile.in @@ -58,6 +58,7 @@ LOCAL_INCLUDES += \ -I$(srcdir)/src/core \ -I$(srcdir)/include/images \ -I$(srcdir)/include/utils/mac \ + -I$(srcdir)/include/utils/win \ -I$(srcdir)/include/views \ -I$(srcdir)/include/effects \ $(NULL) @@ -172,7 +173,6 @@ EXPORTS_skia = \ include/effects/SkLayerDrawLooper.h \ include/effects/SkLayerRasterizer.h \ include/effects/SkDashPathEffect.h \ - include/ports/SkTypeface_mac.h \ $(NULL) DEFINES += -DUSE_SKIA @@ -230,7 +230,6 @@ CPPSRCS = \ SkGlyphCache.cpp \ SkGraphics.cpp \ SkLineClipper.cpp \ - SkMMapStream.cpp \ SkMallocPixelRef.cpp \ SkMask.cpp \ SkMaskFilter.cpp \ @@ -286,7 +285,6 @@ CPPSRCS = \ SkGlobals_global.cpp \ SkOSFile_stdio.cpp \ SkThread_none.cpp \ - SkTime_Unix.cpp \ SkGradientShader.cpp \ SkBitmapCache.cpp \ SkBlurDrawLooper.cpp \ @@ -308,6 +306,7 @@ CPPSRCS += \ SkBlitRow_opts_SSE2.cpp \ SkUtils_opts_SSE2.cpp \ opts_check_SSE2.cpp \ + SkTime_Unix.cpp \ $(NULL) endif @@ -319,10 +318,27 @@ CPPSRCS += \ SkFontHost_android.cpp \ SkFontHost_gamma.cpp \ SkUtils_opts_none.cpp \ + SkMMapStream.cpp \ + SkTime_Unix.cpp \ $(NULL) DEFINES += -DSK_BUILD_FOR_ANDROID_NDK OS_CXXFLAGS += $(CAIRO_FT_CFLAGS) endif +ifeq (windows,$(MOZ_WIDGET_TOOLKIT)) +EXPORTS_skia += \ + include/config/sk_stdint.h \ + include/ports/SkTypeface_win.h \ + $(NULL) +CPPSRCS += \ + SkFontHost_win.cpp \ + SkTime_win.cpp \ + SkBitmapProcState_opts_SSE2.cpp \ + SkBlitRow_opts_SSE2.cpp \ + SkUtils_opts_SSE2.cpp \ + opts_check_SSE2.cpp \ + $(NULL) +endif + include $(topsrcdir)/config/rules.mk diff --git a/gfx/skia/include/core/SkPreConfig.h b/gfx/skia/include/core/SkPreConfig.h index f8f4f62c5284..ec798ade3c08 100644 --- a/gfx/skia/include/core/SkPreConfig.h +++ b/gfx/skia/include/core/SkPreConfig.h @@ -59,6 +59,7 @@ #define SK_RESTRICT __restrict #endif #include "sk_stdint.h" + #define SK_IGNORE_STDINT_DOT_H #endif ////////////////////////////////////////////////////////////////////// diff --git a/gfx/thebes/Makefile.in b/gfx/thebes/Makefile.in index ed7ddd2aff41..3c1a157be699 100644 --- a/gfx/thebes/Makefile.in +++ b/gfx/thebes/Makefile.in @@ -151,6 +151,11 @@ EXPORTS += \ WGLLibrary.h \ gfxDWriteFonts.h \ gfxD2DSurface.h \ + gfxGDIFont.h \ + gfxGDIFontList.h \ + gfxPlatformFontList.h \ + gfxAtoms.h \ + gfxAtomList.h \ $(NULL) endif diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 776aea394bee..02f6ec5674fe 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -482,6 +482,11 @@ gfxWindowsPlatform::CreateOffscreenDrawTarget(const IntSize& aSize, SurfaceForma return Factory::CreateDrawTarget(BACKEND_DIRECT2D, aSize, aFormat); } #endif + + if (Preferences::GetBool("gfx.canvas.azure.prefer-skia", false)) { + return Factory::CreateDrawTarget(BACKEND_SKIA, aSize, aFormat); + } + return NULL; } @@ -500,7 +505,13 @@ gfxWindowsPlatform::GetScaledFontForFont(gfxFont *aFont) return scaledFont; } - return NULL; + NativeFont nativeFont; + nativeFont.mType = NATIVE_FONT_GDI_FONT_FACE; + nativeFont.mFont = aFont; + RefPtr scaledFont = + Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); + + return scaledFont; } already_AddRefed diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index 14fa06380da2..1c65a308c361 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -362,7 +362,7 @@ ifdef HAVE_CLOCK_MONOTONIC EXTRA_DSO_LDOPTS += $(REALTIME_LIBS) endif -ifeq (,$(filter-out cocoa android,$(MOZ_WIDGET_TOOLKIT))) +ifeq (,$(filter-out cocoa android windows,$(MOZ_WIDGET_TOOLKIT))) EXTRA_DSO_LDOPTS += $(MOZ_SKIA_LIBS) endif