Chromium Code Reviews| Index: Source/core/html/canvas/CanvasRenderingContext2DState.h |
| diff --git a/Source/core/html/canvas/CanvasRenderingContext2DState.h b/Source/core/html/canvas/CanvasRenderingContext2DState.h |
| index 47de35b645893cf6f3c2673a2db44f5695737ca4..385d8cc00f8bd1a8acd073fb74fbe910bd14ea6a 100644 |
| --- a/Source/core/html/canvas/CanvasRenderingContext2DState.h |
| +++ b/Source/core/html/canvas/CanvasRenderingContext2DState.h |
| @@ -41,7 +41,7 @@ public: |
| void setLineDash(const Vector<float>&); |
| const Vector<float>& lineDash() const { return m_lineDash; } |
| - void setLineDashOffset(float offset) { m_lineDashOffset = offset; } |
| + void setLineDashOffset(float); |
| float lineDashOffset() const { return m_lineDashOffset; } |
| // setTransform returns true iff transform is invertible; |
| @@ -61,10 +61,10 @@ public: |
| void setUnparsedFont(const String& font) { m_unparsedFont = font; } |
| const String& unparsedFont() const { return m_unparsedFont; } |
| - void setStrokeStyle(PassRefPtrWillBeRawPtr<CanvasStyle> style) { m_strokeStyle = style; } |
| + void setStrokeStyle(PassRefPtrWillBeRawPtr<CanvasStyle>); |
| CanvasStyle* strokeStyle() const { return m_strokeStyle.get(); } |
| - void setFillStyle(PassRefPtrWillBeRawPtr<CanvasStyle> style) { m_fillStyle = style; } |
| + void setFillStyle(PassRefPtrWillBeRawPtr<CanvasStyle>); |
| CanvasStyle* fillStyle() const { return m_fillStyle.get(); } |
| enum Direction { |
| @@ -74,44 +74,44 @@ public: |
| }; |
| void setDirection(Direction direction) { m_direction = direction; } |
| - Direction direction() const { return m_direction; } |
| + Direction direction() const { return static_cast<Direction>(m_direction); } |
|
Stephen White
2015/03/19 20:35:17
We shouldn't need these static_casts anymore?
Justin Novosad
2015/03/19 21:03:36
Acknowledged.
|
| void setTextAlign(TextAlign align) { m_textAlign = align; } |
| - TextAlign textAlign() const { return m_textAlign; } |
| + TextAlign textAlign() const { return static_cast<TextAlign>(m_textAlign); } |
| void setTextBaseline(TextBaseline baseline) { m_textBaseline = baseline; } |
| - TextBaseline textBaseline() const { return m_textBaseline; } |
| + TextBaseline textBaseline() const { return static_cast<TextBaseline>(m_textBaseline); } |
| - void setLineWidth(float lineWidth) { m_lineWidth = lineWidth; } |
| - float lineWidth() const { return m_lineWidth; } |
| + void setLineWidth(float lineWidth) { m_strokePaint.setStrokeWidth(lineWidth); } |
| + float lineWidth() const { return m_strokePaint.getStrokeWidth(); } |
| - void setLineCap(LineCap lineCap) { m_lineCap = lineCap; } |
| - LineCap lineCap() const { return m_lineCap; } |
| + void setLineCap(LineCap lineCap) { m_strokePaint.setStrokeCap(static_cast<SkPaint::Cap>(lineCap)); } |
| + LineCap lineCap() const { return static_cast<LineCap>(m_strokePaint.getStrokeCap()); } |
| - void setLineJoin(LineJoin lineJoin) { m_lineJoin = lineJoin; } |
| - LineJoin lineJoin() const { return m_lineJoin; } |
| + void setLineJoin(LineJoin lineJoin) { m_strokePaint.setStrokeJoin(static_cast<SkPaint::Join>(lineJoin)); } |
| + LineJoin lineJoin() const { return static_cast<LineJoin>(m_strokePaint.getStrokeJoin()); } |
| - void setMiterLimit(float miterLimit) { m_miterLimit = miterLimit; } |
| - float miterLimit() const { return m_miterLimit; } |
| + void setMiterLimit(float miterLimit) { m_strokePaint.setStrokeMiter(miterLimit); } |
| + float miterLimit() const { return m_strokePaint.getStrokeMiter(); } |
| - void setShadowOffsetX(float x) { m_shadowOffset.setWidth(x); } |
| - void setShadowOffsetY(float y) { m_shadowOffset.setHeight(y); } |
| + void setShadowOffsetX(float); |
| + void setShadowOffsetY(float); |
| const FloatSize& shadowOffset() const { return m_shadowOffset; } |
| - void setShadowBlur(float shadowBlur) { m_shadowBlur = shadowBlur; } |
| + void setShadowBlur(float); |
| float shadowBlur() const { return m_shadowBlur; } |
| - void setShadowColor(SkColor shadowColor) { m_shadowColor = shadowColor; } |
| + void setShadowColor(SkColor); |
| SkColor shadowColor() const { return m_shadowColor; } |
| - void setGlobalAlpha(float alpha) { m_globalAlpha = alpha; } |
| + void setGlobalAlpha(float); |
| float globalAlpha() const { return m_globalAlpha; } |
| - void setGlobalComposite(SkXfermode::Mode mode) { m_globalComposite = mode; } |
| - SkXfermode::Mode globalComposite() const { return m_globalComposite; } |
| + void setGlobalComposite(SkXfermode::Mode); |
| + SkXfermode::Mode globalComposite() const; |
| - void setImageSmoothingEnabled(bool enabled) { m_imageSmoothingEnabled = enabled; } |
| - bool imageSmoothingEnabled() const { return m_imageSmoothingEnabled; } |
| + void setImageSmoothingEnabled(bool); |
| + bool imageSmoothingEnabled() const; |
| void setUnparsedStrokeColor(const String& color) { m_unparsedStrokeColor = color; } |
| const String& unparsedStrokeColor() const { return m_unparsedStrokeColor; } |
| @@ -119,7 +119,21 @@ public: |
| void setUnparsedFillColor(const String& color) { m_unparsedFillColor = color; } |
| const String& unparsedFillColor() const { return m_unparsedFillColor; } |
| + bool shouldDrawShadows() const; |
| + |
| + const SkPaint* getPaint(CanvasPaintType, ShadowMode, CanvasShadowStrategy) const; |
| + |
| private: |
| + void updateLineDash() const; |
| + void updateStrokeStyle() const; |
| + void updateFillStyle() const; |
| + void shadowParameterChanged(); |
| + SkDrawLooper* emptyDrawLooper() const; |
| + SkDrawLooper* shadowOnlyDrawLooper() const; |
| + SkDrawLooper* shadowAndForegroundDrawLooper() const; |
| + SkImageFilter* shadowOnlyImageFilter() const; |
| + SkImageFilter* shadowAndForegroundImageFilter() const; |
| + |
| unsigned m_unrealizedSaveCount; |
| String m_unparsedStrokeColor; |
| @@ -127,32 +141,38 @@ private: |
| RefPtrWillBeMember<CanvasStyle> m_strokeStyle; |
| RefPtrWillBeMember<CanvasStyle> m_fillStyle; |
| - float m_lineWidth; |
| - LineCap m_lineCap; |
| - LineJoin m_lineJoin; |
| - float m_miterLimit; |
| + mutable SkPaint m_strokePaint; |
| + mutable SkPaint m_fillPaint; |
| + |
| FloatSize m_shadowOffset; |
| float m_shadowBlur; |
| SkColor m_shadowColor; |
| + mutable RefPtr<SkDrawLooper> m_emptyDrawLooper; |
| + mutable RefPtr<SkDrawLooper> m_shadowOnlyDrawLooper; |
| + mutable RefPtr<SkDrawLooper> m_shadowAndForegroundDrawLooper; |
| + mutable RefPtr<SkImageFilter> m_shadowOnlyImageFilter; |
| + mutable RefPtr<SkImageFilter> m_shadowAndForegroundImageFilter; |
| + |
| float m_globalAlpha; |
| - SkXfermode::Mode m_globalComposite; |
| AffineTransform m_transform; |
| - bool m_isTransformInvertible; |
| Vector<float> m_lineDash; |
| float m_lineDashOffset; |
| - bool m_imageSmoothingEnabled; |
| + |
| + String m_unparsedFont; |
| + Font m_font; |
| // Text state. |
| TextAlign m_textAlign; |
| TextBaseline m_textBaseline; |
| Direction m_direction; |
| - String m_unparsedFont; |
| - Font m_font; |
| - bool m_realizedFont; |
| - |
| - bool m_hasClip; |
| - bool m_hasComplexClip; |
| + bool m_realizedFont : 1; |
| + bool m_isTransformInvertible : 1; |
| + bool m_hasClip : 1; |
| + bool m_hasComplexClip : 1; |
| + mutable bool m_fillStyleDirty : 1; |
| + mutable bool m_strokeStyleDirty : 1; |
| + mutable bool m_lineDashDirty : 1; |
| ClipList m_clipList; |
| }; |