Bug 755869 - Update the patches directory for Skia r=joe

This commit is contained in:
George Wright 2012-05-30 13:53:22 -04:00
parent ee3c9c779a
commit a84669cbf5
26 changed files with 1585 additions and 24 deletions

View File

@ -0,0 +1,66 @@
From 27a914815e757ed12523edf968c9da134dabeaf8 Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:10:44 -0400
Subject: [PATCH 01/10] Bug 755869 - [4] Re-apply bug 687189 - Implement
SkPaint::getPosTextPath r=mattwoodrow
---
gfx/skia/include/core/SkPaint.h | 3 +++
gfx/skia/src/core/SkPaint.cpp | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/gfx/skia/include/core/SkPaint.h b/gfx/skia/include/core/SkPaint.h
index 1930db1..ff37d77 100644
--- a/gfx/skia/include/core/SkPaint.h
+++ b/gfx/skia/include/core/SkPaint.h
@@ -813,6 +813,9 @@ public:
void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y,
SkPath* path) const;
+ void getPosTextPath(const void* text, size_t length,
+ const SkPoint pos[], SkPath* path) const;
+
#ifdef SK_BUILD_FOR_ANDROID
const SkGlyph& getUnicharMetrics(SkUnichar);
const SkGlyph& getGlyphMetrics(uint16_t);
diff --git a/gfx/skia/src/core/SkPaint.cpp b/gfx/skia/src/core/SkPaint.cpp
index 1b74fa1..4c119aa 100644
--- a/gfx/skia/src/core/SkPaint.cpp
+++ b/gfx/skia/src/core/SkPaint.cpp
@@ -1355,6 +1355,33 @@ void SkPaint::getTextPath(const void* textData, size_t length,
}
}
+void SkPaint::getPosTextPath(const void* textData, size_t length,
+ const SkPoint pos[], SkPath* path) const {
+ SkASSERT(length == 0 || textData != NULL);
+
+ const char* text = (const char*)textData;
+ if (text == NULL || length == 0 || path == NULL) {
+ return;
+ }
+
+ SkTextToPathIter iter(text, length, *this, false);
+ SkMatrix matrix;
+ SkPoint prevPos;
+ prevPos.set(0, 0);
+
+ matrix.setScale(iter.getPathScale(), iter.getPathScale());
+ path->reset();
+
+ unsigned int i = 0;
+ const SkPath* iterPath;
+ while ((iterPath = iter.next(NULL)) != NULL) {
+ matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY);
+ path->addPath(*iterPath, matrix);
+ prevPos = pos[i];
+ i++;
+ }
+}
+
static void add_flattenable(SkDescriptor* desc, uint32_t tag,
SkFlattenableWriteBuffer* buffer) {
buffer->flatten(desc->addEntry(tag, buffer->size(), NULL));
--
1.7.5.4

View File

@ -0,0 +1,30 @@
From f310d7e8b8d9cf6870c739650324bb585b591c0c Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:11:32 -0400
Subject: [PATCH 02/10] Bug 755869 - [5] Re-apply bug 688366 - Fix Skia
marking radial gradients with the same radius as
invalid. r=mattwoodrow
---
gfx/skia/src/effects/SkGradientShader.cpp | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/gfx/skia/src/effects/SkGradientShader.cpp b/gfx/skia/src/effects/SkGradientShader.cpp
index 6de820b..59ba48c 100644
--- a/gfx/skia/src/effects/SkGradientShader.cpp
+++ b/gfx/skia/src/effects/SkGradientShader.cpp
@@ -1911,7 +1911,10 @@ public:
SkPMColor* SK_RESTRICT dstC = dstCParam;
// Zero difference between radii: fill with transparent black.
- if (fDiffRadius == 0) {
+ // TODO: Is removing this actually correct? Two circles with the
+ // same radius, but different centers doesn't sound like it
+ // should be cleared
+ if (fDiffRadius == 0 && fCenter1 == fCenter2) {
sk_bzero(dstC, count * sizeof(*dstC));
return;
}
--
1.7.5.4

View File

@ -0,0 +1,39 @@
From ef53776c06cffc7607c3777702f93e04c0852981 Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:13:49 -0400
Subject: [PATCH 03/10] Bug 755869 - [6] Re-apply SkUserConfig (no
original bug) r=mattwoodrow
---
gfx/skia/include/config/SkUserConfig.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/gfx/skia/include/config/SkUserConfig.h b/gfx/skia/include/config/SkUserConfig.h
index 9fdbd0a..f98ba85 100644
--- a/gfx/skia/include/config/SkUserConfig.h
+++ b/gfx/skia/include/config/SkUserConfig.h
@@ -156,6 +156,10 @@
//#define SK_SUPPORT_UNITTEST
#endif
+/* Don't dither 32bit gradients, to match what the canvas test suite expects.
+ */
+#define SK_DISABLE_DITHER_32BIT_GRADIENT
+
/* If your system embeds skia and has complex event logging, define this
symbol to name a file that maps the following macros to your system's
equivalents:
@@ -177,4 +181,10 @@
#define SK_A32_SHIFT 24
#endif
+/* Don't include stdint.h on windows as it conflicts with our build system.
+ */
+#ifdef SK_BUILD_FOR_WIN32
+ #define SK_IGNORE_STDINT_DOT_H
+#endif
+
#endif
--
1.7.5.4

View File

@ -0,0 +1,280 @@
From 81d61682a94d47be5b47fb7882ea7e7c7e6c3351 Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:15:28 -0400
Subject: [PATCH 04/10] Bug 755869 - [7] Re-apply bug 722011 - Fix
trailing commas at end of enum lists r=mattwoodrow
---
gfx/skia/include/core/SkAdvancedTypefaceMetrics.h | 8 ++++----
gfx/skia/include/core/SkBlitRow.h | 2 +-
gfx/skia/include/core/SkCanvas.h | 2 +-
gfx/skia/include/core/SkDevice.h | 2 +-
gfx/skia/include/core/SkDeviceProfile.h | 4 ++--
gfx/skia/include/core/SkFlattenable.h | 2 +-
gfx/skia/include/core/SkFontHost.h | 4 ++--
gfx/skia/include/core/SkMaskFilter.h | 2 +-
gfx/skia/include/core/SkPaint.h | 4 ++--
gfx/skia/include/core/SkScalerContext.h | 9 +++++----
gfx/skia/include/core/SkTypes.h | 2 +-
gfx/skia/include/effects/SkLayerDrawLooper.h | 2 +-
gfx/skia/src/core/SkBitmap.cpp | 2 +-
gfx/skia/src/core/SkGlyphCache.cpp | 2 +-
14 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/gfx/skia/include/core/SkAdvancedTypefaceMetrics.h b/gfx/skia/include/core/SkAdvancedTypefaceMetrics.h
index 09fc9a9..5ffdb45 100644
--- a/gfx/skia/include/core/SkAdvancedTypefaceMetrics.h
+++ b/gfx/skia/include/core/SkAdvancedTypefaceMetrics.h
@@ -34,7 +34,7 @@ public:
kCFF_Font,
kTrueType_Font,
kOther_Font,
- kNotEmbeddable_Font,
+ kNotEmbeddable_Font
};
// The type of the underlying font program. This field determines which
// of the following fields are valid. If it is kOther_Font or
@@ -56,7 +56,7 @@ public:
kItalic_Style = 0x00040,
kAllCaps_Style = 0x10000,
kSmallCaps_Style = 0x20000,
- kForceBold_Style = 0x40000,
+ kForceBold_Style = 0x40000
};
uint16_t fStyle; // Font style characteristics.
int16_t fItalicAngle; // Counterclockwise degrees from vertical of the
@@ -75,7 +75,7 @@ public:
kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data.
kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data.
kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only).
- kToUnicode_PerGlyphInfo = 0x8, // Populate ToUnicode table, ignored
+ kToUnicode_PerGlyphInfo = 0x8 // Populate ToUnicode table, ignored
// for Type 1 fonts
};
@@ -84,7 +84,7 @@ public:
enum MetricType {
kDefault, // Default advance: fAdvance.count = 1
kRange, // Advances for a range: fAdvance.count = fEndID-fStartID
- kRun, // fStartID-fEndID have same advance: fAdvance.count = 1
+ kRun // fStartID-fEndID have same advance: fAdvance.count = 1
};
MetricType fType;
uint16_t fStartId;
diff --git a/gfx/skia/include/core/SkBlitRow.h b/gfx/skia/include/core/SkBlitRow.h
index 973ab4c..febc405 100644
--- a/gfx/skia/include/core/SkBlitRow.h
+++ b/gfx/skia/include/core/SkBlitRow.h
@@ -42,7 +42,7 @@ public:
enum Flags32 {
kGlobalAlpha_Flag32 = 1 << 0,
- kSrcPixelAlpha_Flag32 = 1 << 1,
+ kSrcPixelAlpha_Flag32 = 1 << 1
};
/** Function pointer that blends 32bit colors onto a 32bit destination.
diff --git a/gfx/skia/include/core/SkCanvas.h b/gfx/skia/include/core/SkCanvas.h
index 25cc94a..d942783 100644
--- a/gfx/skia/include/core/SkCanvas.h
+++ b/gfx/skia/include/core/SkCanvas.h
@@ -148,7 +148,7 @@ public:
* low byte to high byte: R, G, B, A.
*/
kRGBA_Premul_Config8888,
- kRGBA_Unpremul_Config8888,
+ kRGBA_Unpremul_Config8888
};
/**
diff --git a/gfx/skia/include/core/SkDevice.h b/gfx/skia/include/core/SkDevice.h
index 1e4e0a3..b4d44bf 100644
--- a/gfx/skia/include/core/SkDevice.h
+++ b/gfx/skia/include/core/SkDevice.h
@@ -139,7 +139,7 @@ public:
protected:
enum Usage {
kGeneral_Usage,
- kSaveLayer_Usage, // <! internal use only
+ kSaveLayer_Usage // <! internal use only
};
struct TextFlags {
diff --git a/gfx/skia/include/core/SkDeviceProfile.h b/gfx/skia/include/core/SkDeviceProfile.h
index 46b9781..f6a0bca 100644
--- a/gfx/skia/include/core/SkDeviceProfile.h
+++ b/gfx/skia/include/core/SkDeviceProfile.h
@@ -17,7 +17,7 @@ public:
kRGB_Horizontal_LCDConfig,
kBGR_Horizontal_LCDConfig,
kRGB_Vertical_LCDConfig,
- kBGR_Vertical_LCDConfig,
+ kBGR_Vertical_LCDConfig
};
enum FontHintLevel {
@@ -25,7 +25,7 @@ public:
kSlight_FontHintLevel,
kNormal_FontHintLevel,
kFull_FontHintLevel,
- kAuto_FontHintLevel,
+ kAuto_FontHintLevel
};
/**
diff --git a/gfx/skia/include/core/SkFlattenable.h b/gfx/skia/include/core/SkFlattenable.h
index 5714f9d..dc115fc 100644
--- a/gfx/skia/include/core/SkFlattenable.h
+++ b/gfx/skia/include/core/SkFlattenable.h
@@ -272,7 +272,7 @@ public:
* Instructs the writer to inline Factory names as there are seen the
* first time (after that we store an index). The pipe code uses this.
*/
- kInlineFactoryNames_Flag = 0x02,
+ kInlineFactoryNames_Flag = 0x02
};
Flags getFlags() const { return (Flags)fFlags; }
void setFlags(Flags flags) { fFlags = flags; }
diff --git a/gfx/skia/include/core/SkFontHost.h b/gfx/skia/include/core/SkFontHost.h
index 732de5c..10f9bdf 100644
--- a/gfx/skia/include/core/SkFontHost.h
+++ b/gfx/skia/include/core/SkFontHost.h
@@ -240,7 +240,7 @@ public:
*/
enum LCDOrientation {
kHorizontal_LCDOrientation = 0, //!< this is the default
- kVertical_LCDOrientation = 1,
+ kVertical_LCDOrientation = 1
};
static void SetSubpixelOrientation(LCDOrientation orientation);
@@ -259,7 +259,7 @@ public:
enum LCDOrder {
kRGB_LCDOrder = 0, //!< this is the default
kBGR_LCDOrder = 1,
- kNONE_LCDOrder = 2,
+ kNONE_LCDOrder = 2
};
static void SetSubpixelOrder(LCDOrder order);
diff --git a/gfx/skia/include/core/SkMaskFilter.h b/gfx/skia/include/core/SkMaskFilter.h
index 9a470a4..3422e27 100644
--- a/gfx/skia/include/core/SkMaskFilter.h
+++ b/gfx/skia/include/core/SkMaskFilter.h
@@ -61,7 +61,7 @@ public:
kNormal_BlurType, //!< fuzzy inside and outside
kSolid_BlurType, //!< solid inside, fuzzy outside
kOuter_BlurType, //!< nothing inside, fuzzy outside
- kInner_BlurType, //!< fuzzy inside, nothing outside
+ kInner_BlurType //!< fuzzy inside, nothing outside
};
struct BlurInfo {
diff --git a/gfx/skia/include/core/SkPaint.h b/gfx/skia/include/core/SkPaint.h
index ff37d77..7c96e193 100644
--- a/gfx/skia/include/core/SkPaint.h
+++ b/gfx/skia/include/core/SkPaint.h
@@ -76,7 +76,7 @@ public:
kNo_Hinting = 0,
kSlight_Hinting = 1,
kNormal_Hinting = 2, //!< this is the default
- kFull_Hinting = 3,
+ kFull_Hinting = 3
};
Hinting getHinting() const {
@@ -289,7 +289,7 @@ public:
kStroke_Style, //!< stroke the geometry
kStrokeAndFill_Style, //!< fill and stroke the geometry
- kStyleCount,
+ kStyleCount
};
/** Return the paint's style, used for controlling how primitives'
diff --git a/gfx/skia/include/core/SkScalerContext.h b/gfx/skia/include/core/SkScalerContext.h
index 2cb171b..3dbce27 100644
--- a/gfx/skia/include/core/SkScalerContext.h
+++ b/gfx/skia/include/core/SkScalerContext.h
@@ -182,21 +182,22 @@ public:
kGenA8FromLCD_Flag = 0x0800,
#ifdef SK_USE_COLOR_LUMINANCE
- kLuminance_Bits = 3,
+ kLuminance_Bits = 3
#else
// luminance : 0 for black text, kLuminance_Max for white text
kLuminance_Shift = 13, // shift to land in the high 3-bits of Flags
- kLuminance_Bits = 3, // ensure Flags doesn't exceed 16bits
+ kLuminance_Bits = 3 // ensure Flags doesn't exceed 16bits
#endif
};
// computed values
enum {
- kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
#ifdef SK_USE_COLOR_LUMINANCE
+ kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag
#else
+ kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
kLuminance_Max = (1 << kLuminance_Bits) - 1,
- kLuminance_Mask = kLuminance_Max << kLuminance_Shift,
+ kLuminance_Mask = kLuminance_Max << kLuminance_Shift
#endif
};
diff --git a/gfx/skia/include/core/SkTypes.h b/gfx/skia/include/core/SkTypes.h
index 7963a7d..0c5c2d7 100644
--- a/gfx/skia/include/core/SkTypes.h
+++ b/gfx/skia/include/core/SkTypes.h
@@ -438,7 +438,7 @@ public:
* current block is dynamically allocated, just return the old
* block.
*/
- kReuse_OnShrink,
+ kReuse_OnShrink
};
/**
diff --git a/gfx/skia/include/effects/SkLayerDrawLooper.h b/gfx/skia/include/effects/SkLayerDrawLooper.h
index 0bc4af2..6cb8ef6 100644
--- a/gfx/skia/include/effects/SkLayerDrawLooper.h
+++ b/gfx/skia/include/effects/SkLayerDrawLooper.h
@@ -41,7 +41,7 @@ public:
* - Flags and Color are always computed using the LayerInfo's
* fFlagsMask and fColorMode.
*/
- kEntirePaint_Bits = -1,
+ kEntirePaint_Bits = -1
};
typedef int32_t BitFlags;
diff --git a/gfx/skia/src/core/SkBitmap.cpp b/gfx/skia/src/core/SkBitmap.cpp
index 6b99145..aff52fd 100644
--- a/gfx/skia/src/core/SkBitmap.cpp
+++ b/gfx/skia/src/core/SkBitmap.cpp
@@ -1376,7 +1376,7 @@ enum {
SERIALIZE_PIXELTYPE_RAW_WITH_CTABLE,
SERIALIZE_PIXELTYPE_RAW_NO_CTABLE,
SERIALIZE_PIXELTYPE_REF_DATA,
- SERIALIZE_PIXELTYPE_REF_PTR,
+ SERIALIZE_PIXELTYPE_REF_PTR
};
/*
diff --git a/gfx/skia/src/core/SkGlyphCache.cpp b/gfx/skia/src/core/SkGlyphCache.cpp
index f3363cd..1fddc9d 100644
--- a/gfx/skia/src/core/SkGlyphCache.cpp
+++ b/gfx/skia/src/core/SkGlyphCache.cpp
@@ -417,7 +417,7 @@ class SkGlyphCache_Globals {
public:
enum UseMutex {
kNo_UseMutex, // thread-local cache
- kYes_UseMutex, // shared cache
+ kYes_UseMutex // shared cache
};
SkGlyphCache_Globals(UseMutex um) {
--
1.7.5.4

View File

@ -0,0 +1,36 @@
From 80350275c72921ed5ac405c029ae33727467d7c5 Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:15:50 -0400
Subject: [PATCH 05/10] Bug 755869 - [8] Re-apply bug 731384 - Fix compile
errors on older versions of clang r=mattwoodrow
---
gfx/skia/include/core/SkPostConfig.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/gfx/skia/include/core/SkPostConfig.h b/gfx/skia/include/core/SkPostConfig.h
index 8316f7a..041fe2a 100644
--- a/gfx/skia/include/core/SkPostConfig.h
+++ b/gfx/skia/include/core/SkPostConfig.h
@@ -288,9 +288,18 @@
#if defined(_MSC_VER)
#define SK_OVERRIDE override
#elif defined(__clang__)
+#if __has_feature(cxx_override_control)
// Some documentation suggests we should be using __attribute__((override)),
// but it doesn't work.
#define SK_OVERRIDE override
+#elif defined(__has_extension)
+#if __has_extension(cxx_override_control)
+#define SK_OVERRIDE override
+#endif
+#endif
+#ifndef SK_OVERRIDE
+#define SK_OVERRIDE
+#endif
#else
// Linux GCC ignores "__attribute__((override))" and rejects "override".
#define SK_OVERRIDE
--
1.7.5.4

View File

@ -0,0 +1,147 @@
From 94916fbbc7865c6fe23a57d6edc48c6daf93dda8 Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:16:08 -0400
Subject: [PATCH 06/10] Bug 755869 - [9] Re-apply bug 751814 - Various
Skia fixes for ARM without EDSP and ARMv6+
r=mattwoodrow
---
gfx/skia/include/core/SkMath.h | 5 +--
gfx/skia/include/core/SkPostConfig.h | 45 ++++++++++++++++++++++
gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp | 6 +-
gfx/skia/src/opts/SkBlitRow_opts_arm.cpp | 9 ++++
4 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/gfx/skia/include/core/SkMath.h b/gfx/skia/include/core/SkMath.h
index 5889103..7a4b707 100644
--- a/gfx/skia/include/core/SkMath.h
+++ b/gfx/skia/include/core/SkMath.h
@@ -153,10 +153,7 @@ static inline bool SkIsPow2(int value) {
With this requirement, we can generate faster instructions on some
architectures.
*/
-#if defined(__arm__) \
- && !defined(__thumb__) \
- && !defined(__ARM_ARCH_4T__) \
- && !defined(__ARM_ARCH_5T__)
+#ifdef SK_ARM_HAS_EDSP
static inline int32_t SkMulS16(S16CPU x, S16CPU y) {
SkASSERT((int16_t)x == x);
SkASSERT((int16_t)y == y);
diff --git a/gfx/skia/include/core/SkPostConfig.h b/gfx/skia/include/core/SkPostConfig.h
index 041fe2a..03105e4 100644
--- a/gfx/skia/include/core/SkPostConfig.h
+++ b/gfx/skia/include/core/SkPostConfig.h
@@ -311,3 +311,48 @@
#ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
#endif
+
+//////////////////////////////////////////////////////////////////////
+// ARM defines
+
+#if defined(__GNUC__) && defined(__arm__)
+
+# define SK_ARM_ARCH 3
+
+# if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) \
+ || defined(_ARM_ARCH_4)
+# undef SK_ARM_ARCH
+# define SK_ARM_ARCH 4
+# endif
+
+# if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
+ || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
+ || defined(__ARM_ARCH_5TEJ__) || defined(_ARM_ARCH_5)
+# undef SK_ARM_ARCH
+# define SK_ARM_ARCH 5
+# endif
+
+# if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
+ || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
+ || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
+ || defined(__ARM_ARCH_6M__) || defined(_ARM_ARCH_6)
+# undef SK_ARM_ARCH
+# define SK_ARM_ARCH 6
+# endif
+
+# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
+ || defined(__ARM_ARCH_7EM__) || defined(_ARM_ARCH_7)
+# undef SK_ARM_ARCH
+# define SK_ARM_ARCH 7
+# endif
+
+# undef SK_ARM_HAS_EDSP
+# if defined(__thumb2__) && (SK_ARM_ARCH >= 6) \
+ || !defined(__thumb__) \
+ && ((SK_ARM_ARCH > 5) || defined(__ARM_ARCH_5E__) \
+ || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__))
+# define SK_ARM_HAS_EDSP 1
+# endif
+
+#endif
diff --git a/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp b/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
index 20d62e1..deb1bfe 100644
--- a/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
+++ b/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
@@ -11,7 +11,7 @@
#include "SkColorPriv.h"
#include "SkUtils.h"
-#if __ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
+#if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
void SI8_D16_nofilter_DX_arm(
const SkBitmapProcState& s,
const uint32_t* SK_RESTRICT xy,
@@ -182,7 +182,7 @@ void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s,
s.fBitmap->getColorTable()->unlockColors(false);
}
-#endif //__ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
+#endif // SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
///////////////////////////////////////////////////////////////////////////////
@@ -200,7 +200,7 @@ void SkBitmapProcState::platformProcs() {
switch (fBitmap->config()) {
case SkBitmap::kIndex8_Config:
-#if __ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
+#if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
if (justDx && !doFilter) {
#if 0 /* crashing on android device */
fSampleProc16 = SI8_D16_nofilter_DX_arm;
diff --git a/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp b/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
index 2490371..c928888 100644
--- a/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
+++ b/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
@@ -675,8 +675,13 @@ static void __attribute((noinline,optimize("-fomit-frame-pointer"))) S32A_Blend_
/* dst1_scale and dst2_scale*/
"lsr r9, r5, #24 \n\t" /* src >> 24 */
"lsr r10, r6, #24 \n\t" /* src >> 24 */
+#ifdef SK_ARM_HAS_EDSP
"smulbb r9, r9, %[alpha] \n\t" /* r9 = SkMulS16 r9 with src_scale */
"smulbb r10, r10, %[alpha] \n\t" /* r10 = SkMulS16 r10 with src_scale */
+#else
+ "mul r9, r9, %[alpha] \n\t" /* r9 = SkMulS16 r9 with src_scale */
+ "mul r10, r10, %[alpha] \n\t" /* r10 = SkMulS16 r10 with src_scale */
+#endif
"lsr r9, r9, #8 \n\t" /* r9 >> 8 */
"lsr r10, r10, #8 \n\t" /* r10 >> 8 */
"rsb r9, r9, #256 \n\t" /* dst1_scale = r9 = 255 - r9 + 1 */
@@ -745,7 +750,11 @@ static void __attribute((noinline,optimize("-fomit-frame-pointer"))) S32A_Blend_
"lsr r6, r5, #24 \n\t" /* src >> 24 */
"and r8, r12, r5, lsr #8 \n\t" /* ag = r8 = r5 masked by r12 lsr by #8 */
+#ifdef SK_ARM_HAS_EDSP
"smulbb r6, r6, %[alpha] \n\t" /* r6 = SkMulS16 with src_scale */
+#else
+ "mul r6, r6, %[alpha] \n\t" /* r6 = SkMulS16 with src_scale */
+#endif
"and r9, r12, r5 \n\t" /* rb = r9 = r5 masked by r12 */
"lsr r6, r6, #8 \n\t" /* r6 >> 8 */
"mul r8, r8, %[alpha] \n\t" /* ag = r8 times scale */
--
1.7.5.4

View File

@ -0,0 +1,702 @@
From 6982ad469adcdfa2b7bdbf8bbd843bc22d3832fc Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Fri, 18 May 2012 14:52:40 -0400
Subject: [PATCH 07/10] Bug 755869 - [10] Re-apply bug 719872 - Fix crash
on Android by reverting to older FontHost impl
r=mattwoodrow
---
gfx/skia/Makefile.in | 5 +-
gfx/skia/src/ports/SkFontHost_android_old.cpp | 664 +++++++++++++++++++++++++
2 files changed, 668 insertions(+), 1 deletions(-)
create mode 100644 gfx/skia/src/ports/SkFontHost_android_old.cpp
diff --git a/gfx/skia/Makefile.in b/gfx/skia/Makefile.in
index 9da098a..8184f1c 100644
--- a/gfx/skia/Makefile.in
+++ b/gfx/skia/Makefile.in
@@ -327,7 +327,10 @@ endif
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += \
SkDebug_android.cpp \
- SkFontHost_none.cpp \
+ SkFontHost_android_old.cpp \
+ SkFontHost_gamma.cpp \
+ SkFontHost_FreeType.cpp \
+ SkFontHost_tables.cpp \
SkMMapStream.cpp \
SkTime_Unix.cpp \
SkThread_pthread.cpp \
diff --git a/gfx/skia/src/ports/SkFontHost_android_old.cpp b/gfx/skia/src/ports/SkFontHost_android_old.cpp
new file mode 100644
index 0000000..b5c4f3c
--- /dev/null
+++ b/gfx/skia/src/ports/SkFontHost_android_old.cpp
@@ -0,0 +1,664 @@
+
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#include "SkFontHost.h"
+#include "SkDescriptor.h"
+#include "SkMMapStream.h"
+#include "SkPaint.h"
+#include "SkString.h"
+#include "SkStream.h"
+#include "SkThread.h"
+#include "SkTSearch.h"
+#include <stdio.h>
+
+#define FONT_CACHE_MEMORY_BUDGET (768 * 1024)
+
+#ifndef SK_FONT_FILE_PREFIX
+ #define SK_FONT_FILE_PREFIX "/fonts/"
+#endif
+
+bool find_name_and_attributes(SkStream* stream, SkString* name, SkTypeface::Style* style,
+ bool* isFixedWidth);
+
+static void GetFullPathForSysFonts(SkString* full, const char name[]) {
+ full->set(getenv("ANDROID_ROOT"));
+ full->append(SK_FONT_FILE_PREFIX);
+ full->append(name);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+struct FamilyRec;
+
+/* This guy holds a mapping of a name -> family, used for looking up fonts.
+ Since it is stored in a stretchy array that doesn't preserve object
+ semantics, we don't use constructor/destructors, but just have explicit
+ helpers to manage our internal bookkeeping.
+*/
+struct NameFamilyPair {
+ const char* fName; // we own this
+ FamilyRec* fFamily; // we don't own this, we just reference it
+
+ void construct(const char name[], FamilyRec* family) {
+ fName = strdup(name);
+ fFamily = family; // we don't own this, so just record the referene
+ }
+
+ void destruct() {
+ free((char*)fName);
+ // we don't own family, so just ignore our reference
+ }
+};
+
+// we use atomic_inc to grow this for each typeface we create
+static int32_t gUniqueFontID;
+
+// this is the mutex that protects these globals
+static SkMutex gFamilyMutex;
+static FamilyRec* gFamilyHead;
+static SkTDArray<NameFamilyPair> gNameList;
+
+struct FamilyRec {
+ FamilyRec* fNext;
+ SkTypeface* fFaces[4];
+
+ FamilyRec()
+ {
+ fNext = gFamilyHead;
+ memset(fFaces, 0, sizeof(fFaces));
+ gFamilyHead = this;
+ }
+};
+
+static SkTypeface* find_best_face(const FamilyRec* family,
+ SkTypeface::Style style) {
+ SkTypeface* const* faces = family->fFaces;
+
+ if (faces[style] != NULL) { // exact match
+ return faces[style];
+ }
+ // look for a matching bold
+ style = (SkTypeface::Style)(style ^ SkTypeface::kItalic);
+ if (faces[style] != NULL) {
+ return faces[style];
+ }
+ // look for the plain
+ if (faces[SkTypeface::kNormal] != NULL) {
+ return faces[SkTypeface::kNormal];
+ }
+ // look for anything
+ for (int i = 0; i < 4; i++) {
+ if (faces[i] != NULL) {
+ return faces[i];
+ }
+ }
+ // should never get here, since the faces list should not be empty
+ SkASSERT(!"faces list is empty");
+ return NULL;
+}
+
+static FamilyRec* find_family(const SkTypeface* member) {
+ FamilyRec* curr = gFamilyHead;
+ while (curr != NULL) {
+ for (int i = 0; i < 4; i++) {
+ if (curr->fFaces[i] == member) {
+ return curr;
+ }
+ }
+ curr = curr->fNext;
+ }
+ return NULL;
+}
+
+/* Returns the matching typeface, or NULL. If a typeface is found, its refcnt
+ is not modified.
+ */
+static SkTypeface* find_from_uniqueID(uint32_t uniqueID) {
+ FamilyRec* curr = gFamilyHead;
+ while (curr != NULL) {
+ for (int i = 0; i < 4; i++) {
+ SkTypeface* face = curr->fFaces[i];
+ if (face != NULL && face->uniqueID() == uniqueID) {
+ return face;
+ }
+ }
+ curr = curr->fNext;
+ }
+ return NULL;
+}
+
+/* Remove reference to this face from its family. If the resulting family
+ is empty (has no faces), return that family, otherwise return NULL
+*/
+static FamilyRec* remove_from_family(const SkTypeface* face) {
+ FamilyRec* family = find_family(face);
+ SkASSERT(family->fFaces[face->style()] == face);
+ family->fFaces[face->style()] = NULL;
+
+ for (int i = 0; i < 4; i++) {
+ if (family->fFaces[i] != NULL) { // family is non-empty
+ return NULL;
+ }
+ }
+ return family; // return the empty family
+}
+
+// maybe we should make FamilyRec be doubly-linked
+static void detach_and_delete_family(FamilyRec* family) {
+ FamilyRec* curr = gFamilyHead;
+ FamilyRec* prev = NULL;
+
+ while (curr != NULL) {
+ FamilyRec* next = curr->fNext;
+ if (curr == family) {
+ if (prev == NULL) {
+ gFamilyHead = next;
+ } else {
+ prev->fNext = next;
+ }
+ SkDELETE(family);
+ return;
+ }
+ prev = curr;
+ curr = next;
+ }
+ SkASSERT(!"Yikes, couldn't find family in our list to remove/delete");
+}
+
+static SkTypeface* find_typeface(const char name[], SkTypeface::Style style) {
+ NameFamilyPair* list = gNameList.begin();
+ int count = gNameList.count();
+
+ int index = SkStrLCSearch(&list[0].fName, count, name, sizeof(list[0]));
+
+ if (index >= 0) {
+ return find_best_face(list[index].fFamily, style);
+ }
+ return NULL;
+}
+
+static SkTypeface* find_typeface(const SkTypeface* familyMember,
+ SkTypeface::Style style) {
+ const FamilyRec* family = find_family(familyMember);
+ return family ? find_best_face(family, style) : NULL;
+}
+
+static void add_name(const char name[], FamilyRec* family) {
+ SkAutoAsciiToLC tolc(name);
+ name = tolc.lc();
+
+ NameFamilyPair* list = gNameList.begin();
+ int count = gNameList.count();
+
+ int index = SkStrLCSearch(&list[0].fName, count, name, sizeof(list[0]));
+
+ if (index < 0) {
+ list = gNameList.insert(~index);
+ list->construct(name, family);
+ }
+}
+
+static void remove_from_names(FamilyRec* emptyFamily)
+{
+#ifdef SK_DEBUG
+ for (int i = 0; i < 4; i++) {
+ SkASSERT(emptyFamily->fFaces[i] == NULL);
+ }
+#endif
+
+ SkTDArray<NameFamilyPair>& list = gNameList;
+
+ // must go backwards when removing
+ for (int i = list.count() - 1; i >= 0; --i) {
+ NameFamilyPair* pair = &list[i];
+ if (pair->fFamily == emptyFamily) {
+ pair->destruct();
+ list.remove(i);
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+class FamilyTypeface : public SkTypeface {
+public:
+ FamilyTypeface(Style style, bool sysFont, SkTypeface* familyMember,
+ bool isFixedWidth)
+ : SkTypeface(style, sk_atomic_inc(&gUniqueFontID) + 1, isFixedWidth) {
+ fIsSysFont = sysFont;
+
+ SkAutoMutexAcquire ac(gFamilyMutex);
+
+ FamilyRec* rec = NULL;
+ if (familyMember) {
+ rec = find_family(familyMember);
+ SkASSERT(rec);
+ } else {
+ rec = SkNEW(FamilyRec);
+ }
+ rec->fFaces[style] = this;
+ }
+
+ virtual ~FamilyTypeface() {
+ SkAutoMutexAcquire ac(gFamilyMutex);
+
+ // remove us from our family. If the family is now empty, we return
+ // that and then remove that family from the name list
+ FamilyRec* family = remove_from_family(this);
+ if (NULL != family) {
+ remove_from_names(family);
+ detach_and_delete_family(family);
+ }
+ }
+
+ bool isSysFont() const { return fIsSysFont; }
+
+ virtual SkStream* openStream() = 0;
+ virtual const char* getUniqueString() const = 0;
+ virtual const char* getFilePath() const = 0;
+
+private:
+ bool fIsSysFont;
+
+ typedef SkTypeface INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+class StreamTypeface : public FamilyTypeface {
+public:
+ StreamTypeface(Style style, bool sysFont, SkTypeface* familyMember,
+ SkStream* stream, bool isFixedWidth)
+ : INHERITED(style, sysFont, familyMember, isFixedWidth) {
+ SkASSERT(stream);
+ stream->ref();
+ fStream = stream;
+ }
+ virtual ~StreamTypeface() {
+ fStream->unref();
+ }
+
+ // overrides
+ virtual SkStream* openStream() {
+ // we just ref our existing stream, since the caller will call unref()
+ // when they are through
+ fStream->ref();
+ // must rewind each time, since the caller assumes a "new" stream
+ fStream->rewind();
+ return fStream;
+ }
+ virtual const char* getUniqueString() const { return NULL; }
+ virtual const char* getFilePath() const { return NULL; }
+
+private:
+ SkStream* fStream;
+
+ typedef FamilyTypeface INHERITED;
+};
+
+class FileTypeface : public FamilyTypeface {
+public:
+ FileTypeface(Style style, bool sysFont, SkTypeface* familyMember,
+ const char path[], bool isFixedWidth)
+ : INHERITED(style, sysFont, familyMember, isFixedWidth) {
+ SkString fullpath;
+
+ if (sysFont) {
+ GetFullPathForSysFonts(&fullpath, path);
+ path = fullpath.c_str();
+ }
+ fPath.set(path);
+ }
+
+ // overrides
+ virtual SkStream* openStream() {
+ SkStream* stream = SkNEW_ARGS(SkMMAPStream, (fPath.c_str()));
+
+ // check for failure
+ if (stream->getLength() <= 0) {
+ SkDELETE(stream);
+ // maybe MMAP isn't supported. try FILE
+ stream = SkNEW_ARGS(SkFILEStream, (fPath.c_str()));
+ if (stream->getLength() <= 0) {
+ SkDELETE(stream);
+ stream = NULL;
+ }
+ }
+ return stream;
+ }
+ virtual const char* getUniqueString() const {
+ const char* str = strrchr(fPath.c_str(), '/');
+ if (str) {
+ str += 1; // skip the '/'
+ }
+ return str;
+ }
+ virtual const char* getFilePath() const {
+ return fPath.c_str();
+ }
+
+private:
+ SkString fPath;
+
+ typedef FamilyTypeface INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+static bool get_name_and_style(const char path[], SkString* name,
+ SkTypeface::Style* style,
+ bool* isFixedWidth, bool isExpected) {
+ SkString fullpath;
+ GetFullPathForSysFonts(&fullpath, path);
+
+ SkMMAPStream stream(fullpath.c_str());
+ if (stream.getLength() > 0) {
+ find_name_and_attributes(&stream, name, style, isFixedWidth);
+ return true;
+ }
+ else {
+ SkFILEStream stream(fullpath.c_str());
+ if (stream.getLength() > 0) {
+ find_name_and_attributes(&stream, name, style, isFixedWidth);
+ return true;
+ }
+ }
+
+ if (isExpected) {
+ SkDebugf("---- failed to open <%s> as a font\n", fullpath.c_str());
+ }
+ return false;
+}
+
+// used to record our notion of the pre-existing fonts
+struct FontInitRec {
+ const char* fFileName;
+ const char* const* fNames; // null-terminated list
+};
+
+static const char* gSansNames[] = {
+ "sans-serif", "arial", "helvetica", "tahoma", "verdana", NULL
+};
+
+static const char* gSerifNames[] = {
+ "serif", "times", "times new roman", "palatino", "georgia", "baskerville",
+ "goudy", "fantasy", "cursive", "ITC Stone Serif", NULL
+};
+
+static const char* gMonoNames[] = {
+ "monospace", "courier", "courier new", "monaco", NULL
+};
+
+// deliberately empty, but we use the address to identify fallback fonts
+static const char* gFBNames[] = { NULL };
+
+/* Fonts must be grouped by family, with the first font in a family having the
+ list of names (even if that list is empty), and the following members having
+ null for the list. The names list must be NULL-terminated
+*/
+static const FontInitRec gSystemFonts[] = {
+ { "DroidSans.ttf", gSansNames },
+ { "DroidSans-Bold.ttf", NULL },
+ { "DroidSerif-Regular.ttf", gSerifNames },
+ { "DroidSerif-Bold.ttf", NULL },
+ { "DroidSerif-Italic.ttf", NULL },
+ { "DroidSerif-BoldItalic.ttf", NULL },
+ { "DroidSansMono.ttf", gMonoNames },
+ /* These are optional, and can be ignored if not found in the file system.
+ These are appended to gFallbackFonts[] as they are seen, so we list
+ them in the order we want them to be accessed by NextLogicalFont().
+ */
+ { "DroidSansArabic.ttf", gFBNames },
+ { "DroidSansHebrew.ttf", gFBNames },
+ { "DroidSansThai.ttf", gFBNames },
+ { "MTLmr3m.ttf", gFBNames }, // Motoya Japanese Font
+ { "MTLc3m.ttf", gFBNames }, // Motoya Japanese Font
+ { "DroidSansJapanese.ttf", gFBNames },
+ { "DroidSansFallback.ttf", gFBNames }
+};
+
+#define DEFAULT_NAMES gSansNames
+
+// these globals are assigned (once) by load_system_fonts()
+static FamilyRec* gDefaultFamily;
+static SkTypeface* gDefaultNormal;
+
+/* This is sized conservatively, assuming that it will never be a size issue.
+ It will be initialized in load_system_fonts(), and will be filled with the
+ fontIDs that can be used for fallback consideration, in sorted order (sorted
+ meaning element[0] should be used first, then element[1], etc. When we hit
+ a fontID==0 in the array, the list is done, hence our allocation size is
+ +1 the total number of possible system fonts. Also see NextLogicalFont().
+ */
+static uint32_t gFallbackFonts[SK_ARRAY_COUNT(gSystemFonts)+1];
+
+/* Called once (ensured by the sentinel check at the beginning of our body).
+ Initializes all the globals, and register the system fonts.
+ */
+static void load_system_fonts() {
+ // check if we've already be called
+ if (NULL != gDefaultNormal) {
+ return;
+ }
+
+ const FontInitRec* rec = gSystemFonts;
+ SkTypeface* firstInFamily = NULL;
+ int fallbackCount = 0;
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gSystemFonts); i++) {
+ // if we're the first in a new family, clear firstInFamily
+ if (rec[i].fNames != NULL) {
+ firstInFamily = NULL;
+ }
+
+ bool isFixedWidth;
+ SkString name;
+ SkTypeface::Style style;
+
+ // we expect all the fonts, except the "fallback" fonts
+ bool isExpected = (rec[i].fNames != gFBNames);
+ if (!get_name_and_style(rec[i].fFileName, &name, &style,
+ &isFixedWidth, isExpected)) {
+ continue;
+ }
+
+ SkTypeface* tf = SkNEW_ARGS(FileTypeface,
+ (style,
+ true, // system-font (cannot delete)
+ firstInFamily, // what family to join
+ rec[i].fFileName,
+ isFixedWidth) // filename
+ );
+
+ if (rec[i].fNames != NULL) {
+ // see if this is one of our fallback fonts
+ if (rec[i].fNames == gFBNames) {
+ // SkDebugf("---- adding %s as fallback[%d] fontID %d\n",
+ // rec[i].fFileName, fallbackCount, tf->uniqueID());
+ gFallbackFonts[fallbackCount++] = tf->uniqueID();
+ }
+
+ firstInFamily = tf;
+ FamilyRec* family = find_family(tf);
+ const char* const* names = rec[i].fNames;
+
+ // record the default family if this is it
+ if (names == DEFAULT_NAMES) {
+ gDefaultFamily = family;
+ }
+ // add the names to map to this family
+ while (*names) {
+ add_name(*names, family);
+ names += 1;
+ }
+ }
+ }
+
+ // do this after all fonts are loaded. This is our default font, and it
+ // acts as a sentinel so we only execute load_system_fonts() once
+ gDefaultNormal = find_best_face(gDefaultFamily, SkTypeface::kNormal);
+ // now terminate our fallback list with the sentinel value
+ gFallbackFonts[fallbackCount] = 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
+ const char* name = ((FamilyTypeface*)face)->getUniqueString();
+
+ stream->write8((uint8_t)face->style());
+
+ if (NULL == name || 0 == *name) {
+ stream->writePackedUInt(0);
+// SkDebugf("--- fonthost serialize null\n");
+ } else {
+ uint32_t len = strlen(name);
+ stream->writePackedUInt(len);
+ stream->write(name, len);
+// SkDebugf("--- fonthost serialize <%s> %d\n", name, face->style());
+ }
+}
+
+SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
+ load_system_fonts();
+
+ int style = stream->readU8();
+
+ int len = stream->readPackedUInt();
+ if (len > 0) {
+ SkString str;
+ str.resize(len);
+ stream->read(str.writable_str(), len);
+
+ const FontInitRec* rec = gSystemFonts;
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gSystemFonts); i++) {
+ if (strcmp(rec[i].fFileName, str.c_str()) == 0) {
+ // backup until we hit the fNames
+ for (int j = i; j >= 0; --j) {
+ if (rec[j].fNames != NULL) {
+ return SkFontHost::CreateTypeface(NULL,
+ rec[j].fNames[0], (SkTypeface::Style)style);
+ }
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
+ const char familyName[],
+ SkTypeface::Style style) {
+ load_system_fonts();
+
+ SkAutoMutexAcquire ac(gFamilyMutex);
+
+ // clip to legal style bits
+ style = (SkTypeface::Style)(style & SkTypeface::kBoldItalic);
+
+ SkTypeface* tf = NULL;
+
+ if (NULL != familyFace) {
+ tf = find_typeface(familyFace, style);
+ } else if (NULL != familyName) {
+// SkDebugf("======= familyName <%s>\n", familyName);
+ tf = find_typeface(familyName, style);
+ }
+
+ if (NULL == tf) {
+ tf = find_best_face(gDefaultFamily, style);
+ }
+
+ // we ref(), since the symantic is to return a new instance
+ tf->ref();
+ return tf;
+}
+
+SkStream* SkFontHost::OpenStream(uint32_t fontID) {
+ SkAutoMutexAcquire ac(gFamilyMutex);
+
+ FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
+ SkStream* stream = tf ? tf->openStream() : NULL;
+
+ if (stream && stream->getLength() == 0) {
+ stream->unref();
+ stream = NULL;
+ }
+ return stream;
+}
+
+size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length,
+ int32_t* index) {
+ SkAutoMutexAcquire ac(gFamilyMutex);
+
+ FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
+ const char* src = tf ? tf->getFilePath() : NULL;
+
+ if (src) {
+ size_t size = strlen(src);
+ if (path) {
+ memcpy(path, src, SkMin32(size, length));
+ }
+ if (index) {
+ *index = 0; // we don't have collections (yet)
+ }
+ return size;
+ } else {
+ return 0;
+ }
+}
+
+SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) {
+ load_system_fonts();
+
+ /* First see if fontID is already one of our fallbacks. If so, return
+ its successor. If fontID is not in our list, then return the first one
+ in our list. Note: list is zero-terminated, and returning zero means
+ we have no more fonts to use for fallbacks.
+ */
+ const uint32_t* list = gFallbackFonts;
+ for (int i = 0; list[i] != 0; i++) {
+ if (list[i] == currFontID) {
+ return list[i+1];
+ }
+ }
+ return list[0];
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
+ if (NULL == stream || stream->getLength() <= 0) {
+ return NULL;
+ }
+
+ bool isFixedWidth;
+ SkString name;
+ SkTypeface::Style style;
+ find_name_and_attributes(stream, &name, &style, &isFixedWidth);
+
+ if (!name.isEmpty()) {
+ return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth));
+ } else {
+ return NULL;
+ }
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
+ SkStream* stream = SkNEW_ARGS(SkMMAPStream, (path));
+ SkTypeface* face = SkFontHost::CreateTypefaceFromStream(stream);
+ // since we created the stream, we let go of our ref() here
+ stream->unref();
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
--
1.7.5.4

View File

@ -0,0 +1,173 @@
From f941ea32e44a2436d235e83ef1a434289a9d9c1e Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Wed, 23 May 2012 11:40:25 -0400
Subject: [PATCH 08/10] Bug 755869 - [11] Re-apply bug 687188 - Skia
radial gradients should use the 0/1 color stop values
for clamping. r=mattwoodrow
---
gfx/skia/src/effects/SkGradientShader.cpp | 76 +++++++++++++++++++++++------
1 files changed, 61 insertions(+), 15 deletions(-)
diff --git a/gfx/skia/src/effects/SkGradientShader.cpp b/gfx/skia/src/effects/SkGradientShader.cpp
index 59ba48c..ea05a39 100644
--- a/gfx/skia/src/effects/SkGradientShader.cpp
+++ b/gfx/skia/src/effects/SkGradientShader.cpp
@@ -204,6 +204,7 @@ private:
mutable SkMallocPixelRef* fCache32PixelRef;
mutable unsigned fCacheAlpha; // the alpha value we used when we computed the cache. larger than 8bits so we can store uninitialized value
+ static SkPMColor PremultiplyColor(SkColor c0, U8CPU alpha);
static void Build16bitCache(uint16_t[], SkColor c0, SkColor c1, int count);
static void Build32bitCache(SkPMColor[], SkColor c0, SkColor c1, int count,
U8CPU alpha);
@@ -507,6 +508,21 @@ static inline U8CPU dither_ceil_fixed_to_8(SkFixed n) {
return ((n << 1) - (n | (n >> 8))) >> 8;
}
+SkPMColor Gradient_Shader::PremultiplyColor(SkColor c0, U8CPU paintAlpha)
+{
+ SkFixed a = SkMulDiv255Round(SkColorGetA(c0), paintAlpha);
+ SkFixed r = SkColorGetR(c0);
+ SkFixed g = SkColorGetG(c0);
+ SkFixed b = SkColorGetB(c0);
+
+ a = SkIntToFixed(a) + 0x8000;
+ r = SkIntToFixed(r) + 0x8000;
+ g = SkIntToFixed(g) + 0x8000;
+ b = SkIntToFixed(b) + 0x8000;
+
+ return SkPremultiplyARGBInline(a >> 16, r >> 16, g >> 16, b >> 16);
+}
+
void Gradient_Shader::Build32bitCache(SkPMColor cache[], SkColor c0, SkColor c1,
int count, U8CPU paintAlpha) {
SkASSERT(count > 1);
@@ -628,14 +644,14 @@ static void complete_32bit_cache(SkPMColor* cache, int stride) {
const SkPMColor* Gradient_Shader::getCache32() const {
if (fCache32 == NULL) {
// double the count for dither entries
- const int entryCount = kCache32Count * 2;
+ const int entryCount = kCache32Count * 2 + 2;
const size_t allocSize = sizeof(SkPMColor) * entryCount;
if (NULL == fCache32PixelRef) {
fCache32PixelRef = SkNEW_ARGS(SkMallocPixelRef,
(NULL, allocSize, NULL));
}
- fCache32 = (SkPMColor*)fCache32PixelRef->getAddr();
+ fCache32 = (SkPMColor*)fCache32PixelRef->getAddr() + 1;
if (fColorCount == 2) {
Build32bitCache(fCache32, fOrigColors[0], fOrigColors[1],
kGradient32Length, fCacheAlpha);
@@ -659,7 +675,7 @@ const SkPMColor* Gradient_Shader::getCache32() const {
SkMallocPixelRef* newPR = SkNEW_ARGS(SkMallocPixelRef,
(NULL, allocSize, NULL));
SkPMColor* linear = fCache32; // just computed linear data
- SkPMColor* mapped = (SkPMColor*)newPR->getAddr(); // storage for mapped data
+ SkPMColor* mapped = (SkPMColor*)newPR->getAddr() + 1; // storage for mapped data
SkUnitMapper* map = fMapper;
for (int i = 0; i < kGradient32Length; i++) {
int index = map->mapUnit16((i << 8) | i) >> 8;
@@ -668,10 +684,13 @@ const SkPMColor* Gradient_Shader::getCache32() const {
}
fCache32PixelRef->unref();
fCache32PixelRef = newPR;
- fCache32 = (SkPMColor*)newPR->getAddr();
+ fCache32 = (SkPMColor*)newPR->getAddr() + 1;
}
complete_32bit_cache(fCache32, kCache32Count);
}
+ //Write the clamp colours into the first and last entries of fCache32
+ fCache32[-1] = PremultiplyColor(fOrigColors[0], fCacheAlpha);
+ fCache32[kCache32Count * 2] = PremultiplyColor(fOrigColors[fColorCount - 1], fCacheAlpha);
return fCache32;
}
@@ -857,6 +876,18 @@ void shadeSpan_linear_vertical(TileProc proc, SkFixed dx, SkFixed fx,
SkPMColor* SK_RESTRICT dstC,
const SkPMColor* SK_RESTRICT cache,
int toggle, int count) {
+ if (proc == clamp_tileproc) {
+ // Read out clamp values from beginning/end of the cache. No need to lerp
+ // or dither
+ if (fx < 0) {
+ sk_memset32(dstC, cache[-1], count);
+ return;
+ } else if (fx > 0xFFFF) {
+ sk_memset32(dstC, cache[Gradient_Shader::kCache32Count * 2], count);
+ return;
+ }
+ }
+
// We're a vertical gradient, so no change in a span.
// If colors change sharply across the gradient, dithering is
// insufficient (it subsamples the color space) and we need to lerp.
@@ -875,6 +906,18 @@ void shadeSpan_linear_vertical_lerp(TileProc proc, SkFixed dx, SkFixed fx,
SkPMColor* SK_RESTRICT dstC,
const SkPMColor* SK_RESTRICT cache,
int toggle, int count) {
+ if (proc == clamp_tileproc) {
+ // Read out clamp values from beginning/end of the cache. No need to lerp
+ // or dither
+ if (fx < 0) {
+ sk_memset32(dstC, cache[-1], count);
+ return;
+ } else if (fx > 0xFFFF) {
+ sk_memset32(dstC, cache[Gradient_Shader::kCache32Count * 2], count);
+ return;
+ }
+ }
+
// We're a vertical gradient, so no change in a span.
// If colors change sharply across the gradient, dithering is
// insufficient (it subsamples the color space) and we need to lerp.
@@ -900,10 +943,8 @@ void shadeSpan_linear_clamp(TileProc proc, SkFixed dx, SkFixed fx,
range.init(fx, dx, count, 0, Gradient_Shader::kGradient32Length);
if ((count = range.fCount0) > 0) {
- sk_memset32_dither(dstC,
- cache[toggle + range.fV0],
- cache[(toggle ^ Gradient_Shader::kDitherStride32) + range.fV0],
- count);
+ // Shouldn't be any need to dither for clamping?
+ sk_memset32(dstC, cache[-1], count);
dstC += count;
}
if ((count = range.fCount1) > 0) {
@@ -922,10 +963,8 @@ void shadeSpan_linear_clamp(TileProc proc, SkFixed dx, SkFixed fx,
}
}
if ((count = range.fCount2) > 0) {
- sk_memset32_dither(dstC,
- cache[toggle + range.fV1],
- cache[(toggle ^ Gradient_Shader::kDitherStride32) + range.fV1],
- count);
+ // Shouldn't be any need to dither for clamping?
+ sk_memset32(dstC, cache[Gradient_Shader::kCache32Count * 2], count);
}
}
@@ -1796,9 +1835,16 @@ void shadeSpan_twopoint_clamp(SkScalar fx, SkScalar dx,
for (; count > 0; --count) {
SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura,
fOneOverTwoA, posRoot);
- SkFixed index = SkClampMax(t, 0xFFFF);
- SkASSERT(index <= 0xFFFF);
- *dstC++ = cache[index >> Gradient_Shader::kCache32Shift];
+
+ if (t < 0) {
+ *dstC++ = cache[-1];
+ } else if (t > 0xFFFF) {
+ *dstC++ = cache[Gradient_Shader::kCache32Count * 2];
+ } else {
+ SkASSERT(t <= 0xFFFF);
+ *dstC++ = cache[t >> Gradient_Shader::kCache32Shift];
+ }
+
fx += dx;
fy += dy;
b += db;
--
1.7.5.4

View File

@ -0,0 +1,28 @@
From df3be24040f7cb2f9c7ed86ad3e47206630e885f Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Wed, 23 May 2012 14:49:57 -0400
Subject: [PATCH 09/10] Bug 755869 - [12] Re-apply bug 749533 - Add
support for GNU/kFreeBSD and Hurd in Skia.
r=mattwoodrow
---
gfx/skia/include/core/SkPreConfig.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gfx/skia/include/core/SkPreConfig.h b/gfx/skia/include/core/SkPreConfig.h
index 46c6929..16c4d6c 100644
--- a/gfx/skia/include/core/SkPreConfig.h
+++ b/gfx/skia/include/core/SkPreConfig.h
@@ -35,7 +35,8 @@
#elif defined(ANDROID)
#define SK_BUILD_FOR_ANDROID
#elif defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
- defined(__sun) || defined(__NetBSD__) || defined(__DragonFly__)
+ defined(__sun) || defined(__NetBSD__) || defined(__DragonFly__) || \
+ defined(__GLIBC__) || defined(__GNU__)
#define SK_BUILD_FOR_UNIX
#elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define SK_BUILD_FOR_IOS
--
1.7.5.4

View File

@ -0,0 +1,36 @@
From dc1292fc8c2b9da900ebcac953120eaffd0d329e Mon Sep 17 00:00:00 2001
From: George Wright <gwright@mozilla.com>
Date: Wed, 23 May 2012 14:52:36 -0400
Subject: [PATCH 10/10] Bug 755869 - [13] Re-apply bug 750733 - Use
handles in API object hooks where possible
r=mattwoodrow
---
gfx/skia/src/xml/SkJS.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gfx/skia/src/xml/SkJS.cpp b/gfx/skia/src/xml/SkJS.cpp
index f2e7a83..b2717d7 100644
--- a/gfx/skia/src/xml/SkJS.cpp
+++ b/gfx/skia/src/xml/SkJS.cpp
@@ -74,7 +74,7 @@ extern "C" {
#endif
static JSBool
-global_enumerate(JSContext *cx, JSObject *obj)
+global_enumerate(JSContext *cx, JSHandleObject *obj)
{
#ifdef LAZY_STANDARD_CLASSES
return JS_EnumerateStandardClasses(cx, obj);
@@ -84,7 +84,7 @@ global_enumerate(JSContext *cx, JSObject *obj)
}
static JSBool
-global_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
+global_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
{
#ifdef LAZY_STANDARD_CLASSES
if ((flags & JSRESOLVE_ASSIGNING) == 0) {
--
1.7.5.4

View File

@ -0,0 +1,28 @@
From cf855f31194ff071f2c787a7413d70a43f15f204 Mon Sep 17 00:00:00 2001
From: Ehsan Akhgari <ehsan@mozilla.com>
Date: Tue, 29 May 2012 15:39:55 -0400
Subject: [PATCH] Bug 755869 - Re-apply patch from bug 719575 to fix clang
builds for the new Skia r=gw280
---
gfx/skia/src/ports/SkFontHost_mac_coretext.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp b/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp
index c43d1a6..ce5f409 100644
--- a/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp
+++ b/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp
@@ -807,8 +807,8 @@ CGRGBPixel* Offscreen::getCG(const SkScalerContext_Mac& context, const SkGlyph&
void SkScalerContext_Mac::getVerticalOffset(CGGlyph glyphID, SkIPoint* offset) const {
CGSize vertOffset;
CTFontGetVerticalTranslationsForGlyphs(fCTVerticalFont, &glyphID, &vertOffset, 1);
- const SkPoint trans = {SkFloatToScalar(vertOffset.width),
- SkFloatToScalar(vertOffset.height)};
+ const SkPoint trans = {SkScalar(SkFloatToScalar(vertOffset.width)),
+ SkScalar(SkFloatToScalar(vertOffset.height))};
SkPoint floatOffset;
fVerticalMatrix.mapPoints(&floatOffset, &trans, 1);
if (!isSnowLeopard()) {
--
1.7.5.4

16
gfx/skia/patches/README Normal file
View File

@ -0,0 +1,16 @@
This directory contains the patches currently applied against upstream Skia.
The original patches are archived in archive/
See the relevant bugs in bugzilla for information on these patches:
0001-Bug-687189-Implement-SkPaint-getPosTextPath.patch
0002-Bug-688366-Dont-invalidate-all-radial-gradients.patch
0003-SkUserConfig-for-Mozilla.patch
0004-Bug-722011-Fix-trailing-commas-in-enums.patch
0005-Bug-731384-Fix-clang-SK_OVERRIDE.patch
0006-Bug-751814-ARM-EDSP-ARMv6-Skia-fixes.patch
0007-Bug-719872-Old-Android-FontHost.patch
0008-Bug-687188-Skia-radial-gradients.patch
0009-Bug-755869-FreeBSD-Hurd.patch
0010-Bug-689069-ARM-Opts.patch
0011-Bug-719575-Fix-clang-build.patch

View File

@ -92,27 +92,7 @@ else
echo "Remember to update README_MOZILLA with the version details."
fi
# Bug 689069 - Patch to get arm opts to build with frame pointers enabled.
patch -p3 < arm-opts.patch
# Bug 687188 - Skia radial gradients should use the 0/1 color stop values for clamping.
patch -p3 < fix-gradient-clamp.patch
# Bug 687189 - Implement SkPaint::getPosTextPath.
patch -p3 < getpostextpath.patch
# Bug 688365 - Enable Skia 'New AA' mode.
patch -p3 < new-aa.patch
# Bug 688366 - Fix Skia marking radial gradients with the same radius as invalid.
patch -p3 < radial-gradients.patch
# Fix restrict keyword problem for VS2005
patch -p3 < skia_restrict_problem.patch
# Changes to SkUserConfig.h - no bug
patch -p3 < user-config.patch
# Bug 715718 - Unitialized variable 'margin' in compute_bounds : SkDraw.cpp
patch -p3 < uninitialized-margin.patch
# Bug 722011 - Fix comma at end of enum list
patch -p3 < fix-comma-end-enum-list.patch
# Bug 719872 - Fix crash on Android by reverting to older FontHost impl
patch -p3 < old-android-fonthost.patch
# Bug 731384 - Fix compile errors on older versions of clang
patch -p3 < SkPostConfig.patch
# Bug 751814 - Various Skia fixes for ARM without EDSP and ARMv6+
patch -p3 < arm-fixes.patch
for file in `ls patches/*.patch`; do
echo "Applying patch $file"
patch -p3 < $file
done