aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-26 11:41:27 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-26 11:41:27 +0000
commite70e400bac1ee4c9743c1f0c3c7444e0f3c35bfc (patch)
tree27f1bf93cb4ab9e6fa9f371a4d5d3822d3a265a7 /src/ports
parenteebb4a2681af98047a804b6f8d4d76e0cd40ab76 (diff)
checkpoint for better 8bit->5bit reduction (disable for now)
git-svn-id: http://skia.googlecode.com/svn/trunk@1429 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontHost_mac_coretext.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp
index e6378777ce..7898ec3434 100644
--- a/src/ports/SkFontHost_mac_coretext.cpp
+++ b/src/ports/SkFontHost_mac_coretext.cpp
@@ -400,6 +400,28 @@ static void bytes_to_bits(uint8_t dst[], const uint8_t src[], int count) {
}
}
+#if 1
+static inline int r32_to_16(int x) { return SkR32ToR16(x); }
+static inline int g32_to_16(int x) { return SkG32ToG16(x); }
+static inline int b32_to_16(int x) { return SkB32ToB16(x); }
+#else
+static inline int round8to5(int x) {
+ return (x + 3 - (x >> 5) + (x >> 7)) >> 3;
+}
+static inline int round8to6(int x) {
+ int xx = (x + 1 - (x >> 6) + (x >> 7)) >> 2;
+ SkASSERT((unsigned)xx <= 63);
+
+ int ix = x >> 2;
+ SkASSERT(SkAbs32(xx - ix) <= 1);
+ return xx;
+}
+
+static inline int r32_to_16(int x) { return round8to5(x); }
+static inline int g32_to_16(int x) { return round8to6(x); }
+static inline int b32_to_16(int x) { return round8to5(x); }
+#endif
+
static inline uint16_t rgb_to_lcd16(uint32_t rgb) {
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
@@ -411,7 +433,7 @@ static inline uint16_t rgb_to_lcd16(uint32_t rgb) {
g = 255 - g;
b = 255 - b;
- return SkPackRGB16(SkR32ToR16(r), SkG32ToG16(g), SkB32ToB16(b));
+ return SkPackRGB16(r32_to_16(r), g32_to_16(g), b32_to_16(b));
}
#define BITMAP_INFO_RGB (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host)