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

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

Issue 207683004: Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: totalInverse param optional; SkShader::computeTotalInverse; SkBitmapProcShader::validInternal Created 6 years, 9 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkRadialGradient.h" 9 #include "SkRadialGradient.h"
10 #include "SkRadialGradient_Table.h" 10 #include "SkRadialGradient_Table.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 : SkGradientShaderBase(desc), 150 : SkGradientShaderBase(desc),
151 fCenter(center), 151 fCenter(center),
152 fRadius(radius) 152 fRadius(radius)
153 { 153 {
154 // make sure our table is insync with our current #define for kSQRT_TABLE_SI ZE 154 // make sure our table is insync with our current #define for kSQRT_TABLE_SI ZE
155 SkASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE); 155 SkASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE);
156 156
157 rad_to_unit_matrix(center, radius, &fPtsToUnit); 157 rad_to_unit_matrix(center, radius, &fPtsToUnit);
158 } 158 }
159 159
160 #if 0
160 void SkRadialGradient::shadeSpan16(int x, int y, uint16_t* dstCParam, 161 void SkRadialGradient::shadeSpan16(int x, int y, uint16_t* dstCParam,
161 int count) { 162 int count) {
162 SkASSERT(count > 0); 163 SkASSERT(count > 0);
163 164
164 uint16_t* SK_RESTRICT dstC = dstCParam; 165 uint16_t* SK_RESTRICT dstC = dstCParam;
165 166
166 SkPoint srcPt; 167 SkPoint srcPt;
167 SkMatrix::MapXYProc dstProc = fDstToIndexProc; 168 SkMatrix::MapXYProc dstProc = fDstToIndexProc;
168 TileProc proc = fTileProc; 169 TileProc proc = fTileProc;
169 const uint16_t* SK_RESTRICT cache = this->getCache16(); 170 const uint16_t* SK_RESTRICT cache = this->getCache16();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 SkASSERT(fi <= 0xFFFF); 206 SkASSERT(fi <= 0xFFFF);
206 207
207 int index = fi >> (16 - kCache16Bits); 208 int index = fi >> (16 - kCache16Bits);
208 *dstC++ = cache[toggle + index]; 209 *dstC++ = cache[toggle + index];
209 toggle = next_dither_toggle16(toggle); 210 toggle = next_dither_toggle16(toggle);
210 211
211 dstX += SK_Scalar1; 212 dstX += SK_Scalar1;
212 } while (--count != 0); 213 } while (--count != 0);
213 } 214 }
214 } 215 }
216 #endif
215 217
216 SkShader::BitmapType SkRadialGradient::asABitmap(SkBitmap* bitmap, 218 SkShader::BitmapType SkRadialGradient::asABitmap(SkBitmap* bitmap,
217 SkMatrix* matrix, SkShader::TileMode* xy) const { 219 SkMatrix* matrix, SkShader::TileMode* xy) const {
218 if (bitmap) { 220 if (bitmap) {
219 this->getGradientTableBitmap(bitmap); 221 this->getGradientTableBitmap(bitmap);
220 } 222 }
221 if (matrix) { 223 if (matrix) {
222 matrix->setScale(SkIntToScalar(kCache32Count), 224 matrix->setScale(SkIntToScalar(kCache32Count),
223 SkIntToScalar(kCache32Count)); 225 SkIntToScalar(kCache32Count));
224 matrix->preConcat(fPtsToUnit); 226 matrix->preConcat(fPtsToUnit);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 384 }
383 385
384 void shadeSpan_radial_repeat(SkScalar fx, SkScalar dx, SkScalar fy, SkScalar dy, 386 void shadeSpan_radial_repeat(SkScalar fx, SkScalar dx, SkScalar fy, SkScalar dy,
385 SkPMColor* SK_RESTRICT dstC, const SkPMColor* SK_RE STRICT cache, 387 SkPMColor* SK_RESTRICT dstC, const SkPMColor* SK_RE STRICT cache,
386 int count, int toggle) { 388 int count, int toggle) {
387 shadeSpan_radial<repeat_tileproc_nonstatic>(fx, dx, fy, dy, dstC, cache, cou nt, toggle); 389 shadeSpan_radial<repeat_tileproc_nonstatic>(fx, dx, fy, dy, dstC, cache, cou nt, toggle);
388 } 390 }
389 391
390 } // namespace 392 } // namespace
391 393
394 #if 0
392 void SkRadialGradient::shadeSpan(int x, int y, 395 void SkRadialGradient::shadeSpan(int x, int y,
393 SkPMColor* SK_RESTRICT dstC, int count) { 396 SkPMColor* SK_RESTRICT dstC, int count) {
394 SkASSERT(count > 0); 397 SkASSERT(count > 0);
395 398
396 SkPoint srcPt; 399 SkPoint srcPt;
397 SkMatrix::MapXYProc dstProc = fDstToIndexProc; 400 SkMatrix::MapXYProc dstProc = fDstToIndexProc;
398 TileProc proc = fTileProc; 401 TileProc proc = fTileProc;
399 const SkPMColor* SK_RESTRICT cache = this->getCache32(); 402 const SkPMColor* SK_RESTRICT cache = this->getCache32();
400 int toggle = init_dither_toggle(x, y); 403 int toggle = init_dither_toggle(x, y);
401 404
(...skipping 27 matching lines...) Expand all
429 SkScalar dstY = SkIntToScalar(y); 432 SkScalar dstY = SkIntToScalar(y);
430 do { 433 do {
431 dstProc(fDstToIndex, dstX, dstY, &srcPt); 434 dstProc(fDstToIndex, dstX, dstY, &srcPt);
432 unsigned fi = proc(SkScalarToFixed(srcPt.length())); 435 unsigned fi = proc(SkScalarToFixed(srcPt.length()));
433 SkASSERT(fi <= 0xFFFF); 436 SkASSERT(fi <= 0xFFFF);
434 *dstC++ = cache[fi >> SkGradientShaderBase::kCache32Shift]; 437 *dstC++ = cache[fi >> SkGradientShaderBase::kCache32Shift];
435 dstX += SK_Scalar1; 438 dstX += SK_Scalar1;
436 } while (--count != 0); 439 } while (--count != 0);
437 } 440 }
438 } 441 }
442 #endif
439 443
440 ///////////////////////////////////////////////////////////////////// 444 /////////////////////////////////////////////////////////////////////
441 445
442 #if SK_SUPPORT_GPU 446 #if SK_SUPPORT_GPU
443 447
444 #include "GrTBackendEffectFactory.h" 448 #include "GrTBackendEffectFactory.h"
445 449
446 class GrGLRadialGradient : public GrGLGradientEffect { 450 class GrGLRadialGradient : public GrGLGradientEffect {
447 public: 451 public:
448 452
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 str->appendScalar(fCenter.fY); 577 str->appendScalar(fCenter.fY);
574 str->append(") radius: "); 578 str->append(") radius: ");
575 str->appendScalar(fRadius); 579 str->appendScalar(fRadius);
576 str->append(" "); 580 str->append(" ");
577 581
578 this->INHERITED::toString(str); 582 this->INHERITED::toString(str);
579 583
580 str->append(")"); 584 str->append(")");
581 } 585 }
582 #endif 586 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698