| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2013 Google Inc. All rights reserved. | |
| 2 // | |
| 3 // Redistribution and use in source and binary forms, with or without | |
| 4 // modification, are permitted provided that the following conditions are | |
| 5 // met: | |
| 6 // | |
| 7 // * Redistributions of source code must retain the above copyright | |
| 8 // notice, this list of conditions and the following disclaimer. | |
| 9 // * Redistributions in binary form must reproduce the above | |
| 10 // copyright notice, this list of conditions and the following disclaimer | |
| 11 // in the documentation and/or other materials provided with the | |
| 12 // distribution. | |
| 13 // * Neither the name of Google Inc. nor the names of its | |
| 14 // contributors may be used to endorse or promote products derived from | |
| 15 // this software without specific prior written permission. | |
| 16 // | |
| 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | |
| 29 #ifndef StrokeData_h | |
| 30 #define StrokeData_h | |
| 31 | |
| 32 #include "core/platform/graphics/Gradient.h" | |
| 33 #include "core/platform/graphics/Pattern.h" | |
| 34 #include "platform/graphics/DashArray.h" | |
| 35 #include "platform/graphics/GraphicsTypes.h" | |
| 36 #include "third_party/skia/include/core/SkColorPriv.h" | |
| 37 #include "third_party/skia/include/effects/SkDashPathEffect.h" | |
| 38 #include "wtf/PassRefPtr.h" | |
| 39 #include "wtf/RefPtr.h" | |
| 40 | |
| 41 namespace WebCore { | |
| 42 | |
| 43 // Encapsulates stroke painting information. | |
| 44 // It is pulled out of GraphicsContextState to enable other methods to use it. | |
| 45 class StrokeData { | |
| 46 public: | |
| 47 StrokeData() | |
| 48 : m_style(SolidStroke) | |
| 49 , m_thickness(0) | |
| 50 , m_color(Color::black) | |
| 51 , m_lineCap(SkPaint::kDefault_Cap) | |
| 52 , m_lineJoin(SkPaint::kDefault_Join) | |
| 53 , m_miterLimit(4) | |
| 54 { | |
| 55 } | |
| 56 | |
| 57 StrokeStyle style() const { return m_style; } | |
| 58 void setStyle(const StrokeStyle style) { m_style = style; } | |
| 59 | |
| 60 float thickness() const { return m_thickness; } | |
| 61 void setThickness(const float thickness) { m_thickness = thickness; } | |
| 62 | |
| 63 Color color() const { return m_color; } | |
| 64 void setColor(const Color& color) { m_color = color; } | |
| 65 | |
| 66 Gradient* gradient() const { return m_gradient.get(); } | |
| 67 void setGradient(const PassRefPtr<Gradient> gradient) { m_gradient = gradien
t; } | |
| 68 void clearGradient() { m_gradient.clear(); } | |
| 69 | |
| 70 Pattern* pattern() const { return m_pattern.get(); } | |
| 71 void setPattern(const PassRefPtr<Pattern> pattern) { m_pattern = pattern; } | |
| 72 void clearPattern() { m_pattern.clear(); } | |
| 73 | |
| 74 LineCap lineCap() const { return (LineCap)m_lineCap; } | |
| 75 void setLineCap(const LineCap cap) { m_lineCap = (SkPaint::Cap)cap; } | |
| 76 | |
| 77 LineJoin lineJoin() const { return (LineJoin)m_lineJoin; } | |
| 78 void setLineJoin(const LineJoin join) { m_lineJoin = (SkPaint::Join)join; } | |
| 79 | |
| 80 float miterLimit() const { return m_miterLimit; } | |
| 81 void setMiterLimit(const float miterLimit) { m_miterLimit = miterLimit; } | |
| 82 | |
| 83 void setLineDash(const DashArray&, const float); | |
| 84 | |
| 85 // Sets everything on the paint except the pattern, gradient and color. | |
| 86 // GraphicsContext::setupShader does that. Returns a float representing the | |
| 87 // effective width of the pen. If a non-zero length is provided, the | |
| 88 // number of dashes/dots on a dashed/dotted line will be adjusted to | |
| 89 // start and end that length with a dash/dot. | |
| 90 float setupPaint(SkPaint*, int length = 0) const; | |
| 91 | |
| 92 private: | |
| 93 StrokeStyle m_style; | |
| 94 float m_thickness; | |
| 95 Color m_color; | |
| 96 RefPtr<Gradient> m_gradient; | |
| 97 RefPtr<Pattern> m_pattern; | |
| 98 SkPaint::Cap m_lineCap; | |
| 99 SkPaint::Join m_lineJoin; | |
| 100 float m_miterLimit; | |
| 101 RefPtr<SkDashPathEffect> m_dash; | |
| 102 }; | |
| 103 | |
| 104 } // namespace WebCore | |
| 105 | |
| 106 #endif // StrokeData_h | |
| OLD | NEW |