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

Side by Side Diff: Source/core/platform/graphics/StrokeData.cpp

Issue 18551004: Miscellaneous cleanup to reduce number of includes in platform/graphics/ Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
OLDNEW
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 11 matching lines...) Expand all
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/platform/graphics/StrokeData.h" 30 #include "core/platform/graphics/StrokeData.h"
31 31
32 #include "core/platform/graphics/Gradient.h"
33 #include "core/platform/graphics/Pattern.h"
34 #include "third_party/skia/include/core/SkRefCnt.h"
35 #include "third_party/skia/include/effects/SkDashPathEffect.h"
36
32 namespace WebCore { 37 namespace WebCore {
33 38
34 static const int dashRatio = 3; // Ratio of the length of a dash to its width. 39 static const int dashRatio = 3; // Ratio of the length of a dash to its width.
35 40
41 StrokeData::StrokeData()
42 : m_style(SolidStroke)
43 , m_thickness(0)
44 , m_color(Color::black)
45 , m_lineCap(SkPaint::kDefault_Cap)
46 , m_lineJoin(SkPaint::kDefault_Join)
47 , m_miterLimit(4)
48 , m_dash(0)
49 {
50 }
51
52 StrokeData::StrokeData(const StrokeData& other)
53 : m_style(other.m_style)
54 , m_thickness(other.m_thickness)
55 , m_color(other.m_color)
56 , m_gradient(other.m_gradient)
57 , m_pattern(other.m_pattern)
58 , m_lineCap(other.m_lineCap)
59 , m_lineJoin(other.m_lineJoin)
60 , m_miterLimit(other.m_miterLimit)
61 , m_dash(other.m_dash)
62 {
63 SkSafeRef(m_dash);
64 }
65
66 StrokeData::~StrokeData()
67 {
68 SkSafeUnref(m_dash);
69 }
70
71 void StrokeData::setColor(const Color& color)
72 {
73 m_color = color;
74 m_gradient.clear();
75 m_pattern.clear();
76 }
77
78 void StrokeData::setGradient(PassRefPtr<Gradient> gradient)
79 {
80 m_gradient = gradient;
81 m_pattern.clear();
82 }
83
84 void StrokeData::setPattern(PassRefPtr<Pattern> pattern)
85 {
86 m_pattern = pattern;
87 m_gradient.clear();
88 }
89
36 void StrokeData::setLineDash(const DashArray& dashes, float dashOffset) 90 void StrokeData::setLineDash(const DashArray& dashes, float dashOffset)
37 { 91 {
38 // FIXME: This is lifted directly off SkiaSupport, lines 49-74 92 // FIXME: This is lifted directly off SkiaSupport, lines 49-74
39 // so it is not guaranteed to work correctly. 93 // so it is not guaranteed to work correctly.
40 size_t dashLength = dashes.size(); 94 size_t dashLength = dashes.size();
41 if (!dashLength) { 95 if (!dashLength) {
42 // If no dash is set, revert to solid stroke 96 // If no dash is set, revert to solid stroke
43 // FIXME: do we need to set NoStroke in some cases? 97 // FIXME: do we need to set NoStroke in some cases?
44 m_style = SolidStroke; 98 m_style = SolidStroke;
45 SkSafeUnref(m_dash); 99 SkSafeUnref(m_dash);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 SkScalar dashLengthSk = SkIntToScalar(dashLength); 157 SkScalar dashLengthSk = SkIntToScalar(dashLength);
104 SkScalar intervals[2] = { dashLengthSk, dashLengthSk }; 158 SkScalar intervals[2] = { dashLengthSk, dashLengthSk };
105 paint->setPathEffect(new SkDashPathEffect(intervals, 2, SkIntToScala r(phase)))->unref(); 159 paint->setPathEffect(new SkDashPathEffect(intervals, 2, SkIntToScala r(phase)))->unref();
106 } 160 }
107 } 161 }
108 162
109 return width; 163 return width;
110 } 164 }
111 165
112 } // namespace 166 } // namespace
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/StrokeData.h ('k') | Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698