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 "SkLinearGradient.h" | 8 #include "SkLinearGradient.h" |
9 | 9 |
10 static inline int repeat_bits(int x, const int bits) { | 10 static inline int repeat_bits(int x, const int bits) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { | 69 void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { |
70 this->INHERITED::flatten(buffer); | 70 this->INHERITED::flatten(buffer); |
71 buffer.writePoint(fStart); | 71 buffer.writePoint(fStart); |
72 buffer.writePoint(fEnd); | 72 buffer.writePoint(fEnd); |
73 } | 73 } |
74 | 74 |
75 size_t SkLinearGradient::contextSize() const { | 75 size_t SkLinearGradient::contextSize() const { |
76 return sizeof(LinearGradientContext); | 76 return sizeof(LinearGradientContext); |
77 } | 77 } |
78 | 78 |
79 SkShader::Context* SkLinearGradient::createContext(const ContextRec& rec, void*
storage) const { | 79 SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void
* storage) const { |
80 if (!this->validContext(rec)) { | |
81 return NULL; | |
82 } | |
83 | |
84 return SkNEW_PLACEMENT_ARGS(storage, LinearGradientContext, (*this, rec)); | 80 return SkNEW_PLACEMENT_ARGS(storage, LinearGradientContext, (*this, rec)); |
85 } | 81 } |
86 | 82 |
87 SkLinearGradient::LinearGradientContext::LinearGradientContext( | 83 SkLinearGradient::LinearGradientContext::LinearGradientContext( |
88 const SkLinearGradient& shader, const ContextRec& rec) | 84 const SkLinearGradient& shader, const ContextRec& rec) |
89 : INHERITED(shader, rec) | 85 : INHERITED(shader, rec) |
90 { | 86 { |
91 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; | 87 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; |
92 if ((fDstToIndex.getType() & ~mask) == 0) { | 88 if ((fDstToIndex.getType() & ~mask) == 0) { |
93 // when we dither, we are (usually) not const-in-Y | 89 // when we dither, we are (usually) not const-in-Y |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 str->append("SkLinearGradient ("); | 571 str->append("SkLinearGradient ("); |
576 | 572 |
577 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 573 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
578 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 574 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
579 | 575 |
580 this->INHERITED::toString(str); | 576 this->INHERITED::toString(str); |
581 | 577 |
582 str->append(")"); | 578 str->append(")"); |
583 } | 579 } |
584 #endif | 580 #endif |
OLD | NEW |