Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | From: David Zbarsky <dzbarsky@gmail.com> |
michael@0 | 2 | Bug 766017 - Fix some skia warnings r=gw280 |
michael@0 | 3 | |
michael@0 | 4 | diff --git a/gfx/skia/include/utils/mac/SkCGUtils.h b/gfx/skia/include/utils/mac/SkCGUtils.h |
michael@0 | 5 | --- a/gfx/skia/include/utils/mac/SkCGUtils.h |
michael@0 | 6 | +++ b/gfx/skia/include/utils/mac/SkCGUtils.h |
michael@0 | 7 | @@ -39,18 +39,16 @@ static inline CGImageRef SkCreateCGImage |
michael@0 | 8 | /** |
michael@0 | 9 | * Draw the bitmap into the specified CG context. The bitmap will be converted |
michael@0 | 10 | * to a CGImage using the generic RGB colorspace. (x,y) specifies the position |
michael@0 | 11 | * of the top-left corner of the bitmap. The bitmap is converted using the |
michael@0 | 12 | * colorspace returned by CGColorSpaceCreateDeviceRGB() |
michael@0 | 13 | */ |
michael@0 | 14 | void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y); |
michael@0 | 15 | |
michael@0 | 16 | -bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output); |
michael@0 | 17 | - |
michael@0 | 18 | /** |
michael@0 | 19 | * Return a provider that wraps the specified stream. It will become an |
michael@0 | 20 | * owner of the stream, so the caller must still manage its ownership. |
michael@0 | 21 | * |
michael@0 | 22 | * To hand-off ownership of the stream to the provider, the caller must do |
michael@0 | 23 | * something like the following: |
michael@0 | 24 | * |
michael@0 | 25 | * SkStream* stream = new ...; |
michael@0 | 26 | diff --git a/gfx/skia/src/core/SkAAClip.cpp b/gfx/skia/src/core/SkAAClip.cpp |
michael@0 | 27 | --- a/gfx/skia/src/core/SkAAClip.cpp |
michael@0 | 28 | +++ b/gfx/skia/src/core/SkAAClip.cpp |
michael@0 | 29 | @@ -246,17 +246,17 @@ static void count_left_right_zeros(const |
michael@0 | 30 | zeros = 0; |
michael@0 | 31 | } |
michael@0 | 32 | row += 2; |
michael@0 | 33 | width -= n; |
michael@0 | 34 | } |
michael@0 | 35 | *riteZ = zeros; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | -#ifdef SK_DEBUG |
michael@0 | 39 | +#if 0 |
michael@0 | 40 | static void test_count_left_right_zeros() { |
michael@0 | 41 | static bool gOnce; |
michael@0 | 42 | if (gOnce) { |
michael@0 | 43 | return; |
michael@0 | 44 | } |
michael@0 | 45 | gOnce = true; |
michael@0 | 46 | |
michael@0 | 47 | const uint8_t data0[] = { 0, 0, 10, 0xFF }; |
michael@0 | 48 | @@ -1319,22 +1319,16 @@ bool SkAAClip::setPath(const SkPath& pat |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 52 | |
michael@0 | 53 | typedef void (*RowProc)(SkAAClip::Builder&, int bottom, |
michael@0 | 54 | const uint8_t* rowA, const SkIRect& rectA, |
michael@0 | 55 | const uint8_t* rowB, const SkIRect& rectB); |
michael@0 | 56 | |
michael@0 | 57 | -static void sectRowProc(SkAAClip::Builder& builder, int bottom, |
michael@0 | 58 | - const uint8_t* rowA, const SkIRect& rectA, |
michael@0 | 59 | - const uint8_t* rowB, const SkIRect& rectB) { |
michael@0 | 60 | - |
michael@0 | 61 | -} |
michael@0 | 62 | - |
michael@0 | 63 | typedef U8CPU (*AlphaProc)(U8CPU alphaA, U8CPU alphaB); |
michael@0 | 64 | |
michael@0 | 65 | static U8CPU sectAlphaProc(U8CPU alphaA, U8CPU alphaB) { |
michael@0 | 66 | // Multiply |
michael@0 | 67 | return SkMulDiv255Round(alphaA, alphaB); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | static U8CPU unionAlphaProc(U8CPU alphaA, U8CPU alphaB) { |
michael@0 | 71 | @@ -1429,31 +1423,16 @@ private: |
michael@0 | 72 | static void adjust_row(RowIter& iter, int& leftA, int& riteA, int rite) { |
michael@0 | 73 | if (rite == riteA) { |
michael@0 | 74 | iter.next(); |
michael@0 | 75 | leftA = iter.left(); |
michael@0 | 76 | riteA = iter.right(); |
michael@0 | 77 | } |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | -static bool intersect(int& min, int& max, int boundsMin, int boundsMax) { |
michael@0 | 81 | - SkASSERT(min < max); |
michael@0 | 82 | - SkASSERT(boundsMin < boundsMax); |
michael@0 | 83 | - if (min >= boundsMax || max <= boundsMin) { |
michael@0 | 84 | - return false; |
michael@0 | 85 | - } |
michael@0 | 86 | - if (min < boundsMin) { |
michael@0 | 87 | - min = boundsMin; |
michael@0 | 88 | - } |
michael@0 | 89 | - if (max > boundsMax) { |
michael@0 | 90 | - max = boundsMax; |
michael@0 | 91 | - } |
michael@0 | 92 | - return true; |
michael@0 | 93 | -} |
michael@0 | 94 | - |
michael@0 | 95 | static void operatorX(SkAAClip::Builder& builder, int lastY, |
michael@0 | 96 | RowIter& iterA, RowIter& iterB, |
michael@0 | 97 | AlphaProc proc, const SkIRect& bounds) { |
michael@0 | 98 | int leftA = iterA.left(); |
michael@0 | 99 | int riteA = iterA.right(); |
michael@0 | 100 | int leftB = iterB.left(); |
michael@0 | 101 | int riteB = iterB.right(); |
michael@0 | 102 | |
michael@0 | 103 | @@ -1970,34 +1949,33 @@ static void small_bzero(void* dst, size_ |
michael@0 | 104 | static inline uint8_t mergeOne(uint8_t value, unsigned alpha) { |
michael@0 | 105 | return SkMulDiv255Round(value, alpha); |
michael@0 | 106 | } |
michael@0 | 107 | static inline uint16_t mergeOne(uint16_t value, unsigned alpha) { |
michael@0 | 108 | unsigned r = SkGetPackedR16(value); |
michael@0 | 109 | unsigned g = SkGetPackedG16(value); |
michael@0 | 110 | unsigned b = SkGetPackedB16(value); |
michael@0 | 111 | return SkPackRGB16(SkMulDiv255Round(r, alpha), |
michael@0 | 112 | - SkMulDiv255Round(r, alpha), |
michael@0 | 113 | - SkMulDiv255Round(r, alpha)); |
michael@0 | 114 | + SkMulDiv255Round(g, alpha), |
michael@0 | 115 | + SkMulDiv255Round(b, alpha)); |
michael@0 | 116 | } |
michael@0 | 117 | static inline SkPMColor mergeOne(SkPMColor value, unsigned alpha) { |
michael@0 | 118 | unsigned a = SkGetPackedA32(value); |
michael@0 | 119 | unsigned r = SkGetPackedR32(value); |
michael@0 | 120 | unsigned g = SkGetPackedG32(value); |
michael@0 | 121 | unsigned b = SkGetPackedB32(value); |
michael@0 | 122 | return SkPackARGB32(SkMulDiv255Round(a, alpha), |
michael@0 | 123 | SkMulDiv255Round(r, alpha), |
michael@0 | 124 | SkMulDiv255Round(g, alpha), |
michael@0 | 125 | SkMulDiv255Round(b, alpha)); |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | template <typename T> void mergeT(const T* SK_RESTRICT src, int srcN, |
michael@0 | 129 | const uint8_t* SK_RESTRICT row, int rowN, |
michael@0 | 130 | T* SK_RESTRICT dst) { |
michael@0 | 131 | - SkDEBUGCODE(int accumulated = 0;) |
michael@0 | 132 | for (;;) { |
michael@0 | 133 | SkASSERT(rowN > 0); |
michael@0 | 134 | SkASSERT(srcN > 0); |
michael@0 | 135 | |
michael@0 | 136 | int n = SkMin32(rowN, srcN); |
michael@0 | 137 | unsigned rowA = row[1]; |
michael@0 | 138 | if (0xFF == rowA) { |
michael@0 | 139 | small_memcpy(dst, src, n * sizeof(T)); |
michael@0 | 140 | diff --git a/gfx/skia/src/core/SkBlitMask_D32.cpp b/gfx/skia/src/core/SkBlitMask_D32.cpp |
michael@0 | 141 | --- a/gfx/skia/src/core/SkBlitMask_D32.cpp |
michael@0 | 142 | +++ b/gfx/skia/src/core/SkBlitMask_D32.cpp |
michael@0 | 143 | @@ -268,107 +268,49 @@ bool SkBlitMask::BlitColor(const SkBitma |
michael@0 | 144 | return true; |
michael@0 | 145 | } |
michael@0 | 146 | return false; |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 150 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 151 | |
michael@0 | 152 | -static void BW_RowProc_Blend(SkPMColor* SK_RESTRICT dst, |
michael@0 | 153 | - const uint8_t* SK_RESTRICT mask, |
michael@0 | 154 | - const SkPMColor* SK_RESTRICT src, int count) { |
michael@0 | 155 | - int i, octuple = (count + 7) >> 3; |
michael@0 | 156 | - for (i = 0; i < octuple; ++i) { |
michael@0 | 157 | - int m = *mask++; |
michael@0 | 158 | - if (m & 0x80) { dst[0] = SkPMSrcOver(src[0], dst[0]); } |
michael@0 | 159 | - if (m & 0x40) { dst[1] = SkPMSrcOver(src[1], dst[1]); } |
michael@0 | 160 | - if (m & 0x20) { dst[2] = SkPMSrcOver(src[2], dst[2]); } |
michael@0 | 161 | - if (m & 0x10) { dst[3] = SkPMSrcOver(src[3], dst[3]); } |
michael@0 | 162 | - if (m & 0x08) { dst[4] = SkPMSrcOver(src[4], dst[4]); } |
michael@0 | 163 | - if (m & 0x04) { dst[5] = SkPMSrcOver(src[5], dst[5]); } |
michael@0 | 164 | - if (m & 0x02) { dst[6] = SkPMSrcOver(src[6], dst[6]); } |
michael@0 | 165 | - if (m & 0x01) { dst[7] = SkPMSrcOver(src[7], dst[7]); } |
michael@0 | 166 | - src += 8; |
michael@0 | 167 | - dst += 8; |
michael@0 | 168 | - } |
michael@0 | 169 | - count &= 7; |
michael@0 | 170 | - if (count > 0) { |
michael@0 | 171 | - int m = *mask; |
michael@0 | 172 | - do { |
michael@0 | 173 | - if (m & 0x80) { dst[0] = SkPMSrcOver(src[0], dst[0]); } |
michael@0 | 174 | - m <<= 1; |
michael@0 | 175 | - src += 1; |
michael@0 | 176 | - dst += 1; |
michael@0 | 177 | - } while (--count > 0); |
michael@0 | 178 | - } |
michael@0 | 179 | -} |
michael@0 | 180 | - |
michael@0 | 181 | -static void BW_RowProc_Opaque(SkPMColor* SK_RESTRICT dst, |
michael@0 | 182 | - const uint8_t* SK_RESTRICT mask, |
michael@0 | 183 | - const SkPMColor* SK_RESTRICT src, int count) { |
michael@0 | 184 | - int i, octuple = (count + 7) >> 3; |
michael@0 | 185 | - for (i = 0; i < octuple; ++i) { |
michael@0 | 186 | - int m = *mask++; |
michael@0 | 187 | - if (m & 0x80) { dst[0] = src[0]; } |
michael@0 | 188 | - if (m & 0x40) { dst[1] = src[1]; } |
michael@0 | 189 | - if (m & 0x20) { dst[2] = src[2]; } |
michael@0 | 190 | - if (m & 0x10) { dst[3] = src[3]; } |
michael@0 | 191 | - if (m & 0x08) { dst[4] = src[4]; } |
michael@0 | 192 | - if (m & 0x04) { dst[5] = src[5]; } |
michael@0 | 193 | - if (m & 0x02) { dst[6] = src[6]; } |
michael@0 | 194 | - if (m & 0x01) { dst[7] = src[7]; } |
michael@0 | 195 | - src += 8; |
michael@0 | 196 | - dst += 8; |
michael@0 | 197 | - } |
michael@0 | 198 | - count &= 7; |
michael@0 | 199 | - if (count > 0) { |
michael@0 | 200 | - int m = *mask; |
michael@0 | 201 | - do { |
michael@0 | 202 | - if (m & 0x80) { dst[0] = SkPMSrcOver(src[0], dst[0]); } |
michael@0 | 203 | - m <<= 1; |
michael@0 | 204 | - src += 1; |
michael@0 | 205 | - dst += 1; |
michael@0 | 206 | - } while (--count > 0); |
michael@0 | 207 | - } |
michael@0 | 208 | -} |
michael@0 | 209 | - |
michael@0 | 210 | static void A8_RowProc_Blend(SkPMColor* SK_RESTRICT dst, |
michael@0 | 211 | const uint8_t* SK_RESTRICT mask, |
michael@0 | 212 | const SkPMColor* SK_RESTRICT src, int count) { |
michael@0 | 213 | for (int i = 0; i < count; ++i) { |
michael@0 | 214 | if (mask[i]) { |
michael@0 | 215 | dst[i] = SkBlendARGB32(src[i], dst[i], mask[i]); |
michael@0 | 216 | } |
michael@0 | 217 | } |
michael@0 | 218 | } |
michael@0 | 219 | |
michael@0 | 220 | // expand the steps that SkAlphaMulQ performs, but this way we can |
michael@0 | 221 | -// exand.. add.. combine |
michael@0 | 222 | +// expand.. add.. combine |
michael@0 | 223 | // instead of |
michael@0 | 224 | // expand..combine add expand..combine |
michael@0 | 225 | // |
michael@0 | 226 | #define EXPAND0(v, m, s) ((v) & (m)) * (s) |
michael@0 | 227 | #define EXPAND1(v, m, s) (((v) >> 8) & (m)) * (s) |
michael@0 | 228 | #define COMBINE(e0, e1, m) ((((e0) >> 8) & (m)) | ((e1) & ~(m))) |
michael@0 | 229 | |
michael@0 | 230 | static void A8_RowProc_Opaque(SkPMColor* SK_RESTRICT dst, |
michael@0 | 231 | const uint8_t* SK_RESTRICT mask, |
michael@0 | 232 | const SkPMColor* SK_RESTRICT src, int count) { |
michael@0 | 233 | - const uint32_t rbmask = gMask_00FF00FF; |
michael@0 | 234 | for (int i = 0; i < count; ++i) { |
michael@0 | 235 | int m = mask[i]; |
michael@0 | 236 | if (m) { |
michael@0 | 237 | m += (m >> 7); |
michael@0 | 238 | #if 1 |
michael@0 | 239 | // this is slightly slower than the expand/combine version, but it |
michael@0 | 240 | // is much closer to the old results, so we use it for now to reduce |
michael@0 | 241 | // rebaselining. |
michael@0 | 242 | dst[i] = SkAlphaMulQ(src[i], m) + SkAlphaMulQ(dst[i], 256 - m); |
michael@0 | 243 | #else |
michael@0 | 244 | + const uint32_t rbmask = gMask_00FF00FF; |
michael@0 | 245 | uint32_t v = src[i]; |
michael@0 | 246 | uint32_t s0 = EXPAND0(v, rbmask, m); |
michael@0 | 247 | uint32_t s1 = EXPAND1(v, rbmask, m); |
michael@0 | 248 | v = dst[i]; |
michael@0 | 249 | uint32_t d0 = EXPAND0(v, rbmask, m); |
michael@0 | 250 | uint32_t d1 = EXPAND1(v, rbmask, m); |
michael@0 | 251 | dst[i] = COMBINE(s0 + d0, s1 + d1, rbmask); |
michael@0 | 252 | #endif |
michael@0 | 253 | @@ -559,17 +501,17 @@ SkBlitMask::RowProc SkBlitMask::RowFacto |
michael@0 | 254 | // make this opt-in until chrome can rebaseline |
michael@0 | 255 | RowProc proc = PlatformRowProcs(config, format, flags); |
michael@0 | 256 | if (proc) { |
michael@0 | 257 | return proc; |
michael@0 | 258 | } |
michael@0 | 259 | |
michael@0 | 260 | static const RowProc gProcs[] = { |
michael@0 | 261 | // need X coordinate to handle BW |
michael@0 | 262 | - NULL, NULL, //(RowProc)BW_RowProc_Blend, (RowProc)BW_RowProc_Opaque, |
michael@0 | 263 | + NULL, NULL, |
michael@0 | 264 | (RowProc)A8_RowProc_Blend, (RowProc)A8_RowProc_Opaque, |
michael@0 | 265 | (RowProc)LCD16_RowProc_Blend, (RowProc)LCD16_RowProc_Opaque, |
michael@0 | 266 | (RowProc)LCD32_RowProc_Blend, (RowProc)LCD32_RowProc_Opaque, |
michael@0 | 267 | }; |
michael@0 | 268 | |
michael@0 | 269 | int index; |
michael@0 | 270 | switch (config) { |
michael@0 | 271 | case SkBitmap::kARGB_8888_Config: |
michael@0 | 272 | diff --git a/gfx/skia/src/core/SkConcaveToTriangles.cpp b/gfx/skia/src/core/SkConcaveToTriangles.cpp |
michael@0 | 273 | --- a/gfx/skia/src/core/SkConcaveToTriangles.cpp |
michael@0 | 274 | +++ b/gfx/skia/src/core/SkConcaveToTriangles.cpp |
michael@0 | 275 | @@ -37,17 +37,16 @@ |
michael@0 | 276 | #include "SkTDArray.h" |
michael@0 | 277 | #include "SkGeometry.h" |
michael@0 | 278 | #include "SkTSort.h" |
michael@0 | 279 | |
michael@0 | 280 | // This is used to prevent runaway code bugs, and can probably be removed after |
michael@0 | 281 | // the code has been proven robust. |
michael@0 | 282 | #define kMaxCount 1000 |
michael@0 | 283 | |
michael@0 | 284 | -#define DEBUG |
michael@0 | 285 | #ifdef DEBUG |
michael@0 | 286 | //------------------------------------------------------------------------------ |
michael@0 | 287 | // Debugging support |
michael@0 | 288 | //------------------------------------------------------------------------------ |
michael@0 | 289 | |
michael@0 | 290 | #include <cstdio> |
michael@0 | 291 | #include <stdarg.h> |
michael@0 | 292 | |
michael@0 | 293 | diff --git a/gfx/skia/src/core/SkPath.cpp b/gfx/skia/src/core/SkPath.cpp |
michael@0 | 294 | --- a/gfx/skia/src/core/SkPath.cpp |
michael@0 | 295 | +++ b/gfx/skia/src/core/SkPath.cpp |
michael@0 | 296 | @@ -469,17 +469,16 @@ void SkPath::incReserve(U16CPU inc) { |
michael@0 | 297 | fPts.setReserve(fPts.count() + inc); |
michael@0 | 298 | |
michael@0 | 299 | SkDEBUGCODE(this->validate();) |
michael@0 | 300 | } |
michael@0 | 301 | |
michael@0 | 302 | void SkPath::moveTo(SkScalar x, SkScalar y) { |
michael@0 | 303 | SkDEBUGCODE(this->validate();) |
michael@0 | 304 | |
michael@0 | 305 | - int vc = fVerbs.count(); |
michael@0 | 306 | SkPoint* pt; |
michael@0 | 307 | |
michael@0 | 308 | // remember our index |
michael@0 | 309 | fLastMoveToIndex = fPts.count(); |
michael@0 | 310 | |
michael@0 | 311 | pt = fPts.append(); |
michael@0 | 312 | *fVerbs.append() = kMove_Verb; |
michael@0 | 313 | pt->set(x, y); |
michael@0 | 314 | @@ -1163,17 +1162,16 @@ void SkPath::reversePathTo(const SkPath& |
michael@0 | 315 | } |
michael@0 | 316 | pts -= gPtsInVerb[verbs[i]]; |
michael@0 | 317 | } |
michael@0 | 318 | } |
michael@0 | 319 | |
michael@0 | 320 | void SkPath::reverseAddPath(const SkPath& src) { |
michael@0 | 321 | this->incReserve(src.fPts.count()); |
michael@0 | 322 | |
michael@0 | 323 | - const SkPoint* startPts = src.fPts.begin(); |
michael@0 | 324 | const SkPoint* pts = src.fPts.end(); |
michael@0 | 325 | const uint8_t* startVerbs = src.fVerbs.begin(); |
michael@0 | 326 | const uint8_t* verbs = src.fVerbs.end(); |
michael@0 | 327 | |
michael@0 | 328 | fIsOval = false; |
michael@0 | 329 | |
michael@0 | 330 | bool needMove = true; |
michael@0 | 331 | bool needClose = false; |
michael@0 | 332 | diff --git a/gfx/skia/src/core/SkRegion.cpp b/gfx/skia/src/core/SkRegion.cpp |
michael@0 | 333 | --- a/gfx/skia/src/core/SkRegion.cpp |
michael@0 | 334 | +++ b/gfx/skia/src/core/SkRegion.cpp |
michael@0 | 335 | @@ -920,20 +920,16 @@ static int operate(const SkRegion::RunTy |
michael@0 | 336 | /* Given count RunTypes in a complex region, return the worst case number of |
michael@0 | 337 | logical intervals that represents (i.e. number of rects that would be |
michael@0 | 338 | returned from the iterator). |
michael@0 | 339 | |
michael@0 | 340 | We could just return count/2, since there must be at least 2 values per |
michael@0 | 341 | interval, but we can first trim off the const overhead of the initial TOP |
michael@0 | 342 | value, plus the final BOTTOM + 2 sentinels. |
michael@0 | 343 | */ |
michael@0 | 344 | -static int count_to_intervals(int count) { |
michael@0 | 345 | - SkASSERT(count >= 6); // a single rect is 6 values |
michael@0 | 346 | - return (count - 4) >> 1; |
michael@0 | 347 | -} |
michael@0 | 348 | |
michael@0 | 349 | /* Given a number of intervals, what is the worst case representation of that |
michael@0 | 350 | many intervals? |
michael@0 | 351 | |
michael@0 | 352 | Worst case (from a storage perspective), is a vertical stack of single |
michael@0 | 353 | intervals: TOP + N * (BOTTOM INTERVALCOUNT LEFT RIGHT SENTINEL) + SENTINEL |
michael@0 | 354 | */ |
michael@0 | 355 | static int intervals_to_count(int intervals) { |
michael@0 | 356 | diff --git a/gfx/skia/src/core/SkScalerContext.cpp b/gfx/skia/src/core/SkScalerContext.cpp |
michael@0 | 357 | --- a/gfx/skia/src/core/SkScalerContext.cpp |
michael@0 | 358 | +++ b/gfx/skia/src/core/SkScalerContext.cpp |
michael@0 | 359 | @@ -336,44 +336,16 @@ SK_ERROR: |
michael@0 | 360 | glyph->fTop = 0; |
michael@0 | 361 | glyph->fWidth = 0; |
michael@0 | 362 | glyph->fHeight = 0; |
michael@0 | 363 | // put a valid value here, in case it was earlier set to |
michael@0 | 364 | // MASK_FORMAT_JUST_ADVANCE |
michael@0 | 365 | glyph->fMaskFormat = fRec.fMaskFormat; |
michael@0 | 366 | } |
michael@0 | 367 | |
michael@0 | 368 | -static bool isLCD(const SkScalerContext::Rec& rec) { |
michael@0 | 369 | - return SkMask::kLCD16_Format == rec.fMaskFormat || |
michael@0 | 370 | - SkMask::kLCD32_Format == rec.fMaskFormat; |
michael@0 | 371 | -} |
michael@0 | 372 | - |
michael@0 | 373 | -static uint16_t a8_to_rgb565(unsigned a8) { |
michael@0 | 374 | - return SkPackRGB16(a8 >> 3, a8 >> 2, a8 >> 3); |
michael@0 | 375 | -} |
michael@0 | 376 | - |
michael@0 | 377 | -static void copyToLCD16(const SkBitmap& src, const SkMask& dst) { |
michael@0 | 378 | - SkASSERT(SkBitmap::kA8_Config == src.config()); |
michael@0 | 379 | - SkASSERT(SkMask::kLCD16_Format == dst.fFormat); |
michael@0 | 380 | - |
michael@0 | 381 | - const int width = dst.fBounds.width(); |
michael@0 | 382 | - const int height = dst.fBounds.height(); |
michael@0 | 383 | - const uint8_t* srcP = src.getAddr8(0, 0); |
michael@0 | 384 | - size_t srcRB = src.rowBytes(); |
michael@0 | 385 | - uint16_t* dstP = (uint16_t*)dst.fImage; |
michael@0 | 386 | - size_t dstRB = dst.fRowBytes; |
michael@0 | 387 | - for (int y = 0; y < height; ++y) { |
michael@0 | 388 | - for (int x = 0; x < width; ++x) { |
michael@0 | 389 | - dstP[x] = a8_to_rgb565(srcP[x]); |
michael@0 | 390 | - } |
michael@0 | 391 | - srcP += srcRB; |
michael@0 | 392 | - dstP = (uint16_t*)((char*)dstP + dstRB); |
michael@0 | 393 | - } |
michael@0 | 394 | -} |
michael@0 | 395 | - |
michael@0 | 396 | #define SK_FREETYPE_LCD_LERP 160 |
michael@0 | 397 | |
michael@0 | 398 | static int lerp(int start, int end) { |
michael@0 | 399 | SkASSERT((unsigned)SK_FREETYPE_LCD_LERP <= 256); |
michael@0 | 400 | return start + ((end - start) * (SK_FREETYPE_LCD_LERP) >> 8); |
michael@0 | 401 | } |
michael@0 | 402 | |
michael@0 | 403 | static uint16_t packLCD16(unsigned r, unsigned g, unsigned b) { |
michael@0 | 404 | diff --git a/gfx/skia/src/core/SkScan_AntiPath.cpp b/gfx/skia/src/core/SkScan_AntiPath.cpp |
michael@0 | 405 | --- a/gfx/skia/src/core/SkScan_AntiPath.cpp |
michael@0 | 406 | +++ b/gfx/skia/src/core/SkScan_AntiPath.cpp |
michael@0 | 407 | @@ -230,52 +230,16 @@ void SuperBlitter::blitH(int x, int y, i |
michael@0 | 408 | fOffsetX); |
michael@0 | 409 | |
michael@0 | 410 | #ifdef SK_DEBUG |
michael@0 | 411 | fRuns.assertValid(y & MASK, (1 << (8 - SHIFT))); |
michael@0 | 412 | fCurrX = x + width; |
michael@0 | 413 | #endif |
michael@0 | 414 | } |
michael@0 | 415 | |
michael@0 | 416 | -static void set_left_rite_runs(SkAlphaRuns& runs, int ileft, U8CPU leftA, |
michael@0 | 417 | - int n, U8CPU riteA) { |
michael@0 | 418 | - SkASSERT(leftA <= 0xFF); |
michael@0 | 419 | - SkASSERT(riteA <= 0xFF); |
michael@0 | 420 | - |
michael@0 | 421 | - int16_t* run = runs.fRuns; |
michael@0 | 422 | - uint8_t* aa = runs.fAlpha; |
michael@0 | 423 | - |
michael@0 | 424 | - if (ileft > 0) { |
michael@0 | 425 | - run[0] = ileft; |
michael@0 | 426 | - aa[0] = 0; |
michael@0 | 427 | - run += ileft; |
michael@0 | 428 | - aa += ileft; |
michael@0 | 429 | - } |
michael@0 | 430 | - |
michael@0 | 431 | - SkASSERT(leftA < 0xFF); |
michael@0 | 432 | - if (leftA > 0) { |
michael@0 | 433 | - *run++ = 1; |
michael@0 | 434 | - *aa++ = leftA; |
michael@0 | 435 | - } |
michael@0 | 436 | - |
michael@0 | 437 | - if (n > 0) { |
michael@0 | 438 | - run[0] = n; |
michael@0 | 439 | - aa[0] = 0xFF; |
michael@0 | 440 | - run += n; |
michael@0 | 441 | - aa += n; |
michael@0 | 442 | - } |
michael@0 | 443 | - |
michael@0 | 444 | - SkASSERT(riteA < 0xFF); |
michael@0 | 445 | - if (riteA > 0) { |
michael@0 | 446 | - *run++ = 1; |
michael@0 | 447 | - *aa++ = riteA; |
michael@0 | 448 | - } |
michael@0 | 449 | - run[0] = 0; |
michael@0 | 450 | -} |
michael@0 | 451 | - |
michael@0 | 452 | void SuperBlitter::blitRect(int x, int y, int width, int height) { |
michael@0 | 453 | SkASSERT(width > 0); |
michael@0 | 454 | SkASSERT(height > 0); |
michael@0 | 455 | |
michael@0 | 456 | // blit leading rows |
michael@0 | 457 | while ((y & MASK)) { |
michael@0 | 458 | this->blitH(x, y++, width); |
michael@0 | 459 | if (--height <= 0) { |
michael@0 | 460 | diff --git a/gfx/skia/src/effects/SkGradientShader.cpp b/gfx/skia/src/effects/SkGradientShader.cpp |
michael@0 | 461 | --- a/gfx/skia/src/effects/SkGradientShader.cpp |
michael@0 | 462 | +++ b/gfx/skia/src/effects/SkGradientShader.cpp |
michael@0 | 463 | @@ -865,45 +865,16 @@ bool Linear_Gradient::setContext(const S |
michael@0 | 464 | } while (0) |
michael@0 | 465 | |
michael@0 | 466 | namespace { |
michael@0 | 467 | |
michael@0 | 468 | typedef void (*LinearShadeProc)(TileProc proc, SkFixed dx, SkFixed fx, |
michael@0 | 469 | SkPMColor* dstC, const SkPMColor* cache, |
michael@0 | 470 | int toggle, int count); |
michael@0 | 471 | |
michael@0 | 472 | -// This function is deprecated, and will be replaced by |
michael@0 | 473 | -// shadeSpan_linear_vertical_lerp() once Chrome has been weaned off of it. |
michael@0 | 474 | -void shadeSpan_linear_vertical(TileProc proc, SkFixed dx, SkFixed fx, |
michael@0 | 475 | - SkPMColor* SK_RESTRICT dstC, |
michael@0 | 476 | - const SkPMColor* SK_RESTRICT cache, |
michael@0 | 477 | - int toggle, int count) { |
michael@0 | 478 | - if (proc == clamp_tileproc) { |
michael@0 | 479 | - // Read out clamp values from beginning/end of the cache. No need to lerp |
michael@0 | 480 | - // or dither |
michael@0 | 481 | - if (fx < 0) { |
michael@0 | 482 | - sk_memset32(dstC, cache[-1], count); |
michael@0 | 483 | - return; |
michael@0 | 484 | - } else if (fx > 0xFFFF) { |
michael@0 | 485 | - sk_memset32(dstC, cache[Gradient_Shader::kCache32Count * 2], count); |
michael@0 | 486 | - return; |
michael@0 | 487 | - } |
michael@0 | 488 | - } |
michael@0 | 489 | - |
michael@0 | 490 | - // We're a vertical gradient, so no change in a span. |
michael@0 | 491 | - // If colors change sharply across the gradient, dithering is |
michael@0 | 492 | - // insufficient (it subsamples the color space) and we need to lerp. |
michael@0 | 493 | - unsigned fullIndex = proc(fx); |
michael@0 | 494 | - unsigned fi = fullIndex >> (16 - Gradient_Shader::kCache32Bits); |
michael@0 | 495 | - sk_memset32_dither(dstC, |
michael@0 | 496 | - cache[toggle + fi], |
michael@0 | 497 | - cache[(toggle ^ Gradient_Shader::kDitherStride32) + fi], |
michael@0 | 498 | - count); |
michael@0 | 499 | -} |
michael@0 | 500 | - |
michael@0 | 501 | // Linear interpolation (lerp) is unnecessary if there are no sharp |
michael@0 | 502 | // discontinuities in the gradient - which must be true if there are |
michael@0 | 503 | // only 2 colors - but it's cheap. |
michael@0 | 504 | void shadeSpan_linear_vertical_lerp(TileProc proc, SkFixed dx, SkFixed fx, |
michael@0 | 505 | SkPMColor* SK_RESTRICT dstC, |
michael@0 | 506 | const SkPMColor* SK_RESTRICT cache, |
michael@0 | 507 | int toggle, int count) { |
michael@0 | 508 | if (proc == clamp_tileproc) { |
michael@0 | 509 | @@ -2131,16 +2102,18 @@ protected: |
michael@0 | 510 | buffer.writePoint(fCenter); |
michael@0 | 511 | } |
michael@0 | 512 | |
michael@0 | 513 | private: |
michael@0 | 514 | typedef Gradient_Shader INHERITED; |
michael@0 | 515 | const SkPoint fCenter; |
michael@0 | 516 | }; |
michael@0 | 517 | |
michael@0 | 518 | +#ifndef SK_SCALAR_IS_FLOAT |
michael@0 | 519 | + |
michael@0 | 520 | #ifdef COMPUTE_SWEEP_TABLE |
michael@0 | 521 | #define PI 3.14159265 |
michael@0 | 522 | static bool gSweepTableReady; |
michael@0 | 523 | static uint8_t gSweepTable[65]; |
michael@0 | 524 | |
michael@0 | 525 | /* Our table stores precomputed values for atan: [0...1] -> [0..PI/4] |
michael@0 | 526 | We scale the results to [0..32] |
michael@0 | 527 | */ |
michael@0 | 528 | @@ -2168,20 +2141,23 @@ static const uint8_t gSweepTable[] = { |
michael@0 | 529 | 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, 16, 17, 17, 18, 18, |
michael@0 | 530 | 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26, |
michael@0 | 531 | 26, 27, 27, 27, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, |
michael@0 | 532 | 32 |
michael@0 | 533 | }; |
michael@0 | 534 | static const uint8_t* build_sweep_table() { return gSweepTable; } |
michael@0 | 535 | #endif |
michael@0 | 536 | |
michael@0 | 537 | +#endif |
michael@0 | 538 | + |
michael@0 | 539 | // divide numer/denom, with a bias of 6bits. Assumes numer <= denom |
michael@0 | 540 | // and denom != 0. Since our table is 6bits big (+1), this is a nice fit. |
michael@0 | 541 | // Same as (but faster than) SkFixedDiv(numer, denom) >> 10 |
michael@0 | 542 | |
michael@0 | 543 | +#ifndef SK_SCALAR_IS_FLOAT |
michael@0 | 544 | //unsigned div_64(int numer, int denom); |
michael@0 | 545 | static unsigned div_64(int numer, int denom) { |
michael@0 | 546 | SkASSERT(numer <= denom); |
michael@0 | 547 | SkASSERT(numer > 0); |
michael@0 | 548 | SkASSERT(denom > 0); |
michael@0 | 549 | |
michael@0 | 550 | int nbits = SkCLZ(numer); |
michael@0 | 551 | int dbits = SkCLZ(denom); |
michael@0 | 552 | @@ -2294,16 +2270,17 @@ static unsigned atan_0_90(SkFixed y, SkF |
michael@0 | 553 | result = 64 - result; |
michael@0 | 554 | // pin to 63 |
michael@0 | 555 | result -= result >> 6; |
michael@0 | 556 | } |
michael@0 | 557 | |
michael@0 | 558 | SkASSERT(result <= 63); |
michael@0 | 559 | return result; |
michael@0 | 560 | } |
michael@0 | 561 | +#endif |
michael@0 | 562 | |
michael@0 | 563 | // returns angle in a circle [0..2PI) -> [0..255] |
michael@0 | 564 | #ifdef SK_SCALAR_IS_FLOAT |
michael@0 | 565 | static unsigned SkATan2_255(float y, float x) { |
michael@0 | 566 | // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); |
michael@0 | 567 | static const float g255Over2PI = 40.584510488433314f; |
michael@0 | 568 | |
michael@0 | 569 | float result = sk_float_atan2(y, x); |
michael@0 | 570 | diff --git a/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp b/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp |
michael@0 | 571 | --- a/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp |
michael@0 | 572 | +++ b/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp |
michael@0 | 573 | @@ -112,17 +112,17 @@ void BlitRect32_OpaqueWide_SSE2(SkPMColo |
michael@0 | 574 | } |
michael@0 | 575 | |
michael@0 | 576 | void ColorRect32_SSE2(SkPMColor* destination, |
michael@0 | 577 | int width, int height, |
michael@0 | 578 | size_t rowBytes, uint32_t color) { |
michael@0 | 579 | if (0 == height || 0 == width || 0 == color) { |
michael@0 | 580 | return; |
michael@0 | 581 | } |
michael@0 | 582 | - unsigned colorA = SkGetPackedA32(color); |
michael@0 | 583 | + //unsigned colorA = SkGetPackedA32(color); |
michael@0 | 584 | //if (255 == colorA) { |
michael@0 | 585 | //if (width < 31) { |
michael@0 | 586 | //BlitRect32_OpaqueNarrow_SSE2(destination, width, height, |
michael@0 | 587 | //rowBytes, color); |
michael@0 | 588 | //} else { |
michael@0 | 589 | //BlitRect32_OpaqueWide_SSE2(destination, width, height, |
michael@0 | 590 | //rowBytes, color); |
michael@0 | 591 | //} |
michael@0 | 592 | diff --git a/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp b/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp |
michael@0 | 593 | --- a/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp |
michael@0 | 594 | +++ b/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp |
michael@0 | 595 | @@ -75,20 +75,16 @@ static CGFloat CGRectGetMinY_inline(cons |
michael@0 | 596 | static CGFloat CGRectGetMaxY_inline(const CGRect& rect) { |
michael@0 | 597 | return rect.origin.y + rect.size.height; |
michael@0 | 598 | } |
michael@0 | 599 | |
michael@0 | 600 | static CGFloat CGRectGetWidth_inline(const CGRect& rect) { |
michael@0 | 601 | return rect.size.width; |
michael@0 | 602 | } |
michael@0 | 603 | |
michael@0 | 604 | -static CGFloat CGRectGetHeight(const CGRect& rect) { |
michael@0 | 605 | - return rect.size.height; |
michael@0 | 606 | -} |
michael@0 | 607 | - |
michael@0 | 608 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 609 | |
michael@0 | 610 | static void sk_memset_rect32(uint32_t* ptr, uint32_t value, size_t width, |
michael@0 | 611 | size_t height, size_t rowBytes) { |
michael@0 | 612 | SkASSERT(width); |
michael@0 | 613 | SkASSERT(width * sizeof(uint32_t) <= rowBytes); |
michael@0 | 614 | |
michael@0 | 615 | if (width >= 32) { |
michael@0 | 616 | @@ -125,28 +121,30 @@ static void sk_memset_rect32(uint32_t* p |
michael@0 | 617 | *ptr++ = value; |
michael@0 | 618 | } while (--w > 0); |
michael@0 | 619 | ptr = (uint32_t*)((char*)ptr + rowBytes); |
michael@0 | 620 | height -= 1; |
michael@0 | 621 | } |
michael@0 | 622 | } |
michael@0 | 623 | } |
michael@0 | 624 | |
michael@0 | 625 | +#if 0 |
michael@0 | 626 | // Potentially this should be made (1) public (2) optimized when width is small. |
michael@0 | 627 | // Also might want 16 and 32 bit version |
michael@0 | 628 | // |
michael@0 | 629 | static void sk_memset_rect(void* ptr, U8CPU byte, size_t width, size_t height, |
michael@0 | 630 | size_t rowBytes) { |
michael@0 | 631 | uint8_t* dst = (uint8_t*)ptr; |
michael@0 | 632 | while (height) { |
michael@0 | 633 | memset(dst, byte, width); |
michael@0 | 634 | dst += rowBytes; |
michael@0 | 635 | height -= 1; |
michael@0 | 636 | } |
michael@0 | 637 | } |
michael@0 | 638 | +#endif |
michael@0 | 639 | |
michael@0 | 640 | #include <sys/utsname.h> |
michael@0 | 641 | |
michael@0 | 642 | typedef uint32_t CGRGBPixel; |
michael@0 | 643 | |
michael@0 | 644 | static unsigned CGRGBPixel_getAlpha(CGRGBPixel pixel) { |
michael@0 | 645 | return pixel & 0xFF; |
michael@0 | 646 | } |
michael@0 | 647 | @@ -250,23 +248,16 @@ static CGAffineTransform MatrixToCGAffin |
michael@0 | 648 | return CGAffineTransformMake(ScalarToCG(matrix[SkMatrix::kMScaleX]) * sx, |
michael@0 | 649 | -ScalarToCG(matrix[SkMatrix::kMSkewY]) * sy, |
michael@0 | 650 | -ScalarToCG(matrix[SkMatrix::kMSkewX]) * sx, |
michael@0 | 651 | ScalarToCG(matrix[SkMatrix::kMScaleY]) * sy, |
michael@0 | 652 | ScalarToCG(matrix[SkMatrix::kMTransX]) * sx, |
michael@0 | 653 | ScalarToCG(matrix[SkMatrix::kMTransY]) * sy); |
michael@0 | 654 | } |
michael@0 | 655 | |
michael@0 | 656 | -static void CGAffineTransformToMatrix(const CGAffineTransform& xform, SkMatrix* matrix) { |
michael@0 | 657 | - matrix->setAll( |
michael@0 | 658 | - CGToScalar(xform.a), CGToScalar(xform.c), CGToScalar(xform.tx), |
michael@0 | 659 | - CGToScalar(xform.b), CGToScalar(xform.d), CGToScalar(xform.ty), |
michael@0 | 660 | - 0, 0, SK_Scalar1); |
michael@0 | 661 | -} |
michael@0 | 662 | - |
michael@0 | 663 | static SkScalar getFontScale(CGFontRef cgFont) { |
michael@0 | 664 | int unitsPerEm = CGFontGetUnitsPerEm(cgFont); |
michael@0 | 665 | return SkScalarInvert(SkIntToScalar(unitsPerEm)); |
michael@0 | 666 | } |
michael@0 | 667 | |
michael@0 | 668 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 669 | |
michael@0 | 670 | #define BITMAP_INFO_RGB (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host) |
michael@0 | 671 | @@ -1075,16 +1066,17 @@ static const uint8_t* getInverseTable(bo |
michael@0 | 672 | if (!gInited) { |
michael@0 | 673 | build_power_table(gWhiteTable, 1.5f); |
michael@0 | 674 | build_power_table(gTable, 2.2f); |
michael@0 | 675 | gInited = true; |
michael@0 | 676 | } |
michael@0 | 677 | return isWhite ? gWhiteTable : gTable; |
michael@0 | 678 | } |
michael@0 | 679 | |
michael@0 | 680 | +#ifdef SK_USE_COLOR_LUMINANCE |
michael@0 | 681 | static const uint8_t* getGammaTable(U8CPU luminance) { |
michael@0 | 682 | static uint8_t gGammaTables[4][256]; |
michael@0 | 683 | static bool gInited; |
michael@0 | 684 | if (!gInited) { |
michael@0 | 685 | #if 1 |
michael@0 | 686 | float start = 1.1; |
michael@0 | 687 | float stop = 2.1; |
michael@0 | 688 | for (int i = 0; i < 4; ++i) { |
michael@0 | 689 | @@ -1097,45 +1089,49 @@ static const uint8_t* getGammaTable(U8CP |
michael@0 | 690 | build_power_table(gGammaTables[2], 1); |
michael@0 | 691 | build_power_table(gGammaTables[3], 1); |
michael@0 | 692 | #endif |
michael@0 | 693 | gInited = true; |
michael@0 | 694 | } |
michael@0 | 695 | SkASSERT(0 == (luminance >> 8)); |
michael@0 | 696 | return gGammaTables[luminance >> 6]; |
michael@0 | 697 | } |
michael@0 | 698 | +#endif |
michael@0 | 699 | |
michael@0 | 700 | +#ifndef SK_USE_COLOR_LUMINANCE |
michael@0 | 701 | static void invertGammaMask(bool isWhite, CGRGBPixel rgb[], int width, |
michael@0 | 702 | int height, size_t rb) { |
michael@0 | 703 | const uint8_t* table = getInverseTable(isWhite); |
michael@0 | 704 | for (int y = 0; y < height; ++y) { |
michael@0 | 705 | for (int x = 0; x < width; ++x) { |
michael@0 | 706 | uint32_t c = rgb[x]; |
michael@0 | 707 | int r = (c >> 16) & 0xFF; |
michael@0 | 708 | int g = (c >> 8) & 0xFF; |
michael@0 | 709 | int b = (c >> 0) & 0xFF; |
michael@0 | 710 | rgb[x] = (table[r] << 16) | (table[g] << 8) | table[b]; |
michael@0 | 711 | } |
michael@0 | 712 | rgb = (CGRGBPixel*)((char*)rgb + rb); |
michael@0 | 713 | } |
michael@0 | 714 | } |
michael@0 | 715 | +#endif |
michael@0 | 716 | |
michael@0 | 717 | static void cgpixels_to_bits(uint8_t dst[], const CGRGBPixel src[], int count) { |
michael@0 | 718 | while (count > 0) { |
michael@0 | 719 | uint8_t mask = 0; |
michael@0 | 720 | for (int i = 7; i >= 0; --i) { |
michael@0 | 721 | mask |= (CGRGBPixel_getAlpha(*src++) >> 7) << i; |
michael@0 | 722 | if (0 == --count) { |
michael@0 | 723 | break; |
michael@0 | 724 | } |
michael@0 | 725 | } |
michael@0 | 726 | *dst++ = mask; |
michael@0 | 727 | } |
michael@0 | 728 | } |
michael@0 | 729 | |
michael@0 | 730 | +#ifdef SK_USE_COLOR_LUMINANCE |
michael@0 | 731 | static int lerpScale(int dst, int src, int scale) { |
michael@0 | 732 | return dst + (scale * (src - dst) >> 23); |
michael@0 | 733 | } |
michael@0 | 734 | |
michael@0 | 735 | static CGRGBPixel lerpPixel(CGRGBPixel dst, CGRGBPixel src, |
michael@0 | 736 | int scaleR, int scaleG, int scaleB) { |
michael@0 | 737 | int sr = (src >> 16) & 0xFF; |
michael@0 | 738 | int sg = (src >> 8) & 0xFF; |
michael@0 | 739 | @@ -1147,37 +1143,31 @@ static CGRGBPixel lerpPixel(CGRGBPixel d |
michael@0 | 740 | int rr = lerpScale(dr, sr, scaleR); |
michael@0 | 741 | int rg = lerpScale(dg, sg, scaleG); |
michael@0 | 742 | int rb = lerpScale(db, sb, scaleB); |
michael@0 | 743 | return (rr << 16) | (rg << 8) | rb; |
michael@0 | 744 | } |
michael@0 | 745 | |
michael@0 | 746 | static void lerpPixels(CGRGBPixel dst[], const CGRGBPixel src[], int width, |
michael@0 | 747 | int height, int rowBytes, int lumBits) { |
michael@0 | 748 | -#ifdef SK_USE_COLOR_LUMINANCE |
michael@0 | 749 | int scaleR = (1 << 23) * SkColorGetR(lumBits) / 0xFF; |
michael@0 | 750 | int scaleG = (1 << 23) * SkColorGetG(lumBits) / 0xFF; |
michael@0 | 751 | int scaleB = (1 << 23) * SkColorGetB(lumBits) / 0xFF; |
michael@0 | 752 | -#else |
michael@0 | 753 | - int scale = (1 << 23) * lumBits / SkScalerContext::kLuminance_Max; |
michael@0 | 754 | - int scaleR = scale; |
michael@0 | 755 | - int scaleG = scale; |
michael@0 | 756 | - int scaleB = scale; |
michael@0 | 757 | -#endif |
michael@0 | 758 | |
michael@0 | 759 | for (int y = 0; y < height; ++y) { |
michael@0 | 760 | for (int x = 0; x < width; ++x) { |
michael@0 | 761 | // bit-not the src, since it was drawn from black, so we need the |
michael@0 | 762 | // compliment of those bits |
michael@0 | 763 | dst[x] = lerpPixel(dst[x], ~src[x], scaleR, scaleG, scaleB); |
michael@0 | 764 | } |
michael@0 | 765 | src = (CGRGBPixel*)((char*)src + rowBytes); |
michael@0 | 766 | dst = (CGRGBPixel*)((char*)dst + rowBytes); |
michael@0 | 767 | } |
michael@0 | 768 | } |
michael@0 | 769 | +#endif |
michael@0 | 770 | |
michael@0 | 771 | #if 1 |
michael@0 | 772 | static inline int r32_to_16(int x) { return SkR32ToR16(x); } |
michael@0 | 773 | static inline int g32_to_16(int x) { return SkG32ToG16(x); } |
michael@0 | 774 | static inline int b32_to_16(int x) { return SkB32ToB16(x); } |
michael@0 | 775 | #else |
michael@0 | 776 | static inline int round8to5(int x) { |
michael@0 | 777 | return (x + 3 - (x >> 5) + (x >> 7)) >> 3; |
michael@0 | 778 | @@ -1212,22 +1202,21 @@ static inline uint32_t rgb_to_lcd32(CGRG |
michael@0 | 779 | return SkPackARGB32(0xFF, r, g, b); |
michael@0 | 780 | } |
michael@0 | 781 | |
michael@0 | 782 | #define BLACK_LUMINANCE_LIMIT 0x40 |
michael@0 | 783 | #define WHITE_LUMINANCE_LIMIT 0xA0 |
michael@0 | 784 | |
michael@0 | 785 | void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) { |
michael@0 | 786 | CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID(fBaseGlyphCount); |
michael@0 | 787 | - |
michael@0 | 788 | const bool isLCD = isLCDFormat(glyph.fMaskFormat); |
michael@0 | 789 | +#ifdef SK_USE_COLOR_LUMINANCE |
michael@0 | 790 | const bool isBW = SkMask::kBW_Format == glyph.fMaskFormat; |
michael@0 | 791 | const bool isA8 = !isLCD && !isBW; |
michael@0 | 792 | - |
michael@0 | 793 | -#ifdef SK_USE_COLOR_LUMINANCE |
michael@0 | 794 | + |
michael@0 | 795 | unsigned lumBits = fRec.getLuminanceColor(); |
michael@0 | 796 | uint32_t xorMask = 0; |
michael@0 | 797 | |
michael@0 | 798 | if (isA8) { |
michael@0 | 799 | // for A8, we just want a component (they're all the same) |
michael@0 | 800 | lumBits = SkColorGetR(lumBits); |
michael@0 | 801 | } |
michael@0 | 802 | #else |
michael@0 | 803 | diff --git a/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp b/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp |
michael@0 | 804 | --- a/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp |
michael@0 | 805 | +++ b/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp |
michael@0 | 806 | @@ -163,59 +163,8 @@ private: |
michael@0 | 807 | CGPDFDocumentRef fDoc; |
michael@0 | 808 | }; |
michael@0 | 809 | |
michael@0 | 810 | static void CGDataProviderReleaseData_FromMalloc(void*, const void* data, |
michael@0 | 811 | size_t size) { |
michael@0 | 812 | sk_free((void*)data); |
michael@0 | 813 | } |
michael@0 | 814 | |
michael@0 | 815 | -bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) { |
michael@0 | 816 | - size_t size = stream->getLength(); |
michael@0 | 817 | - void* ptr = sk_malloc_throw(size); |
michael@0 | 818 | - stream->read(ptr, size); |
michael@0 | 819 | - CGDataProviderRef data = CGDataProviderCreateWithData(NULL, ptr, size, |
michael@0 | 820 | - CGDataProviderReleaseData_FromMalloc); |
michael@0 | 821 | - if (NULL == data) { |
michael@0 | 822 | - return false; |
michael@0 | 823 | - } |
michael@0 | 824 | - |
michael@0 | 825 | - CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(data); |
michael@0 | 826 | - CGDataProviderRelease(data); |
michael@0 | 827 | - if (NULL == pdf) { |
michael@0 | 828 | - return false; |
michael@0 | 829 | - } |
michael@0 | 830 | - SkAutoPDFRelease releaseMe(pdf); |
michael@0 | 831 | - |
michael@0 | 832 | - CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1); |
michael@0 | 833 | - if (NULL == page) { |
michael@0 | 834 | - return false; |
michael@0 | 835 | - } |
michael@0 | 836 | - |
michael@0 | 837 | - CGRect bounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); |
michael@0 | 838 | - |
michael@0 | 839 | - int w = (int)CGRectGetWidth(bounds); |
michael@0 | 840 | - int h = (int)CGRectGetHeight(bounds); |
michael@0 | 841 | - |
michael@0 | 842 | - SkBitmap bitmap; |
michael@0 | 843 | - bitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); |
michael@0 | 844 | - bitmap.allocPixels(); |
michael@0 | 845 | - bitmap.eraseColor(SK_ColorWHITE); |
michael@0 | 846 | - |
michael@0 | 847 | - size_t bitsPerComponent; |
michael@0 | 848 | - CGBitmapInfo info; |
michael@0 | 849 | - getBitmapInfo(bitmap, &bitsPerComponent, &info, NULL); |
michael@0 | 850 | - |
michael@0 | 851 | - CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); |
michael@0 | 852 | - CGContextRef ctx = CGBitmapContextCreate(bitmap.getPixels(), w, h, |
michael@0 | 853 | - bitsPerComponent, bitmap.rowBytes(), |
michael@0 | 854 | - cs, info); |
michael@0 | 855 | - CGColorSpaceRelease(cs); |
michael@0 | 856 | - |
michael@0 | 857 | - if (ctx) { |
michael@0 | 858 | - CGContextDrawPDFPage(ctx, page); |
michael@0 | 859 | - CGContextRelease(ctx); |
michael@0 | 860 | - } |
michael@0 | 861 | - |
michael@0 | 862 | - output->swap(bitmap); |
michael@0 | 863 | - return true; |
michael@0 | 864 | -} |
michael@0 | 865 | - |