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

Side by Side Diff: Source/platform/graphics/GraphicsContextState.cpp

Issue 1213723006: Drop pattern-related state from GraphicsContext(State) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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
« no previous file with comments | « Source/platform/graphics/GraphicsContextState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/graphics/GraphicsContextState.h" 6 #include "platform/graphics/GraphicsContextState.h"
7 7
8 namespace blink { 8 namespace blink {
9 9
10 GraphicsContextState::GraphicsContextState() 10 GraphicsContextState::GraphicsContextState()
(...skipping 16 matching lines...) Expand all
27 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(m_ interpolationQuality)); 27 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(m_ interpolationQuality));
28 m_fillPaint.setAntiAlias(m_shouldAntialias); 28 m_fillPaint.setAntiAlias(m_shouldAntialias);
29 } 29 }
30 30
31 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) 31 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other)
32 : m_strokePaint(other.m_strokePaint) 32 : m_strokePaint(other.m_strokePaint)
33 , m_fillPaint(other.m_fillPaint) 33 , m_fillPaint(other.m_fillPaint)
34 , m_strokeData(other.m_strokeData) 34 , m_strokeData(other.m_strokeData)
35 , m_strokeColor(other.m_strokeColor) 35 , m_strokeColor(other.m_strokeColor)
36 , m_strokeGradient(other.m_strokeGradient) 36 , m_strokeGradient(other.m_strokeGradient)
37 , m_strokePattern(other.m_strokePattern)
38 , m_fillColor(other.m_fillColor) 37 , m_fillColor(other.m_fillColor)
39 , m_fillGradient(other.m_fillGradient) 38 , m_fillGradient(other.m_fillGradient)
40 , m_fillPattern(other.m_fillPattern)
41 , m_looper(other.m_looper) 39 , m_looper(other.m_looper)
42 , m_textDrawingMode(other.m_textDrawingMode) 40 , m_textDrawingMode(other.m_textDrawingMode)
43 , m_colorFilter(other.m_colorFilter) 41 , m_colorFilter(other.m_colorFilter)
44 , m_interpolationQuality(other.m_interpolationQuality) 42 , m_interpolationQuality(other.m_interpolationQuality)
45 , m_saveCount(0) 43 , m_saveCount(0)
46 , m_shouldAntialias(other.m_shouldAntialias) { } 44 , m_shouldAntialias(other.m_shouldAntialias) { }
47 45
48 void GraphicsContextState::copy(const GraphicsContextState& source) 46 void GraphicsContextState::copy(const GraphicsContextState& source)
49 { 47 {
50 this->~GraphicsContextState(); 48 this->~GraphicsContextState();
(...skipping 22 matching lines...) Expand all
73 71
74 void GraphicsContextState::setStrokeThickness(float thickness) 72 void GraphicsContextState::setStrokeThickness(float thickness)
75 { 73 {
76 m_strokeData.setThickness(thickness); 74 m_strokeData.setThickness(thickness);
77 m_strokePaint.setStrokeWidth(SkFloatToScalar(thickness)); 75 m_strokePaint.setStrokeWidth(SkFloatToScalar(thickness));
78 } 76 }
79 77
80 void GraphicsContextState::setStrokeColor(const Color& color) 78 void GraphicsContextState::setStrokeColor(const Color& color)
81 { 79 {
82 m_strokeGradient.clear(); 80 m_strokeGradient.clear();
83 m_strokePattern.clear();
84 m_strokeColor = color; 81 m_strokeColor = color;
85 m_strokePaint.setColor(color.rgb()); 82 m_strokePaint.setColor(color.rgb());
86 m_strokePaint.setShader(0); 83 m_strokePaint.setShader(0);
87 } 84 }
88 85
89 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient , float alpha) 86 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient , float alpha)
90 { 87 {
91 m_strokeColor = Color::black; 88 m_strokeColor = Color::black;
92 m_strokePattern.clear();
93 m_strokeGradient = gradient; 89 m_strokeGradient = gradient;
94 m_strokePaint.setColor(scaleAlpha(SK_ColorBLACK, alpha)); 90 m_strokePaint.setColor(scaleAlpha(SK_ColorBLACK, alpha));
95 m_strokePaint.setShader(m_strokeGradient->shader()); 91 m_strokePaint.setShader(m_strokeGradient->shader());
96 } 92 }
97 93
98 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern, f loat alpha)
99 {
100 m_strokeColor = Color::black;
101 m_strokeGradient.clear();
102 m_strokePattern = pattern;
103 m_strokePaint.setColor(scaleAlpha(SK_ColorBLACK, alpha));
104 m_strokePaint.setShader(m_strokePattern->shader());
105 }
106
107 void GraphicsContextState::setLineCap(LineCap cap) 94 void GraphicsContextState::setLineCap(LineCap cap)
108 { 95 {
109 m_strokeData.setLineCap(cap); 96 m_strokeData.setLineCap(cap);
110 m_strokePaint.setStrokeCap((SkPaint::Cap)cap); 97 m_strokePaint.setStrokeCap((SkPaint::Cap)cap);
111 } 98 }
112 99
113 void GraphicsContextState::setLineJoin(LineJoin join) 100 void GraphicsContextState::setLineJoin(LineJoin join)
114 { 101 {
115 m_strokeData.setLineJoin(join); 102 m_strokeData.setLineJoin(join);
116 m_strokePaint.setStrokeJoin((SkPaint::Join)join); 103 m_strokePaint.setStrokeJoin((SkPaint::Join)join);
117 } 104 }
118 105
119 void GraphicsContextState::setMiterLimit(float miterLimit) 106 void GraphicsContextState::setMiterLimit(float miterLimit)
120 { 107 {
121 m_strokeData.setMiterLimit(miterLimit); 108 m_strokeData.setMiterLimit(miterLimit);
122 m_strokePaint.setStrokeMiter(SkFloatToScalar(miterLimit)); 109 m_strokePaint.setStrokeMiter(SkFloatToScalar(miterLimit));
123 } 110 }
124 111
125 void GraphicsContextState::setFillColor(const Color& color) 112 void GraphicsContextState::setFillColor(const Color& color)
126 { 113 {
127 m_fillColor = color; 114 m_fillColor = color;
128 m_fillGradient.clear(); 115 m_fillGradient.clear();
129 m_fillPattern.clear();
130 m_fillPaint.setColor(color.rgb()); 116 m_fillPaint.setColor(color.rgb());
131 m_fillPaint.setShader(0); 117 m_fillPaint.setShader(0);
132 } 118 }
133 119
134 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient, float alpha) 120 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient, float alpha)
135 { 121 {
136 m_fillColor = Color::black; 122 m_fillColor = Color::black;
137 m_fillPattern.clear();
138 m_fillGradient = gradient; 123 m_fillGradient = gradient;
139 m_fillPaint.setColor(scaleAlpha(SK_ColorBLACK, alpha)); 124 m_fillPaint.setColor(scaleAlpha(SK_ColorBLACK, alpha));
140 m_fillPaint.setShader(m_fillGradient->shader()); 125 m_fillPaint.setShader(m_fillGradient->shader());
141 } 126 }
142 127
143 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern, flo at alpha)
144 {
145 m_fillColor = Color::black;
146 m_fillGradient.clear();
147 m_fillPattern = pattern;
148 m_fillPaint.setColor(scaleAlpha(SK_ColorBLACK, alpha));
149 m_fillPaint.setShader(m_fillPattern->shader());
150 }
151
152 // Shadow. (This will need tweaking if we use draw loopers for other things.) 128 // Shadow. (This will need tweaking if we use draw loopers for other things.)
153 void GraphicsContextState::setDrawLooper(PassRefPtr<SkDrawLooper> drawLooper) 129 void GraphicsContextState::setDrawLooper(PassRefPtr<SkDrawLooper> drawLooper)
154 { 130 {
155 m_looper = drawLooper; 131 m_looper = drawLooper;
156 m_strokePaint.setLooper(m_looper.get()); 132 m_strokePaint.setLooper(m_looper.get());
157 m_fillPaint.setLooper(m_looper.get()); 133 m_fillPaint.setLooper(m_looper.get());
158 } 134 }
159 135
160 void GraphicsContextState::clearDrawLooper() 136 void GraphicsContextState::clearDrawLooper()
161 { 137 {
(...skipping 22 matching lines...) Expand all
184 } 160 }
185 161
186 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) 162 void GraphicsContextState::setShouldAntialias(bool shouldAntialias)
187 { 163 {
188 m_shouldAntialias = shouldAntialias; 164 m_shouldAntialias = shouldAntialias;
189 m_strokePaint.setAntiAlias(shouldAntialias); 165 m_strokePaint.setAntiAlias(shouldAntialias);
190 m_fillPaint.setAntiAlias(shouldAntialias); 166 m_fillPaint.setAntiAlias(shouldAntialias);
191 } 167 }
192 168
193 } // namespace blink 169 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContextState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698