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

Side by Side Diff: src/utils/win/SkDWriteGeometrySink.cpp

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium Created 7 years 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 | « src/utils/SkPathUtils.cpp ('k') | src/views/SkTouchGesture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #include "SkDWriteGeometrySink.h" 10 #include "SkDWriteGeometrySink.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 } 59 }
60 60
61 void STDMETHODCALLTYPE SkDWriteGeometrySink::SetSegmentFlags(D2D1_PATH_SEGMENT v ertexFlags) { 61 void STDMETHODCALLTYPE SkDWriteGeometrySink::SetSegmentFlags(D2D1_PATH_SEGMENT v ertexFlags) {
62 if (vertexFlags == D2D1_PATH_SEGMENT_NONE || vertexFlags == D2D1_PATH_SEGMEN T_FORCE_ROUND_LINE_JOIN) { 62 if (vertexFlags == D2D1_PATH_SEGMENT_NONE || vertexFlags == D2D1_PATH_SEGMEN T_FORCE_ROUND_LINE_JOIN) {
63 SkDEBUGFAIL("Invalid D2D1_PATH_SEGMENT value."); 63 SkDEBUGFAIL("Invalid D2D1_PATH_SEGMENT value.");
64 } 64 }
65 } 65 }
66 66
67 void STDMETHODCALLTYPE SkDWriteGeometrySink::BeginFigure(D2D1_POINT_2F startPoin t, D2D1_FIGURE_BEGIN figureBegin) { 67 void STDMETHODCALLTYPE SkDWriteGeometrySink::BeginFigure(D2D1_POINT_2F startPoin t, D2D1_FIGURE_BEGIN figureBegin) {
68 fPath->moveTo(SkFloatToScalar(startPoint.x), SkFloatToScalar(startPoint.y)); 68 fPath->moveTo(startPoint.x, startPoint.y);
69 if (figureBegin == D2D1_FIGURE_BEGIN_HOLLOW) { 69 if (figureBegin == D2D1_FIGURE_BEGIN_HOLLOW) {
70 SkDEBUGFAIL("Invalid D2D1_FIGURE_BEGIN value."); 70 SkDEBUGFAIL("Invalid D2D1_FIGURE_BEGIN value.");
71 } 71 }
72 } 72 }
73 73
74 void STDMETHODCALLTYPE SkDWriteGeometrySink::AddLines(const D2D1_POINT_2F *point s, UINT pointsCount) { 74 void STDMETHODCALLTYPE SkDWriteGeometrySink::AddLines(const D2D1_POINT_2F *point s, UINT pointsCount) {
75 for (const D2D1_POINT_2F *end = &points[pointsCount]; points < end; ++points ) { 75 for (const D2D1_POINT_2F *end = &points[pointsCount]; points < end; ++points ) {
76 fPath->lineTo(SkFloatToScalar(points->x), SkFloatToScalar(points->y)); 76 fPath->lineTo(points->x, points->y);
77 } 77 }
78 } 78 }
79 79
80 static bool approximately_equal(float a, float b) { 80 static bool approximately_equal(float a, float b) {
81 const SkFloatingPoint<float, 10> lhs(a), rhs(b); 81 const SkFloatingPoint<float, 10> lhs(a), rhs(b);
82 return lhs.AlmostEquals(rhs); 82 return lhs.AlmostEquals(rhs);
83 } 83 }
84 84
85 typedef struct { 85 typedef struct {
86 float x; 86 float x;
(...skipping 27 matching lines...) Expand all
114 fPath->getLastPt(&lastPt); 114 fPath->getLastPt(&lastPt);
115 D2D1_POINT_2F prevPt = { SkScalarToFloat(lastPt.fX), SkScalarToFloat(lastPt. fY) }; 115 D2D1_POINT_2F prevPt = { SkScalarToFloat(lastPt.fX), SkScalarToFloat(lastPt. fY) };
116 116
117 for (const D2D1_BEZIER_SEGMENT *end = &beziers[beziersCount]; beziers < end; ++beziers) { 117 for (const D2D1_BEZIER_SEGMENT *end = &beziers[beziersCount]; beziers < end; ++beziers) {
118 Cubic cubic = { { prevPt.x, prevPt.y }, 118 Cubic cubic = { { prevPt.x, prevPt.y },
119 { beziers->point1.x, beziers->point1.y }, 119 { beziers->point1.x, beziers->point1.y },
120 { beziers->point2.x, beziers->point2.y }, 120 { beziers->point2.x, beziers->point2.y },
121 { beziers->point3.x, beziers->point3.y }, }; 121 { beziers->point3.x, beziers->point3.y }, };
122 Quadratic quadratic; 122 Quadratic quadratic;
123 if (check_quadratic(cubic, quadratic)) { 123 if (check_quadratic(cubic, quadratic)) {
124 fPath->quadTo(SkFloatToScalar(quadratic[1].x), SkFloatToScalar(quadr atic[1].y), 124 fPath->quadTo(quadratic[1].x, quadratic[1].y,
125 SkFloatToScalar(quadratic[2].x), SkFloatToScalar(quadr atic[2].y)); 125 quadratic[2].x, quadratic[2].y);
126 } else { 126 } else {
127 fPath->cubicTo(SkFloatToScalar(beziers->point1.x), SkFloatToScalar(b eziers->point1.y), 127 fPath->cubicTo(beziers->point1.x, beziers->point1.y,
128 SkFloatToScalar(beziers->point2.x), SkFloatToScalar(b eziers->point2.y), 128 beziers->point2.x, beziers->point2.y,
129 SkFloatToScalar(beziers->point3.x), SkFloatToScalar(b eziers->point3.y)); 129 beziers->point3.x, beziers->point3.y);
130 } 130 }
131 prevPt = beziers->point3; 131 prevPt = beziers->point3;
132 } 132 }
133 } 133 }
134 134
135 void STDMETHODCALLTYPE SkDWriteGeometrySink::EndFigure(D2D1_FIGURE_END figureEnd ) { 135 void STDMETHODCALLTYPE SkDWriteGeometrySink::EndFigure(D2D1_FIGURE_END figureEnd ) {
136 fPath->close(); 136 fPath->close();
137 } 137 }
138 138
139 HRESULT SkDWriteGeometrySink::Close() { 139 HRESULT SkDWriteGeometrySink::Close() {
140 return S_OK; 140 return S_OK;
141 } 141 }
142 142
143 HRESULT SkDWriteGeometrySink::Create(SkPath* path, IDWriteGeometrySink** geometr yToPath) { 143 HRESULT SkDWriteGeometrySink::Create(SkPath* path, IDWriteGeometrySink** geometr yToPath) {
144 *geometryToPath = new SkDWriteGeometrySink(path); 144 *geometryToPath = new SkDWriteGeometrySink(path);
145 return S_OK; 145 return S_OK;
146 } 146 }
OLDNEW
« no previous file with comments | « src/utils/SkPathUtils.cpp ('k') | src/views/SkTouchGesture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698