Changeset 28867 in webkit
- Timestamp:
- Dec 19, 2007, 11:24:10 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r28864 r28867 1 2007-12-19 Dave Hyatt <hyatt@apple.com> 2 3 Add support for GDI text rendering to WebKit. 4 5 Reviewed by mitz 6 7 * css/CSSStyleSelector.cpp: 8 (WebCore::CSSStyleSelector::applyProperty): 9 * dom/Document.cpp: 10 (WebCore::Document::recalcStyle): 11 * page/Settings.cpp: 12 (WebCore::Settings::setFontRenderingMode): 13 (WebCore::Settings::fontRenderingMode): 14 * page/Settings.h: 15 * platform/graphics/Font.h: 16 (WebCore::Font::renderingMode): 17 * platform/graphics/FontCache.cpp: 18 (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey): 19 (WebCore::FontPlatformDataCacheKey::operator==): 20 (WebCore::computeHash): 21 (WebCore::FontCache::getCachedFontPlatformData): 22 * platform/graphics/FontDescription.h: 23 (WebCore::): 24 (WebCore::FontDescription::FontDescription): 25 (WebCore::FontDescription::renderingMode): 26 (WebCore::FontDescription::setRenderingMode): 27 (WebCore::FontDescription::operator==): 28 * platform/graphics/GraphicsContext.h: 29 * platform/graphics/win/FontCacheWin.cpp: 30 (WebCore::FontCache::fontExists): 31 (WebCore::FontCache::createFontPlatformData): 32 * platform/graphics/win/FontDataWin.cpp: 33 (WebCore::FontData::platformInit): 34 (WebCore::FontData::smallCapsFontData): 35 (WebCore::FontData::containsCharacters): 36 (WebCore::FontData::determinePitch): 37 (WebCore::FontData::platformWidthForGlyph): 38 * platform/graphics/win/FontPlatformData.h: 39 (WebCore::FontPlatformData::FontPlatformData): 40 (WebCore::FontPlatformData::useGDI): 41 (WebCore::FontPlatformData::operator==): 42 * platform/graphics/win/FontPlatformDataWin.cpp: 43 (WebCore::FontPlatformData::FontPlatformData): 44 * platform/graphics/win/FontWin.cpp: 45 (WebCore::Font::drawGlyphs): 46 * platform/graphics/win/IconWin.cpp: 47 (WebCore::Icon::paint): 48 * platform/win/GraphicsContextWin.cpp: 49 (WebCore::GraphicsContext::getWindowsContext): 50 (WebCore::GraphicsContext::releaseWindowsContext): 51 * platform/win/UniscribeController.cpp: 52 (WebCore::UniscribeController::shapeAndPlaceItem): 53 * platform/win/UniscribeController.h: 54 * plugins/win/PluginViewWin.cpp: 55 (WebCore::PluginViewWin::paint): 56 1 57 2007-12-19 Sven Herzberg <sven@imendio.com> 2 58 -
trunk/WebCore/css/CSSStyleSelector.cpp
r28775 r28867 3339 3339 fontDirty = true; 3340 3340 } else if (isInitial) { 3341 Settings* settings = m_document->settings(); 3341 3342 FontDescription fontDescription; 3342 3343 fontDescription.setGenericFamily(FontDescription::StandardFamily); 3344 fontDescription.setRenderingMode(settings->fontRenderingMode()); 3345 fontDescription.setUsePrinterFont(m_document->printing()); 3343 3346 const AtomicString& standardFontFamily = m_document->settings()->standardFontFamily(); 3344 3347 if (!standardFontFamily.isEmpty()) { -
trunk/WebCore/dom/Document.cpp
r28784 r28867 1065 1065 fontDescription.setUsePrinterFont(printing()); 1066 1066 if (Settings* settings = this->settings()) { 1067 fontDescription.setRenderingMode(settings->fontRenderingMode()); 1067 1068 if (printing() && !settings->shouldPrintBackgrounds()) 1068 1069 _style->setForceBackgroundsToWhite(true); -
trunk/WebCore/page/Settings.cpp
r28693 r28867 315 315 } 316 316 317 void Settings::setFontRenderingMode(FontRenderingMode mode) 318 { 319 if (m_fontRenderingMode == mode) 320 return; 321 m_fontRenderingMode = mode; 322 setNeedsReapplyStylesInAllFrames(m_page); 323 } 324 325 FontRenderingMode Settings::fontRenderingMode() const 326 { 327 return m_fontRenderingMode; 328 } 329 317 330 } // namespace WebCore -
trunk/WebCore/page/Settings.h
r28693 r28867 30 30 #include "AtomicString.h" 31 31 #include "KURL.h" 32 #include "FontDescription.h" 32 33 33 34 namespace WebCore { … … 147 148 unsigned long long defaultDatabaseOriginQuota() const; 148 149 150 void setFontRenderingMode(FontRenderingMode mode); 151 FontRenderingMode fontRenderingMode() const; 152 149 153 private: 150 154 Page* m_page; … … 182 186 bool m_developerExtrasEnabled : 1; 183 187 bool m_authorAndUserStylesEnabled : 1; 188 FontRenderingMode m_fontRenderingMode : 1; 184 189 }; 185 190 -
trunk/WebCore/platform/graphics/Font.h
r28688 r28867 160 160 bool isFixedPitch() const; 161 161 bool isPrinterFont() const { return m_fontDescription.usePrinterFont(); } 162 163 FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); } 162 164 163 165 FontFamily& firstFamily() { return m_fontDescription.firstFamily(); } -
trunk/WebCore/platform/graphics/FontCache.cpp
r28626 r28867 41 41 struct FontPlatformDataCacheKey { 42 42 FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, bool bold = false, bool italic = false, 43 bool isPrinterFont = false )43 bool isPrinterFont = false, FontRenderingMode renderingMode = NormalRenderingMode) 44 44 : m_family(family) 45 45 , m_size(size) … … 47 47 , m_italic(italic) 48 48 , m_printerFont(isPrinterFont) 49 , m_renderingMode(renderingMode) 49 50 { 50 51 } … … 53 54 { 54 55 return equalIgnoringCase(m_family, other.m_family) && m_size == other.m_size && 55 m_bold == other.m_bold && m_italic == other.m_italic && m_printerFont == other.m_printerFont; 56 m_bold == other.m_bold && m_italic == other.m_italic && m_printerFont == other.m_printerFont && 57 m_renderingMode == other.m_renderingMode; 56 58 } 57 59 … … 61 63 bool m_italic; 62 64 bool m_printerFont; 65 FontRenderingMode m_renderingMode; 63 66 }; 64 67 65 68 inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey) 66 69 { 67 unsigned hashCodes[ 3] = {70 unsigned hashCodes[4] = { 68 71 CaseFoldingHash::hash(fontKey.m_family), 69 72 fontKey.m_size, 70 static_cast<unsigned>(fontKey.m_bold) << 2 | static_cast<unsigned>(fontKey.m_italic) << 1 | static_cast<unsigned>(fontKey.m_printerFont) 73 static_cast<unsigned>(fontKey.m_bold) << 3 | static_cast<unsigned>(fontKey.m_italic) << 2 | static_cast<unsigned>(fontKey.m_printerFont) << 1 | 74 static_cast<unsigned>(fontKey.m_renderingMode) 71 75 }; 72 return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 3* sizeof(unsigned) / sizeof(UChar));76 return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 4 * sizeof(unsigned) / sizeof(UChar)); 73 77 } 74 78 … … 142 146 143 147 FontPlatformDataCacheKey key(familyName, fontDescription.computedPixelSize(), fontDescription.bold(), fontDescription.italic(), 144 fontDescription.usePrinterFont() );148 fontDescription.usePrinterFont(), fontDescription.renderingMode()); 145 149 FontPlatformData* result = 0; 146 150 bool foundResult; -
trunk/WebCore/platform/graphics/FontDescription.h
r28234 r28867 32 32 const unsigned cBoldWeight = 63; 33 33 34 // This setting is used to provide ways of switching between multiple rendering modes that may have different 35 // metrics. It is used to switch between CG and GDI text on Windows. 36 enum FontRenderingMode { NormalRenderingMode, AlternateRenderingMode }; 37 34 38 class FontDescription { 35 39 public: … … 40 44 : m_specifiedSize(0), m_computedSize(0), 41 45 m_italic(false), m_smallCaps(false), m_isAbsoluteSize(false), m_weight(cNormalWeight), 42 m_genericFamily(NoFamily), m_usePrinterFont(false), m_ keywordSize(0)46 m_genericFamily(NoFamily), m_usePrinterFont(false), m_renderingMode(NormalRenderingMode), m_keywordSize(0) 43 47 {} 44 48 … … 58 62 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); } 59 63 bool usePrinterFont() const { return m_usePrinterFont; } 64 FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); } 60 65 int keywordSize() const { return m_keywordSize; } 61 66 … … 70 75 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; } 71 76 void setUsePrinterFont(bool p) { m_usePrinterFont = p; } 77 void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; } 72 78 void setKeywordSize(int s) { m_keywordSize = s; } 73 79 … … 86 92 unsigned m_genericFamily : 3; // GenericFamilyType 87 93 bool m_usePrinterFont : 1; 88 94 95 unsigned m_renderingMode : 1; // Used to switch between CG and GDI text on Windows. 96 89 97 int m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium). If so, 90 98 // then we can accurately translate across different generic families to adjust for different preference settings … … 103 111 && m_genericFamily == other.m_genericFamily 104 112 && m_usePrinterFont == other.m_usePrinterFont 113 && m_renderingMode == other.m_renderingMode 105 114 && m_keywordSize == other.m_keywordSize; 106 115 } -
trunk/WebCore/platform/graphics/GraphicsContext.h
r28588 r28867 222 222 #if PLATFORM(WIN) 223 223 GraphicsContext(HDC); // FIXME: To be removed. 224 HDC getWindowsContext( bool supportAlphaBlend = false, const IntRect* = 0); // The passed in rect is used to create a bitmap for compositing inside transparency layers.225 void releaseWindowsContext(HDC, bool supportAlphaBlend = false, const IntRect* = 0); // The passed in HDC should be the one handed back by getWindowsContext.224 HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers. 225 void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true); // The passed in HDC should be the one handed back by getWindowsContext. 226 226 #endif 227 227 -
trunk/WebCore/platform/graphics/win/FontCacheWin.cpp
r28838 r28867 216 216 // Windows will always give us a valid pointer here, even if the face name is non-existent. We have to double-check 217 217 // and see if the family name was really used. 218 HDC dc = GetDC( (HWND)0);218 HDC dc = GetDC(0); 219 219 SaveDC(dc); 220 220 SelectObject(dc, hfont); … … 231 231 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family) 232 232 { 233 bool isLucidaGrande = false; 234 static AtomicString lucidaStr("Lucida Grande"); 235 if (equalIgnoringCase(family, lucidaStr)) 236 isLucidaGrande = true; 237 238 bool useGDI = fontDescription.renderingMode() == AlternateRenderingMode && !isLucidaGrande; 239 233 240 LOGFONT winfont; 234 241 235 // The size here looks unusual. The negative number is intentional. The logical size constant is 32. 236 winfont.lfHeight = -fontDescription.computedPixelSize() * 32; 242 // The size here looks unusual. The negative number is intentional. The logical size constant is 32. We do this 243 // for subpixel precision when rendering using Uniscribe. This masks rounding errors related to the HFONT metrics being 244 // different from the CGFont metrics. 245 // FIXME: We will eventually want subpixel precision for GDI mode, but the scaled rendering doesn't look as nice. That may be solvable though. 246 winfont.lfHeight = -fontDescription.computedPixelSize() * (useGDI ? 1 : 32); 237 247 winfont.lfWidth = 0; 238 248 winfont.lfEscapement = 0; … … 241 251 winfont.lfStrikeOut = false; 242 252 winfont.lfCharSet = DEFAULT_CHARSET; 243 #if PLATFORM(CG)244 253 winfont.lfOutPrecision = OUT_TT_ONLY_PRECIS; 245 #else 246 winfont.lfOutPrecision = OUT_TT_PRECIS; 247 #endif 248 winfont.lfQuality = 5; // Force cleartype. 254 winfont.lfQuality = DEFAULT_QUALITY; 249 255 winfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 250 256 winfont.lfItalic = fontDescription.italic(); … … 255 261 // FIXME: Hardcoding Lucida Grande for now. It uses different weights than typical Win32 fonts 256 262 // (500/600 instead of 400/700). 257 static AtomicString lucidaStr("Lucida Grande"); 258 if (equalIgnoringCase(family, lucidaStr)) 263 if (isLucidaGrande) { 259 264 winfont.lfWeight = fontDescription.bold() ? 600 : 500; 260 else 265 useGDI = false; // Never use GDI for Lucida Grande. 266 } else 261 267 winfont.lfWeight = fontDescription.bold() ? 700 : 400; 262 268 int len = min(family.length(), (unsigned int)LF_FACESIZE - 1); … … 267 273 // Windows will always give us a valid pointer here, even if the face name is non-existent. We have to double-check 268 274 // and see if the family name was really used. 269 HDC dc = GetDC( (HWND)0);275 HDC dc = GetDC(0); 270 276 SaveDC(dc); 271 277 SelectObject(dc, hfont); … … 281 287 282 288 FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), 283 fontDescription.bold(), fontDescription.italic() );289 fontDescription.bold(), fontDescription.italic(), useGDI); 284 290 if (!result->cgFont()) { 285 291 // The creation of the CGFontRef failed for some reason. We already asserted in debug builds, but to make -
trunk/WebCore/platform/graphics/win/FontDataWin.cpp
r28641 r28867 60 60 { 61 61 m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f; 62 m_scriptCache = 0; 63 m_scriptFontProperties = 0; 64 m_isSystemFont = false; 65 66 if (m_font.useGDI()) { 67 HDC hdc = GetDC(0); 68 HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); 69 OUTLINETEXTMETRIC metrics; 70 GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics); 71 TEXTMETRIC& textMetrics = metrics.otmTextMetrics; 72 m_ascent = textMetrics.tmAscent; 73 m_descent = textMetrics.tmDescent; 74 m_lineGap = textMetrics.tmExternalLeading; 75 m_lineSpacing = m_ascent + m_descent + m_lineGap; 76 m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present. 77 78 GLYPHMETRICS gm; 79 MAT2 mat = { 1, 0, 0, 1 }; 80 DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); 81 if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) 82 m_xHeight = gm.gmptGlyphOrigin.y; 83 84 m_unitsPerEm = metrics.otmEMSquare; 85 86 SelectObject(hdc, oldFont); 87 ReleaseDC(0, hdc); 88 89 return; 90 } 62 91 63 92 CGFontRef font = m_font.cgFont(); … … 71 100 float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize; 72 101 73 m_isSystemFont = false;74 102 if (!isCustomFont()) { 75 103 HDC dc = GetDC(0); … … 116 144 m_xHeight = scaleEmToUnits(iXHeight, m_unitsPerEm) * pointSize; 117 145 } 118 119 m_scriptCache = 0;120 m_scriptFontProperties = 0;121 146 } 122 147 … … 146 171 LOGFONT winfont; 147 172 GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont); 148 winfont.lfHeight = -lroundf(smallCapsHeight * 32);173 winfont.lfHeight = -lroundf(smallCapsHeight * m_font.useGDI() ? 1 : 32); 149 174 HFONT hfont = CreateFontIndirect(&winfont); 150 m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight, fontDescription.bold(), fontDescription.italic() ));175 m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight, fontDescription.bold(), fontDescription.italic(), m_font.useGDI())); 151 176 } 152 177 } … … 167 192 return false; 168 193 169 HDC dc = GetDC( (HWND)0);194 HDC dc = GetDC(0); 170 195 171 196 DWORD acpCodePages; … … 198 223 199 224 // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that. 200 HDC dc = GetDC( (HWND)0);225 HDC dc = GetDC(0); 201 226 SaveDC(dc); 202 227 SelectObject(dc, m_font.hfont()); … … 214 239 float FontData::platformWidthForGlyph(Glyph glyph) const 215 240 { 241 if (m_font.useGDI()) { 242 HDC hdc = GetDC(0); 243 HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); 244 int width; 245 GetCharWidthI(hdc, glyph, 1, 0, &width); 246 SelectObject(hdc, oldFont); 247 ReleaseDC(0, hdc); 248 return width; 249 } 250 216 251 CGFontRef font = m_font.cgFont(); 217 252 float pointSize = m_font.size(); -
trunk/WebCore/platform/graphics/win/FontPlatformData.h
r28641 r28867 46 46 , m_syntheticBold(false) 47 47 , m_syntheticOblique(false) 48 , m_useGDI(false) 48 49 {} 49 50 … … 54 55 , m_syntheticBold(false) 55 56 , m_syntheticOblique(false) 57 , m_useGDI(false) 56 58 {} 57 59 58 FontPlatformData(HFONT, float size, bool bold, bool oblique );60 FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI); 59 61 FontPlatformData(CGFontRef, float size, bool bold, bool oblique); 60 62 ~FontPlatformData(); … … 67 69 bool syntheticBold() const { return m_syntheticBold; } 68 70 bool syntheticOblique() const { return m_syntheticOblique; } 71 bool useGDI() const { return m_useGDI; } 69 72 70 73 unsigned hash() const … … 76 79 { 77 80 return m_font == other.m_font && m_cgFont ==other.m_cgFont && m_size == other.m_size && 78 m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique; 81 m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique && 82 m_useGDI == other.m_useGDI; 79 83 } 80 84 … … 86 90 bool m_syntheticBold; 87 91 bool m_syntheticOblique; 92 bool m_useGDI; 88 93 }; 89 94 -
trunk/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
r28641 r28867 129 129 } 130 130 131 FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique )131 FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI) 132 132 : m_font(font) 133 133 , m_size(size) … … 135 135 , m_syntheticBold(false) 136 136 , m_syntheticOblique(false) 137 , m_useGDI(useGDI) 137 138 { 138 139 HDC hdc = GetDC(0); … … 179 180 } 180 181 182 // For GDI text, synthetic bold and oblique never need to be set. 183 m_syntheticBold = m_syntheticOblique = false; 184 181 185 // Try the face name first. Windows may end up localizing this name, and CG doesn't know about 182 186 // the localization. If the create fails, we'll try the PostScript name. … … 203 207 , m_syntheticBold(bold) 204 208 , m_syntheticOblique(oblique) 209 , m_useGDI(false) 205 210 { 206 211 } -
trunk/WebCore/platform/graphics/win/FontWin.cpp
r28536 r28867 45 45 int from, int numGlyphs, const FloatPoint& point) const 46 46 { 47 if (font->m_font.useGDI()) { 48 // FIXME: Support alpha blending. 49 // FIXME: Support text stroke/fill. 50 // FIXME: Support text shadow. 51 Color fillColor = graphicsContext->fillColor(); 52 if (fillColor.alpha() == 0) 53 return; 54 55 // We have to convert CG's two-dimensional floating point advances to just horizontal integer advances. 56 Vector<int, 2048> gdiAdvances; 57 int totalWidth = 0; 58 for (int i = 0; i < numGlyphs; i++) { 59 gdiAdvances.append(lroundf(glyphBuffer.advanceAt(from + i))); 60 totalWidth += gdiAdvances[i]; 61 } 62 63 // We put slop into this rect, since glyphs can overflow the ascent/descent bounds and the left/right edges. 64 IntRect textRect(point.x() - font->lineGap(), point.y() - font->ascent() - font->lineGap(), totalWidth + 2 * font->lineGap(), font->lineSpacing()); 65 HDC hdc = graphicsContext->getWindowsContext(textRect); 66 SelectObject(hdc, font->m_font.hfont()); 67 68 // Set the correct color. 69 HDC textDrawingDC = hdc; 70 /*if (fillColor.hasAlpha() || graphicsContext->inTransparencyLayer()) { 71 // GDI can't handle drawing transparent text. We have to draw into a mask. We draw black text on a white-filled background. 72 // We also do this when inside transparency layers, since GDI also can't draw onto a surface with alpha. 73 graphicsContext->save(); 74 graphicsContext->setFillColor(Color::white); 75 textDrawingDC = graphicsContext->getWindowsBitmapContext(textRect); 76 SetTextColor(hdc, RGB(0, 0, 0)); 77 } else*/ 78 SetTextColor(hdc, RGB(fillColor.red(), fillColor.green(), fillColor.blue())); 79 80 SetBkMode(hdc, TRANSPARENT); 81 SetTextAlign(hdc, TA_LEFT | TA_BASELINE); 82 83 // Uniscribe gives us offsets to help refine the positioning of combining glyphs. 84 FloatSize translation = glyphBuffer.offsetAt(from); 85 if (translation.width() || translation.height()) { 86 XFORM xform; 87 xform.eM11 = 1.0; 88 xform.eM12 = 0; 89 xform.eM21 = 0; 90 xform.eM22 = 1.0; 91 xform.eDx = translation.width(); 92 xform.eDy = translation.height(); 93 ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY); 94 } 95 ExtTextOut(hdc, point.x(), point.y(), ETO_GLYPH_INDEX, 0, (WCHAR*)glyphBuffer.glyphs(from), numGlyphs, gdiAdvances.data()); 96 97 /*if (fillColor.hasAlpha() || graphicsContext->inTransparencyLayer()) { 98 // TODOD: We have to walk the bits of the bitmap and invert them. We also copy over the green component value into the alpha value 99 // to keep ClearType looking reasonable. 100 101 // Now that we have drawn the text into a bitmap and inverted it, obtain a CGImageRef mask. 102 CGImageRef mask = graphicsContext->releaseWindowsBitmapContextIntoMask(textDrawingDC, textRect); 103 104 // Apply the mask to the fill color. 105 CGContextRef bitmapContext = graphicsContext->getWindowsCompatibleCGBitmapContext(textRect.size()); 106 CGFloat red, green, blue, alpha; 107 color.getRGBA(red, green, blue, alpha); 108 CGContextSetRGBFillColor(context, red, green, blue, alpha); 109 CGContextFillRect(bitmapContext, IntRect(0, 0, textRect.width(), textRect.height())); 110 CGImageRef fillColorImage = CGBitmapContextCreateImage(bitmapContext); 111 112 // Apply the mask. 113 CGImageRef finalImage = CGImageCreateWithMask(fillColorImage, mask); 114 115 // The bitmap image needs to be drawn into the HDC. 116 graphicsContext->drawImageIntoWindowsContext(hdc, finalImage); 117 118 // Release our images and contexts. 119 CGImageRelease(mask); 120 CGImageRelease(fillColorImage); 121 CGImageRelease(finalImage); 122 CGContextRelease(bitmapContext); 123 }*/ 124 125 graphicsContext->releaseWindowsContext(hdc, textRect); 126 return; 127 } 128 47 129 CGContextRef cgContext = graphicsContext->platformContext(); 48 130 -
trunk/WebCore/platform/graphics/win/IconWin.cpp
r25754 r28867 63 63 return; 64 64 65 HDC hdc = context->getWindowsContext( );65 HDC hdc = context->getWindowsContext(r); 66 66 67 67 DrawIconEx(hdc, r.x(), r.y(), m_hIcon, r.width(), r.height(), 0, 0, DI_NORMAL); 68 68 69 context->releaseWindowsContext(hdc );69 context->releaseWindowsContext(hdc, r); 70 70 } 71 71 -
trunk/WebCore/platform/win/GraphicsContextWin.cpp
r28005 r28867 78 78 } 79 79 80 HDC GraphicsContext::getWindowsContext( bool supportAlphaBlend, const IntRect* dstRect)80 HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend) 81 81 { 82 82 if (m_data->m_transparencyCount) { 83 // We're in a transparency layer. 84 ASSERT(dstRect); 85 if (!dstRect) 83 if (dstRect.isEmpty()) 86 84 return 0; 87 85 88 86 // Create a bitmap DC in which to draw. 89 87 BITMAPINFO bitmapInfo; 90 88 bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 91 bitmapInfo.bmiHeader.biWidth = dstRect ->width();92 bitmapInfo.bmiHeader.biHeight = dstRect ->height();89 bitmapInfo.bmiHeader.biWidth = dstRect.width(); 90 bitmapInfo.bmiHeader.biHeight = dstRect.height(); 93 91 bitmapInfo.bmiHeader.biPlanes = 1; 94 92 bitmapInfo.bmiHeader.biBitCount = 32; … … 125 123 xform.eM21 = 0; 126 124 xform.eM22 = 1.0; 127 xform.eDx = -dstRect ->x();128 xform.eDy = -dstRect ->y();125 xform.eDx = -dstRect.x(); 126 xform.eDy = -dstRect.y(); 129 127 ::SetWorldTransform(bitmapDC, &xform); 130 128 … … 137 135 } 138 136 139 void GraphicsContext::releaseWindowsContext(HDC hdc, bool supportAlphaBlend, const IntRect* dstRect)137 void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend) 140 138 { 141 139 if (hdc && m_data->m_transparencyCount) { 140 if (dstRect.isEmpty()) 141 return; 142 142 143 HBITMAP bitmap = (HBITMAP)GetCurrentObject(hdc, OBJ_BITMAP); 143 144 … … 155 156 156 157 CGImageRef image = CGBitmapContextCreateImage(bitmapContext); 157 CGContextDrawImage(m_data->m_cgContext, *dstRect, image);158 CGContextDrawImage(m_data->m_cgContext, dstRect, image); 158 159 159 160 // Delete all our junk. -
trunk/WebCore/platform/win/UniscribeController.cpp
r28621 r28867 254 254 Vector<int> roundingHackWordBoundaries(glyphs.size()); 255 255 roundingHackWordBoundaries.fill(-1); 256 unsigned logicalSpaceWidth = fontData->m_spaceWidth * 32.0f; 256 257 const float cLogicalScale = fontData->m_font.useGDI() ? 1.0f : 32.0f; 258 unsigned logicalSpaceWidth = fontData->m_spaceWidth * cLogicalScale; 257 259 float roundedSpaceWidth = roundf(fontData->m_spaceWidth); 258 260 … … 283 285 for (unsigned k = 0; k < glyphs.size(); k++) { 284 286 Glyph glyph = glyphs[k]; 285 float advance = advances[k] / 32.0f;286 float offsetX = offsets[k].du / 32.0f;287 float offsetY = offsets[k].dv / 32.0f;287 float advance = advances[k] / cLogicalScale; 288 float offsetX = offsets[k].du / cLogicalScale; 289 float offsetY = offsets[k].dv / cLogicalScale; 288 290 289 291 // Match AppKit's rules for the integer vs. non-integer rendering modes. -
trunk/WebCore/platform/win/UniscribeController.h
r28621 r28867 30 30 #define UniscribeController_h 31 31 32 #include <usp10.h> 32 33 #include "Font.h" 33 34 #include "GlyphBuffer.h" 34 35 #include "Vector.h" 35 #include <usp10.h>36 36 37 37 namespace WebCore { -
trunk/WebCore/plugins/win/PluginViewWin.cpp
r28816 r28867 473 473 return; 474 474 475 HDC hdc = context->getWindowsContext(); 476 475 HDC hdc = context->getWindowsContext(frameGeometry()); 476 477 // FIXME: This is completely wrong and will break in the presence of opacity, SVG transforms 478 // and CSS transforms. 477 479 // The plugin expects that the passed in DC has window coordinates. 478 480 // (This probably breaks funky SVG transform stuff) … … 516 518 dispatchNPEvent(npEvent); 517 519 518 context->releaseWindowsContext(hdc );520 context->releaseWindowsContext(hdc, frameGeometry()); 519 521 } 520 522
Note:
See TracChangeset
for help on using the changeset viewer.