OLD | NEW |
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 "SkSweepGradient.h" | 8 #include "SkSweepGradient.h" |
9 | 9 |
10 static SkMatrix translate(SkScalar dx, SkScalar dy) { | 10 static SkMatrix translate(SkScalar dx, SkScalar dy) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
47 | 47 |
48 size_t SkSweepGradient::onContextSize(const ContextRec&) const { | 48 size_t SkSweepGradient::onContextSize(const ContextRec&) const { |
49 return sizeof(SweepGradientContext); | 49 return sizeof(SweepGradientContext); |
50 } | 50 } |
51 | 51 |
52 SkShader::Context* SkSweepGradient::onCreateContext(const ContextRec& rec, void*
storage) const { | 52 SkShader::Context* SkSweepGradient::onCreateContext(const ContextRec& rec, void*
storage) const { |
53 return new (storage) SweepGradientContext(*this, rec); | 53 return CheckedCreateContext<SweepGradientContext>(storage, *this, rec); |
54 } | 54 } |
55 | 55 |
56 SkSweepGradient::SweepGradientContext::SweepGradientContext( | 56 SkSweepGradient::SweepGradientContext::SweepGradientContext( |
57 const SkSweepGradient& shader, const ContextRec& rec) | 57 const SkSweepGradient& shader, const ContextRec& rec) |
58 : INHERITED(shader, rec) {} | 58 : INHERITED(shader, rec) {} |
59 | 59 |
60 // returns angle in a circle [0..2PI) -> [0..255] | 60 // returns angle in a circle [0..2PI) -> [0..255] |
61 static unsigned SkATan2_255(float y, float x) { | 61 static unsigned SkATan2_255(float y, float x) { |
62 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); | 62 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); |
63 static const float g255Over2PI = 40.584510488433314f; | 63 static const float g255Over2PI = 40.584510488433314f; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 str->appendScalar(fCenter.fX); | 267 str->appendScalar(fCenter.fX); |
268 str->append(", "); | 268 str->append(", "); |
269 str->appendScalar(fCenter.fY); | 269 str->appendScalar(fCenter.fY); |
270 str->append(") "); | 270 str->append(") "); |
271 | 271 |
272 this->INHERITED::toString(str); | 272 this->INHERITED::toString(str); |
273 | 273 |
274 str->append(")"); | 274 str->append(")"); |
275 } | 275 } |
276 #endif | 276 #endif |
OLD | NEW |