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

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

Issue 768183002: Revert of 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
63 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) { 71 SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
64 DescriptorScope desc; 72 DescriptorScope desc;
65 if (!desc.unflatten(buffer)) { 73 if (!desc.unflatten(buffer)) {
66 return NULL; 74 return NULL;
67 } 75 }
68 SkPoint pts[2]; 76 SkPoint pts[2];
69 pts[0] = buffer.readPoint(); 77 pts[0] = buffer.readPoint();
70 pts[1] = buffer.readPoint(); 78 pts[1] = buffer.readPoint();
71 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt, 79 return SkGradientShader::CreateLinear(pts, desc.fColors, desc.fPos, desc.fCo unt,
72 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix); 80 desc.fTileMode, desc.fGradFlags, desc. fLocalMatrix);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 t.append(".x"); 561 t.append(".x");
554 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 562 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers);
555 } 563 }
556 564
557 ///////////////////////////////////////////////////////////////////// 565 /////////////////////////////////////////////////////////////////////
558 566
559 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int, 567 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int,
560 const SkMatrix* localMatrix, GrColor* paintColor, 568 const SkMatrix* localMatrix, GrColor* paintColor,
561 GrFragmentProcessor** fp) const { 569 GrFragmentProcessor** fp) const {
562 SkASSERT(context); 570 SkASSERT(context);
563 571
564 SkMatrix matrix; 572 SkMatrix matrix;
565 if (!this->getLocalMatrix().invert(&matrix)) { 573 if (!this->getLocalMatrix().invert(&matrix)) {
566 return false; 574 return false;
567 } 575 }
568 if (localMatrix) { 576 if (localMatrix) {
569 SkMatrix inv; 577 SkMatrix inv;
570 if (!localMatrix->invert(&inv)) { 578 if (!localMatrix->invert(&inv)) {
571 return false; 579 return false;
572 } 580 }
573 matrix.postConcat(inv); 581 matrix.postConcat(inv);
574 } 582 }
575 matrix.postConcat(fPtsToUnit); 583 matrix.postConcat(fPtsToUnit);
576 584
577 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 585 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
578 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode); 586 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode);
579 587
580 return true; 588 return true;
581 } 589 }
582 590
583 #else 591 #else
584 592
585 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix*, GrColor*, 593 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix*, GrColor*,
586 GrFragmentProcessor**) const { 594 GrFragmentProcessor**) const {
587 SkDEBUGFAIL("Should not call in GPU-less build"); 595 SkDEBUGFAIL("Should not call in GPU-less build");
588 return false; 596 return false;
589 } 597 }
590 598
591 #endif 599 #endif
592 600
593 #ifndef SK_IGNORE_TO_STRING 601 #ifndef SK_IGNORE_TO_STRING
594 void SkLinearGradient::toString(SkString* str) const { 602 void SkLinearGradient::toString(SkString* str) const {
595 str->append("SkLinearGradient ("); 603 str->append("SkLinearGradient (");
596 604
597 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 605 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
598 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 606 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
599 607
600 this->INHERITED::toString(str); 608 this->INHERITED::toString(str);
601 609
602 str->append(")"); 610 str->append(")");
603 } 611 }
604 #endif 612 #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