diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-22 20:49:22 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-22 20:49:22 +0000 |
commit | 484561ffde0b605b82beceb448a7334493c4e5fe (patch) | |
tree | 9fc18dff84aa697ad47e4b291dd78da49f95ba91 /src/core | |
parent | 2b49cc8422231cfa56790887f211604628694639 (diff) |
improve accuracy for luminance coefficients
rebaseline image in response to that.
git-svn-id: http://skia.googlecode.com/svn/trunk@2735 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPaint.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 5f5514dbe7..5ed22fd91f 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1289,10 +1289,16 @@ static unsigned computeLuminance(const SkPaint& paint) { int r = SkColorGetR(c); int g = SkColorGetG(c); int b = SkColorGetB(c); - // compute luminance to 11 bits (0..0x3F) - int luminance = r * 2 + g * 5 + b; - SkASSERT(luminance <= 0x7FF); + // compute luminance + // R=0.2126 G=0.7152 B=0.0722 + // scaling by 127 yields 27, 92, 9 +#if 1 + int luminance = r * 27 + g * 92 + b * 9; + luminance >>= 15 - SkScalerContext::kLuminance_Bits; +#else + int luminance = r * 2 + g * 5 + b * 1; luminance >>= 11 - SkScalerContext::kLuminance_Bits; +#endif SkASSERT(luminance <= SkScalerContext::kLuminance_Max); return luminance; } |