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

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

Issue 169283008: Maintain SkPaint in GraphicsContextState. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: A couple more optimizations. Created 6 years, 9 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 | Annotate | Revision Log
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 float blue; 65 float blue;
66 float alpha; 66 float alpha;
67 67
68 ColorStop() : stop(0), red(0), green(0), blue(0), alpha(0) { } 68 ColorStop() : stop(0), red(0), green(0), blue(0), alpha(0) { }
69 ColorStop(float s, float r, float g, float b, float a) : stop(s), red(r) , green(g), blue(b), alpha(a) { } 69 ColorStop(float s, float r, float g, float b, float a) : stop(s), red(r) , green(g), blue(b), alpha(a) { }
70 }; 70 };
71 void addColorStop(const ColorStop&); 71 void addColorStop(const ColorStop&);
72 void addColorStop(float, const Color&); 72 void addColorStop(float, const Color&);
73 73
74 bool hasAlpha() const; 74 bool hasAlpha() const;
75 bool shaderChanged() const { return !m_gradient; }
75 76
76 bool isRadial() const { return m_radial; } 77 bool isRadial() const { return m_radial; }
77 bool isZeroSize() const { return m_p0.x() == m_p1.x() && m_p0.y() == m_p1.y( ) && (!m_radial || m_r0 == m_r1); } 78 bool isZeroSize() const { return m_p0.x() == m_p1.x() && m_p0.y() == m_p1.y( ) && (!m_radial || m_r0 == m_r1); }
78 79
79 const FloatPoint& p0() const { return m_p0; } 80 const FloatPoint& p0() const { return m_p0; }
80 const FloatPoint& p1() const { return m_p1; } 81 const FloatPoint& p1() const { return m_p1; }
81 82
82 void setP0(const FloatPoint& p) 83 void setP0(const FloatPoint& p)
83 { 84 {
84 if (m_p0 == p) 85 if (m_p0 == p)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformat ion; } 129 AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformat ion; }
129 130
130 private: 131 private:
131 Gradient(const FloatPoint& p0, const FloatPoint& p1); 132 Gradient(const FloatPoint& p0, const FloatPoint& p1);
132 Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, flo at aspectRatio); 133 Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, flo at aspectRatio);
133 134
134 void destroyShader(); 135 void destroyShader();
135 136
136 void sortStopsIfNecessary(); 137 void sortStopsIfNecessary();
137 138
138 // Keep any parameters relevant to rendering in sync with the structure in G radient::hash().
139 bool m_radial;
140 FloatPoint m_p0; 139 FloatPoint m_p0;
141 FloatPoint m_p1; 140 FloatPoint m_p1;
142 float m_r0; 141 float m_r0;
143 float m_r1; 142 float m_r1;
144 float m_aspectRatio; // For elliptical gradient, width / height. 143 float m_aspectRatio; // For elliptical gradient, width / height.
145 mutable Vector<ColorStop, 2> m_stops; 144 mutable Vector<ColorStop, 2> m_stops;
145 bool m_radial;
146 mutable bool m_stopsSorted; 146 mutable bool m_stopsSorted;
147 bool m_drawInPMColorSpace;
147 GradientSpreadMethod m_spreadMethod; 148 GradientSpreadMethod m_spreadMethod;
148 AffineTransform m_gradientSpaceTransformation; 149 AffineTransform m_gradientSpaceTransformation;
149 150
150 bool m_drawInPMColorSpace;
151 151
152 RefPtr<SkShader> m_gradient; 152 RefPtr<SkShader> m_gradient;
153 }; 153 };
154 154
155 } // namespace WebCore 155 } // namespace WebCore
156 156
157 #endif 157 #endif
OLDNEW
« no previous file with comments | « Source/platform/graphics/CrossfadeGeneratedImage.cpp ('k') | Source/platform/graphics/Gradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698