Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Gradient.h

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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&,
110 SkColor) const = 0;
110 111
111 private: 112 private:
112 sk_sp<PaintShader> CreateShaderInternal(const SkMatrix& local_matrix); 113 std::unique_ptr<PaintShader> CreateShaderInternal(
114 const SkMatrix& local_matrix);
113 115
114 void SortStopsIfNecessary(); 116 void SortStopsIfNecessary();
115 void FillSkiaStops(ColorBuffer&, OffsetBuffer&) const; 117 void FillSkiaStops(ColorBuffer&, OffsetBuffer&) const;
116 118
117 const Type type_; 119 const Type type_;
118 const GradientSpreadMethod spread_method_; 120 const GradientSpreadMethod spread_method_;
119 const ColorInterpolation color_interpolation_; 121 const ColorInterpolation color_interpolation_;
120 122
121 Vector<ColorStop, 2> stops_; 123 Vector<ColorStop, 2> stops_;
122 bool stops_sorted_; 124 bool stops_sorted_;
123 125
124 mutable sk_sp<PaintShader> cached_shader_; 126 mutable std::unique_ptr<PaintShader> cached_shader_;
125 }; 127 };
126 128
127 } // namespace blink 129 } // namespace blink
128 130
129 #endif 131 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698