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

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

Issue 15733007: use Descriptor struct to encapsulate all the common paramaeters between our various gradient types.… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 "SkLinearGradient.h" 9 #include "SkLinearGradient.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SkScalar inv = mag ? SkScalarInvert(mag) : 0; 55 SkScalar inv = mag ? SkScalarInvert(mag) : 0;
56 56
57 vec.scale(inv); 57 vec.scale(inv);
58 matrix->setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY); 58 matrix->setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY);
59 matrix->postTranslate(-pts[0].fX, -pts[0].fY); 59 matrix->postTranslate(-pts[0].fX, -pts[0].fY);
60 matrix->postScale(inv, inv); 60 matrix->postScale(inv, inv);
61 } 61 }
62 62
63 /////////////////////////////////////////////////////////////////////////////// 63 ///////////////////////////////////////////////////////////////////////////////
64 64
65 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], 65 SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc)
66 const SkColor colors[], 66 : SkGradientShaderBase(desc)
67 const SkScalar pos[],
68 int colorCount,
69 SkShader::TileMode mode,
70 SkUnitMapper* mapper)
71 : SkGradientShaderBase(colors, pos, colorCount, mode, mapper)
72 , fStart(pts[0]) 67 , fStart(pts[0])
73 , fEnd(pts[1]) { 68 , fEnd(pts[1]) {
74 pts_to_unit_matrix(pts, &fPtsToUnit); 69 pts_to_unit_matrix(pts, &fPtsToUnit);
75 } 70 }
76 71
77 SkLinearGradient::SkLinearGradient(SkFlattenableReadBuffer& buffer) 72 SkLinearGradient::SkLinearGradient(SkFlattenableReadBuffer& buffer)
78 : INHERITED(buffer) 73 : INHERITED(buffer)
79 , fStart(buffer.readPoint()) 74 , fStart(buffer.readPoint())
80 , fEnd(buffer.readPoint()) { 75 , fEnd(buffer.readPoint()) {
81 } 76 }
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 str->append("SkLinearGradient ("); 568 str->append("SkLinearGradient (");
574 569
575 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 570 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
576 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 571 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
577 572
578 this->INHERITED::toString(str); 573 this->INHERITED::toString(str);
579 574
580 str->append(")"); 575 str->append(")");
581 } 576 }
582 #endif 577 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698