Diff
Modified: trunk/Source/WebCore/ChangeLog (89987 => 89988)
--- trunk/Source/WebCore/ChangeLog 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/ChangeLog 2011-06-29 06:01:53 UTC (rev 89988)
@@ -1,3 +1,43 @@
+2011-06-28 Kenichi Ishibashi <[email protected]>
+
+ Reviewed by Tony Chang.
+
+ [Chromium] Remove dependencies on harfbuzz from FontPlatformDataLinux and FontLinux
+ https://bugs.webkit.org/show_bug.cgi?id=62530
+
+ - Moved codes of FontLinux which depend on harfbuzz APIs to ComplexTextController. Removed Some methods of ComplexTextController(advances() and logClusters()) since they are no longer needed.
+ - Moved RefCountedHarfbuzzFace from FontPlatformDataLinux to HarfbuzzSkia and renamed it to HarfbuzzFace.
+
+ No new tests because there is no behavior change (The existing tests should cover the changes).
+
+ * platform/graphics/chromium/ComplexTextControllerLinux.cpp:
+ (WebCore::ComplexTextController::ComplexTextController): Added arguments so eliminating setter invocations.
+ (WebCore::ComplexTextController::setupForRTL): Added.
+ (WebCore::ComplexTextController::setupFontForScriptRun): Adopt the change of HarfbuzzFace class.
+ (WebCore::ComplexTextController::setGlyphPositions): Use m_item.log_clusters instead of removed method.
+ (WebCore::ComplexTextController::glyphIndexForXPositionInScriptRun): Added.
+ (WebCore::ComplexTextController::offsetForPosition): Ditto.
+ (WebCore::ComplexTextController::selectionRect): Ditto.
+ * platform/graphics/chromium/ComplexTextControllerLinux.h:
+ (WebCore::ComplexTextController::width):
+ * platform/graphics/chromium/FontLinux.cpp: Removed truncateFixedPointToInteger().
+ (WebCore::Font::drawComplexText): Removed setter invocations of ComplexTextController.
+ (WebCore::Font::floatWidthForComplexText): Ditto.
+ (WebCore::Font::offsetForPositionForComplexText): Moved harfbuzz dependent code to ComplexTextController.
+ (WebCore::Font::selectionRectForComplexText): Ditto.
+ * platform/graphics/chromium/FontPlatformDataLinux.cpp:
+ (WebCore::FontPlatformData::harfbuzzFace): Wrapped up HB_FaceRec in HarfbuzzFace class.
+ * platform/graphics/chromium/FontPlatformDataLinux.h: Moved RefCountedHarfbuzzFace class and renamed to HarfbuzzFace.
+ * platform/graphics/chromium/HarfbuzzSkia.cpp:
+ (WebCore::allocHarfbuzzFont): Moved from ComplexTextControllerLinux.cpp.
+ (WebCore::HarfbuzzFace::HarfbuzzFace): Added.
+ (WebCore::HarfbuzzFace::~HarfbuzzFace): Added.
+ * platform/graphics/chromium/HarfbuzzSkia.h:
+ (WebCore::HarfbuzzFace::create): Added.
+ (WebCore::HarfbuzzFace::face): Added.
+ * platform/graphics/skia/GlyphPageTreeNodeSkia.cpp:
+ (WebCore::substituteWithVerticalGlyphs): Adopt the change of HarfbuzzFace class.
+
2011-06-28 Roland Steiner <[email protected]>
Reviewed by Eric Seidel.
Modified: trunk/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp 2011-06-29 06:01:53 UTC (rev 89988)
@@ -31,9 +31,14 @@
#include "config.h"
#include "ComplexTextControllerLinux.h"
+#include "FloatRect.h"
#include "Font.h"
#include "TextRun.h"
+extern "C" {
+#include "harfbuzz-unicode.h"
+}
+
#include <unicode/normlzr.h>
namespace WebCore {
@@ -46,14 +51,9 @@
return value >> 6;
}
-ComplexTextController::ComplexTextController(const TextRun& run, unsigned startingX, unsigned startingY, const Font* font)
+ComplexTextController::ComplexTextController(const TextRun& run, unsigned startingX, unsigned startingY, unsigned wordSpacing, unsigned letterSpacing, unsigned padding, const Font* font)
: m_font(font)
, m_run(getNormalizedTextRun(run, m_normalizedRun, m_normalizedBuffer))
- , m_wordSpacingAdjustment(0)
- , m_padding(0)
- , m_padPerWordBreak(0)
- , m_padError(0)
- , m_letterSpacing(0)
{
// Do not use |run| inside this constructor. Use |m_run| instead.
@@ -76,6 +76,10 @@
reset(startingX);
m_startingY = startingY;
+
+ setWordSpacingAdjustment(wordSpacing);
+ setLetterSpacingAdjustment(letterSpacing);
+ setPadding(padding);
}
ComplexTextController::~ComplexTextController()
@@ -118,6 +122,7 @@
void ComplexTextController::setPadding(int padding)
{
m_padding = padding;
+ m_padError = 0;
if (!m_padding)
return;
@@ -143,6 +148,18 @@
m_offsetX = offset;
}
+void ComplexTextController::setupForRTL()
+{
+ int padding = m_padding;
+ // FIXME: this causes us to shape the text twice -- once to compute the width and then again
+ // below when actually rendering. Change ComplexTextController to match platform/mac and
+ // platform/chromium/win by having it store the shaped runs, so we can reuse the results.
+ reset(m_offsetX + widthOfFullRun());
+ // We need to set the padding again because ComplexTextController layout consumed the value.
+ // Fixing the above problem would help here too.
+ setPadding(padding);
+}
+
// Advance to the next script run, returning false when the end of the
// TextRun has been reached.
bool ComplexTextController::nextScriptRun()
@@ -202,7 +219,7 @@
}
const FontData* fontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, fontDataVariant).fontData;
const FontPlatformData& platformData = fontData->fontDataForCharacter(' ')->platformData();
- m_item.face = platformData.harfbuzzFace();
+ m_item.face = platformData.harfbuzzFace()->face();
void* opaquePlatformData = const_cast<FontPlatformData*>(&platformData);
m_item.font->userData = opaquePlatformData;
@@ -217,16 +234,6 @@
m_item.font->y_scale = scale;
}
-HB_FontRec* ComplexTextController::allocHarfbuzzFont()
-{
- HB_FontRec* font = reinterpret_cast<HB_FontRec*>(fastMalloc(sizeof(HB_FontRec)));
- memset(font, 0, sizeof(HB_FontRec));
- font->klass = &harfbuzzSkiaClass;
- font->userData = 0;
-
- return font;
-}
-
void ComplexTextController::deleteGlyphArrays()
{
delete[] m_item.glyphs;
@@ -297,7 +304,7 @@
// Iterate through the glyphs in logical order, flipping for RTL where necessary.
// Glyphs are positioned starting from m_offsetX; in RTL mode they go leftwards from there.
for (size_t i = 0; i < m_item.num_glyphs; ++i) {
- while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] < i)
+ while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && m_item.log_clusters[logClustersIndex] < i)
logClustersIndex++;
// If the current glyph is just after a space, add in the word spacing.
@@ -399,4 +406,96 @@
return *normalizedRun;
}
+int ComplexTextController::glyphIndexForXPositionInScriptRun(int targetX) const
+{
+ // Iterate through the glyphs in logical order, seeing whether targetX falls between the previous
+ // position and halfway through the current glyph.
+ // FIXME: this code probably belongs in ComplexTextController.
+ int lastX = offsetX() - (rtl() ? -m_pixelWidth : m_pixelWidth);
+ for (int glyphIndex = 0; static_cast<unsigned>(glyphIndex) < length(); ++glyphIndex) {
+ int advance = truncateFixedPointToInteger(m_item.advances[glyphIndex]);
+ int nextX = static_cast<int>(positions()[glyphIndex].x()) + advance / 2;
+ if (std::min(nextX, lastX) <= targetX && targetX <= std::max(nextX, lastX))
+ return glyphIndex;
+ lastX = nextX;
+ }
+
+ return length() - 1;
+}
+
+int ComplexTextController::offsetForPosition(int targetX)
+{
+ unsigned basePosition = 0;
+
+ int x = offsetX();
+ while (nextScriptRun()) {
+ int nextX = offsetX();
+
+ if (std::min(x, nextX) <= targetX && targetX <= std::max(x, nextX)) {
+ // The x value in question is within this script run.
+ const int glyphIndex = glyphIndexForXPositionInScriptRun(targetX);
+
+ // Now that we have a glyph index, we have to turn that into a
+ // code-point index. Because of ligatures, several code-points may
+ // have gone into a single glyph. We iterate over the clusters log
+ // and find the first code-point which contributed to the glyph.
+
+ // Some shapers (i.e. Khmer) will produce cluster logs which report
+ // that /no/ code points contributed to certain glyphs. Because of
+ // this, we take any code point which contributed to the glyph in
+ // question, or any subsequent glyph. If we run off the end, then
+ // we take the last code point.
+ for (unsigned j = 0; j < numCodePoints(); ++j) {
+ if (m_item.log_clusters[j] >= glyphIndex)
+ return basePosition + j;
+ }
+
+ return basePosition + numCodePoints() - 1;
+ }
+
+ basePosition += numCodePoints();
+ }
+
+ return basePosition;
+}
+
+FloatRect ComplexTextController::selectionRect(const FloatPoint& point, int height, int from, int to)
+{
+ int fromX = -1, toX = -1;
+ // Iterate through the script runs in logical order, searching for the run covering the positions of interest.
+ while (nextScriptRun() && (fromX == -1 || toX == -1)) {
+ if (fromX == -1 && from >= 0 && static_cast<unsigned>(from) < numCodePoints()) {
+ // |from| is within this script run. So we index the clusters log to
+ // find which glyph this code-point contributed to and find its x
+ // position.
+ int glyph = m_item.log_clusters[from];
+ fromX = positions()[glyph].x();
+ if (rtl())
+ fromX += truncateFixedPointToInteger(m_item.advances[glyph]);
+ } else
+ from -= numCodePoints();
+
+ if (toX == -1 && to >= 0 && static_cast<unsigned>(to) < numCodePoints()) {
+ int glyph = m_item.log_clusters[to];
+ toX = positions()[glyph].x();
+ if (rtl())
+ toX += truncateFixedPointToInteger(m_item.advances[glyph]);
+ } else
+ to -= numCodePoints();
+ }
+
+ // The position in question might be just after the text.
+ if (fromX == -1)
+ fromX = offsetX();
+ if (toX == -1)
+ toX = offsetX();
+
+ ASSERT(fromX != -1 && toX != -1);
+
+ if (fromX < toX)
+ return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
+
+ return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h 2011-06-29 06:01:53 UTC (rev 89988)
@@ -36,6 +36,10 @@
#include "SkScalar.h"
#include "TextRun.h"
+extern "C" {
+#include "harfbuzz-shaper.h"
+}
+
#include <unicode/uchar.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/OwnPtr.h>
@@ -61,7 +65,7 @@
// can call |reset| to start over again.
class ComplexTextController {
public:
- ComplexTextController(const TextRun&, unsigned, unsigned, const Font*);
+ ComplexTextController(const TextRun&, unsigned startingX, unsigned startingY, unsigned wordSpacing, unsigned letterSpacing, unsigned padding, const Font*);
~ComplexTextController();
bool isWordBreak(unsigned);
@@ -85,8 +89,7 @@
void setLetterSpacingAdjustment(int letterSpacingAdjustment) { m_letterSpacing = letterSpacingAdjustment; }
int letterSpacing() const { return m_letterSpacing; }
- // Set the x offset for the next script run. This affects the values in
- // |xPositions|
+ void setupForRTL();
bool rtl() const { return m_run.rtl(); }
const uint16_t* glyphs() const { return m_glyphs16; }
@@ -98,19 +101,6 @@
// run.
const SkPoint* positions() const { return m_positions; }
- // Get the advances (widths) for each glyph.
- const HB_Fixed* advances() const { return m_item.advances; }
-
- // Return the width (in px) of the current script run.
- const unsigned width() const { return m_pixelWidth; }
-
- // Return the cluster log for the current script run. For example:
- // script run: f i a n c é (fi gets ligatured)
- // log clutrs: 0 0 1 2 3 4
- // So, for each input code point, the log tells you which output glyph was
- // generated for it.
- const unsigned short* logClusters() const { return m_item.log_clusters; }
-
// return the number of code points in the current script run
const unsigned numCodePoints() const { return m_item.item.length; }
@@ -119,9 +109,14 @@
const FontPlatformData* fontPlatformDataForScriptRun() { return reinterpret_cast<FontPlatformData*>(m_item.font->userData); }
+ int offsetForPosition(int);
+ FloatRect selectionRect(const FloatPoint&, int height, int from , int to);
+
private:
+ // Return the width (in px) of the current script run.
+ unsigned width() const { return m_pixelWidth; }
+
void setupFontForScriptRun();
- HB_FontRec* allocHarfbuzzFont();
void deleteGlyphArrays();
void createGlyphArrays(int);
void resetGlyphArrays();
@@ -134,6 +129,8 @@
// This matches the logic in RenderBlock::findNextLineBreak
static bool isCodepointSpace(HB_UChar16 c) { return c == ' ' || c == '\t'; }
+ int glyphIndexForXPositionInScriptRun(int targetX) const;
+
const Font* const m_font;
const SimpleFontData* m_currentFontData;
HB_ShaperItem m_item;
Modified: trunk/Source/WebCore/platform/graphics/chromium/FontLinux.cpp (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/FontLinux.cpp 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/FontLinux.cpp 2011-06-29 06:01:53 UTC (rev 89988)
@@ -165,14 +165,6 @@
}
}
-// Harfbuzz uses 26.6 fixed point values for pixel offsets. However, we don't
-// handle subpixel positioning so this function is used to truncate Harfbuzz
-// values to a number of pixels.
-static int truncateFixedPointToInteger(HB_Fixed value)
-{
- return value >> 6;
-}
-
static void setupForTextPainting(SkPaint* paint, SkColor color)
{
paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
@@ -205,20 +197,10 @@
setupForTextPainting(&strokePaint, gc->strokeColor().rgb());
}
- ComplexTextController controller(run, point.x(), point.y(), this);
- controller.setWordSpacingAdjustment(wordSpacing());
- controller.setLetterSpacingAdjustment(letterSpacing());
- controller.setPadding(run.expansion());
+ ComplexTextController controller(run, point.x(), point.y(), wordSpacing(), letterSpacing(), run.expansion(), this);
- if (run.rtl()) {
- // FIXME: this causes us to shape the text twice -- once to compute the width and then again
- // below when actually rendering. Change ComplexTextController to match platform/mac and
- // platform/chromium/win by having it store the shaped runs, so we can reuse the results.
- controller.reset(point.x() + controller.widthOfFullRun());
- // We need to set the padding again because ComplexTextController layout consumed the value.
- // Fixing the above problem would help here too.
- controller.setPadding(run.expansion());
- }
+ if (run.rtl())
+ controller.setupForRTL();
while (controller.nextScriptRun()) {
if (fill) {
@@ -242,30 +224,10 @@
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */, GlyphOverflow* /* glyphOverflow */) const
{
- ComplexTextController controller(run, 0, 0, this);
- controller.setWordSpacingAdjustment(wordSpacing());
- controller.setLetterSpacingAdjustment(letterSpacing());
- controller.setPadding(run.expansion());
+ ComplexTextController controller(run, 0, 0, wordSpacing(), letterSpacing(), run.expansion(), this);
return controller.widthOfFullRun();
}
-static int glyphIndexForXPositionInScriptRun(const ComplexTextController& controller, int targetX)
-{
- // Iterate through the glyphs in logical order, seeing whether targetX falls between the previous
- // position and halfway through the current glyph.
- // FIXME: this code probably belongs in ComplexTextController.
- int lastX = controller.offsetX() - (controller.rtl() ? -controller.width() : controller.width());
- for (int glyphIndex = 0; static_cast<unsigned>(glyphIndex) < controller.length(); ++glyphIndex) {
- int advance = truncateFixedPointToInteger(controller.advances()[glyphIndex]);
- int nextX = static_cast<int>(controller.positions()[glyphIndex].x()) + advance / 2;
- if (std::min(nextX, lastX) <= targetX && targetX <= std::max(nextX, lastX))
- return glyphIndex;
- lastX = nextX;
- }
-
- return controller.length() - 1;
-}
-
// Return the code point index for the given |x| offset into the text run.
int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat,
bool includePartialGlyphs) const
@@ -276,49 +238,10 @@
// (Mac code ignores includePartialGlyphs, and they don't know what it's
// supposed to do, so we just ignore it as well.)
- ComplexTextController controller(run, 0, 0, this);
- controller.setWordSpacingAdjustment(wordSpacing());
- controller.setLetterSpacingAdjustment(letterSpacing());
- controller.setPadding(run.expansion());
- if (run.rtl()) {
- // See FIXME in drawComplexText.
- controller.reset(controller.widthOfFullRun());
- controller.setPadding(run.expansion());
- }
-
- unsigned basePosition = 0;
-
- int x = controller.offsetX();
- while (controller.nextScriptRun()) {
- int nextX = controller.offsetX();
-
- if (std::min(x, nextX) <= targetX && targetX <= std::max(x, nextX)) {
- // The x value in question is within this script run.
- const int glyphIndex = glyphIndexForXPositionInScriptRun(controller, targetX);
-
- // Now that we have a glyph index, we have to turn that into a
- // code-point index. Because of ligatures, several code-points may
- // have gone into a single glyph. We iterate over the clusters log
- // and find the first code-point which contributed to the glyph.
-
- // Some shapers (i.e. Khmer) will produce cluster logs which report
- // that /no/ code points contributed to certain glyphs. Because of
- // this, we take any code point which contributed to the glyph in
- // question, or any subsequent glyph. If we run off the end, then
- // we take the last code point.
- const unsigned short* log = controller.logClusters();
- for (unsigned j = 0; j < controller.numCodePoints(); ++j) {
- if (log[j] >= glyphIndex)
- return basePosition + j;
- }
-
- return basePosition + controller.numCodePoints() - 1;
- }
-
- basePosition += controller.numCodePoints();
- }
-
- return basePosition;
+ ComplexTextController controller(run, 0, 0, wordSpacing(), letterSpacing(), run.expansion(), this);
+ if (run.rtl())
+ controller.setupForRTL();
+ return controller.offsetForPosition(targetX);
}
// Return the rectangle for selecting the given range of code-points in the TextRun.
@@ -326,51 +249,10 @@
const FloatPoint& point, int height,
int from, int to) const
{
- int fromX = -1, toX = -1;
- ComplexTextController controller(run, 0, 0, this);
- controller.setWordSpacingAdjustment(wordSpacing());
- controller.setLetterSpacingAdjustment(letterSpacing());
- controller.setPadding(run.expansion());
- if (run.rtl()) {
- // See FIXME in drawComplexText.
- controller.reset(controller.widthOfFullRun());
- controller.setPadding(run.expansion());
- }
-
- // Iterate through the script runs in logical order, searching for the run covering the positions of interest.
- while (controller.nextScriptRun() && (fromX == -1 || toX == -1)) {
- if (fromX == -1 && from >= 0 && static_cast<unsigned>(from) < controller.numCodePoints()) {
- // |from| is within this script run. So we index the clusters log to
- // find which glyph this code-point contributed to and find its x
- // position.
- int glyph = controller.logClusters()[from];
- fromX = controller.positions()[glyph].x();
- if (controller.rtl())
- fromX += truncateFixedPointToInteger(controller.advances()[glyph]);
- } else
- from -= controller.numCodePoints();
-
- if (toX == -1 && to >= 0 && static_cast<unsigned>(to) < controller.numCodePoints()) {
- int glyph = controller.logClusters()[to];
- toX = controller.positions()[glyph].x();
- if (controller.rtl())
- toX += truncateFixedPointToInteger(controller.advances()[glyph]);
- } else
- to -= controller.numCodePoints();
- }
-
- // The position in question might be just after the text.
- if (fromX == -1)
- fromX = controller.offsetX();
- if (toX == -1)
- toX = controller.offsetX();
-
- ASSERT(fromX != -1 && toX != -1);
-
- if (fromX < toX)
- return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
-
- return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
+ ComplexTextController controller(run, 0, 0, wordSpacing(), letterSpacing(), run.expansion(), this);
+ if (run.rtl())
+ controller.setupForRTL();
+ return controller.selectionRect(point, height, from, to);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp 2011-06-29 06:01:53 UTC (rev 89988)
@@ -31,7 +31,6 @@
#include "config.h"
#include "FontPlatformData.h"
-#include "HarfbuzzSkia.h"
#include "NotImplemented.h"
#include "PlatformBridge.h"
#include "PlatformString.h"
@@ -63,11 +62,6 @@
isSkiaSubpixelGlyphs = isSubpixelGlyphs;
}
-FontPlatformData::RefCountedHarfbuzzFace::~RefCountedHarfbuzzFace()
-{
- HB_FreeFace(m_harfbuzzFace);
-}
-
FontPlatformData::FontPlatformData(const FontPlatformData& src)
: m_typeface(src.m_typeface)
, m_family(src.m_family)
@@ -229,12 +223,12 @@
return false;
}
-HB_FaceRec_* FontPlatformData::harfbuzzFace() const
+HarfbuzzFace* FontPlatformData::harfbuzzFace() const
{
if (!m_harfbuzzFace)
- m_harfbuzzFace = RefCountedHarfbuzzFace::create(HB_NewFace(const_cast<FontPlatformData*>(this), harfbuzzSkiaGetTable));
+ m_harfbuzzFace = HarfbuzzFace::create(const_cast<FontPlatformData*>(this));
- return m_harfbuzzFace->face();
+ return m_harfbuzzFace.get();
}
void FontPlatformData::querySystemForRenderStyle()
Modified: trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h 2011-06-29 06:01:53 UTC (rev 89988)
@@ -33,6 +33,7 @@
#include "FontOrientation.h"
#include "FontRenderStyle.h"
+#include "HarfbuzzSkia.h"
#include "TextOrientation.h"
#include <wtf/Forward.h>
#include <wtf/RefPtr.h>
@@ -43,8 +44,6 @@
class SkTypeface;
typedef uint32_t SkFontID;
-struct HB_FaceRec_;
-
namespace WebCore {
class FontDescription;
@@ -128,7 +127,7 @@
String description() const;
#endif
- HB_FaceRec_* harfbuzzFace() const;
+ HarfbuzzFace* harfbuzzFace() const;
// -------------------------------------------------------------------------
// Global font preferences...
@@ -138,25 +137,6 @@
static void setSubpixelGlyphs(bool on);
private:
- class RefCountedHarfbuzzFace : public RefCounted<RefCountedHarfbuzzFace> {
- public:
- static PassRefPtr<RefCountedHarfbuzzFace> create(HB_FaceRec_* harfbuzzFace)
- {
- return adoptRef(new RefCountedHarfbuzzFace(harfbuzzFace));
- }
-
- ~RefCountedHarfbuzzFace();
-
- HB_FaceRec_* face() const { return m_harfbuzzFace; }
-
- private:
- RefCountedHarfbuzzFace(HB_FaceRec_* harfbuzzFace) : m_harfbuzzFace(harfbuzzFace)
- {
- }
-
- HB_FaceRec_* m_harfbuzzFace;
- };
-
void querySystemForRenderStyle();
// FIXME: Could SkAutoUnref be used here?
@@ -169,7 +149,7 @@
FontOrientation m_orientation;
TextOrientation m_textOrientation;
FontRenderStyle m_style;
- mutable RefPtr<RefCountedHarfbuzzFace> m_harfbuzzFace;
+ mutable RefPtr<HarfbuzzFace> m_harfbuzzFace;
SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTypeface*>(-1); }
};
Modified: trunk/Source/WebCore/platform/graphics/chromium/HarfbuzzSkia.cpp (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/HarfbuzzSkia.cpp 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/HarfbuzzSkia.cpp 2011-06-29 06:01:53 UTC (rev 89988)
@@ -197,6 +197,16 @@
getFontMetric,
};
+HB_Font_* allocHarfbuzzFont()
+{
+ HB_Font_* font = reinterpret_cast<HB_Font_*>(fastMalloc(sizeof(HB_Font_)));
+ memset(font, 0, sizeof(HB_Font_));
+ font->klass = &harfbuzzSkiaClass;
+ font->userData = 0;
+
+ return font;
+}
+
HB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag tag, HB_Byte* buffer, HB_UInt* len)
{
FontPlatformData* font = reinterpret_cast<FontPlatformData*>(voidface);
@@ -216,4 +226,14 @@
return HB_Err_Ok;
}
+HarfbuzzFace::HarfbuzzFace(FontPlatformData* platformData)
+{
+ m_harfbuzzFace = HB_NewFace(platformData, harfbuzzSkiaGetTable);
+}
+
+HarfbuzzFace::~HarfbuzzFace()
+{
+ HB_FreeFace(m_harfbuzzFace);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/HarfbuzzSkia.h (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/chromium/HarfbuzzSkia.h 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/chromium/HarfbuzzSkia.h 2011-06-29 06:01:53 UTC (rev 89988)
@@ -31,14 +31,37 @@
#ifndef HarfbuzzSkia_h
#define HarfbuzzSkia_h
-extern "C" {
-#include "harfbuzz-shaper.h"
-#include "harfbuzz-unicode.h"
-}
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+struct HB_FaceRec_;
+struct HB_Font_;
+
namespace WebCore {
- HB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag, HB_Byte* buffer, HB_UInt* len);
- extern const HB_FontClass harfbuzzSkiaClass;
+
+class FontPlatformData;
+
+class HarfbuzzFace : public RefCounted<HarfbuzzFace> {
+public:
+ static PassRefPtr<HarfbuzzFace> create(FontPlatformData* platformData)
+ {
+ return adoptRef(new HarfbuzzFace(platformData));
+ }
+
+ ~HarfbuzzFace();
+
+ HB_FaceRec_* face() const { return m_harfbuzzFace; }
+
+private:
+ explicit HarfbuzzFace(FontPlatformData*);
+
+ HB_FaceRec_* m_harfbuzzFace;
+};
+
+// FIXME: Remove this asymmetric alloc/free function.
+// We'll remove this once we move to the new Harfbuzz API.
+HB_Font_* allocHarfbuzzFont();
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp (89987 => 89988)
--- trunk/Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp 2011-06-29 04:34:38 UTC (rev 89987)
+++ trunk/Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp 2011-06-29 06:01:53 UTC (rev 89988)
@@ -39,11 +39,15 @@
#include "SkPaint.h"
#include "SkUtils.h"
+extern "C" {
+#include "harfbuzz-shaper.h"
+}
+
namespace WebCore {
static int substituteWithVerticalGlyphs(const SimpleFontData* fontData, uint16_t* glyphs, unsigned bufferLength)
{
- HB_FaceRec_* hbFace = fontData->platformData().harfbuzzFace();
+ HB_FaceRec_* hbFace = fontData->platformData().harfbuzzFace()->face();
if (!hbFace->gsub) {
// if there is no GSUB table, treat it as not covered
return 0Xffff;