michael@0: From: David Zbarsky michael@0: Bug 766017 - Fix some skia warnings r=gw280 michael@0: michael@0: diff --git a/gfx/skia/include/utils/mac/SkCGUtils.h b/gfx/skia/include/utils/mac/SkCGUtils.h michael@0: --- a/gfx/skia/include/utils/mac/SkCGUtils.h michael@0: +++ b/gfx/skia/include/utils/mac/SkCGUtils.h michael@0: @@ -39,18 +39,16 @@ static inline CGImageRef SkCreateCGImage michael@0: /** michael@0: * Draw the bitmap into the specified CG context. The bitmap will be converted michael@0: * to a CGImage using the generic RGB colorspace. (x,y) specifies the position michael@0: * of the top-left corner of the bitmap. The bitmap is converted using the michael@0: * colorspace returned by CGColorSpaceCreateDeviceRGB() michael@0: */ michael@0: void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y); michael@0: michael@0: -bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output); michael@0: - michael@0: /** michael@0: * Return a provider that wraps the specified stream. It will become an michael@0: * owner of the stream, so the caller must still manage its ownership. michael@0: * michael@0: * To hand-off ownership of the stream to the provider, the caller must do michael@0: * something like the following: michael@0: * michael@0: * SkStream* stream = new ...; michael@0: diff --git a/gfx/skia/src/core/SkAAClip.cpp b/gfx/skia/src/core/SkAAClip.cpp michael@0: --- a/gfx/skia/src/core/SkAAClip.cpp michael@0: +++ b/gfx/skia/src/core/SkAAClip.cpp michael@0: @@ -246,17 +246,17 @@ static void count_left_right_zeros(const michael@0: zeros = 0; michael@0: } michael@0: row += 2; michael@0: width -= n; michael@0: } michael@0: *riteZ = zeros; michael@0: } michael@0: michael@0: -#ifdef SK_DEBUG michael@0: +#if 0 michael@0: static void test_count_left_right_zeros() { michael@0: static bool gOnce; michael@0: if (gOnce) { michael@0: return; michael@0: } michael@0: gOnce = true; michael@0: michael@0: const uint8_t data0[] = { 0, 0, 10, 0xFF }; michael@0: @@ -1319,22 +1319,16 @@ bool SkAAClip::setPath(const SkPath& pat michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: typedef void (*RowProc)(SkAAClip::Builder&, int bottom, michael@0: const uint8_t* rowA, const SkIRect& rectA, michael@0: const uint8_t* rowB, const SkIRect& rectB); michael@0: michael@0: -static void sectRowProc(SkAAClip::Builder& builder, int bottom, michael@0: - const uint8_t* rowA, const SkIRect& rectA, michael@0: - const uint8_t* rowB, const SkIRect& rectB) { michael@0: - michael@0: -} michael@0: - michael@0: typedef U8CPU (*AlphaProc)(U8CPU alphaA, U8CPU alphaB); michael@0: michael@0: static U8CPU sectAlphaProc(U8CPU alphaA, U8CPU alphaB) { michael@0: // Multiply michael@0: return SkMulDiv255Round(alphaA, alphaB); michael@0: } michael@0: michael@0: static U8CPU unionAlphaProc(U8CPU alphaA, U8CPU alphaB) { michael@0: @@ -1429,31 +1423,16 @@ private: michael@0: static void adjust_row(RowIter& iter, int& leftA, int& riteA, int rite) { michael@0: if (rite == riteA) { michael@0: iter.next(); michael@0: leftA = iter.left(); michael@0: riteA = iter.right(); michael@0: } michael@0: } michael@0: michael@0: -static bool intersect(int& min, int& max, int boundsMin, int boundsMax) { michael@0: - SkASSERT(min < max); michael@0: - SkASSERT(boundsMin < boundsMax); michael@0: - if (min >= boundsMax || max <= boundsMin) { michael@0: - return false; michael@0: - } michael@0: - if (min < boundsMin) { michael@0: - min = boundsMin; michael@0: - } michael@0: - if (max > boundsMax) { michael@0: - max = boundsMax; michael@0: - } michael@0: - return true; michael@0: -} michael@0: - michael@0: static void operatorX(SkAAClip::Builder& builder, int lastY, michael@0: RowIter& iterA, RowIter& iterB, michael@0: AlphaProc proc, const SkIRect& bounds) { michael@0: int leftA = iterA.left(); michael@0: int riteA = iterA.right(); michael@0: int leftB = iterB.left(); michael@0: int riteB = iterB.right(); michael@0: michael@0: @@ -1970,34 +1949,33 @@ static void small_bzero(void* dst, size_ michael@0: static inline uint8_t mergeOne(uint8_t value, unsigned alpha) { michael@0: return SkMulDiv255Round(value, alpha); michael@0: } michael@0: static inline uint16_t mergeOne(uint16_t value, unsigned alpha) { michael@0: unsigned r = SkGetPackedR16(value); michael@0: unsigned g = SkGetPackedG16(value); michael@0: unsigned b = SkGetPackedB16(value); michael@0: return SkPackRGB16(SkMulDiv255Round(r, alpha), michael@0: - SkMulDiv255Round(r, alpha), michael@0: - SkMulDiv255Round(r, alpha)); michael@0: + SkMulDiv255Round(g, alpha), michael@0: + SkMulDiv255Round(b, alpha)); michael@0: } michael@0: static inline SkPMColor mergeOne(SkPMColor value, unsigned alpha) { michael@0: unsigned a = SkGetPackedA32(value); michael@0: unsigned r = SkGetPackedR32(value); michael@0: unsigned g = SkGetPackedG32(value); michael@0: unsigned b = SkGetPackedB32(value); michael@0: return SkPackARGB32(SkMulDiv255Round(a, alpha), michael@0: SkMulDiv255Round(r, alpha), michael@0: SkMulDiv255Round(g, alpha), michael@0: SkMulDiv255Round(b, alpha)); michael@0: } michael@0: michael@0: template void mergeT(const T* SK_RESTRICT src, int srcN, michael@0: const uint8_t* SK_RESTRICT row, int rowN, michael@0: T* SK_RESTRICT dst) { michael@0: - SkDEBUGCODE(int accumulated = 0;) michael@0: for (;;) { michael@0: SkASSERT(rowN > 0); michael@0: SkASSERT(srcN > 0); michael@0: michael@0: int n = SkMin32(rowN, srcN); michael@0: unsigned rowA = row[1]; michael@0: if (0xFF == rowA) { michael@0: small_memcpy(dst, src, n * sizeof(T)); michael@0: diff --git a/gfx/skia/src/core/SkBlitMask_D32.cpp b/gfx/skia/src/core/SkBlitMask_D32.cpp michael@0: --- a/gfx/skia/src/core/SkBlitMask_D32.cpp michael@0: +++ b/gfx/skia/src/core/SkBlitMask_D32.cpp michael@0: @@ -268,107 +268,49 @@ bool SkBlitMask::BlitColor(const SkBitma michael@0: return true; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: -static void BW_RowProc_Blend(SkPMColor* SK_RESTRICT dst, michael@0: - const uint8_t* SK_RESTRICT mask, michael@0: - const SkPMColor* SK_RESTRICT src, int count) { michael@0: - int i, octuple = (count + 7) >> 3; michael@0: - for (i = 0; i < octuple; ++i) { michael@0: - int m = *mask++; michael@0: - if (m & 0x80) { dst[0] = SkPMSrcOver(src[0], dst[0]); } michael@0: - if (m & 0x40) { dst[1] = SkPMSrcOver(src[1], dst[1]); } michael@0: - if (m & 0x20) { dst[2] = SkPMSrcOver(src[2], dst[2]); } michael@0: - if (m & 0x10) { dst[3] = SkPMSrcOver(src[3], dst[3]); } michael@0: - if (m & 0x08) { dst[4] = SkPMSrcOver(src[4], dst[4]); } michael@0: - if (m & 0x04) { dst[5] = SkPMSrcOver(src[5], dst[5]); } michael@0: - if (m & 0x02) { dst[6] = SkPMSrcOver(src[6], dst[6]); } michael@0: - if (m & 0x01) { dst[7] = SkPMSrcOver(src[7], dst[7]); } michael@0: - src += 8; michael@0: - dst += 8; michael@0: - } michael@0: - count &= 7; michael@0: - if (count > 0) { michael@0: - int m = *mask; michael@0: - do { michael@0: - if (m & 0x80) { dst[0] = SkPMSrcOver(src[0], dst[0]); } michael@0: - m <<= 1; michael@0: - src += 1; michael@0: - dst += 1; michael@0: - } while (--count > 0); michael@0: - } michael@0: -} michael@0: - michael@0: -static void BW_RowProc_Opaque(SkPMColor* SK_RESTRICT dst, michael@0: - const uint8_t* SK_RESTRICT mask, michael@0: - const SkPMColor* SK_RESTRICT src, int count) { michael@0: - int i, octuple = (count + 7) >> 3; michael@0: - for (i = 0; i < octuple; ++i) { michael@0: - int m = *mask++; michael@0: - if (m & 0x80) { dst[0] = src[0]; } michael@0: - if (m & 0x40) { dst[1] = src[1]; } michael@0: - if (m & 0x20) { dst[2] = src[2]; } michael@0: - if (m & 0x10) { dst[3] = src[3]; } michael@0: - if (m & 0x08) { dst[4] = src[4]; } michael@0: - if (m & 0x04) { dst[5] = src[5]; } michael@0: - if (m & 0x02) { dst[6] = src[6]; } michael@0: - if (m & 0x01) { dst[7] = src[7]; } michael@0: - src += 8; michael@0: - dst += 8; michael@0: - } michael@0: - count &= 7; michael@0: - if (count > 0) { michael@0: - int m = *mask; michael@0: - do { michael@0: - if (m & 0x80) { dst[0] = SkPMSrcOver(src[0], dst[0]); } michael@0: - m <<= 1; michael@0: - src += 1; michael@0: - dst += 1; michael@0: - } while (--count > 0); michael@0: - } michael@0: -} michael@0: - michael@0: static void A8_RowProc_Blend(SkPMColor* SK_RESTRICT dst, michael@0: const uint8_t* SK_RESTRICT mask, michael@0: const SkPMColor* SK_RESTRICT src, int count) { michael@0: for (int i = 0; i < count; ++i) { michael@0: if (mask[i]) { michael@0: dst[i] = SkBlendARGB32(src[i], dst[i], mask[i]); michael@0: } michael@0: } michael@0: } michael@0: michael@0: // expand the steps that SkAlphaMulQ performs, but this way we can michael@0: -// exand.. add.. combine michael@0: +// expand.. add.. combine michael@0: // instead of michael@0: // expand..combine add expand..combine michael@0: // michael@0: #define EXPAND0(v, m, s) ((v) & (m)) * (s) michael@0: #define EXPAND1(v, m, s) (((v) >> 8) & (m)) * (s) michael@0: #define COMBINE(e0, e1, m) ((((e0) >> 8) & (m)) | ((e1) & ~(m))) michael@0: michael@0: static void A8_RowProc_Opaque(SkPMColor* SK_RESTRICT dst, michael@0: const uint8_t* SK_RESTRICT mask, michael@0: const SkPMColor* SK_RESTRICT src, int count) { michael@0: - const uint32_t rbmask = gMask_00FF00FF; michael@0: for (int i = 0; i < count; ++i) { michael@0: int m = mask[i]; michael@0: if (m) { michael@0: m += (m >> 7); michael@0: #if 1 michael@0: // this is slightly slower than the expand/combine version, but it michael@0: // is much closer to the old results, so we use it for now to reduce michael@0: // rebaselining. michael@0: dst[i] = SkAlphaMulQ(src[i], m) + SkAlphaMulQ(dst[i], 256 - m); michael@0: #else michael@0: + const uint32_t rbmask = gMask_00FF00FF; michael@0: uint32_t v = src[i]; michael@0: uint32_t s0 = EXPAND0(v, rbmask, m); michael@0: uint32_t s1 = EXPAND1(v, rbmask, m); michael@0: v = dst[i]; michael@0: uint32_t d0 = EXPAND0(v, rbmask, m); michael@0: uint32_t d1 = EXPAND1(v, rbmask, m); michael@0: dst[i] = COMBINE(s0 + d0, s1 + d1, rbmask); michael@0: #endif michael@0: @@ -559,17 +501,17 @@ SkBlitMask::RowProc SkBlitMask::RowFacto michael@0: // make this opt-in until chrome can rebaseline michael@0: RowProc proc = PlatformRowProcs(config, format, flags); michael@0: if (proc) { michael@0: return proc; michael@0: } michael@0: michael@0: static const RowProc gProcs[] = { michael@0: // need X coordinate to handle BW michael@0: - NULL, NULL, //(RowProc)BW_RowProc_Blend, (RowProc)BW_RowProc_Opaque, michael@0: + NULL, NULL, michael@0: (RowProc)A8_RowProc_Blend, (RowProc)A8_RowProc_Opaque, michael@0: (RowProc)LCD16_RowProc_Blend, (RowProc)LCD16_RowProc_Opaque, michael@0: (RowProc)LCD32_RowProc_Blend, (RowProc)LCD32_RowProc_Opaque, michael@0: }; michael@0: michael@0: int index; michael@0: switch (config) { michael@0: case SkBitmap::kARGB_8888_Config: michael@0: diff --git a/gfx/skia/src/core/SkConcaveToTriangles.cpp b/gfx/skia/src/core/SkConcaveToTriangles.cpp michael@0: --- a/gfx/skia/src/core/SkConcaveToTriangles.cpp michael@0: +++ b/gfx/skia/src/core/SkConcaveToTriangles.cpp michael@0: @@ -37,17 +37,16 @@ michael@0: #include "SkTDArray.h" michael@0: #include "SkGeometry.h" michael@0: #include "SkTSort.h" michael@0: michael@0: // This is used to prevent runaway code bugs, and can probably be removed after michael@0: // the code has been proven robust. michael@0: #define kMaxCount 1000 michael@0: michael@0: -#define DEBUG michael@0: #ifdef DEBUG michael@0: //------------------------------------------------------------------------------ michael@0: // Debugging support michael@0: //------------------------------------------------------------------------------ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: diff --git a/gfx/skia/src/core/SkPath.cpp b/gfx/skia/src/core/SkPath.cpp michael@0: --- a/gfx/skia/src/core/SkPath.cpp michael@0: +++ b/gfx/skia/src/core/SkPath.cpp michael@0: @@ -469,17 +469,16 @@ void SkPath::incReserve(U16CPU inc) { michael@0: fPts.setReserve(fPts.count() + inc); michael@0: michael@0: SkDEBUGCODE(this->validate();) michael@0: } michael@0: michael@0: void SkPath::moveTo(SkScalar x, SkScalar y) { michael@0: SkDEBUGCODE(this->validate();) michael@0: michael@0: - int vc = fVerbs.count(); michael@0: SkPoint* pt; michael@0: michael@0: // remember our index michael@0: fLastMoveToIndex = fPts.count(); michael@0: michael@0: pt = fPts.append(); michael@0: *fVerbs.append() = kMove_Verb; michael@0: pt->set(x, y); michael@0: @@ -1163,17 +1162,16 @@ void SkPath::reversePathTo(const SkPath& michael@0: } michael@0: pts -= gPtsInVerb[verbs[i]]; michael@0: } michael@0: } michael@0: michael@0: void SkPath::reverseAddPath(const SkPath& src) { michael@0: this->incReserve(src.fPts.count()); michael@0: michael@0: - const SkPoint* startPts = src.fPts.begin(); michael@0: const SkPoint* pts = src.fPts.end(); michael@0: const uint8_t* startVerbs = src.fVerbs.begin(); michael@0: const uint8_t* verbs = src.fVerbs.end(); michael@0: michael@0: fIsOval = false; michael@0: michael@0: bool needMove = true; michael@0: bool needClose = false; michael@0: diff --git a/gfx/skia/src/core/SkRegion.cpp b/gfx/skia/src/core/SkRegion.cpp michael@0: --- a/gfx/skia/src/core/SkRegion.cpp michael@0: +++ b/gfx/skia/src/core/SkRegion.cpp michael@0: @@ -920,20 +920,16 @@ static int operate(const SkRegion::RunTy michael@0: /* Given count RunTypes in a complex region, return the worst case number of michael@0: logical intervals that represents (i.e. number of rects that would be michael@0: returned from the iterator). michael@0: michael@0: We could just return count/2, since there must be at least 2 values per michael@0: interval, but we can first trim off the const overhead of the initial TOP michael@0: value, plus the final BOTTOM + 2 sentinels. michael@0: */ michael@0: -static int count_to_intervals(int count) { michael@0: - SkASSERT(count >= 6); // a single rect is 6 values michael@0: - return (count - 4) >> 1; michael@0: -} michael@0: michael@0: /* Given a number of intervals, what is the worst case representation of that michael@0: many intervals? michael@0: michael@0: Worst case (from a storage perspective), is a vertical stack of single michael@0: intervals: TOP + N * (BOTTOM INTERVALCOUNT LEFT RIGHT SENTINEL) + SENTINEL michael@0: */ michael@0: static int intervals_to_count(int intervals) { michael@0: diff --git a/gfx/skia/src/core/SkScalerContext.cpp b/gfx/skia/src/core/SkScalerContext.cpp michael@0: --- a/gfx/skia/src/core/SkScalerContext.cpp michael@0: +++ b/gfx/skia/src/core/SkScalerContext.cpp michael@0: @@ -336,44 +336,16 @@ SK_ERROR: michael@0: glyph->fTop = 0; michael@0: glyph->fWidth = 0; michael@0: glyph->fHeight = 0; michael@0: // put a valid value here, in case it was earlier set to michael@0: // MASK_FORMAT_JUST_ADVANCE michael@0: glyph->fMaskFormat = fRec.fMaskFormat; michael@0: } michael@0: michael@0: -static bool isLCD(const SkScalerContext::Rec& rec) { michael@0: - return SkMask::kLCD16_Format == rec.fMaskFormat || michael@0: - SkMask::kLCD32_Format == rec.fMaskFormat; michael@0: -} michael@0: - michael@0: -static uint16_t a8_to_rgb565(unsigned a8) { michael@0: - return SkPackRGB16(a8 >> 3, a8 >> 2, a8 >> 3); michael@0: -} michael@0: - michael@0: -static void copyToLCD16(const SkBitmap& src, const SkMask& dst) { michael@0: - SkASSERT(SkBitmap::kA8_Config == src.config()); michael@0: - SkASSERT(SkMask::kLCD16_Format == dst.fFormat); michael@0: - michael@0: - const int width = dst.fBounds.width(); michael@0: - const int height = dst.fBounds.height(); michael@0: - const uint8_t* srcP = src.getAddr8(0, 0); michael@0: - size_t srcRB = src.rowBytes(); michael@0: - uint16_t* dstP = (uint16_t*)dst.fImage; michael@0: - size_t dstRB = dst.fRowBytes; michael@0: - for (int y = 0; y < height; ++y) { michael@0: - for (int x = 0; x < width; ++x) { michael@0: - dstP[x] = a8_to_rgb565(srcP[x]); michael@0: - } michael@0: - srcP += srcRB; michael@0: - dstP = (uint16_t*)((char*)dstP + dstRB); michael@0: - } michael@0: -} michael@0: - michael@0: #define SK_FREETYPE_LCD_LERP 160 michael@0: michael@0: static int lerp(int start, int end) { michael@0: SkASSERT((unsigned)SK_FREETYPE_LCD_LERP <= 256); michael@0: return start + ((end - start) * (SK_FREETYPE_LCD_LERP) >> 8); michael@0: } michael@0: michael@0: static uint16_t packLCD16(unsigned r, unsigned g, unsigned b) { michael@0: diff --git a/gfx/skia/src/core/SkScan_AntiPath.cpp b/gfx/skia/src/core/SkScan_AntiPath.cpp michael@0: --- a/gfx/skia/src/core/SkScan_AntiPath.cpp michael@0: +++ b/gfx/skia/src/core/SkScan_AntiPath.cpp michael@0: @@ -230,52 +230,16 @@ void SuperBlitter::blitH(int x, int y, i michael@0: fOffsetX); michael@0: michael@0: #ifdef SK_DEBUG michael@0: fRuns.assertValid(y & MASK, (1 << (8 - SHIFT))); michael@0: fCurrX = x + width; michael@0: #endif michael@0: } michael@0: michael@0: -static void set_left_rite_runs(SkAlphaRuns& runs, int ileft, U8CPU leftA, michael@0: - int n, U8CPU riteA) { michael@0: - SkASSERT(leftA <= 0xFF); michael@0: - SkASSERT(riteA <= 0xFF); michael@0: - michael@0: - int16_t* run = runs.fRuns; michael@0: - uint8_t* aa = runs.fAlpha; michael@0: - michael@0: - if (ileft > 0) { michael@0: - run[0] = ileft; michael@0: - aa[0] = 0; michael@0: - run += ileft; michael@0: - aa += ileft; michael@0: - } michael@0: - michael@0: - SkASSERT(leftA < 0xFF); michael@0: - if (leftA > 0) { michael@0: - *run++ = 1; michael@0: - *aa++ = leftA; michael@0: - } michael@0: - michael@0: - if (n > 0) { michael@0: - run[0] = n; michael@0: - aa[0] = 0xFF; michael@0: - run += n; michael@0: - aa += n; michael@0: - } michael@0: - michael@0: - SkASSERT(riteA < 0xFF); michael@0: - if (riteA > 0) { michael@0: - *run++ = 1; michael@0: - *aa++ = riteA; michael@0: - } michael@0: - run[0] = 0; michael@0: -} michael@0: - michael@0: void SuperBlitter::blitRect(int x, int y, int width, int height) { michael@0: SkASSERT(width > 0); michael@0: SkASSERT(height > 0); michael@0: michael@0: // blit leading rows michael@0: while ((y & MASK)) { michael@0: this->blitH(x, y++, width); michael@0: if (--height <= 0) { michael@0: diff --git a/gfx/skia/src/effects/SkGradientShader.cpp b/gfx/skia/src/effects/SkGradientShader.cpp michael@0: --- a/gfx/skia/src/effects/SkGradientShader.cpp michael@0: +++ b/gfx/skia/src/effects/SkGradientShader.cpp michael@0: @@ -865,45 +865,16 @@ bool Linear_Gradient::setContext(const S michael@0: } while (0) michael@0: michael@0: namespace { michael@0: michael@0: typedef void (*LinearShadeProc)(TileProc proc, SkFixed dx, SkFixed fx, michael@0: SkPMColor* dstC, const SkPMColor* cache, michael@0: int toggle, int count); michael@0: michael@0: -// This function is deprecated, and will be replaced by michael@0: -// shadeSpan_linear_vertical_lerp() once Chrome has been weaned off of it. michael@0: -void shadeSpan_linear_vertical(TileProc proc, SkFixed dx, SkFixed fx, michael@0: - SkPMColor* SK_RESTRICT dstC, michael@0: - const SkPMColor* SK_RESTRICT cache, michael@0: - int toggle, int count) { michael@0: - if (proc == clamp_tileproc) { michael@0: - // Read out clamp values from beginning/end of the cache. No need to lerp michael@0: - // or dither michael@0: - if (fx < 0) { michael@0: - sk_memset32(dstC, cache[-1], count); michael@0: - return; michael@0: - } else if (fx > 0xFFFF) { michael@0: - sk_memset32(dstC, cache[Gradient_Shader::kCache32Count * 2], count); michael@0: - return; michael@0: - } michael@0: - } michael@0: - michael@0: - // We're a vertical gradient, so no change in a span. michael@0: - // If colors change sharply across the gradient, dithering is michael@0: - // insufficient (it subsamples the color space) and we need to lerp. michael@0: - unsigned fullIndex = proc(fx); michael@0: - unsigned fi = fullIndex >> (16 - Gradient_Shader::kCache32Bits); michael@0: - sk_memset32_dither(dstC, michael@0: - cache[toggle + fi], michael@0: - cache[(toggle ^ Gradient_Shader::kDitherStride32) + fi], michael@0: - count); michael@0: -} michael@0: - michael@0: // Linear interpolation (lerp) is unnecessary if there are no sharp michael@0: // discontinuities in the gradient - which must be true if there are michael@0: // only 2 colors - but it's cheap. michael@0: void shadeSpan_linear_vertical_lerp(TileProc proc, SkFixed dx, SkFixed fx, michael@0: SkPMColor* SK_RESTRICT dstC, michael@0: const SkPMColor* SK_RESTRICT cache, michael@0: int toggle, int count) { michael@0: if (proc == clamp_tileproc) { michael@0: @@ -2131,16 +2102,18 @@ protected: michael@0: buffer.writePoint(fCenter); michael@0: } michael@0: michael@0: private: michael@0: typedef Gradient_Shader INHERITED; michael@0: const SkPoint fCenter; michael@0: }; michael@0: michael@0: +#ifndef SK_SCALAR_IS_FLOAT michael@0: + michael@0: #ifdef COMPUTE_SWEEP_TABLE michael@0: #define PI 3.14159265 michael@0: static bool gSweepTableReady; michael@0: static uint8_t gSweepTable[65]; michael@0: michael@0: /* Our table stores precomputed values for atan: [0...1] -> [0..PI/4] michael@0: We scale the results to [0..32] michael@0: */ michael@0: @@ -2168,20 +2141,23 @@ static const uint8_t gSweepTable[] = { michael@0: 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, 16, 17, 17, 18, 18, michael@0: 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26, michael@0: 26, 27, 27, 27, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, michael@0: 32 michael@0: }; michael@0: static const uint8_t* build_sweep_table() { return gSweepTable; } michael@0: #endif michael@0: michael@0: +#endif michael@0: + michael@0: // divide numer/denom, with a bias of 6bits. Assumes numer <= denom michael@0: // and denom != 0. Since our table is 6bits big (+1), this is a nice fit. michael@0: // Same as (but faster than) SkFixedDiv(numer, denom) >> 10 michael@0: michael@0: +#ifndef SK_SCALAR_IS_FLOAT michael@0: //unsigned div_64(int numer, int denom); michael@0: static unsigned div_64(int numer, int denom) { michael@0: SkASSERT(numer <= denom); michael@0: SkASSERT(numer > 0); michael@0: SkASSERT(denom > 0); michael@0: michael@0: int nbits = SkCLZ(numer); michael@0: int dbits = SkCLZ(denom); michael@0: @@ -2294,16 +2270,17 @@ static unsigned atan_0_90(SkFixed y, SkF michael@0: result = 64 - result; michael@0: // pin to 63 michael@0: result -= result >> 6; michael@0: } michael@0: michael@0: SkASSERT(result <= 63); michael@0: return result; michael@0: } michael@0: +#endif michael@0: michael@0: // returns angle in a circle [0..2PI) -> [0..255] michael@0: #ifdef SK_SCALAR_IS_FLOAT michael@0: static unsigned SkATan2_255(float y, float x) { michael@0: // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); michael@0: static const float g255Over2PI = 40.584510488433314f; michael@0: michael@0: float result = sk_float_atan2(y, x); michael@0: diff --git a/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp b/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp michael@0: --- a/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp michael@0: +++ b/gfx/skia/src/opts/SkBlitRect_opts_SSE2.cpp michael@0: @@ -112,17 +112,17 @@ void BlitRect32_OpaqueWide_SSE2(SkPMColo michael@0: } michael@0: michael@0: void ColorRect32_SSE2(SkPMColor* destination, michael@0: int width, int height, michael@0: size_t rowBytes, uint32_t color) { michael@0: if (0 == height || 0 == width || 0 == color) { michael@0: return; michael@0: } michael@0: - unsigned colorA = SkGetPackedA32(color); michael@0: + //unsigned colorA = SkGetPackedA32(color); michael@0: //if (255 == colorA) { michael@0: //if (width < 31) { michael@0: //BlitRect32_OpaqueNarrow_SSE2(destination, width, height, michael@0: //rowBytes, color); michael@0: //} else { michael@0: //BlitRect32_OpaqueWide_SSE2(destination, width, height, michael@0: //rowBytes, color); michael@0: //} michael@0: diff --git a/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp b/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp michael@0: --- a/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp michael@0: +++ b/gfx/skia/src/ports/SkFontHost_mac_coretext.cpp michael@0: @@ -75,20 +75,16 @@ static CGFloat CGRectGetMinY_inline(cons michael@0: static CGFloat CGRectGetMaxY_inline(const CGRect& rect) { michael@0: return rect.origin.y + rect.size.height; michael@0: } michael@0: michael@0: static CGFloat CGRectGetWidth_inline(const CGRect& rect) { michael@0: return rect.size.width; michael@0: } michael@0: michael@0: -static CGFloat CGRectGetHeight(const CGRect& rect) { michael@0: - return rect.size.height; michael@0: -} michael@0: - michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: static void sk_memset_rect32(uint32_t* ptr, uint32_t value, size_t width, michael@0: size_t height, size_t rowBytes) { michael@0: SkASSERT(width); michael@0: SkASSERT(width * sizeof(uint32_t) <= rowBytes); michael@0: michael@0: if (width >= 32) { michael@0: @@ -125,28 +121,30 @@ static void sk_memset_rect32(uint32_t* p michael@0: *ptr++ = value; michael@0: } while (--w > 0); michael@0: ptr = (uint32_t*)((char*)ptr + rowBytes); michael@0: height -= 1; michael@0: } michael@0: } michael@0: } michael@0: michael@0: +#if 0 michael@0: // Potentially this should be made (1) public (2) optimized when width is small. michael@0: // Also might want 16 and 32 bit version michael@0: // michael@0: static void sk_memset_rect(void* ptr, U8CPU byte, size_t width, size_t height, michael@0: size_t rowBytes) { michael@0: uint8_t* dst = (uint8_t*)ptr; michael@0: while (height) { michael@0: memset(dst, byte, width); michael@0: dst += rowBytes; michael@0: height -= 1; michael@0: } michael@0: } michael@0: +#endif michael@0: michael@0: #include michael@0: michael@0: typedef uint32_t CGRGBPixel; michael@0: michael@0: static unsigned CGRGBPixel_getAlpha(CGRGBPixel pixel) { michael@0: return pixel & 0xFF; michael@0: } michael@0: @@ -250,23 +248,16 @@ static CGAffineTransform MatrixToCGAffin michael@0: return CGAffineTransformMake(ScalarToCG(matrix[SkMatrix::kMScaleX]) * sx, michael@0: -ScalarToCG(matrix[SkMatrix::kMSkewY]) * sy, michael@0: -ScalarToCG(matrix[SkMatrix::kMSkewX]) * sx, michael@0: ScalarToCG(matrix[SkMatrix::kMScaleY]) * sy, michael@0: ScalarToCG(matrix[SkMatrix::kMTransX]) * sx, michael@0: ScalarToCG(matrix[SkMatrix::kMTransY]) * sy); michael@0: } michael@0: michael@0: -static void CGAffineTransformToMatrix(const CGAffineTransform& xform, SkMatrix* matrix) { michael@0: - matrix->setAll( michael@0: - CGToScalar(xform.a), CGToScalar(xform.c), CGToScalar(xform.tx), michael@0: - CGToScalar(xform.b), CGToScalar(xform.d), CGToScalar(xform.ty), michael@0: - 0, 0, SK_Scalar1); michael@0: -} michael@0: - michael@0: static SkScalar getFontScale(CGFontRef cgFont) { michael@0: int unitsPerEm = CGFontGetUnitsPerEm(cgFont); michael@0: return SkScalarInvert(SkIntToScalar(unitsPerEm)); michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #define BITMAP_INFO_RGB (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host) michael@0: @@ -1075,16 +1066,17 @@ static const uint8_t* getInverseTable(bo michael@0: if (!gInited) { michael@0: build_power_table(gWhiteTable, 1.5f); michael@0: build_power_table(gTable, 2.2f); michael@0: gInited = true; michael@0: } michael@0: return isWhite ? gWhiteTable : gTable; michael@0: } michael@0: michael@0: +#ifdef SK_USE_COLOR_LUMINANCE michael@0: static const uint8_t* getGammaTable(U8CPU luminance) { michael@0: static uint8_t gGammaTables[4][256]; michael@0: static bool gInited; michael@0: if (!gInited) { michael@0: #if 1 michael@0: float start = 1.1; michael@0: float stop = 2.1; michael@0: for (int i = 0; i < 4; ++i) { michael@0: @@ -1097,45 +1089,49 @@ static const uint8_t* getGammaTable(U8CP michael@0: build_power_table(gGammaTables[2], 1); michael@0: build_power_table(gGammaTables[3], 1); michael@0: #endif michael@0: gInited = true; michael@0: } michael@0: SkASSERT(0 == (luminance >> 8)); michael@0: return gGammaTables[luminance >> 6]; michael@0: } michael@0: +#endif michael@0: michael@0: +#ifndef SK_USE_COLOR_LUMINANCE michael@0: static void invertGammaMask(bool isWhite, CGRGBPixel rgb[], int width, michael@0: int height, size_t rb) { michael@0: const uint8_t* table = getInverseTable(isWhite); michael@0: for (int y = 0; y < height; ++y) { michael@0: for (int x = 0; x < width; ++x) { michael@0: uint32_t c = rgb[x]; michael@0: int r = (c >> 16) & 0xFF; michael@0: int g = (c >> 8) & 0xFF; michael@0: int b = (c >> 0) & 0xFF; michael@0: rgb[x] = (table[r] << 16) | (table[g] << 8) | table[b]; michael@0: } michael@0: rgb = (CGRGBPixel*)((char*)rgb + rb); michael@0: } michael@0: } michael@0: +#endif michael@0: michael@0: static void cgpixels_to_bits(uint8_t dst[], const CGRGBPixel src[], int count) { michael@0: while (count > 0) { michael@0: uint8_t mask = 0; michael@0: for (int i = 7; i >= 0; --i) { michael@0: mask |= (CGRGBPixel_getAlpha(*src++) >> 7) << i; michael@0: if (0 == --count) { michael@0: break; michael@0: } michael@0: } michael@0: *dst++ = mask; michael@0: } michael@0: } michael@0: michael@0: +#ifdef SK_USE_COLOR_LUMINANCE michael@0: static int lerpScale(int dst, int src, int scale) { michael@0: return dst + (scale * (src - dst) >> 23); michael@0: } michael@0: michael@0: static CGRGBPixel lerpPixel(CGRGBPixel dst, CGRGBPixel src, michael@0: int scaleR, int scaleG, int scaleB) { michael@0: int sr = (src >> 16) & 0xFF; michael@0: int sg = (src >> 8) & 0xFF; michael@0: @@ -1147,37 +1143,31 @@ static CGRGBPixel lerpPixel(CGRGBPixel d michael@0: int rr = lerpScale(dr, sr, scaleR); michael@0: int rg = lerpScale(dg, sg, scaleG); michael@0: int rb = lerpScale(db, sb, scaleB); michael@0: return (rr << 16) | (rg << 8) | rb; michael@0: } michael@0: michael@0: static void lerpPixels(CGRGBPixel dst[], const CGRGBPixel src[], int width, michael@0: int height, int rowBytes, int lumBits) { michael@0: -#ifdef SK_USE_COLOR_LUMINANCE michael@0: int scaleR = (1 << 23) * SkColorGetR(lumBits) / 0xFF; michael@0: int scaleG = (1 << 23) * SkColorGetG(lumBits) / 0xFF; michael@0: int scaleB = (1 << 23) * SkColorGetB(lumBits) / 0xFF; michael@0: -#else michael@0: - int scale = (1 << 23) * lumBits / SkScalerContext::kLuminance_Max; michael@0: - int scaleR = scale; michael@0: - int scaleG = scale; michael@0: - int scaleB = scale; michael@0: -#endif michael@0: michael@0: for (int y = 0; y < height; ++y) { michael@0: for (int x = 0; x < width; ++x) { michael@0: // bit-not the src, since it was drawn from black, so we need the michael@0: // compliment of those bits michael@0: dst[x] = lerpPixel(dst[x], ~src[x], scaleR, scaleG, scaleB); michael@0: } michael@0: src = (CGRGBPixel*)((char*)src + rowBytes); michael@0: dst = (CGRGBPixel*)((char*)dst + rowBytes); michael@0: } michael@0: } michael@0: +#endif michael@0: michael@0: #if 1 michael@0: static inline int r32_to_16(int x) { return SkR32ToR16(x); } michael@0: static inline int g32_to_16(int x) { return SkG32ToG16(x); } michael@0: static inline int b32_to_16(int x) { return SkB32ToB16(x); } michael@0: #else michael@0: static inline int round8to5(int x) { michael@0: return (x + 3 - (x >> 5) + (x >> 7)) >> 3; michael@0: @@ -1212,22 +1202,21 @@ static inline uint32_t rgb_to_lcd32(CGRG michael@0: return SkPackARGB32(0xFF, r, g, b); michael@0: } michael@0: michael@0: #define BLACK_LUMINANCE_LIMIT 0x40 michael@0: #define WHITE_LUMINANCE_LIMIT 0xA0 michael@0: michael@0: void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) { michael@0: CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID(fBaseGlyphCount); michael@0: - michael@0: const bool isLCD = isLCDFormat(glyph.fMaskFormat); michael@0: +#ifdef SK_USE_COLOR_LUMINANCE michael@0: const bool isBW = SkMask::kBW_Format == glyph.fMaskFormat; michael@0: const bool isA8 = !isLCD && !isBW; michael@0: - michael@0: -#ifdef SK_USE_COLOR_LUMINANCE michael@0: + michael@0: unsigned lumBits = fRec.getLuminanceColor(); michael@0: uint32_t xorMask = 0; michael@0: michael@0: if (isA8) { michael@0: // for A8, we just want a component (they're all the same) michael@0: lumBits = SkColorGetR(lumBits); michael@0: } michael@0: #else michael@0: diff --git a/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp b/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp michael@0: --- a/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp michael@0: +++ b/gfx/skia/src/utils/mac/SkCreateCGImageRef.cpp michael@0: @@ -163,59 +163,8 @@ private: michael@0: CGPDFDocumentRef fDoc; michael@0: }; michael@0: michael@0: static void CGDataProviderReleaseData_FromMalloc(void*, const void* data, michael@0: size_t size) { michael@0: sk_free((void*)data); michael@0: } michael@0: michael@0: -bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) { michael@0: - size_t size = stream->getLength(); michael@0: - void* ptr = sk_malloc_throw(size); michael@0: - stream->read(ptr, size); michael@0: - CGDataProviderRef data = CGDataProviderCreateWithData(NULL, ptr, size, michael@0: - CGDataProviderReleaseData_FromMalloc); michael@0: - if (NULL == data) { michael@0: - return false; michael@0: - } michael@0: - michael@0: - CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(data); michael@0: - CGDataProviderRelease(data); michael@0: - if (NULL == pdf) { michael@0: - return false; michael@0: - } michael@0: - SkAutoPDFRelease releaseMe(pdf); michael@0: - michael@0: - CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1); michael@0: - if (NULL == page) { michael@0: - return false; michael@0: - } michael@0: - michael@0: - CGRect bounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); michael@0: - michael@0: - int w = (int)CGRectGetWidth(bounds); michael@0: - int h = (int)CGRectGetHeight(bounds); michael@0: - michael@0: - SkBitmap bitmap; michael@0: - bitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); michael@0: - bitmap.allocPixels(); michael@0: - bitmap.eraseColor(SK_ColorWHITE); michael@0: - michael@0: - size_t bitsPerComponent; michael@0: - CGBitmapInfo info; michael@0: - getBitmapInfo(bitmap, &bitsPerComponent, &info, NULL); michael@0: - michael@0: - CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); michael@0: - CGContextRef ctx = CGBitmapContextCreate(bitmap.getPixels(), w, h, michael@0: - bitsPerComponent, bitmap.rowBytes(), michael@0: - cs, info); michael@0: - CGColorSpaceRelease(cs); michael@0: - michael@0: - if (ctx) { michael@0: - CGContextDrawPDFPage(ctx, page); michael@0: - CGContextRelease(ctx); michael@0: - } michael@0: - michael@0: - output->swap(bitmap); michael@0: - return true; michael@0: -} michael@0: -