OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The Android Open Source Project | 2 * Copyright 2011 The Android Open Source Project |
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 | 8 |
9 #ifndef SkScan_DEFINED | 9 #ifndef SkScan_DEFINED |
10 #define SkScan_DEFINED | 10 #define SkScan_DEFINED |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 exceed 32K | 86 exceed 32K |
87 */ | 87 */ |
88 static inline void XRect_set(SkXRect* xr, const SkIRect& src) { | 88 static inline void XRect_set(SkXRect* xr, const SkIRect& src) { |
89 xr->fLeft = SkIntToFixed(src.fLeft); | 89 xr->fLeft = SkIntToFixed(src.fLeft); |
90 xr->fTop = SkIntToFixed(src.fTop); | 90 xr->fTop = SkIntToFixed(src.fTop); |
91 xr->fRight = SkIntToFixed(src.fRight); | 91 xr->fRight = SkIntToFixed(src.fRight); |
92 xr->fBottom = SkIntToFixed(src.fBottom); | 92 xr->fBottom = SkIntToFixed(src.fBottom); |
93 } | 93 } |
94 | 94 |
95 /** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates | 95 /** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates |
96 from SkScalar to SkFixed. Behavior is undefined if the src coordinates | 96 from SkScalar to SkFixed. Does not check for overflow if the src coordinates |
97 exceed 32K | 97 exceed 32K |
98 */ | 98 */ |
99 static inline void XRect_set(SkXRect* xr, const SkRect& src) { | 99 static inline void XRect_set(SkXRect* xr, const SkRect& src) { |
100 xr->fLeft = SkScalarToFixed(src.fLeft); | 100 xr->fLeft = SkScalarToFixed(src.fLeft); |
101 xr->fTop = SkScalarToFixed(src.fTop); | 101 xr->fTop = SkScalarToFixed(src.fTop); |
102 xr->fRight = SkScalarToFixed(src.fRight); | 102 xr->fRight = SkScalarToFixed(src.fRight); |
103 xr->fBottom = SkScalarToFixed(src.fBottom); | 103 xr->fBottom = SkScalarToFixed(src.fBottom); |
104 } | 104 } |
105 | 105 |
106 /** Round the SkXRect coordinates, and store the result in the SkIRect. | 106 /** Round the SkXRect coordinates, and store the result in the SkIRect. |
107 */ | 107 */ |
108 static inline void XRect_round(const SkXRect& xr, SkIRect* dst) { | 108 static inline void XRect_round(const SkXRect& xr, SkIRect* dst) { |
109 dst->fLeft = SkFixedRoundToInt(xr.fLeft); | 109 dst->fLeft = SkFixedRoundToInt(xr.fLeft); |
110 dst->fTop = SkFixedRoundToInt(xr.fTop); | 110 dst->fTop = SkFixedRoundToInt(xr.fTop); |
111 dst->fRight = SkFixedRoundToInt(xr.fRight); | 111 dst->fRight = SkFixedRoundToInt(xr.fRight); |
112 dst->fBottom = SkFixedRoundToInt(xr.fBottom); | 112 dst->fBottom = SkFixedRoundToInt(xr.fBottom); |
113 } | 113 } |
114 | 114 |
115 /** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling | 115 /** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling |
116 for right/bottom), and store the result in the SkIRect. | 116 for right/bottom), and store the result in the SkIRect. |
117 */ | 117 */ |
118 static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) { | 118 static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) { |
119 dst->fLeft = SkFixedFloorToInt(xr.fLeft); | 119 dst->fLeft = SkFixedFloorToInt(xr.fLeft); |
120 dst->fTop = SkFixedFloorToInt(xr.fTop); | 120 dst->fTop = SkFixedFloorToInt(xr.fTop); |
121 dst->fRight = SkFixedCeilToInt(xr.fRight); | 121 dst->fRight = SkFixedCeilToInt(xr.fRight); |
122 dst->fBottom = SkFixedCeilToInt(xr.fBottom); | 122 dst->fBottom = SkFixedCeilToInt(xr.fBottom); |
123 } | 123 } |
124 | 124 |
125 #endif | 125 #endif |
OLD | NEW |