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

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

Issue 2416233002: Faster 4f gradient premul path (Closed)
Patch Set: Created 4 years, 2 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 | « src/effects/gradients/Sk4fGradientBase.h ('k') | src/effects/gradients/Sk4fGradientPriv.h » ('j') | 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 2016 Google Inc. 2 * Copyright 2016 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 "Sk4fGradientBase.h" 8 #include "Sk4fGradientBase.h"
9 9
10 #include <functional> 10 #include <functional>
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 319 }
320 } 320 }
321 321
322 template<DstType dstType, ApplyPremul premul, SkShader::TileMode tileMode> 322 template<DstType dstType, ApplyPremul premul, SkShader::TileMode tileMode>
323 void SkGradientShaderBase:: 323 void SkGradientShaderBase::
324 GradientShaderBase4fContext::shadeSpanInternal(int x, int y, 324 GradientShaderBase4fContext::shadeSpanInternal(int x, int y,
325 typename DstTraits<dstType, premu l>::Type dst[], 325 typename DstTraits<dstType, premu l>::Type dst[],
326 int count) const { 326 int count) const {
327 static const int kBufSize = 128; 327 static const int kBufSize = 128;
328 SkScalar ts[kBufSize]; 328 SkScalar ts[kBufSize];
329 TSampler<dstType, tileMode> sampler(*this); 329 TSampler<dstType, premul, tileMode> sampler(*this);
330 330
331 SkASSERT(count > 0); 331 SkASSERT(count > 0);
332 do { 332 do {
333 const int n = SkTMin(kBufSize, count); 333 const int n = SkTMin(kBufSize, count);
334 this->mapTs(x, y, ts, n); 334 this->mapTs(x, y, ts, n);
335 for (int i = 0; i < n; ++i) { 335 for (int i = 0; i < n; ++i) {
336 const Sk4f c = sampler.sample(ts[i]); 336 const Sk4f c = sampler.sample(ts[i]);
337 DstTraits<dstType, premul>::store(c, dst++); 337 DstTraits<dstType, premul>::store(c, dst++);
338 } 338 }
339 x += n; 339 x += n;
340 count -= n; 340 count -= n;
341 } while (count > 0); 341 } while (count > 0);
342 } 342 }
343 343
344 template<DstType dstType, SkShader::TileMode tileMode> 344 template<DstType dstType, ApplyPremul premul, SkShader::TileMode tileMode>
345 class SkGradientShaderBase::GradientShaderBase4fContext::TSampler { 345 class SkGradientShaderBase::GradientShaderBase4fContext::TSampler {
346 public: 346 public:
347 TSampler(const GradientShaderBase4fContext& ctx) 347 TSampler(const GradientShaderBase4fContext& ctx)
348 : fFirstInterval(ctx.fIntervals.begin()) 348 : fFirstInterval(ctx.fIntervals.begin())
349 , fLastInterval(ctx.fIntervals.end() - 1) 349 , fLastInterval(ctx.fIntervals.end() - 1)
350 , fInterval(nullptr) { 350 , fInterval(nullptr) {
351 SkASSERT(fLastInterval >= fFirstInterval); 351 SkASSERT(fLastInterval >= fFirstInterval);
352 } 352 }
353 353
354 Sk4f sample(SkScalar t) { 354 Sk4f sample(SkScalar t) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (i < fFirstInterval) { 417 if (i < fFirstInterval) {
418 i = fLastInterval; 418 i = fLastInterval;
419 } 419 }
420 } while (tiled_t < i->fP0 || tiled_t >= i->fP1); 420 } while (tiled_t < i->fP0 || tiled_t >= i->fP1);
421 } 421 }
422 422
423 return i; 423 return i;
424 } 424 }
425 425
426 void loadIntervalData(const Interval* i) { 426 void loadIntervalData(const Interval* i) {
427 fCc = DstTraits<dstType>::load(i->fC0); 427 fCc = DstTraits<dstType, premul>::load(i->fC0);
428 fDc = DstTraits<dstType>::load(i->fDc); 428 fDc = DstTraits<dstType, premul>::load(i->fDc);
429 } 429 }
430 430
431 const Interval* fFirstInterval; 431 const Interval* fFirstInterval;
432 const Interval* fLastInterval; 432 const Interval* fLastInterval;
433 const Interval* fInterval; 433 const Interval* fInterval;
434 SkScalar fPrevT; 434 SkScalar fPrevT;
435 Sk4f fCc; 435 Sk4f fCc;
436 Sk4f fDc; 436 Sk4f fDc;
437 }; 437 };
OLDNEW
« no previous file with comments | « src/effects/gradients/Sk4fGradientBase.h ('k') | src/effects/gradients/Sk4fGradientPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698