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

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

Issue 18533006: Consider conical shader opaque if it covers entire plane. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.h ('k') | tests/GradientTest.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 /* 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 "SkTwoPointConicalGradient.h" 9 #include "SkTwoPointConicalGradient.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 fCenterX = SkScalarToFloat(center0.fX); 67 fCenterX = SkScalarToFloat(center0.fX);
68 fCenterY = SkScalarToFloat(center0.fY); 68 fCenterY = SkScalarToFloat(center0.fY);
69 fDCenterX = SkScalarToFloat(center1.fX) - fCenterX; 69 fDCenterX = SkScalarToFloat(center1.fX) - fCenterX;
70 fDCenterY = SkScalarToFloat(center1.fY) - fCenterY; 70 fDCenterY = SkScalarToFloat(center1.fY) - fCenterY;
71 fRadius = SkScalarToFloat(rad0); 71 fRadius = SkScalarToFloat(rad0);
72 fDRadius = SkScalarToFloat(rad1) - fRadius; 72 fDRadius = SkScalarToFloat(rad1) - fRadius;
73 73
74 fA = sqr(fDCenterX) + sqr(fDCenterY) - sqr(fDRadius); 74 fA = sqr(fDCenterX) + sqr(fDCenterY) - sqr(fDRadius);
75 fRadius2 = sqr(fRadius); 75 fRadius2 = sqr(fRadius);
76 fRDR = fRadius * fDRadius; 76 fRDR = fRadius * fDRadius;
77
78 fConeFillsPlane = rad0 != rad1 && SkMaxScalar(rad0, rad1) > SkPoint::Distanc e(center0, center1);
77 } 79 }
78 80
79 void TwoPtRadial::setup(SkScalar fx, SkScalar fy, SkScalar dfx, SkScalar dfy) { 81 void TwoPtRadial::setup(SkScalar fx, SkScalar fy, SkScalar dfx, SkScalar dfy) {
80 fRelX = SkScalarToFloat(fx) - fCenterX; 82 fRelX = SkScalarToFloat(fx) - fCenterX;
81 fRelY = SkScalarToFloat(fy) - fCenterY; 83 fRelY = SkScalarToFloat(fy) - fCenterY;
82 fIncX = SkScalarToFloat(dfx); 84 fIncX = SkScalarToFloat(dfx);
83 fIncY = SkScalarToFloat(dfy); 85 fIncY = SkScalarToFloat(dfy);
84 fB = -2 * (fDCenterX * fRelX + fDCenterY * fRelY + fRDR); 86 fB = -2 * (fDCenterX * fRelX + fDCenterY * fRelY + fRDR);
85 fDB = -2 * (fDCenterX * fIncX + fDCenterY * fIncY); 87 fDB = -2 * (fDCenterX * fIncX + fDCenterY * fIncY);
86 } 88 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 fCenter1(start), 184 fCenter1(start),
183 fCenter2(end), 185 fCenter2(end),
184 fRadius1(startRadius), 186 fRadius1(startRadius),
185 fRadius2(endRadius) { 187 fRadius2(endRadius) {
186 // this is degenerate, and should be caught by our caller 188 // this is degenerate, and should be caught by our caller
187 SkASSERT(fCenter1 != fCenter2 || fRadius1 != fRadius2); 189 SkASSERT(fCenter1 != fCenter2 || fRadius1 != fRadius2);
188 this->init(); 190 this->init();
189 } 191 }
190 192
191 bool SkTwoPointConicalGradient::isOpaque() const { 193 bool SkTwoPointConicalGradient::isOpaque() const {
192 // Because areas outside the cone are left untouched, we cannot treat the 194 return INHERITED::isOpaque() && this->fRec.fConeFillsPlane;
193 // shader as opaque even if the gradient itself is opaque.
194 // TODO(junov): Compute whether the cone fills the plane crbug.com/222380
195 return false;
196 } 195 }
197 196
198 void SkTwoPointConicalGradient::shadeSpan(int x, int y, SkPMColor* dstCParam, 197 void SkTwoPointConicalGradient::shadeSpan(int x, int y, SkPMColor* dstCParam,
199 int count) { 198 int count) {
200 int toggle = init_dither_toggle(x, y); 199 int toggle = init_dither_toggle(x, y);
201 200
202 SkASSERT(count > 0); 201 SkASSERT(count > 0);
203 202
204 SkPMColor* SK_RESTRICT dstC = dstCParam; 203 SkPMColor* SK_RESTRICT dstC = dstCParam;
205 204
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 str->appendScalar(fCenter2.fY); 755 str->appendScalar(fCenter2.fY);
757 str->append(") radius2: "); 756 str->append(") radius2: ");
758 str->appendScalar(fRadius2); 757 str->appendScalar(fRadius2);
759 str->append(" "); 758 str->append(" ");
760 759
761 this->INHERITED::toString(str); 760 this->INHERITED::toString(str);
762 761
763 str->append(")"); 762 str->append(")");
764 } 763 }
765 #endif 764 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.h ('k') | tests/GradientTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698