Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: src/effects/gradients/SkLinearGradient.cpp

Issue 464923004: Remove downwards bias when shading gradients Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698