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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc) 57 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc)
58 : SkGradientShaderBase(desc, pts_to_unit_matrix(pts)) 58 : SkGradientShaderBase(desc, pts_to_unit_matrix(pts))
59 , fStart(pts[0]) 59 , fStart(pts[0])
60 , fEnd(pts[1]) { 60 , fEnd(pts[1]) {
61 } 61 }
62 62
63 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) { 63 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
64 DescriptorScope desc; 64 DescriptorScope desc;
65 if (!desc.unflatten(buffer)) { 65 if (!desc.unflatten(buffer)) {
66 return NULL; 66 return nullptr;
67 } 67 }
68 SkPoint pts[2]; 68 SkPoint pts[2];
69 pts[0] = buffer.readPoint(); 69 pts[0] = buffer.readPoint();
70 pts[1] = buffer.readPoint(); 70 pts[1] = buffer.readPoint();
71 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt, 71 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt,
72 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix); 72 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix);
73 } 73 }
74 74
75 void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { 75 void SkLinearGradient::flatten(SkWriteBuffer& buffer) const {
76 this->INHERITED::flatten(buffer); 76 this->INHERITED::flatten(buffer);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const SkPMColor* SK_RESTRICT cache = fCache->getCache32(); 221 const SkPMColor* SK_RESTRICT cache = fCache->getCache32();
222 int toggle = init_dither_toggle(x, y); 222 int toggle = init_dither_toggle(x, y);
223 223
224 if (fDstToIndexClass != kPerspective_MatrixClass) { 224 if (fDstToIndexClass != kPerspective_MatrixClass) {
225 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, 225 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf,
226 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); 226 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
227 SkGradFixed dx, fx = SkScalarToGradFixed(srcPt.fX); 227 SkGradFixed dx, fx = SkScalarToGradFixed(srcPt.fX);
228 228
229 if (fDstToIndexClass == kFixedStepInX_MatrixClass) { 229 if (fDstToIndexClass == kFixedStepInX_MatrixClass) {
230 SkFixed dxStorage[1]; 230 SkFixed dxStorage[1];
231 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL); 231 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, nullptr) ;
232 // todo: do we need a real/high-precision value for dx here? 232 // todo: do we need a real/high-precision value for dx here?
233 dx = SkFixedToGradFixed(dxStorage[0]); 233 dx = SkFixedToGradFixed(dxStorage[0]);
234 } else { 234 } else {
235 SkASSERT(fDstToIndexClass == kLinear_MatrixClass); 235 SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
236 dx = SkScalarToGradFixed(fDstToIndex.getScaleX()); 236 dx = SkScalarToGradFixed(fDstToIndex.getScaleX());
237 } 237 }
238 238
239 LinearShadeProc shadeProc = shadeSpan_linear_repeat; 239 LinearShadeProc shadeProc = shadeSpan_linear_repeat;
240 if (0 == dx) { 240 if (0 == dx) {
241 shadeProc = shadeSpan_linear_vertical_lerp; 241 shadeProc = shadeSpan_linear_vertical_lerp;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 const uint16_t* SK_RESTRICT cache = fCache->getCache16(); 394 const uint16_t* SK_RESTRICT cache = fCache->getCache16();
395 int toggle = init_dither_toggle16(x, y); 395 int toggle = init_dither_toggle16(x, y);
396 396
397 if (fDstToIndexClass != kPerspective_MatrixClass) { 397 if (fDstToIndexClass != kPerspective_MatrixClass) {
398 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, 398 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf,
399 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); 399 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
400 SkGradFixed dx, fx = SkScalarToGradFixed(srcPt.fX); 400 SkGradFixed dx, fx = SkScalarToGradFixed(srcPt.fX);
401 401
402 if (fDstToIndexClass == kFixedStepInX_MatrixClass) { 402 if (fDstToIndexClass == kFixedStepInX_MatrixClass) {
403 SkFixed dxStorage[1]; 403 SkFixed dxStorage[1];
404 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL); 404 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, nullptr) ;
405 // todo: do we need a real/high-precision value for dx here? 405 // todo: do we need a real/high-precision value for dx here?
406 dx = SkFixedToGradFixed(dxStorage[0]); 406 dx = SkFixedToGradFixed(dxStorage[0]);
407 } else { 407 } else {
408 SkASSERT(fDstToIndexClass == kLinear_MatrixClass); 408 SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
409 dx = SkScalarToGradFixed(fDstToIndex.getScaleX()); 409 dx = SkScalarToGradFixed(fDstToIndex.getScaleX());
410 } 410 }
411 411
412 LinearShade16Proc shadeProc = shadeSpan16_linear_repeat; 412 LinearShade16Proc shadeProc = shadeSpan16_linear_repeat;
413 if (fixed_nearly_zero(SkGradFixedToFixed(dx))) { 413 if (fixed_nearly_zero(SkGradFixedToFixed(dx))) {
414 shadeProc = shadeSpan16_linear_vertical; 414 shadeProc = shadeSpan16_linear_vertical;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 SkScalar* stops = stopsArray; 516 SkScalar* stops = stopsArray;
517 SkShader::TileMode tm; 517 SkShader::TileMode tm;
518 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 518 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
519 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, 519 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
520 colors, stops, colorCount, 520 colors, stops, colorCount,
521 tm)); 521 tm));
522 SkPaint paint; 522 SkPaint paint;
523 GrColor paintColor; 523 GrColor paintColor;
524 GrFragmentProcessor* fp; 524 GrFragmentProcessor* fp;
525 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 525 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
526 GrTest::TestMatrix(d->fRandom), N ULL, 526 GrTest::TestMatrix(d->fRandom), n ullptr,
527 &paintColor, d->fProcDataManager, &fp)); 527 &paintColor, d->fProcDataManager, &fp));
528 return fp; 528 return fp;
529 } 529 }
530 530
531 ///////////////////////////////////////////////////////////////////// 531 /////////////////////////////////////////////////////////////////////
532 532
533 void GrGLLinearGradient::emitCode(EmitArgs& args) { 533 void GrGLLinearGradient::emitCode(EmitArgs& args) {
534 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>(); 534 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
535 this->emitUniforms(args.fBuilder, ge); 535 this->emitUniforms(args.fBuilder, ge);
536 SkString t = args.fBuilder->getFragmentShaderBuilder()->ensureFSCoords2D(arg s.fCoords, 0); 536 SkString t = args.fBuilder->getFragmentShaderBuilder()->ensureFSCoords2D(arg s.fCoords, 0);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 str->append("SkLinearGradient ("); 583 str->append("SkLinearGradient (");
584 584
585 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 585 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
586 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 586 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
587 587
588 this->INHERITED::toString(str); 588 this->INHERITED::toString(str);
589 589
590 str->append(")"); 590 str->append(")");
591 } 591 }
592 #endif 592 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShaderPriv.h ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698