gfx/skia/patches/archive/0015-Bug-766017-warnings.patch

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial