OLD | NEW |
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 "SkSweepGradient.h" | 9 #include "SkSweepGradient.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (info) { | 26 if (info) { |
27 commonAsAGradient(info); | 27 commonAsAGradient(info); |
28 info->fPoint[0] = fCenter; | 28 info->fPoint[0] = fCenter; |
29 } | 29 } |
30 return kSweep_GradientType; | 30 return kSweep_GradientType; |
31 } | 31 } |
32 | 32 |
33 SkFlattenable* SkSweepGradient::CreateProc(SkReadBuffer& buffer) { | 33 SkFlattenable* SkSweepGradient::CreateProc(SkReadBuffer& buffer) { |
34 DescriptorScope desc; | 34 DescriptorScope desc; |
35 if (!desc.unflatten(buffer)) { | 35 if (!desc.unflatten(buffer)) { |
36 return NULL; | 36 return nullptr; |
37 } | 37 } |
38 const SkPoint center = buffer.readPoint(); | 38 const SkPoint center = buffer.readPoint(); |
39 return SkGradientShader::CreateSweep(center.x(), center.y(), desc.fColors, d
esc.fPos, | 39 return SkGradientShader::CreateSweep(center.x(), center.y(), desc.fColors, d
esc.fPos, |
40 desc.fCount, desc.fGradFlags, desc.fLoc
alMatrix); | 40 desc.fCount, desc.fGradFlags, desc.fLoc
alMatrix); |
41 } | 41 } |
42 | 42 |
43 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { | 43 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { |
44 this->INHERITED::flatten(buffer); | 44 this->INHERITED::flatten(buffer); |
45 buffer.writePoint(fCenter); | 45 buffer.writePoint(fCenter); |
46 } | 46 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 SkScalar stopsArray[kMaxRandomGradientColors]; | 233 SkScalar stopsArray[kMaxRandomGradientColors]; |
234 SkScalar* stops = stopsArray; | 234 SkScalar* stops = stopsArray; |
235 SkShader::TileMode tmIgnored; | 235 SkShader::TileMode tmIgnored; |
236 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored
); | 236 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored
); |
237 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente
r.fY, | 237 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente
r.fY, |
238 colors, stops, c
olorCount)); | 238 colors, stops, c
olorCount)); |
239 SkPaint paint; | 239 SkPaint paint; |
240 GrFragmentProcessor* fp; | 240 GrFragmentProcessor* fp; |
241 GrColor paintColor; | 241 GrColor paintColor; |
242 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 242 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
243 GrTest::TestMatrix(d->fRandom), N
ULL, | 243 GrTest::TestMatrix(d->fRandom), n
ullptr, |
244 &paintColor, d->fProcDataManager,
&fp)); | 244 &paintColor, d->fProcDataManager,
&fp)); |
245 return fp; | 245 return fp; |
246 } | 246 } |
247 | 247 |
248 ///////////////////////////////////////////////////////////////////// | 248 ///////////////////////////////////////////////////////////////////// |
249 | 249 |
250 void GrGLSweepGradient::emitCode(EmitArgs& args) { | 250 void GrGLSweepGradient::emitCode(EmitArgs& args) { |
251 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>(); | 251 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>(); |
252 this->emitUniforms(args.fBuilder, ge); | 252 this->emitUniforms(args.fBuilder, ge); |
253 SkString coords2D = args.fBuilder->getFragmentShaderBuilder() | 253 SkString coords2D = args.fBuilder->getFragmentShaderBuilder() |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 str->appendScalar(fCenter.fX); | 314 str->appendScalar(fCenter.fX); |
315 str->append(", "); | 315 str->append(", "); |
316 str->appendScalar(fCenter.fY); | 316 str->appendScalar(fCenter.fY); |
317 str->append(") "); | 317 str->append(") "); |
318 | 318 |
319 this->INHERITED::toString(str); | 319 this->INHERITED::toString(str); |
320 | 320 |
321 str->append(")"); | 321 str->append(")"); |
322 } | 322 } |
323 #endif | 323 #endif |
OLD | NEW |