| OLD | NEW |
| 1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 // | 2 // |
| 3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
| 5 // met: | 5 // met: |
| 6 // | 6 // |
| 7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
| 8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
| 9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
| 10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #ifndef GraphicsContextState_h | 29 #ifndef GraphicsContextState_h |
| 30 #define GraphicsContextState_h | 30 #define GraphicsContextState_h |
| 31 | 31 |
| 32 #include "platform/graphics/DrawLooperBuilder.h" | 32 #include "platform/graphics/DrawLooperBuilder.h" |
| 33 #include "platform/graphics/Gradient.h" | 33 #include "platform/graphics/Gradient.h" |
| 34 #include "platform/graphics/GraphicsTypes.h" | 34 #include "platform/graphics/GraphicsTypes.h" |
| 35 #include "platform/graphics/Path.h" | 35 #include "platform/graphics/Path.h" |
| 36 #include "platform/graphics/Pattern.h" | 36 #include "platform/graphics/Pattern.h" |
| 37 #include "platform/graphics/StrokeData.h" | 37 #include "platform/graphics/StrokeData.h" |
| 38 #include "platform/graphics/skia/SkiaUtils.h" |
| 38 #include "third_party/skia/include/core/SkColorFilter.h" | 39 #include "third_party/skia/include/core/SkColorFilter.h" |
| 39 #include "third_party/skia/include/core/SkImageFilter.h" | 40 #include "third_party/skia/include/core/SkImageFilter.h" |
| 40 #include "third_party/skia/include/core/SkPaint.h" | 41 #include "third_party/skia/include/core/SkPaint.h" |
| 41 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 // Encapsulates the state information we store for each pushed graphics state. | 47 // Encapsulates the state information we store for each pushed graphics state. |
| 47 // Only GraphicsContext can use this class. | 48 // Only GraphicsContext can use this class. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 uint16_t saveCount() const { return m_saveCount; } | 68 uint16_t saveCount() const { return m_saveCount; } |
| 68 void incrementSaveCount() { ++m_saveCount; } | 69 void incrementSaveCount() { ++m_saveCount; } |
| 69 void decrementSaveCount() { --m_saveCount; } | 70 void decrementSaveCount() { --m_saveCount; } |
| 70 | 71 |
| 71 // Stroke data | 72 // Stroke data |
| 72 Color strokeColor() const { return m_strokeColor; } | 73 Color strokeColor() const { return m_strokeColor; } |
| 73 SkColor effectiveStrokeColor() const { return applyAlpha(m_strokeColor.rgb()
); } | 74 SkColor effectiveStrokeColor() const { return applyAlpha(m_strokeColor.rgb()
); } |
| 74 void setStrokeColor(const Color&); | 75 void setStrokeColor(const Color&); |
| 75 | 76 |
| 76 Gradient* strokeGradient() const { return m_strokeGradient.get(); } | 77 Gradient* strokeGradient() const { return m_strokeGradient.get(); } |
| 77 void setStrokeGradient(const PassRefPtr<Gradient>); | 78 void setStrokeGradient(const PassRefPtr<Gradient>, float); |
| 78 void clearStrokeGradient(); | 79 void clearStrokeGradient(); |
| 79 | 80 |
| 80 Pattern* strokePattern() const { return m_strokePattern.get(); } | 81 Pattern* strokePattern() const { return m_strokePattern.get(); } |
| 81 void setStrokePattern(const PassRefPtr<Pattern>); | 82 void setStrokePattern(const PassRefPtr<Pattern>, float); |
| 82 void clearStrokePattern(); | 83 void clearStrokePattern(); |
| 83 | 84 |
| 84 const StrokeData& strokeData() const { return m_strokeData; } | 85 const StrokeData& strokeData() const { return m_strokeData; } |
| 85 void setStrokeStyle(StrokeStyle); | 86 void setStrokeStyle(StrokeStyle); |
| 86 void setStrokeThickness(float); | 87 void setStrokeThickness(float); |
| 87 void setLineCap(LineCap); | 88 void setLineCap(LineCap); |
| 88 void setLineJoin(LineJoin); | 89 void setLineJoin(LineJoin); |
| 89 void setMiterLimit(float); | 90 void setMiterLimit(float); |
| 90 void setLineDash(const DashArray&, float); | 91 void setLineDash(const DashArray&, float); |
| 91 | 92 |
| 92 // Fill data | 93 // Fill data |
| 93 Color fillColor() const { return m_fillColor; } | 94 Color fillColor() const { return m_fillColor; } |
| 94 SkColor effectiveFillColor() const { return applyAlpha(m_fillColor.rgb()); } | 95 SkColor effectiveFillColor() const { return applyAlpha(m_fillColor.rgb()); } |
| 95 void setFillColor(const Color&); | 96 void setFillColor(const Color&); |
| 96 | 97 |
| 97 Gradient* fillGradient() const { return m_fillGradient.get(); } | 98 Gradient* fillGradient() const { return m_fillGradient.get(); } |
| 98 void setFillGradient(const PassRefPtr<Gradient>); | 99 void setFillGradient(const PassRefPtr<Gradient>, float); |
| 99 void clearFillGradient(); | 100 void clearFillGradient(); |
| 100 | 101 |
| 101 Pattern* fillPattern() const { return m_fillPattern.get(); } | 102 Pattern* fillPattern() const { return m_fillPattern.get(); } |
| 102 void setFillPattern(const PassRefPtr<Pattern>); | 103 void setFillPattern(const PassRefPtr<Pattern>, float); |
| 103 void clearFillPattern(); | 104 void clearFillPattern(); |
| 104 | 105 |
| 105 // Path fill rule | 106 // Path fill rule |
| 106 WindRule fillRule() const { return m_fillRule; } | 107 WindRule fillRule() const { return m_fillRule; } |
| 107 void setFillRule(WindRule rule) { m_fillRule = rule; } | 108 void setFillRule(WindRule rule) { m_fillRule = rule; } |
| 108 | 109 |
| 109 // Shadow. (This will need tweaking if we use draw loopers for other things.
) | 110 // Shadow. (This will need tweaking if we use draw loopers for other things.
) |
| 110 SkDrawLooper* drawLooper() const { return m_looper.get(); } | 111 SkDrawLooper* drawLooper() const { return m_looper.get(); } |
| 111 void setDrawLooper(PassRefPtr<SkDrawLooper>); | 112 void setDrawLooper(PassRefPtr<SkDrawLooper>); |
| 112 void clearDrawLooper(); | 113 void clearDrawLooper(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 bool hasComplexClip() const; | 146 bool hasComplexClip() const; |
| 146 void setHasComplexClip(); | 147 void setHasComplexClip(); |
| 147 | 148 |
| 148 private: | 149 private: |
| 149 GraphicsContextState(); | 150 GraphicsContextState(); |
| 150 explicit GraphicsContextState(const GraphicsContextState&); | 151 explicit GraphicsContextState(const GraphicsContextState&); |
| 151 GraphicsContextState& operator=(const GraphicsContextState&); | 152 GraphicsContextState& operator=(const GraphicsContextState&); |
| 152 | 153 |
| 153 // Helper function for applying the state's alpha value to the given input | 154 // Helper function for applying the state's alpha value to the given input |
| 154 // color to produce a new output color. | 155 // color to produce a new output color. |
| 155 SkColor applyAlpha(SkColor c) const | 156 SkColor applyAlpha(SkColor color) const |
| 156 { | 157 { |
| 157 int a = SkAlphaMul(SkColorGetA(c), m_alpha); | 158 return multiplyAlpha(color, m_alpha); |
| 158 return (c & 0x00FFFFFF) | (a << 24); | |
| 159 } | 159 } |
| 160 | 160 |
| 161 // These are mutbale to enable gradient updates when the paints are fetched
for use. | 161 // These are mutbale to enable gradient updates when the paints are fetched
for use. |
| 162 mutable SkPaint m_strokePaint; | 162 mutable SkPaint m_strokePaint; |
| 163 mutable SkPaint m_fillPaint; | 163 mutable SkPaint m_fillPaint; |
| 164 | 164 |
| 165 StrokeData m_strokeData; | 165 StrokeData m_strokeData; |
| 166 | 166 |
| 167 Color m_strokeColor; | 167 Color m_strokeColor; |
| 168 RefPtr<Gradient> m_strokeGradient; | 168 RefPtr<Gradient> m_strokeGradient; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 188 uint16_t m_saveCount; | 188 uint16_t m_saveCount; |
| 189 | 189 |
| 190 bool m_shouldAntialias : 1; | 190 bool m_shouldAntialias : 1; |
| 191 bool m_shouldClampToSourceRect : 1; | 191 bool m_shouldClampToSourceRect : 1; |
| 192 bool m_hasComplexClip : 1; | 192 bool m_hasComplexClip : 1; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 } // namespace blink | 195 } // namespace blink |
| 196 | 196 |
| 197 #endif // GraphicsContextState_h | 197 #endif // GraphicsContextState_h |
| OLD | NEW |