| author | Ryan VanderMeulen <ryanvm@gmail.com> |
| Wed, 15 May 2013 21:26:11 -0400 | |
| changeset 132008 | cc139752bed4ee2ac2cf8c05ec93e7ddad9d16d9 |
| parent 132002 | 19cc1efe80976702ee0815cc325962a4fa164956 (current diff) |
| parent 132007 | 1e9dcad2319f442c04317ebc732224b397723345 (diff) |
| child 132020 | c7df35aa72e16657a929f8442ed7810d442bad2b |
| child 132021 | ed2c321c9bf68f5c3c36a1d3b472c8caba97b652 |
| child 132040 | a4cb8cb12ab49b245a969cf59f29f2c2a86a6744 |
| push id | 24679 |
| push user | ryanvm@gmail.com |
| push date | Thu, 16 May 2013 01:26:25 +0000 |
| treeherder | mozilla-central@cc139752bed4 [default view] [failures only] |
| perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
| milestone | 24.0a1 |
| first release with | nightly linux32
cc139752bed4
/
24.0a1
/
20130516031004
/
files
nightly linux64
cc139752bed4
/
24.0a1
/
20130516031004
/
files
nightly mac
cc139752bed4
/
24.0a1
/
20130516031004
/
files
nightly win32
cc139752bed4
/
24.0a1
/
20130516031004
/
files
nightly win64
|
| last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
| releases | nightly linux32
24.0a1
/
20130516031004
/
pushlog to previous
nightly linux64
24.0a1
/
20130516031004
/
pushlog to previous
nightly mac
24.0a1
/
20130516031004
/
pushlog to previous
nightly win32
24.0a1
/
20130516031004
/
pushlog to previous
|
| gfx/2d/ScaledFontCairo.cpp | file | annotate | diff | comparison | revisions | |
| gfx/2d/ScaledFontCairo.h | file | annotate | diff | comparison | revisions | |
| gfx/skia/include/ports/SkTypeface_cairo.h | file | annotate | diff | comparison | revisions | |
| gfx/skia/src/ports/SkFontHost_cairo.cpp | file | annotate | diff | comparison | revisions |
--- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1769,37 +1769,37 @@ public: * Returns a presshell for this document, if there is one. This will be * aDoc's direct presshell if there is one, otherwise we'll look at all * ancestor documents to try to find a presshell, so for example this can * still find a presshell for documents in display:none frames that have * no presentation. So you have to be careful how you use this presshell --- * getting generic data like a device context or widget from it is OK, but it * might not be this document's actual presentation. */ - static nsIPresShell* FindPresShellForDocument(nsIDocument* aDoc); + static nsIPresShell* FindPresShellForDocument(const nsIDocument* aDoc); /** * Returns the widget for this document if there is one. Looks at all ancestor * documents to try to find a widget, so for example this can still find a * widget for documents in display:none frames that have no presentation. */ - static nsIWidget* WidgetForDocument(nsIDocument* aDoc); + static nsIWidget* WidgetForDocument(const nsIDocument* aDoc); /** * Returns a layer manager to use for the given document. Basically we * look up the document hierarchy for the first document which has * a presentation with an associated widget, and use that widget's * layer manager. * * @param aDoc the document for which to return a layer manager. * @param aAllowRetaining an outparam that states whether the returned * layer manager should be used for retained layers */ static already_AddRefed<mozilla::layers::LayerManager> - LayerManagerForDocument(nsIDocument *aDoc, bool *aAllowRetaining = nullptr); + LayerManagerForDocument(const nsIDocument *aDoc, bool *aAllowRetaining = nullptr); /** * Returns a layer manager to use for the given document. Basically we * look up the document hierarchy for the first document which has * a presentation with an associated widget, and use that widget's * layer manager. In addition to the normal layer manager lookup this will * specifically request a persistent layer manager. This means that the layer * manager is expected to remain the layer manager for the document in the
--- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -6202,19 +6202,19 @@ nsContentUtils::PlatformToDOMLineBreaks( // Mac linebreaks: Map any remaining CR to LF: aString.ReplaceSubstring(NS_LITERAL_STRING("\r").get(), NS_LITERAL_STRING("\n").get()); } } nsIPresShell* -nsContentUtils::FindPresShellForDocument(nsIDocument* aDoc) -{ - nsIDocument* doc = aDoc; +nsContentUtils::FindPresShellForDocument(const nsIDocument* aDoc) +{ + const nsIDocument* doc = aDoc; nsIDocument* displayDoc = doc->GetDisplayDocument(); if (displayDoc) { doc = displayDoc; } nsIPresShell* shell = doc->GetShell(); if (shell) { return shell; @@ -6236,17 +6236,17 @@ nsContentUtils::FindPresShellForDocument docShellTreeItem->GetParent(getter_AddRefs(parent)); docShellTreeItem = parent; } return nullptr; } nsIWidget* -nsContentUtils::WidgetForDocument(nsIDocument* aDoc) +nsContentUtils::WidgetForDocument(const nsIDocument* aDoc) { nsIPresShell* shell = FindPresShellForDocument(aDoc); if (shell) { nsViewManager* VM = shell->GetViewManager(); if (VM) { nsView* rootView = VM->GetRootView(); if (rootView) { nsView* displayRoot = nsViewManager::GetDisplayRootFor(rootView); @@ -6256,33 +6256,33 @@ nsContentUtils::WidgetForDocument(nsIDoc } } } return nullptr; } static already_AddRefed<LayerManager> -LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent, +LayerManagerForDocumentInternal(const nsIDocument *aDoc, bool aRequirePersistent, bool* aAllowRetaining) { nsIWidget *widget = nsContentUtils::WidgetForDocument(aDoc); if (widget) { nsRefPtr<LayerManager> manager = widget->GetLayerManager(aRequirePersistent ? nsIWidget::LAYER_MANAGER_PERSISTENT : nsIWidget::LAYER_MANAGER_CURRENT, aAllowRetaining); return manager.forget(); } return nullptr; } already_AddRefed<LayerManager> -nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc, bool *aAllowRetaining) +nsContentUtils::LayerManagerForDocument(const nsIDocument *aDoc, bool *aAllowRetaining) { return LayerManagerForDocumentInternal(aDoc, false, aAllowRetaining); } already_AddRefed<LayerManager> nsContentUtils::PersistentLayerManagerForDocument(nsIDocument *aDoc, bool *aAllowRetaining) { return LayerManagerForDocumentInternal(aDoc, true, aAllowRetaining);
--- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -797,17 +797,22 @@ CanvasRenderingContext2D::EnsureTarget() if (gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) { SurfaceCaps caps = SurfaceCaps::ForRGBA(); caps.preserve = true; mGLContext = mozilla::gl::GLContextProvider::CreateOffscreen(gfxIntSize(size.width, size.height), caps, mozilla::gl::GLContext::ContextFlagsNone); - mTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForFBO(0, mGLContext, size, format); + + if (mGLContext) { + mTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForFBO(0, mGLContext, size, format); + } else { + mTarget = layerManager->CreateDrawTarget(size, format); + } } else #endif mTarget = layerManager->CreateDrawTarget(size, format); } else { mTarget = gfxPlatform::GetPlatform()->CreateOffscreenDrawTarget(size, format); } }
--- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -919,21 +919,16 @@ public: static void SetGlobalEventRecorder(DrawEventRecorder *aRecorder); #ifdef USE_SKIA_GPU static TemporaryRef<DrawTarget> CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext *aContext, const IntSize &aSize, SurfaceFormat aFormat); #endif -#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE) - static TemporaryRef<GlyphRenderingOptions> - CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting); -#endif - #ifdef WIN32 static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat); static TemporaryRef<DrawTarget> CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA, ID3D10Texture2D *aTextureB, SurfaceFormat aFormat); static void SetDirect3D10Device(ID3D10Device1 *aDevice);
--- a/gfx/2d/DrawTargetSkia.cpp +++ b/gfx/2d/DrawTargetSkia.cpp @@ -1,17 +1,16 @@ /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DrawTargetSkia.h" #include "SourceSurfaceSkia.h" #include "ScaledFontBase.h" -#include "ScaledFontCairo.h" #include "skia/SkDevice.h" #ifdef USE_SKIA_GPU #include "skia/SkGpuDevice.h" #endif #include "skia/SkTypeface.h" #include "skia/SkGradientShader.h" @@ -441,56 +440,33 @@ DrawTargetSkia::Fill(const Path *aPath, mCanvas->drawPath(skiaPath->GetPath(), paint.mPaint); } void DrawTargetSkia::FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aOptions, - const GlyphRenderingOptions *aRenderingOptions) + const GlyphRenderingOptions*) { if (aFont->GetType() != FONT_MAC && aFont->GetType() != FONT_SKIA && aFont->GetType() != FONT_GDI) { return; } MarkChanged(); ScaledFontBase* skiaFont = static_cast<ScaledFontBase*>(aFont); AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern); paint.mPaint.setTypeface(skiaFont->GetSkTypeface()); paint.mPaint.setTextSize(SkFloatToScalar(skiaFont->mSize)); paint.mPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); - - if (aRenderingOptions && aRenderingOptions->GetType() == FONT_CAIRO) { - switch (static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions)->GetHinting()) { - case FONT_HINTING_NONE: - paint.mPaint.setHinting(SkPaint::kNo_Hinting); - break; - case FONT_HINTING_LIGHT: - paint.mPaint.setHinting(SkPaint::kSlight_Hinting); - break; - case FONT_HINTING_NORMAL: - paint.mPaint.setHinting(SkPaint::kNormal_Hinting); - break; - case FONT_HINTING_FULL: - paint.mPaint.setHinting(SkPaint::kFull_Hinting); - break; - } - - if (static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions)->GetAutoHinting()) { - paint.mPaint.setAutohinted(true); - } - } else { - paint.mPaint.setHinting(SkPaint::kNormal_Hinting); - } - + std::vector<uint16_t> indices; std::vector<SkPoint> offsets; indices.resize(aBuffer.mNumGlyphs); offsets.resize(aBuffer.mNumGlyphs); for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) { indices[i] = aBuffer.mGlyphs[i].mIndex; offsets[i].fX = SkFloatToScalar(aBuffer.mGlyphs[i].mPosition.x);
--- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -2,25 +2,24 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "2D.h" #ifdef USE_CAIRO #include "DrawTargetCairo.h" -#include "ScaledFontCairo.h" +#include "ScaledFontBase.h" #endif #ifdef USE_SKIA #include "DrawTargetSkia.h" #include "ScaledFontBase.h" #ifdef MOZ_ENABLE_FREETYPE -#define USE_SKIA_FREETYPE -#include "ScaledFontCairo.h" +#include "ScaledFontFreetype.h" #endif #endif #if defined(WIN32) && defined(USE_SKIA) #include "ScaledFontWin.h" #endif #ifdef XP_MACOSX @@ -293,20 +292,30 @@ Factory::CreateScaledFontForNativeFont(c #endif #endif #ifdef XP_MACOSX case NATIVE_FONT_MAC_FONT_FACE: { return new ScaledFontMac(static_cast<CGFontRef>(aNativeFont.mFont), aSize); } #endif -#if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE) +#ifdef USE_SKIA +#ifdef MOZ_ENABLE_FREETYPE + case NATIVE_FONT_SKIA_FONT_FACE: + { + return new ScaledFontFreetype(static_cast<FontOptions*>(aNativeFont.mFont), aSize); + } +#endif +#endif +#ifdef USE_CAIRO case NATIVE_FONT_CAIRO_FONT_FACE: { - return new ScaledFontCairo(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont), aSize); + ScaledFontBase* fontBase = new ScaledFontBase(aSize); + fontBase->SetCairoScaledFont(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont)); + return fontBase; } #endif default: gfxWarning() << "Invalid native font type specified."; return nullptr; } } @@ -445,29 +454,16 @@ TemporaryRef<DrawTarget> Factory::CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext *aGrContext, const IntSize &aSize, SurfaceFormat aFormat) { RefPtr<DrawTargetSkia> newTarget = new DrawTargetSkia(); newTarget->InitWithFBO(aFBOID, aGrContext, aSize, aFormat); return newTarget; } #endif // USE_SKIA_GPU -#ifdef USE_SKIA_FREETYPE -TemporaryRef<GlyphRenderingOptions> -Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting) -{ - RefPtr<GlyphRenderingOptionsCairo> options = - new GlyphRenderingOptionsCairo(); - - options->SetHinting(aHinting); - options->SetAutoHinting(aAutoHinting); - return options; -} -#endif - TemporaryRef<DrawTarget> Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize) { RefPtr<DrawTarget> retVal; #ifdef USE_CAIRO RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
--- a/gfx/2d/Makefile.in +++ b/gfx/2d/Makefile.in @@ -23,17 +23,16 @@ CPPSRCS = \ PathCairo.cpp \ DrawTargetRecording.cpp \ PathRecording.cpp \ RecordedEvent.cpp \ DrawEventRecorder.cpp \ Blur.cpp \ Scale.cpp \ ScaledFontBase.cpp \ - ScaledFontCairo.cpp \ DrawTargetDual.cpp \ ImageScaling.cpp \ SourceSurfaceRawData.cpp \ $(NULL) GTEST_CPPSRCS = \ GTestMain.cpp \ TestBase.cpp \ @@ -69,18 +68,20 @@ endif ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ ScaledFontMac.cpp \ $(NULL) endif ifeq ($(MOZ_WIDGET_TOOLKIT),$(findstring $(MOZ_WIDGET_TOOLKIT),android gtk2 gonk qt)) +CPPSRCS += \ + ScaledFontFreetype.cpp \ + $(NULL) DEFINES += -DMOZ_ENABLE_FREETYPE -OS_CXXFLAGS += $(CAIRO_FT_CFLAGS) endif DEFINES += -DSK_A32_SHIFT=24 -DSK_R32_SHIFT=16 -DSK_G32_SHIFT=8 -DSK_B32_SHIFT=0 ifdef MOZ_DEBUG DEFINES += -DGFX_LOG_DEBUG -DGFX_LOG_WARNING endif
--- a/gfx/2d/ScaledFontBase.cpp +++ b/gfx/2d/ScaledFontBase.cpp @@ -23,28 +23,28 @@ using namespace std; namespace mozilla { namespace gfx { ScaledFontBase::~ScaledFontBase() { #ifdef USE_SKIA SkSafeUnref(mTypeface); #endif -#ifdef USE_CAIRO_SCALED_FONT +#ifdef USE_CAIRO cairo_scaled_font_destroy(mScaledFont); #endif } ScaledFontBase::ScaledFontBase(Float aSize) : mSize(aSize) { #ifdef USE_SKIA mTypeface = nullptr; #endif -#ifdef USE_CAIRO_SCALED_FONT +#ifdef USE_CAIRO mScaledFont = nullptr; #endif } TemporaryRef<Path> ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) { #ifdef USE_SKIA @@ -101,17 +101,17 @@ ScaledFontBase::GetPathForGlyphs(const G void ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder) { // XXX - implement me MOZ_ASSERT(false); return; } -#ifdef USE_CAIRO_SCALED_FONT +#ifdef USE_CAIRO void ScaledFontBase::SetCairoScaledFont(cairo_scaled_font_t* font) { MOZ_ASSERT(!mScaledFont); mScaledFont = font; cairo_scaled_font_reference(mScaledFont); }
--- a/gfx/2d/ScaledFontBase.h +++ b/gfx/2d/ScaledFontBase.h @@ -3,25 +3,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_ #define MOZILLA_GFX_SCALEDFONTBASE_H_ #include "2D.h" -// Skia uses cairo_scaled_font_t as the internal font type in ScaledFont -#if defined(USE_SKIA) || defined(USE_CAIRO) -#define USE_CAIRO_SCALED_FONT -#endif - #ifdef USE_SKIA #include "skia/SkTypeface.h" #endif -#ifdef USE_CAIRO_SCALED_FONT +#ifdef USE_CAIRO #include "cairo.h" #endif class gfxFont; namespace mozilla { namespace gfx { @@ -39,27 +34,27 @@ public: #ifdef USE_SKIA virtual SkTypeface* GetSkTypeface() { return mTypeface; } #endif // Not true, but required to instantiate a ScaledFontBase. virtual FontType GetType() const { return FONT_SKIA; } -#ifdef USE_CAIRO_SCALED_FONT +#ifdef USE_CAIRO cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; } void SetCairoScaledFont(cairo_scaled_font_t* font); #endif protected: friend class DrawTargetSkia; #ifdef USE_SKIA SkTypeface* mTypeface; #endif -#ifdef USE_CAIRO_SCALED_FONT +#ifdef USE_CAIRO cairo_scaled_font_t* mScaledFont; #endif Float mSize; }; } }
deleted file mode 100644 --- a/gfx/2d/ScaledFontCairo.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "ScaledFontCairo.h" -#include "Logging.h" - -#include "gfxFont.h" - -#ifdef MOZ_ENABLE_FREETYPE -#include <ft2build.h> -#include FT_FREETYPE_H -#include "cairo-ft.h" -#endif - -#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE) -#include "skia/SkTypeface.h" -#include "skia/SkTypeface_cairo.h" -#endif - -#include <string> - -typedef struct FT_FaceRec_* FT_Face; - -using namespace std; - -namespace mozilla { -namespace gfx { - -// On Linux and Android our "platform" font is a cairo_scaled_font_t and we use -// an SkFontHost implementation that allows Skia to render using this. -// This is mainly because FT_Face is not good for sharing between libraries, which -// is a requirement when we consider runtime switchable backends and so on -ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize) - : ScaledFontBase(aSize) -{ - mScaledFont = aScaledFont; -#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE) - cairo_font_face_t* fontFace = cairo_scaled_font_get_font_face(aScaledFont); - FT_Face face = cairo_ft_scaled_font_lock_face(aScaledFont); - - int style = SkTypeface::kNormal; - - if (face->style_flags & FT_STYLE_FLAG_ITALIC) - style |= SkTypeface::kItalic; - - if (face->style_flags & FT_STYLE_FLAG_BOLD) - style |= SkTypeface::kBold; - - bool isFixedWidth = face->face_flags & FT_FACE_FLAG_FIXED_WIDTH; - cairo_ft_scaled_font_unlock_face(aScaledFont); - - mTypeface = SkCreateTypefaceFromCairoFont(fontFace, (SkTypeface::Style)style, isFixedWidth); -#endif -} - -} -}
deleted file mode 100644 --- a/gfx/2d/ScaledFontCairo.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef MOZILLA_GFX_SCALEDFONTCAIRO_H_ -#define MOZILLA_GFX_SCALEDFONTCAIRO_H_ - -#include "ScaledFontBase.h" - -#include "cairo.h" - -namespace mozilla { -namespace gfx { - -class ScaledFontCairo : public ScaledFontBase -{ -public: - - ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize); -}; - -// We need to be able to tell Skia whether or not to use -// hinting when rendering text, so that the glyphs it renders -// are the same as what layout is expecting. At the moment, only -// Skia uses this class when rendering with FreeType, as gfxFT2Font -// is the only gfxFont that honours gfxPlatform::FontHintingEnabled(). -class GlyphRenderingOptionsCairo : public GlyphRenderingOptions -{ -public: - GlyphRenderingOptionsCairo() - : mHinting(FONT_HINTING_NORMAL) - , mAutoHinting(false) - { - } - - void SetHinting(FontHinting aHinting) { mHinting = aHinting; } - void SetAutoHinting(bool aAutoHinting) { mAutoHinting = aAutoHinting; } - FontHinting GetHinting() const { return mHinting; } - bool GetAutoHinting() const { return mAutoHinting; } - virtual FontType GetType() const { return FONT_CAIRO; } -private: - FontHinting mHinting; - bool mAutoHinting; -}; - -} -} - -#endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */
new file mode 100644 --- /dev/null +++ b/gfx/2d/ScaledFontFreetype.cpp @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "ScaledFontFreetype.h" +#include "Logging.h" + +#include "gfxFont.h" + +#ifdef USE_SKIA +#include "skia/SkTypeface.h" +#endif + +#include <string> + +using namespace std; + +namespace mozilla { +namespace gfx { + +#ifdef USE_SKIA +static SkTypeface::Style +fontStyleToSkia(FontStyle aStyle) +{ + switch (aStyle) { + case FONT_STYLE_NORMAL: + return SkTypeface::kNormal; + case FONT_STYLE_ITALIC: + return SkTypeface::kItalic; + case FONT_STYLE_BOLD: + return SkTypeface::kBold; + case FONT_STYLE_BOLD_ITALIC: + return SkTypeface::kBoldItalic; + } + + gfxWarning() << "Unknown font style"; + return SkTypeface::kNormal; +} +#endif + +// Ideally we want to use FT_Face here but as there is currently no way to get +// an SkTypeface from an FT_Face we do this. +ScaledFontFreetype::ScaledFontFreetype(FontOptions* aFont, Float aSize) + : ScaledFontBase(aSize) +{ +#ifdef USE_SKIA + mTypeface = SkTypeface::CreateFromName(aFont->mName.c_str(), fontStyleToSkia(aFont->mStyle)); +#endif +} + +} +}
new file mode 100644 --- /dev/null +++ b/gfx/2d/ScaledFontFreetype.h @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MOZILLA_GFX_SCALEDFONTFREETYPE_H_ +#define MOZILLA_GFX_SCALEDFONTFREETYPE_H_ + +#include "ScaledFontBase.h" + +namespace mozilla { +namespace gfx { + +class ScaledFontFreetype : public ScaledFontBase +{ +public: + + ScaledFontFreetype(FontOptions* aFont, Float aSize); +}; + +} +} + +#endif /* MOZILLA_GFX_SCALEDFONTFREETYPE_H_ */
--- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -83,24 +83,16 @@ enum NativeFontType enum FontStyle { FONT_STYLE_NORMAL, FONT_STYLE_ITALIC, FONT_STYLE_BOLD, FONT_STYLE_BOLD_ITALIC }; -enum FontHinting -{ - FONT_HINTING_NONE, - FONT_HINTING_LIGHT, - FONT_HINTING_NORMAL, - FONT_HINTING_FULL -}; - enum CompositionOp { OP_OVER, OP_ADD, OP_ATOP, OP_OUT, OP_IN, OP_SOURCE, OP_DEST_IN, OP_DEST_OUT, OP_DEST_OVER, OP_DEST_ATOP, OP_XOR, OP_MULTIPLY, OP_SCREEN, OP_OVERLAY, OP_DARKEN, OP_LIGHTEN, OP_COLOR_DODGE, OP_COLOR_BURN, OP_HARD_LIGHT, OP_SOFT_LIGHT, OP_DIFFERENCE, OP_EXCLUSION, OP_HUE, OP_SATURATION, OP_COLOR, OP_LUMINOSITY, OP_COUNT }; enum ExtendMode { EXTEND_CLAMP, EXTEND_REPEAT, EXTEND_REFLECT }; enum FillRule { FILL_WINDING, FILL_EVEN_ODD }; enum AntialiasMode { AA_NONE, AA_GRAY, AA_SUBPIXEL, AA_DEFAULT }; enum Snapping { SNAP_NONE, SNAP_ALIGNED }; enum Filter { FILTER_LINEAR, FILTER_POINT }; enum PatternType { PATTERN_COLOR, PATTERN_SURFACE, PATTERN_LINEAR_GRADIENT, PATTERN_RADIAL_GRADIENT };
--- a/gfx/skia/Makefile.in +++ b/gfx/skia/Makefile.in @@ -294,59 +294,52 @@ CPPSRCS += \ $(NULL) endif ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ SkFontHost_mac_coretext.cpp \ SkStream_mac.cpp \ SkTime_Unix.cpp \ - SkThread_pthread.cpp \ $(NULL) -DEFINES += -DSK_USE_POSIX_THREADS=1 endif ifeq (android,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ SkDebug_android.cpp \ - SkFontHost_cairo.cpp \ + SkFontHost_android_old.cpp \ + SkFontHost_FreeType.cpp \ SkFontHost_FreeType_common.cpp \ SkFontHost_tables.cpp \ SkMMapStream.cpp \ SkTime_Unix.cpp \ SkThread_pthread.cpp \ $(NULL) +OS_CXXFLAGS += $(CAIRO_FT_CFLAGS) DEFINES += -DSK_USE_POSIX_THREADS=1 -EXPORTS_skia += \ - include/ports/SkTypeface_cairo.h \ - $(NULL) - -OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(CAIRO_FT_CFLAGS) else CPPSRCS += \ SkDebug_stdio.cpp \ + SkThread_none.cpp \ $(NULL) endif ifeq (gtk2,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ - SkFontHost_cairo.cpp \ + SkFontHost_FreeType.cpp \ SkFontHost_FreeType_common.cpp \ + SkFontHost_linux.cpp \ SkFontHost_tables.cpp \ SkTime_Unix.cpp \ SkMMapStream.cpp \ SkOSFile.cpp \ $(NULL) -EXPORTS_skia += \ - include/ports/SkTypeface_cairo.h \ - $(NULL) - -OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(CAIRO_FT_CFLAGS) +OS_CXXFLAGS += $(MOZ_PANGO_CFLAGS) endif ifeq (qt,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ SkFontHost_FreeType.cpp \ SkFontHost_FreeType_common.cpp \ SkFontHost_tables.cpp \ SkMMapStream.cpp \ @@ -359,28 +352,24 @@ CPPSRCS += \ SkTime_Unix.cpp \ $(NULL) endif OS_CXXFLAGS += $(MOZ_PANGO_CFLAGS) endif ifeq (Linux,$(OS_TARGET)) DEFINES += -DSK_USE_POSIX_THREADS=1 -CPPSRCS += \ - SkThread_pthread.cpp \ - $(NULL) endif ifeq (windows,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ SkFontHost_win.cpp \ SkFontHost_tables.cpp \ SkFontHost_sandbox_none.cpp \ SkTime_win.cpp \ - SkThread_win.cpp \ $(NULL) DEFINES += -DSKIA_IMPLEMENTATION=1 -DGR_IMPLEMENTATION=1 endif ifneq (,$(INTEL_ARCHITECTURE)) CPPSRCS += \ SkBitmapProcState_opts_SSE2.cpp \ SkBlitRect_opts_SSE2.cpp \
deleted file mode 100644 --- a/gfx/skia/include/ports/SkTypeface_cairo.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef SkTypeface_cairo_DEFINED -#define SkTypeface_cairo_DEFINED - -#include <cairo.h> - -#include "SkTypeface.h" - -SK_API extern SkTypeface* SkCreateTypefaceFromCairoFont(cairo_font_face_t* fontFace, SkTypeface::Style style, bool isFixedWidth); - -#endif -
deleted file mode 100644 --- a/gfx/skia/src/ports/SkFontHost_cairo.cpp +++ /dev/null @@ -1,382 +0,0 @@ - -/* - * Copyright 2012 Mozilla Foundation - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "cairo.h" -#include "cairo-ft.h" - -#include "SkFontHost_FreeType_common.h" - -#include "SkAdvancedTypefaceMetrics.h" -#include "SkFontHost.h" -#include "SkPath.h" -#include "SkScalerContext.h" -#include "SkTypefaceCache.h" - -#include <ft2build.h> -#include FT_FREETYPE_H - -static cairo_user_data_key_t kSkTypefaceKey; - -class SkScalerContext_CairoFT : public SkScalerContext_FreeType_Base { -public: - SkScalerContext_CairoFT(const SkDescriptor* desc); - virtual ~SkScalerContext_CairoFT(); - -protected: - virtual unsigned generateGlyphCount() SK_OVERRIDE; - virtual uint16_t generateCharToGlyph(SkUnichar uniChar) SK_OVERRIDE; - virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; - virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; - virtual void generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) SK_OVERRIDE; - virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; - virtual void generateFontMetrics(SkPaint::FontMetrics* mx, - SkPaint::FontMetrics* my) SK_OVERRIDE; - virtual SkUnichar generateGlyphToChar(uint16_t glyph) SK_OVERRIDE; -private: - cairo_scaled_font_t* fScaledFont; - uint32_t fLoadGlyphFlags; -}; - -class CairoLockedFTFace { -public: - CairoLockedFTFace(cairo_scaled_font_t* scaledFont) - : fScaledFont(scaledFont) - , fFace(cairo_ft_scaled_font_lock_face(scaledFont)) - {} - - ~CairoLockedFTFace() - { - cairo_ft_scaled_font_unlock_face(fScaledFont); - } - - FT_Face getFace() - { - return fFace; - } - -private: - cairo_scaled_font_t* fScaledFont; - FT_Face fFace; -}; - -class SkCairoFTTypeface : public SkTypeface { -public: - static SkTypeface* CreateTypeface(cairo_font_face_t* fontFace, SkTypeface::Style style, bool isFixedWidth) { - SkASSERT(fontFace != NULL); - SkASSERT(cairo_font_face_get_type(fontFace) == CAIRO_FONT_TYPE_FT); - - SkFontID newId = SkTypefaceCache::NewFontID(); - - return SkNEW_ARGS(SkCairoFTTypeface, (fontFace, style, newId, isFixedWidth)); - } - - cairo_font_face_t* getFontFace() { - return fFontFace; - } - -private: - - SkCairoFTTypeface(cairo_font_face_t* fontFace, SkTypeface::Style style, SkFontID id, bool isFixedWidth) - : SkTypeface(style, id, isFixedWidth) - , fFontFace(fontFace) - { - cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, this, NULL); - cairo_font_face_reference(fFontFace); - } - - ~SkCairoFTTypeface() - { - cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, NULL, NULL); - cairo_font_face_destroy(fFontFace); - } - - cairo_font_face_t* fFontFace; -}; - -SkTypeface* SkCreateTypefaceFromCairoFont(cairo_font_face_t* fontFace, SkTypeface::Style style, bool isFixedWidth) -{ - SkTypeface* typeface = reinterpret_cast<SkTypeface*>(cairo_font_face_get_user_data(fontFace, &kSkTypefaceKey)); - - if (typeface) { - typeface->ref(); - } else { - typeface = SkCairoFTTypeface::CreateTypeface(fontFace, style, isFixedWidth); - SkTypefaceCache::Add(typeface, style); - } - - return typeface; -} - -SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, - const char famillyName[], - SkTypeface::Style style) -{ - SkDEBUGFAIL("SkFontHost::FindTypeface unimplemented"); - return NULL; -} - -SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream*) -{ - SkDEBUGFAIL("SkFontHost::CreateTypeface unimplemented"); - return NULL; -} - -SkTypeface* SkFontHost::CreateTypefaceFromFile(char const*) -{ - SkDEBUGFAIL("SkFontHost::CreateTypefaceFromFile unimplemented"); - return NULL; -} - -// static -SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( - uint32_t fontID, - SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, - const uint32_t* glyphIDs, - uint32_t glyphIDsCount) -{ - return NULL; -} - -void SkFontHost::FilterRec(SkScalerContext::Rec* rec) { -} - -/////////////////////////////////////////////////////////////////////////////// - -SkStream* SkFontHost::OpenStream(uint32_t uniqueID) -{ - SkDEBUGFAIL("SkFontHost::OpenStream unimplemented"); - return NULL; -} - -size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, - int32_t* index) { - SkDebugf("SkFontHost::GetFileName unimplemented\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// - -void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) -{ - SkDEBUGFAIL("SkFontHost::Serialize unimplemented"); -} - -SkTypeface* SkFontHost::Deserialize(SkStream* stream) { - SkDEBUGFAIL("SkFontHost::Deserialize unimplemented"); - return NULL; -} - -static bool isLCD(const SkScalerContext::Rec& rec) { - switch (rec.fMaskFormat) { - case SkMask::kLCD16_Format: - case SkMask::kLCD32_Format: - return true; - default: - return false; - } -} - -/////////////////////////////////////////////////////////////////////////////// -SkScalerContext_CairoFT::SkScalerContext_CairoFT(const SkDescriptor* desc) - : SkScalerContext_FreeType_Base(desc) -{ - SkCairoFTTypeface* typeface = static_cast<SkCairoFTTypeface*>(SkTypefaceCache::FindByID(fRec.fFontID)); - - SkMatrix matrix; - fRec.getSingleMatrix(&matrix); - - cairo_font_face_t* fontFace = typeface->getFontFace(); - - cairo_matrix_t fontMatrix, ctMatrix; - cairo_matrix_init(&fontMatrix, matrix.getScaleX(), matrix.getSkewY(), matrix.getSkewX(), matrix.getScaleY(), 0.0, 0.0); - cairo_matrix_init_scale(&ctMatrix, 1.0, 1.0); - - // We need to ensure that the font options match for hinting, as generateMetrics() - // uses the fScaledFont which uses these font options - cairo_font_options_t *fontOptions = cairo_font_options_create(); - - FT_Int32 loadFlags = FT_LOAD_DEFAULT; - - if (SkMask::kBW_Format == fRec.fMaskFormat) { - // See http://code.google.com/p/chromium/issues/detail?id=43252#c24 - loadFlags = FT_LOAD_TARGET_MONO; - if (fRec.getHinting() == SkPaint::kNo_Hinting) { - cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_NONE); - loadFlags = FT_LOAD_NO_HINTING; - } - } else { - switch (fRec.getHinting()) { - case SkPaint::kNo_Hinting: - loadFlags = FT_LOAD_NO_HINTING; - cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_NONE); - break; - case SkPaint::kSlight_Hinting: - loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT - cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_SLIGHT); - break; - case SkPaint::kNormal_Hinting: - cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_MEDIUM); - if (fRec.fFlags & SkScalerContext::kAutohinting_Flag) { - loadFlags = FT_LOAD_FORCE_AUTOHINT; - } - break; - case SkPaint::kFull_Hinting: - cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_FULL); - if (fRec.fFlags & SkScalerContext::kAutohinting_Flag) { - loadFlags = FT_LOAD_FORCE_AUTOHINT; - } - if (isLCD(fRec)) { - if (SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag)) { - loadFlags = FT_LOAD_TARGET_LCD_V; - } else { - loadFlags = FT_LOAD_TARGET_LCD; - } - } - break; - default: - SkDebugf("---------- UNKNOWN hinting %d\n", fRec.getHinting()); - break; - } - } - - fScaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctMatrix, fontOptions); - - if ((fRec.fFlags & SkScalerContext::kEmbeddedBitmapText_Flag) == 0) { - loadFlags |= FT_LOAD_NO_BITMAP; - } - - // Always using FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH to get correct - // advances, as fontconfig and cairo do. - // See http://code.google.com/p/skia/issues/detail?id=222. - loadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; - - fLoadGlyphFlags = loadFlags; -} - -SkScalerContext_CairoFT::~SkScalerContext_CairoFT() -{ - cairo_scaled_font_destroy(fScaledFont); -} - -SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) -{ - return SkNEW_ARGS(SkScalerContext_CairoFT, (desc)); -} - -SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) -{ - return 0; -} - -#ifdef SK_BUILD_FOR_ANDROID -uint32_t SkFontHost::GetUnitsPerEm(SkFontID fontID) { - return 0; -} -#endif - -unsigned SkScalerContext_CairoFT::generateGlyphCount() -{ - CairoLockedFTFace faceLock(fScaledFont); - return faceLock.getFace()->num_glyphs; -} - -uint16_t SkScalerContext_CairoFT::generateCharToGlyph(SkUnichar uniChar) -{ - CairoLockedFTFace faceLock(fScaledFont); - return SkToU16(FT_Get_Char_Index(faceLock.getFace(), uniChar)); -} - -void SkScalerContext_CairoFT::generateAdvance(SkGlyph* glyph) -{ - generateMetrics(glyph); -} - -void SkScalerContext_CairoFT::generateMetrics(SkGlyph* glyph) -{ - SkASSERT(fScaledFont != NULL); - cairo_text_extents_t extents; - cairo_glyph_t cairoGlyph = { glyph->getGlyphID(fBaseGlyphCount), 0.0, 0.0 }; - cairo_scaled_font_glyph_extents(fScaledFont, &cairoGlyph, 1, &extents); - - glyph->fAdvanceX = SkDoubleToFixed(extents.x_advance); - glyph->fAdvanceY = SkDoubleToFixed(extents.y_advance); - glyph->fWidth = SkToU16(SkScalarCeil(extents.width)); - glyph->fHeight = SkToU16(SkScalarCeil(extents.height)); - glyph->fLeft = SkToS16(SkScalarCeil(extents.x_bearing)); - glyph->fTop = SkToS16(SkScalarCeil(extents.y_bearing)); - glyph->fLsbDelta = 0; - glyph->fRsbDelta = 0; -} - -void SkScalerContext_CairoFT::generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) -{ - SkASSERT(fScaledFont != NULL); - CairoLockedFTFace faceLock(fScaledFont); - FT_Face face = faceLock.getFace(); - - FT_Error err = FT_Load_Glyph(face, glyph.getGlyphID(fBaseGlyphCount), fLoadGlyphFlags); - - if (err != 0) { - memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight); - return; - } - - generateGlyphImage(face, glyph, maskPreBlend); -} - -void SkScalerContext_CairoFT::generatePath(const SkGlyph& glyph, SkPath* path) -{ - SkASSERT(fScaledFont != NULL); - CairoLockedFTFace faceLock(fScaledFont); - FT_Face face = faceLock.getFace(); - - SkASSERT(&glyph && path); - - uint32_t flags = fLoadGlyphFlags; - flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline - flags &= ~FT_LOAD_RENDER; // don't scan convert (we just want the outline) - - FT_Error err = FT_Load_Glyph(face, glyph.getGlyphID(fBaseGlyphCount), flags); - - if (err != 0) { - path->reset(); - return; - } - - generateGlyphPath(face, glyph, path); -} - -void SkScalerContext_CairoFT::generateFontMetrics(SkPaint::FontMetrics* mx, - SkPaint::FontMetrics* my) -{ -} - -SkUnichar SkScalerContext_CairoFT::generateGlyphToChar(uint16_t glyph) -{ - SkASSERT(fScaledFont != NULL); - CairoLockedFTFace faceLock(fScaledFont); - FT_Face face = faceLock.getFace(); - - FT_UInt glyphIndex; - SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex); - while (glyphIndex != 0) { - if (glyphIndex == glyph) { - return charCode; - } - charCode = FT_Get_Next_Char(face, charCode, &glyphIndex); - } - - return 0; -} - -#ifdef SK_BUILD_FOR_ANDROID -SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, - SkFontID origFontID) { - return NULL; -} -#endif
--- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -317,23 +317,26 @@ gfxAndroidPlatform::MakePlatformFont(con aFontData, aLength); } TemporaryRef<ScaledFont> gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) { NativeFont nativeFont; - if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) { + if (aTarget->GetType() == BACKEND_CAIRO) { nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE; - nativeFont.mFont = aFont->GetCairoScaledFont(); - return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); + nativeFont.mFont = NULL; + return Factory::CreateScaledFontWithCairo(nativeFont, aFont->GetAdjustedSize(), aFont->GetCairoScaledFont()); } - - return nullptr; + + NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_FT2, "Expecting Freetype font"); + nativeFont.mType = NATIVE_FONT_SKIA_FONT_FACE; + nativeFont.mFont = static_cast<gfxFT2FontBase*>(aFont)->GetFontOptions(); + return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); } bool gfxAndroidPlatform::FontHintingEnabled() { // In "mobile" builds, we sometimes use non-reflow-zoom, so we // might not want hinting. Let's see.
--- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -31,17 +31,16 @@ #include "nsUnicodeRange.h" #include "nsCRT.h" #include "nsXULAppAPI.h" #include "prlog.h" #include "prinit.h" #include "mozilla/Preferences.h" -#include "mozilla/gfx/2D.h" // rounding and truncation functions for a Freetype floating point number // (FT26Dot6) stored in a 32bit integer with high 26 bits for the integer // part and low 6 bits for the fractional part. #define MOZ_FT_ROUND(x) (((x) + 32) & ~63) // 63 = 2^6 - 1 #define MOZ_FT_TRUNC(x) ((x) >> 6) #define CONVERT_DESIGN_UNITS_TO_PIXELS(v, s) \ MOZ_FT_TRUNC(MOZ_FT_ROUND(FT_MulFix((v) , (s)))) @@ -655,26 +654,8 @@ gfxFT2Font::SizeOfExcludingThis(nsMalloc void gfxFT2Font::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); SizeOfExcludingThis(aMallocSizeOf, aSizes); } - -#ifdef USE_SKIA -mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> -gfxFT2Font::GetGlyphRenderingOptions() -{ - mozilla::gfx::FontHinting hinting; - - if (gfxPlatform::GetPlatform()->FontHintingEnabled()) { - hinting = mozilla::gfx::FONT_HINTING_NORMAL; - } else { - hinting = mozilla::gfx::FONT_HINTING_NONE; - } - - // We don't want to force the use of the autohinter over the font's built in hints - return mozilla::gfx::Factory::CreateCairoGlyphRenderingOptions(hinting, false); -} -#endif -
--- a/gfx/thebes/gfxFT2Fonts.h +++ b/gfx/thebes/gfxFT2Fonts.h @@ -63,20 +63,16 @@ public: // new functions return &entry->mData; } virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, FontCacheSizes* aSizes) const; virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, FontCacheSizes* aSizes) const; -#ifdef USE_SKIA - virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions(); -#endif - protected: virtual bool ShapeText(gfxContext *aContext, const PRUnichar *aText, uint32_t aOffset, uint32_t aLength, int32_t aScript, gfxShapedText *aShapedText, bool aPreferPlatformShaping);
--- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -772,20 +772,16 @@ public: // The PangoFont returned is owned by the gfxFcFont PangoFont *GetPangoFont() { if (!mPangoFont) { MakePangoFont(); } return mPangoFont; } -#ifdef USE_SKIA - virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions(); -#endif - protected: virtual bool ShapeText(gfxContext *aContext, const PRUnichar *aText, uint32_t aOffset, uint32_t aLength, int32_t aScript, gfxShapedText *aShapedText, bool aPreferPlatformShaping); @@ -3230,41 +3226,8 @@ ApplyGdkScreenFontOptions(FcPattern *aPa { const cairo_font_options_t *options = gdk_screen_get_font_options(gdk_screen_get_default()); cairo_ft_font_options_substitute(options, aPattern); } #endif // MOZ_WIDGET_GTK2 - -#ifdef USE_SKIA -mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> -gfxFcFont::GetGlyphRenderingOptions() -{ - cairo_scaled_font_t *scaled_font = CairoScaledFont(); - cairo_font_options_t *options = cairo_font_options_create(); - cairo_scaled_font_get_font_options(scaled_font, options); - cairo_hint_style_t hint_style = cairo_font_options_get_hint_style(options); - cairo_font_options_destroy(options); - - mozilla::gfx::FontHinting hinting; - - switch (hint_style) { - case CAIRO_HINT_STYLE_NONE: - hinting = mozilla::gfx::FONT_HINTING_NONE; - break; - case CAIRO_HINT_STYLE_SLIGHT: - hinting = mozilla::gfx::FONT_HINTING_LIGHT; - break; - case CAIRO_HINT_STYLE_FULL: - hinting = mozilla::gfx::FONT_HINTING_FULL; - break; - default: - hinting = mozilla::gfx::FONT_HINTING_NORMAL; - break; - } - - // We don't want to force the use of the autohinter over the font's built in hints - return mozilla::gfx::Factory::CreateCairoGlyphRenderingOptions(hinting, false); -} -#endif -
--- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -753,18 +753,18 @@ gfxPlatformGtk::GetGdkDrawable(gfxASurfa return NULL; } #endif TemporaryRef<ScaledFont> gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) { NativeFont nativeFont; - - if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) { + if (aTarget->GetType() == BACKEND_CAIRO) { nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE; - nativeFont.mFont = aFont->GetCairoScaledFont(); - return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); + nativeFont.mFont = NULL; + return Factory::CreateScaledFontWithCairo(nativeFont, aFont->GetAdjustedSize(), aFont->GetCairoScaledFont()); } - - return NULL; - + NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_FT2, "Expecting Freetype font"); + nativeFont.mType = NATIVE_FONT_SKIA_FONT_FACE; + nativeFont.mFont = static_cast<gfxFT2FontBase*>(aFont)->GetFontOptions(); + return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); }
--- a/mobile/android/base/tests/testAboutPage.java.in +++ b/mobile/android/base/tests/testAboutPage.java.in @@ -23,39 +23,21 @@ public class testAboutPage extends Pixel Element awesomebar = mDriver.findElement(getActivity(), "awesome_bar_title"); mAsserter.isnot(awesomebar, null, "Got the awesomebar"); assertMatches(awesomebar.getText(), "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)", "page title match"); // Open a new page to remove the about: page from the current tab url = getAbsoluteUrl("/robocop/robocop_blank_01.html"); loadUrl(url); - // Use the menu to open the Settings - mActions.sendSpecialKey(Actions.SpecialKey.MENU); - - // Look for the 'More' menu if this device/OS uses it - if (mSolo.waitForText("^More$")) { - mAsserter.dumpLog("found More item in menu"); - mSolo.clickOnText("^More$"); - } - - if (mSolo.waitForText("^Settings$")) { - mAsserter.dumpLog("found Settings item in menu"); - } - mSolo.clickOnText("^Settings$"); - // Set up listeners to catch the page load we're about to do Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added"); Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); - // Tap on the "About Xxxx" setting - if (mSolo.waitForText("About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)")) { - mAsserter.dumpLog("found About... title text"); - } - mSolo.clickOnText("About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)"); + selectSettingsItem("General", "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)"); // Wait for the new tab and page to load tabEventExpecter.blockForEvent(); contentEventExpecter.blockForEvent(); tabEventExpecter.unregisterListener(); contentEventExpecter.unregisterListener();
--- a/mobile/android/base/tests/testAddSearchEngine.java.in +++ b/mobile/android/base/tests/testAddSearchEngine.java.in @@ -46,18 +46,17 @@ public class testAddSearchEngine extends mAsserter.dumpLog("Something went wrong and the context menu was not opened. Trying again"); mSolo.clickLongOnScreen(width,height); } mAsserter.ok(waitForText("Add Search Engine"), "Waiting for the context menu to be opened", "The context menu was opened"); // Add the search engine mSolo.clickOnText("Add Search Engine"); waitForText("Cancel"); - Device device = new Device(); - if (device.version.equals("4.x")) { + if (mDevice.version.equals("4.x")) { // If the OS is ICS the vkb is opened when the popup is triggered so we need to close it in order to click the OK button mActions.sendSpecialKey(Actions.SpecialKey.BACK); waitForText("OK"); // Make sure the OK button is visible } mSolo.clickOnButton("OK"); mAsserter.ok(!mSolo.searchText("Add Search Engine"), "Adding the search engine", "The add serach engine pop-up has been cloesed"); // Check that the number of search results has increased
--- a/mobile/android/base/tests/testSystemPages.java.in +++ b/mobile/android/base/tests/testSystemPages.java.in @@ -75,21 +75,18 @@ public class testSystemPages extends Pix contentEventExpecter.blockForEvent(); tabEventExpecter.unregisterListener(); contentEventExpecter.unregisterListener(); verifyTabCount(expectedTabCount); verifyUrl(expectedUrls[i]); } else { // Make sure the about: page was loaded without opening a new tab and verify the page Url - selectMenuItem(item); - waitForText("About"); - paintExpecter = mActions.expectPaint(); // Set up listener to catch the page load - mSolo.clickOnText("About"); + selectSettingsItem("General", "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)"); waitForPaint(paintExpecter); // Waiting for the page to load paintExpecter.unregisterListener(); expectedTabCount--; // Decreasing since we don't expect this in a new tab verifyTabCount(expectedTabCount); verifyUrl(expectedUrls[i]); // Since the page is already loaded this should be instantly } }
--- a/mobile/android/base/tests/testTabHistory.java.in +++ b/mobile/android/base/tests/testTabHistory.java.in @@ -21,22 +21,21 @@ public class testTabHistory extends Pixe String url3 = getAbsoluteUrl("/robocop/robocop_blank_03.html"); // Create tab history loadAndPaint(url); loadAndPaint(url2); loadAndPaint(url3); // Get the device information and create the navigation for it - Device device = new Device(); - Navigation nav = new Navigation(device); - mAsserter.dumpLog("device type: "+device.type); - mAsserter.dumpLog("device version: "+device.version); - mAsserter.dumpLog("device width: "+device.width); - mAsserter.dumpLog("device height: "+device.height); + Navigation nav = new Navigation(mDevice); + mAsserter.dumpLog("device type: "+mDevice.type); + mAsserter.dumpLog("device version: "+mDevice.version); + mAsserter.dumpLog("device width: "+mDevice.width); + mAsserter.dumpLog("device height: "+mDevice.height); // Go to the 2nd page nav.back(); waitForText("Browser Blank Page 02"); verifyPageTitle("Browser Blank Page 02"); // Go to the first page nav.back();
--- a/mobile/android/base/tests/testVkbOverlap.java.in +++ b/mobile/android/base/tests/testVkbOverlap.java.in @@ -17,21 +17,20 @@ public class testVkbOverlap extends Pixe private static final int PAGE_SETTLE_TIME = 5000; @Override protected int getTestType() { return TEST_MOCHITEST; } public void testVkbOverlap() { - Device device = new Device(); blockForGeckoReady(); testSetup("initial-scale=1.0, user-scalable=no", false); testSetup("initial-scale=1.0", false); - testSetup("", "phone".equals(device.type)); + testSetup("", "phone".equals(mDevice.type)); } private void testSetup(String viewport, boolean shouldZoom) { loadAndPaint(getAbsoluteUrl("/robocop/test_viewport.sjs?metadata=" + Uri.encode(viewport))); // scroll to the bottom of the page and let it settle Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
--- a/mobile/android/base/tests/testWebContentContextMenu.java.in +++ b/mobile/android/base/tests/testWebContentContextMenu.java.in @@ -102,17 +102,16 @@ public class testWebContentContextMenu e // Verifying if the Share Link option menu is opened mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share Link option menu to open", "The Share Link option menu is opened"); mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Share Link option menu mSolo.waitForText("Big Link"); } else { if (opt.equals("Bookmark Link")) { - Device mDevice = new Device(); Navigation nav = new Navigation(mDevice); accessSection(0, opt, urls); mAsserter.is(mSolo.waitForText("Bookmark added"), true, "Bookmark added verified"); // This waitForIdleSync improves reliability of the following loadUrl. // TODO: understand why! getInstrumentation().waitForIdleSync();
--- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -72,24 +72,27 @@ class TreeMetadataEmitter(object): sub.output_path = os.path.join(sandbox['OBJDIR'], path) sub.relpath = path yield sub # Proxy some variables as-is until we have richer classes to represent # them. We should aim to keep this set small because it violates the # desired abstraction of the build definition away from makefiles. passthru = VariablePassthru(sandbox) - if sandbox['MODULE']: - passthru.variables['MODULE'] = sandbox['MODULE'] - if sandbox['XPIDL_SOURCES']: - passthru.variables['XPIDLSRCS'] = sandbox['XPIDL_SOURCES'] - if sandbox['XPIDL_MODULE']: - passthru.variables['XPIDL_MODULE'] = sandbox['XPIDL_MODULE'] - if sandbox['XPIDL_FLAGS']: - passthru.variables['XPIDL_FLAGS'] = sandbox['XPIDL_FLAGS'] + varmap = dict( + # Makefile.in : moz.build + ASFILES='ASFILES', + MODULE='MODULE', + XPIDL_FLAGS='XPIDL_FLAGS', + XPIDL_MODULE='XPIDL_MODULE', + XPIDLSRCS='XPIDL_SOURCES', + ) + for mak, moz in varmap.items(): + if sandbox[moz]: + passthru.variables[mak] = sandbox[moz] if passthru.variables: yield passthru exports = sandbox.get('EXPORTS') if exports: yield Exports(sandbox, exports)
--- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py +++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py @@ -52,16 +52,22 @@ def doc_to_paragraphs(doc): # This defines the set of mutable global variables. # # Each variable is a tuple of: # # (type, default_value, docs) # VARIABLES = { # Variables controlling reading of other frontend files. + 'ASFILES': (list, [], + """ Assembly file sources. + + This variable contains a list of files to invoke the assembler on. + """), + 'DIRS': (list, [], """Child directories to descend into looking for build frontend files. This works similarly to the DIRS variable in make files. Each str value in the list is the name of a child directory. When this file is done parsing, the build reader will descend into each listed directory and read the frontend file there. If there is no frontend file, an error is raised. @@ -195,17 +201,16 @@ VARIABLES = { 'XPIDL_FLAGS': (list, [], """XPCOM Interface Definition Module Flags. This is a list of extra flags that are passed to the IDL compiler. Typically this is a set of -I flags that denote extra include directories to search for included .idl files. """), -# 'EXPORTS': (HierarchicalStringList, HierarchicalStringList(), 'XPCSHELL_TESTS_MANIFESTS': (list, [], """XPCSHELL Test Manifest list This is a list of xpcshell.ini manifest files. Formerly XPCSHELL_TESTS= """), }
--- a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build +++ b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build @@ -1,7 +1,9 @@ # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- # Any copyright is dedicated to the Public Domain. # http://creativecommons.org/publicdomain/zero/1.0/ XPIDL_SOURCES = ['foo.idl', 'bar.idl', 'biz.idl'] XPIDL_MODULE = 'module_name' XPIDL_FLAGS = ['-Idir1', '-Idir2', '-Idir3'] + +ASFILES = ['foo.asm', 'bar.s']
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -131,27 +131,33 @@ class TestRecursiveMakeBackend(BackendTe ]) def test_variable_passthru(self): """Ensure variable passthru is written out correctly.""" env = self._consume('variable_passthru', RecursiveMakeBackend) backend_path = os.path.join(env.topobjdir, 'backend.mk') lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:-1]] - self.assertEqual(lines[3:6], [ - 'XPIDLSRCS += foo.idl', - 'XPIDLSRCS += bar.idl', - 'XPIDLSRCS += biz.idl', - ]) - self.assertEqual(lines[6:9], [ - 'XPIDL_FLAGS += -Idir1', - 'XPIDL_FLAGS += -Idir2', - 'XPIDL_FLAGS += -Idir3', - ]) - self.assertEqual(lines[9], 'XPIDL_MODULE := module_name') + + expected = { + 'ASFILES': ['ASFILES += foo.asm', 'ASFILES += bar.s'], + 'XPIDL_FLAGS': ['XPIDL_FLAGS += -Idir1', + 'XPIDL_FLAGS += -Idir2', + 'XPIDL_FLAGS += -Idir3', + ], + 'XPIDL_MODULE': ['XPIDL_MODULE := module_name'], + 'XPIDLSRCS': ['XPIDLSRCS += foo.idl', + 'XPIDLSRCS += bar.idl', + 'XPIDLSRCS += biz.idl'] + } + + for var, val in expected.items(): + # print("test_variable_passthru[%s]" % (var)) + found = [str for str in lines if str.startswith(var)] + self.assertEqual(found, val) def test_exports(self): """Ensure EXPORTS is written out correctly.""" env = self._consume('exports', RecursiveMakeBackend) backend_path = os.path.join(env.topobjdir, 'backend.mk') lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:-1]]
--- a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build +++ b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build @@ -1,7 +1,9 @@ # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- # Any copyright is dedicated to the Public Domain. # http://creativecommons.org/publicdomain/zero/1.0/ XPIDL_SOURCES += ['foo.idl', 'bar.idl', 'biz.idl'] XPIDL_MODULE = 'module_name' XPIDL_FLAGS += ['-Idir1', '-Idir2', '-Idir3'] + +ASFILES += ['tans.s', 'fans.asm']
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -119,26 +119,30 @@ class TestEmitterBasic(unittest.TestCase def test_variable_passthru(self): reader = self.reader('variable-passthru') objs = self.read_topsrcdir(reader) self.assertEqual(len(objs), 2) self.assertIsInstance(objs[0], DirectoryTraversal) self.assertIsInstance(objs[1], VariablePassthru) + wanted = dict( + ASFILES=['tans.s', 'fans.asm'], + XPIDLSRCS=['foo.idl', 'bar.idl', 'biz.idl'], + XPIDL_MODULE='module_name', + XPIDL_FLAGS=['-Idir1', '-Idir2', '-Idir3'], + ) + variables = objs[1].variables - self.assertEqual(len(variables), 3) - self.assertIn('XPIDLSRCS', variables) - self.assertEqual(variables['XPIDLSRCS'], - ['foo.idl', 'bar.idl', 'biz.idl']) - self.assertIn('XPIDL_MODULE', variables) - self.assertEqual(variables['XPIDL_MODULE'], 'module_name') - self.assertIn('XPIDL_FLAGS', variables) - self.assertEqual(variables['XPIDL_FLAGS'], - ['-Idir1', '-Idir2', '-Idir3']) + self.assertEqual(len(variables), len(wanted)) + + for var, val in wanted.items(): + # print("test_variable_passthru[%s]" % var) + self.assertIn(var, variables) + self.assertEqual(variables[var], val) def test_exports(self): reader = self.reader('exports') objs = self.read_topsrcdir(reader) self.assertEqual(len(objs), 2) self.assertIsInstance(objs[0], DirectoryTraversal) self.assertIsInstance(objs[1], Exports)