| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkLinearGradient.h" | 8 #include "SkLinearGradient.h" |
| 9 | 9 |
| 10 static inline int repeat_bits(int x, const int bits) { | 10 static inline int repeat_bits(int x, const int bits) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 SkPoint srcPt; | 211 SkPoint srcPt; |
| 212 SkMatrix::MapXYProc dstProc = fDstToIndexProc; | 212 SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
| 213 TileProc proc = linearGradient.fTileProc; | 213 TileProc proc = linearGradient.fTileProc; |
| 214 const SkPMColor* SK_RESTRICT cache = fCache->getCache32(); | 214 const SkPMColor* SK_RESTRICT cache = fCache->getCache32(); |
| 215 int toggle = init_dither_toggle(x, y); | 215 int toggle = init_dither_toggle(x, y); |
| 216 | 216 |
| 217 if (fDstToIndexClass != kPerspective_MatrixClass) { | 217 if (fDstToIndexClass != kPerspective_MatrixClass) { |
| 218 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, | 218 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, |
| 219 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 219 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 220 SkFixed dx, fx = SkScalarToFixed(srcPt.fX); | 220 SkFixed dx, fx = SkScalarToFixed(srcPt.fX) - (SK_FixedHalf >> kCache32Bi
ts); |
| 221 | 221 |
| 222 if (fDstToIndexClass == kFixedStepInX_MatrixClass) { | 222 if (fDstToIndexClass == kFixedStepInX_MatrixClass) { |
| 223 SkFixed dxStorage[1]; | 223 SkFixed dxStorage[1]; |
| 224 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL); | 224 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL); |
| 225 dx = dxStorage[0]; | 225 dx = dxStorage[0]; |
| 226 } else { | 226 } else { |
| 227 SkASSERT(fDstToIndexClass == kLinear_MatrixClass); | 227 SkASSERT(fDstToIndexClass == kLinear_MatrixClass); |
| 228 dx = SkScalarToFixed(fDstToIndex.getScaleX()); | 228 dx = SkScalarToFixed(fDstToIndex.getScaleX()); |
| 229 } | 229 } |
| 230 | 230 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 SkPoint srcPt; | 398 SkPoint srcPt; |
| 399 SkMatrix::MapXYProc dstProc = fDstToIndexProc; | 399 SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
| 400 TileProc proc = linearGradient.fTileProc; | 400 TileProc proc = linearGradient.fTileProc; |
| 401 const uint16_t* SK_RESTRICT cache = fCache->getCache16(); | 401 const uint16_t* SK_RESTRICT cache = fCache->getCache16(); |
| 402 int toggle = init_dither_toggle16(x, y); | 402 int toggle = init_dither_toggle16(x, y); |
| 403 | 403 |
| 404 if (fDstToIndexClass != kPerspective_MatrixClass) { | 404 if (fDstToIndexClass != kPerspective_MatrixClass) { |
| 405 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, | 405 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, |
| 406 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 406 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 407 SkFixed dx, fx = SkScalarToFixed(srcPt.fX); | 407 SkFixed dx, fx = SkScalarToFixed(srcPt.fX) - (SK_FixedHalf >> kCache32Bi
ts); |
| 408 | 408 |
| 409 if (fDstToIndexClass == kFixedStepInX_MatrixClass) { | 409 if (fDstToIndexClass == kFixedStepInX_MatrixClass) { |
| 410 SkFixed dxStorage[1]; | 410 SkFixed dxStorage[1]; |
| 411 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL); | 411 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL); |
| 412 dx = dxStorage[0]; | 412 dx = dxStorage[0]; |
| 413 } else { | 413 } else { |
| 414 SkASSERT(fDstToIndexClass == kLinear_MatrixClass); | 414 SkASSERT(fDstToIndexClass == kLinear_MatrixClass); |
| 415 dx = SkScalarToFixed(fDstToIndex.getScaleX()); | 415 dx = SkScalarToFixed(fDstToIndex.getScaleX()); |
| 416 } | 416 } |
| 417 | 417 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 str->append("SkLinearGradient ("); | 592 str->append("SkLinearGradient ("); |
| 593 | 593 |
| 594 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 594 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
| 595 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 595 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
| 596 | 596 |
| 597 this->INHERITED::toString(str); | 597 this->INHERITED::toString(str); |
| 598 | 598 |
| 599 str->append(")"); | 599 str->append(")"); |
| 600 } | 600 } |
| 601 #endif | 601 #endif |
| OLD | NEW |