OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2008 Torch Mobile, Inc. | 4 * Copyright (C) 2008 Torch Mobile, Inc. |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 void AddColorStops(const Vector<Gradient::ColorStop>&); | 96 void AddColorStops(const Vector<Gradient::ColorStop>&); |
97 | 97 |
98 void ApplyToFlags(PaintFlags&, const SkMatrix& local_matrix); | 98 void ApplyToFlags(PaintFlags&, const SkMatrix& local_matrix); |
99 | 99 |
100 protected: | 100 protected: |
101 Gradient(Type, GradientSpreadMethod, ColorInterpolation); | 101 Gradient(Type, GradientSpreadMethod, ColorInterpolation); |
102 | 102 |
103 using ColorBuffer = Vector<SkColor, 8>; | 103 using ColorBuffer = Vector<SkColor, 8>; |
104 using OffsetBuffer = Vector<SkScalar, 8>; | 104 using OffsetBuffer = Vector<SkScalar, 8>; |
105 virtual std::unique_ptr<PaintShader> CreateShader(const ColorBuffer&, | 105 virtual sk_sp<SkShader> CreateShader(const ColorBuffer&, |
106 const OffsetBuffer&, | 106 const OffsetBuffer&, |
107 SkShader::TileMode, | 107 SkShader::TileMode, |
108 uint32_t flags, | 108 uint32_t flags, |
109 const SkMatrix&, | 109 const SkMatrix&) const = 0; |
110 SkColor) const = 0; | |
111 | 110 |
112 private: | 111 private: |
113 std::unique_ptr<PaintShader> CreateShaderInternal( | 112 sk_sp<PaintShader> CreateShaderInternal(const SkMatrix& local_matrix); |
114 const SkMatrix& local_matrix); | |
115 | 113 |
116 void SortStopsIfNecessary(); | 114 void SortStopsIfNecessary(); |
117 void FillSkiaStops(ColorBuffer&, OffsetBuffer&) const; | 115 void FillSkiaStops(ColorBuffer&, OffsetBuffer&) const; |
118 | 116 |
119 const Type type_; | 117 const Type type_; |
120 const GradientSpreadMethod spread_method_; | 118 const GradientSpreadMethod spread_method_; |
121 const ColorInterpolation color_interpolation_; | 119 const ColorInterpolation color_interpolation_; |
122 | 120 |
123 Vector<ColorStop, 2> stops_; | 121 Vector<ColorStop, 2> stops_; |
124 bool stops_sorted_; | 122 bool stops_sorted_; |
125 | 123 |
126 mutable std::unique_ptr<PaintShader> cached_shader_; | 124 mutable sk_sp<PaintShader> cached_shader_; |
127 }; | 125 }; |
128 | 126 |
129 } // namespace blink | 127 } // namespace blink |
130 | 128 |
131 #endif | 129 #endif |
OLD | NEW |