diff options
author | Steve Block <steveblock@google.com> | 2010-02-15 12:23:52 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-16 11:48:32 +0000 |
commit | 8a0914b749bbe7da7768e07a7db5c6d4bb09472b (patch) | |
tree | 73f9065f370435d6fde32ae129d458a8c77c8dff /WebCore/platform/graphics/wx | |
parent | bf14be70295513b8076f3fa47a268a7e42b2c478 (diff) | |
download | external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.zip external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.gz external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.bz2 |
Merge webkit.org at r54731 : Initial merge by git
Change-Id: Ia79977b6cf3b0b00c06ef39419989b28e57e4f4a
Diffstat (limited to 'WebCore/platform/graphics/wx')
-rw-r--r-- | WebCore/platform/graphics/wx/FontCacheWx.cpp | 8 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/FontPlatformData.h | 7 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/FontPlatformDataWx.cpp | 12 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/FontWx.cpp | 69 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/GraphicsContextWx.cpp | 18 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/ImageWx.cpp | 16 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/PathWx.cpp | 9 | ||||
-rw-r--r-- | WebCore/platform/graphics/wx/SimpleFontDataWx.cpp | 53 |
8 files changed, 147 insertions, 45 deletions
diff --git a/WebCore/platform/graphics/wx/FontCacheWx.cpp b/WebCore/platform/graphics/wx/FontCacheWx.cpp index db107e4..b2dea2e 100644 --- a/WebCore/platform/graphics/wx/FontCacheWx.cpp +++ b/WebCore/platform/graphics/wx/FontCacheWx.cpp @@ -46,17 +46,17 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, cons return fontData; } -FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) +SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) { - return new FontPlatformData(font.fontDescription(), font.family().family()); + return getCachedFontData(font.fontDescription(), font.family().family()); } -FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) +SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) { // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick // the default that the user would get without changing any prefs. static AtomicString timesStr("systemfont"); - return getCachedFontPlatformData(fontDescription, timesStr); + return getCachedFontData(fontDescription, timesStr); } FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family) diff --git a/WebCore/platform/graphics/wx/FontPlatformData.h b/WebCore/platform/graphics/wx/FontPlatformData.h index 3b99830..be00edc 100644 --- a/WebCore/platform/graphics/wx/FontPlatformData.h +++ b/WebCore/platform/graphics/wx/FontPlatformData.h @@ -113,6 +113,13 @@ public: bool isHashTableDeletedValue() const { return m_fontState == DELETED; } + bool roundsGlyphAdvances() const { return false; } + +#if OS(WINDOWS) + bool useGDI() const; + HFONT hfont() const; +#endif + #ifndef NDEBUG String description() const; #endif diff --git a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp index fd3322f..c9646d7 100644 --- a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp +++ b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp @@ -129,4 +129,16 @@ String FontPlatformData::description() const } #endif +#if OS(WINDOWS) +bool FontPlatformData::useGDI() const +{ + return true; +} + +HFONT FontPlatformData::hfont() const +{ + return static_cast<HFONT>(m_font->font()->GetHFONT()); +} +#endif + } diff --git a/WebCore/platform/graphics/wx/FontWx.cpp b/WebCore/platform/graphics/wx/FontWx.cpp index 04b2ec4..98b5a0a 100644 --- a/WebCore/platform/graphics/wx/FontWx.cpp +++ b/WebCore/platform/graphics/wx/FontWx.cpp @@ -33,6 +33,10 @@ #include "NotImplemented.h" #include "SimpleFontData.h" +#if OS(WINDOWS) +#include "UniscribeController.h" +#endif + #include <wx/dcclient.h> #include "fontprops.h" #include "non-kerned-drawing.h" @@ -41,7 +45,11 @@ namespace WebCore { bool Font::canReturnFallbackFontsForComplexText() { +#if OS(WINDOWS) + return true; +#else return false; +#endif } void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, @@ -59,25 +67,80 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const { +#if OS(WINDOWS) + UniscribeController it(this, run); + it.advance(from); + float beforeWidth = it.runWidthSoFar(); + it.advance(to); + float afterWidth = it.runWidthSoFar(); + + // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning + if (run.rtl()) { + it.advance(run.length()); + float totalWidth = it.runWidthSoFar(); + return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h); + } + + return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h); +#else notImplemented(); return FloatRect(); +#endif } -void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const +void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { +#if OS(WINDOWS) + // This glyph buffer holds our glyphs + advances + font data for each glyph. + GlyphBuffer glyphBuffer; + + float startX = point.x(); + UniscribeController controller(this, run); + controller.advance(from); + float beforeWidth = controller.runWidthSoFar(); + controller.advance(to, &glyphBuffer); + + // We couldn't generate any glyphs for the run. Give up. + if (glyphBuffer.isEmpty()) + return; + + float afterWidth = controller.runWidthSoFar(); + + if (run.rtl()) { + controller.advance(run.length()); + startX += controller.runWidthSoFar() - afterWidth; + } else + startX += beforeWidth; + + // Draw the glyph buffer now at the starting point returned in startX. + FloatPoint startPoint(startX, point.y()); + drawGlyphBuffer(context, glyphBuffer, run, startPoint); +#else notImplemented(); +#endif } -float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */) const + +float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts) const { +#if OS(WINDOWS) + UniscribeController controller(this, run, fallbackFonts); + controller.advance(run.length()); + return controller.runWidthSoFar(); +#else notImplemented(); return 0; +#endif } int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const { +#if OS(WINDOWS) + UniscribeController controller(this, run); + return controller.offsetForPosition(x, includePartialGlyphs); +#else notImplemented(); return 0; +#endif } - } diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp index e35334e..8e1a391 100644 --- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -27,7 +27,6 @@ #include "GraphicsContext.h" #include "AffineTransform.h" -#include "TransformationMatrix.h" #include "FloatRect.h" #include "Font.h" #include "IntRect.h" @@ -360,18 +359,12 @@ void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*) notImplemented(); } -AffineTransform GraphicsContext::getAffineCTM() const +AffineTransform GraphicsContext::getCTM() const { notImplemented(); return AffineTransform(); } -TransformationMatrix GraphicsContext::getCTM() const -{ - notImplemented(); - return TransformationMatrix(); -} - void GraphicsContext::translate(float tx, float ty) { #if USE(WXGC) @@ -487,15 +480,6 @@ void GraphicsContext::concatCTM(const AffineTransform& transform) return; } -void GraphicsContext::concatCTM(const TransformationMatrix& transform) -{ - if (paintingDisabled()) - return; - - notImplemented(); - return; -} - void GraphicsContext::setPlatformShouldAntialias(bool enable) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/wx/ImageWx.cpp b/WebCore/platform/graphics/wx/ImageWx.cpp index ff60d6f..c246ec1 100644 --- a/WebCore/platform/graphics/wx/ImageWx.cpp +++ b/WebCore/platform/graphics/wx/ImageWx.cpp @@ -26,13 +26,13 @@ #include "config.h" #include "Image.h" +#include "AffineTransform.h" #include "BitmapImage.h" #include "FloatConversion.h" #include "FloatRect.h" #include "GraphicsContext.h" #include "ImageObserver.h" #include "NotImplemented.h" -#include "TransformationMatrix.h" #include <math.h> #include <stdio.h> @@ -176,17 +176,16 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatR observer->didDraw(this); } -void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const TransformationMatrix& patternTransform, const FloatPoint& phase, ColorSpace, CompositeOperator, const FloatRect& dstRect) +void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace, CompositeOperator, const FloatRect& dstRect) { - if (!m_source.initialized()) - return; + #if USE(WXGC) wxGCDC* context = (wxGCDC*)ctxt->platformContext(); - wxGraphicsBitmap* bitmap = frameAtIndex(m_currentFrame); + wxGraphicsBitmap* bitmap = nativeImageForCurrentFrame(); #else wxWindowDC* context = ctxt->platformContext(); - wxBitmap* bitmap = frameAtIndex(m_currentFrame); + wxBitmap* bitmap = nativeImageForCurrentFrame(); #endif if (!bitmap) // If it's too early we won't have an image yet. @@ -261,9 +260,4 @@ void BitmapImage::invalidatePlatformData() } -void Image::drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, const FloatPoint& phase, ColorSpace, CompositeOperator, const FloatRect& destRect) -{ - notImplemented(); -} - } diff --git a/WebCore/platform/graphics/wx/PathWx.cpp b/WebCore/platform/graphics/wx/PathWx.cpp index 21693c9..6c115ac 100644 --- a/WebCore/platform/graphics/wx/PathWx.cpp +++ b/WebCore/platform/graphics/wx/PathWx.cpp @@ -27,7 +27,6 @@ #include "Path.h" #include "AffineTransform.h" -#include "TransformationMatrix.h" #include "FloatPoint.h" #include "FloatRect.h" #include "NotImplemented.h" @@ -211,14 +210,6 @@ void Path::transform(const AffineTransform& transform) #endif } -void Path::transform(const TransformationMatrix& transform) -{ -#if USE(WXGC) - if (m_path) - m_path->Transform(transform); -#endif -} - void Path::apply(void* info, PathApplierFunction function) const { notImplemented(); diff --git a/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp b/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp index 85979de..d9fd2b3 100644 --- a/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp +++ b/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp @@ -55,6 +55,13 @@ void SimpleFontData::platformInit() m_unitsPerEm = 1; // FIXME! m_lineGap = props.GetLineGap(); } + +#if OS(WINDOWS) + m_scriptCache = 0; + m_scriptFontProperties = 0; + m_isSystemFont = false; + m_syntheticBoldOffset = 0.0f; +#endif } void SimpleFontData::platformCharWidthInit() @@ -68,6 +75,16 @@ void SimpleFontData::platformDestroy() { delete m_smallCapsFontData; m_smallCapsFontData = 0; + +#if OS(WINDOWS) + if (m_scriptFontProperties) { + delete m_scriptFontProperties; + m_scriptFontProperties = 0; + } + + if (m_scriptCache) + ScriptFreeCache(&m_scriptCache); +#endif } SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const @@ -84,7 +101,7 @@ SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDes bool SimpleFontData::containsCharacters(const UChar* characters, int length) const { // FIXME: We will need to implement this to load non-ASCII encoding sites - return true; + return wxFontContainsCharacters(*m_platformData.font(), characters, length); } void SimpleFontData::determinePitch() @@ -97,10 +114,44 @@ void SimpleFontData::determinePitch() float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { +#if __WXMSW__ + // under Windows / wxMSW we currently always use GDI fonts. + return widthForGDIGlyph(glyph); +#else // TODO: fix this! Make GetTextExtents a method of wxFont in 2.9 int width = 10; GetTextExtent(*m_platformData.font(), (wxChar)glyph, &width, NULL); return width; +#endif +} + +#if OS(WINDOWS) +SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const +{ + // AFAICT this is never called even by the Win port anymore. + return 0; +} + +void SimpleFontData::initGDIFont() +{ + // unused by wx port +} + +void SimpleFontData::platformCommonDestroy() +{ + // unused by wx port +} + +float SimpleFontData::widthForGDIGlyph(Glyph glyph) const +{ + HDC hdc = GetDC(0); + HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont()); + int width; + GetCharWidthI(hdc, glyph, 1, 0, &width); + SelectObject(hdc, oldFont); + ReleaseDC(0, hdc); + return width; } +#endif } |