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 sk_sp<SkShader> CreateShader(const ColorBuffer&, | 105 virtual std::unique_ptr<PaintShader> 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&) const = 0; | 109 const SkMatrix&) const = 0; |
110 | 110 |
111 private: | 111 private: |
112 sk_sp<PaintShader> CreateShaderInternal(const SkMatrix& local_matrix); | 112 std::unique_ptr<PaintShader> CreateShaderInternal( |
| 113 const SkMatrix& local_matrix); |
113 | 114 |
114 void SortStopsIfNecessary(); | 115 void SortStopsIfNecessary(); |
115 void FillSkiaStops(ColorBuffer&, OffsetBuffer&) const; | 116 void FillSkiaStops(ColorBuffer&, OffsetBuffer&) const; |
116 | 117 |
117 const Type type_; | 118 const Type type_; |
118 const GradientSpreadMethod spread_method_; | 119 const GradientSpreadMethod spread_method_; |
119 const ColorInterpolation color_interpolation_; | 120 const ColorInterpolation color_interpolation_; |
120 | 121 |
121 Vector<ColorStop, 2> stops_; | 122 Vector<ColorStop, 2> stops_; |
122 bool stops_sorted_; | 123 bool stops_sorted_; |
123 | 124 |
124 mutable sk_sp<PaintShader> cached_shader_; | 125 mutable std::unique_ptr<PaintShader> cached_shader_; |
125 }; | 126 }; |
126 | 127 |
127 } // namespace blink | 128 } // namespace blink |
128 | 129 |
129 #endif | 130 #endif |
OLD | NEW |