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

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

Issue 769953002: Remove SK_SUPPORT_LEGACY_DEEPFLATTENING. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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/SkGradientShader.cpp ('k') | src/effects/gradients/SkRadialGradient.cpp » ('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 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 /////////////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////////////
54 54
55 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc) 55 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc)
56 : SkGradientShaderBase(desc) 56 : SkGradientShaderBase(desc)
57 , fStart(pts[0]) 57 , fStart(pts[0])
58 , fEnd(pts[1]) 58 , fEnd(pts[1])
59 { 59 {
60 pts_to_unit_matrix(pts, &fPtsToUnit); 60 pts_to_unit_matrix(pts, &fPtsToUnit);
61 } 61 }
62 62
63 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
64 SkLinearGradient::SkLinearGradient(SkReadBuffer& buffer)
65 : INHERITED(buffer)
66 , fStart(buffer.readPoint())
67 , fEnd(buffer.readPoint()) {
68 }
69 #endif
70
71 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) { 63 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
72 DescriptorScope desc; 64 DescriptorScope desc;
73 if (!desc.unflatten(buffer)) { 65 if (!desc.unflatten(buffer)) {
74 return NULL; 66 return NULL;
75 } 67 }
76 SkPoint pts[2]; 68 SkPoint pts[2];
77 pts[0] = buffer.readPoint(); 69 pts[0] = buffer.readPoint();
78 pts[1] = buffer.readPoint(); 70 pts[1] = buffer.readPoint();
79 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt, 71 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt,
80 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix); 72 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 t.append(".x"); 553 t.append(".x");
562 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 554 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers);
563 } 555 }
564 556
565 ///////////////////////////////////////////////////////////////////// 557 /////////////////////////////////////////////////////////////////////
566 558
567 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int, 559 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int,
568 const SkMatrix* localMatrix, GrColor* paintColor, 560 const SkMatrix* localMatrix, GrColor* paintColor,
569 GrFragmentProcessor** fp) const { 561 GrFragmentProcessor** fp) const {
570 SkASSERT(context); 562 SkASSERT(context);
571 563
572 SkMatrix matrix; 564 SkMatrix matrix;
573 if (!this->getLocalMatrix().invert(&matrix)) { 565 if (!this->getLocalMatrix().invert(&matrix)) {
574 return false; 566 return false;
575 } 567 }
576 if (localMatrix) { 568 if (localMatrix) {
577 SkMatrix inv; 569 SkMatrix inv;
578 if (!localMatrix->invert(&inv)) { 570 if (!localMatrix->invert(&inv)) {
579 return false; 571 return false;
580 } 572 }
581 matrix.postConcat(inv); 573 matrix.postConcat(inv);
582 } 574 }
583 matrix.postConcat(fPtsToUnit); 575 matrix.postConcat(fPtsToUnit);
584 576
585 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 577 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
586 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode); 578 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode);
587 579
588 return true; 580 return true;
589 } 581 }
590 582
591 #else 583 #else
592 584
593 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix*, GrColor*, 585 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix*, GrColor*,
594 GrFragmentProcessor**) const { 586 GrFragmentProcessor**) const {
595 SkDEBUGFAIL("Should not call in GPU-less build"); 587 SkDEBUGFAIL("Should not call in GPU-less build");
596 return false; 588 return false;
597 } 589 }
598 590
599 #endif 591 #endif
600 592
601 #ifndef SK_IGNORE_TO_STRING 593 #ifndef SK_IGNORE_TO_STRING
602 void SkLinearGradient::toString(SkString* str) const { 594 void SkLinearGradient::toString(SkString* str) const {
603 str->append("SkLinearGradient ("); 595 str->append("SkLinearGradient (");
604 596
605 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 597 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
606 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 598 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
607 599
608 this->INHERITED::toString(str); 600 this->INHERITED::toString(str);
609 601
610 str->append(")"); 602 str->append(")");
611 } 603 }
612 #endif 604 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698