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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { | 50 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { |
51 this->INHERITED::flatten(buffer); | 51 this->INHERITED::flatten(buffer); |
52 buffer.writePoint(fCenter); | 52 buffer.writePoint(fCenter); |
53 } | 53 } |
54 | 54 |
55 size_t SkSweepGradient::contextSize() const { | 55 size_t SkSweepGradient::contextSize() const { |
56 return sizeof(SweepGradientContext); | 56 return sizeof(SweepGradientContext); |
57 } | 57 } |
58 | 58 |
59 SkShader::Context* SkSweepGradient::createContext(const ContextRec& rec, void* s
torage) const { | 59 SkShader::Context* SkSweepGradient::onCreateContext(const ContextRec& rec, void*
storage) const { |
60 if (!this->validContext(rec)) { | |
61 return NULL; | |
62 } | |
63 | |
64 return SkNEW_PLACEMENT_ARGS(storage, SweepGradientContext, (*this, rec)); | 60 return SkNEW_PLACEMENT_ARGS(storage, SweepGradientContext, (*this, rec)); |
65 } | 61 } |
66 | 62 |
67 SkSweepGradient::SweepGradientContext::SweepGradientContext( | 63 SkSweepGradient::SweepGradientContext::SweepGradientContext( |
68 const SkSweepGradient& shader, const ContextRec& rec) | 64 const SkSweepGradient& shader, const ContextRec& rec) |
69 : INHERITED(shader, rec) {} | 65 : INHERITED(shader, rec) {} |
70 | 66 |
71 // returns angle in a circle [0..2PI) -> [0..255] | 67 // returns angle in a circle [0..2PI) -> [0..255] |
72 static unsigned SkATan2_255(float y, float x) { | 68 static unsigned SkATan2_255(float y, float x) { |
73 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); | 69 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 str->appendScalar(fCenter.fX); | 305 str->appendScalar(fCenter.fX); |
310 str->append(", "); | 306 str->append(", "); |
311 str->appendScalar(fCenter.fY); | 307 str->appendScalar(fCenter.fY); |
312 str->append(") "); | 308 str->append(") "); |
313 | 309 |
314 this->INHERITED::toString(str); | 310 this->INHERITED::toString(str); |
315 | 311 |
316 str->append(")"); | 312 str->append(")"); |
317 } | 313 } |
318 #endif | 314 #endif |
OLD | NEW |