2007-07-23 Ada Chan <adachan@apple.com>
authoradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2007 00:39:26 +0000 (00:39 +0000)
committeradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2007 00:39:26 +0000 (00:39 +0000)
        Reviewed by Steve.

        Added a new text drawing method that allows caller to override the font smoothing level.

        * WebKit.vcproj/WebKit.def:
        * WebKit.vcproj/WebKit_debug.def:
        * WebKitGraphics.cpp:
        (WebDrawText):
        * WebKitGraphics.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24553 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/WebKit.vcproj/WebKit.def
WebKit/win/WebKit.vcproj/WebKit_debug.def
WebKit/win/WebKitGraphics.cpp
WebKit/win/WebKitGraphics.h

index 0ad774bc2df6e7836f3a0c4f00cbbd7df6364894..16f34d8cadfa084be2a52b0f912cfb198a3f4ee8 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-23  Ada Chan  <adachan@apple.com>
+
+        Reviewed by Steve.
+        
+        Added a new text drawing method that allows caller to override the font smoothing level.
+
+        * WebKit.vcproj/WebKit.def:
+        * WebKit.vcproj/WebKit_debug.def:
+        * WebKitGraphics.cpp:
+        (WebDrawText):
+        * WebKitGraphics.h:
+
 2007-07-22  Adam Roben  <aroben@apple.com>
 
         Implement IDOMElement::setAttribute
index bea5cd1c83665cf0fd6f3c32ad7bf82d010d0335..cce6bbe7b8bb8e78952961428dce597baf99416e 100644 (file)
@@ -89,6 +89,7 @@ EXPORTS
         WebLocalizedLPCTSTR
         SetWebLocalizedStringMainBundle
         DrawTextAtPoint
+        WebDrawText
         FontMetrics
         TextFloatWidth
         CenterTruncateStringToWidth
index bff61685750ee8642181eacaa8078bccf18d8b64..fbc23f4f33e18c1b54f78ed8535b55506704304c 100644 (file)
@@ -89,6 +89,7 @@ EXPORTS
         WebLocalizedLPCTSTR
         SetWebLocalizedStringMainBundle
         DrawTextAtPoint
+        WebDrawText
         FontMetrics
         TextFloatWidth
         CenterTruncateStringToWidth
index 65d7d084a1b42f5f558d7b3a9d7964e7d4bad6cf..3156857b45341d50fcaddf23fdfefd2d9e8a2c34 100644 (file)
@@ -41,7 +41,7 @@
 #include <CoreGraphics/CoreGraphics.h>
 #pragma warning(pop)
 
-#include <windows.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 
 using namespace WebCore;
 
@@ -78,6 +78,23 @@ void DrawTextAtPoint(CGContextRef cgContext, LPCTSTR text, int length, POINT poi
     WebCoreDrawTextAtPoint(context, drawString, point, makeFont(description), textColor, underlinedIndex);
 }
 
+void WebDrawText(WebTextRenderInfo* info)
+{
+    if (!info || info->structSize != sizeof(WebTextRenderInfo) || !info->cgContext || !info->description)
+        return;
+
+    int oldFontSmoothingLevel = -1;
+    if (info->overrideSmoothingLevel >= 0) {
+        oldFontSmoothingLevel = wkGetFontSmoothingLevel();
+        wkSetFontSmoothingLevel(info->overrideSmoothingLevel);
+    }
+
+    DrawTextAtPoint(info->cgContext, info->text, info->length, info->pt, *(info->description), info->color, info->underlinedIndex, info->drawAsPassword);
+
+    if (info->overrideSmoothingLevel >= 0)
+        wkSetFontSmoothingLevel(oldFontSmoothingLevel);
+}
+
 float TextFloatWidth(LPCTSTR text, int length, const WebFontDescription& description)
 {
     return WebCoreTextFloatWidth(String(text, length), makeFont(description));
index 15f9dc405f53311090e8b646bad51925e9399d4f..199469816f05297a9b0fe2a6e77761b34d7c4fbc 100644 (file)
 #ifndef WebKitGraphics_h
 #define WebKitGraphics_h
 
+#include <windows.h>
+
 typedef struct CGColor* CGColorRef;
 typedef struct CGContext* CGContextRef;
-typedef struct tagPOINT POINT;
 
 typedef wchar_t WCHAR;
 typedef __nullterminated const WCHAR* LPCWSTR;
@@ -42,7 +43,22 @@ struct WebFontDescription {
     bool italic;
 };
 
+struct WebTextRenderInfo
+{
+    DWORD structSize;
+    CGContextRef cgContext;
+    LPCTSTR text;
+    int length;
+    POINT pt;
+    const WebFontDescription* description;
+    CGColorRef color;
+    int underlinedIndex;
+    bool drawAsPassword;
+    int overrideSmoothingLevel; // pass in -1 if caller does not want to override smoothing level
+};
+
 void DrawTextAtPoint(CGContextRef, LPCTSTR text, int length, POINT, const WebFontDescription&, CGColorRef, int underlinedIndex = -1, bool drawAsPassword = false);
+void WebDrawText(WebTextRenderInfo*);
 float TextFloatWidth(LPCTSTR text, int length, const WebFontDescription&);
 void FontMetrics(const WebFontDescription&, int* ascent, int* descent, int* lineSpacing);