aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-11 19:01:12 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-11 19:01:12 +0000
commitad91799832b9ba2a3de30c0f57968148b4be17af (patch)
treea05df754859059ad0a58e46b5e3550855735342b
parent5877ffd5ea71a3ea70096d5c11c843798defa690 (diff)
code style
git-svn-id: http://skia.googlecode.com/svn/trunk@1106 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkEndian.h18
-rw-r--r--include/core/SkGeometry.h35
-rw-r--r--include/core/SkShader.h115
3 files changed, 93 insertions, 75 deletions
diff --git a/include/core/SkEndian.h b/include/core/SkEndian.h
index f08a9a990b..a72dfe31b6 100644
--- a/include/core/SkEndian.h
+++ b/include/core/SkEndian.h
@@ -36,8 +36,7 @@
/** Swap the two bytes in the low 16bits of the parameters.
e.g. 0x1234 -> 0x3412
*/
-inline uint16_t SkEndianSwap16(U16CPU value)
-{
+static inline uint16_t SkEndianSwap16(U16CPU value) {
SkASSERT(value == (uint16_t)value);
return (uint16_t)((value >> 8) | (value << 8));
}
@@ -45,12 +44,10 @@ inline uint16_t SkEndianSwap16(U16CPU value)
/** Vector version of SkEndianSwap16(), which swaps the
low two bytes of each value in the array.
*/
-inline void SkEndianSwap16s(uint16_t array[], int count)
-{
+static inline void SkEndianSwap16s(uint16_t array[], int count) {
SkASSERT(count == 0 || array != NULL);
- while (--count >= 0)
- {
+ while (--count >= 0) {
*array = SkEndianSwap16(*array);
array += 1;
}
@@ -59,8 +56,7 @@ inline void SkEndianSwap16s(uint16_t array[], int count)
/** Reverse all 4 bytes in a 32bit value.
e.g. 0x12345678 -> 0x78563412
*/
-inline uint32_t SkEndianSwap32(uint32_t value)
-{
+static inline uint32_t SkEndianSwap32(uint32_t value) {
return ((value & 0xFF) << 24) |
((value & 0xFF00) << 8) |
((value & 0xFF0000) >> 8) |
@@ -70,12 +66,10 @@ inline uint32_t SkEndianSwap32(uint32_t value)
/** Vector version of SkEndianSwap16(), which swaps the
bytes of each value in the array.
*/
-inline void SkEndianSwap32s(uint32_t array[], int count)
-{
+static inline void SkEndianSwap32s(uint32_t array[], int count) {
SkASSERT(count == 0 || array != NULL);
- while (--count >= 0)
- {
+ while (--count >= 0) {
*array = SkEndianSwap32(*array);
array += 1;
}
diff --git a/include/core/SkGeometry.h b/include/core/SkGeometry.h
index d4b13fb5df..000ca73699 100644
--- a/include/core/SkGeometry.h
+++ b/include/core/SkGeometry.h
@@ -32,7 +32,8 @@ typedef SkPoint SkXRay;
one of the endpoints' y coordinates, indicating that another query y
coordinate is preferred for robustness.
*/
-bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2], bool* ambiguous = NULL);
+bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2],
+ bool* ambiguous = NULL);
/** Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the
equation.
@@ -44,8 +45,10 @@ int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]);
/** Set pt to the point on the src quadratic specified by t. t must be
0 <= t <= 1.0
*/
-void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tangent = NULL);
-void SkEvalQuadAtHalf(const SkPoint src[3], SkPoint* pt, SkVector* tangent = NULL);
+void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt,
+ SkVector* tangent = NULL);
+void SkEvalQuadAtHalf(const SkPoint src[3], SkPoint* pt,
+ SkVector* tangent = NULL);
/** Given a src quadratic bezier, chop it at the specified t value,
where 0 < t < 1, and return the two new quadratics in dst:
@@ -92,7 +95,7 @@ int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5]);
*/
SK_API void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4]);
-////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
/** Convert from parametric from (pts) to polynomial coefficients
coeff[0]*T^3 + coeff[1]*T^2 + coeff[2]*T + coeff[3]
@@ -102,14 +105,16 @@ void SkGetCubicCoeff(const SkPoint pts[4], SkScalar cx[4], SkScalar cy[4]);
/** Set pt to the point on the src cubic specified by t. t must be
0 <= t <= 1.0
*/
-void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* locOrNull, SkVector* tangentOrNull, SkVector* curvatureOrNull);
+void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* locOrNull,
+ SkVector* tangentOrNull, SkVector* curvatureOrNull);
/** Given a src cubic bezier, chop it at the specified t value,
where 0 < t < 1, and return the two new cubics in dst:
dst[0..3] and dst[3..6]
*/
void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t);
-void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], const SkScalar t[], int t_count);
+void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], const SkScalar t[],
+ int t_count);
/** Given a src cubic bezier, chop it at the specified t == 1/2,
The new cubics are returned in dst[0..3] and dst[3..6]
@@ -125,7 +130,8 @@ void SkChopCubicAtHalf(const SkPoint src[4], SkPoint dst[7]);
1 0 < tValues[0] < 1
2 0 < tValues[0] < tValues[1] < 1
*/
-int SkFindCubicExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar d, SkScalar tValues[2]);
+int SkFindCubicExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar d,
+ SkScalar tValues[2]);
/** Given 4 points on a cubic bezier, chop it into 1, 2, 3 beziers such that
the resulting beziers are monotonic in Y. This is called by the scan converter.
@@ -149,7 +155,8 @@ int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[2]);
int SkChopCubicAtInflections(const SkPoint src[4], SkPoint dst[10]);
int SkFindCubicMaxCurvature(const SkPoint src[4], SkScalar tValues[3]);
-int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tValues[3] = NULL);
+int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13],
+ SkScalar tValues[3] = NULL);
/** Given a monotonic cubic bezier, determine whether an xray intersects the
cubic.
@@ -163,7 +170,8 @@ int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tV
coordinates, indicating that another query y coordinate is preferred
for robustness.
*/
-bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4], bool* ambiguous = NULL);
+bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4],
+ bool* ambiguous = NULL);
/** Given an arbitrary cubic bezier, return the number of times an xray crosses
the cubic. Valid return values are [0..3]
@@ -177,9 +185,10 @@ bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4], bool*
coordinates or at a tangent point, indicating that another query y
coordinate is preferred for robustness.
*/
-int SkNumXRayCrossingsForCubic(const SkXRay& pt, const SkPoint cubic[4], bool* ambiguous = NULL);
+int SkNumXRayCrossingsForCubic(const SkXRay& pt, const SkPoint cubic[4],
+ bool* ambiguous = NULL);
-///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
enum SkRotationDirection {
kCW_SkRotationDirection,
@@ -197,7 +206,7 @@ enum SkRotationDirection {
matrix, if not null, is appled to the points before they are returned.
*/
-int SkBuildQuadArc(const SkVector& unitStart, const SkVector& unitStop, SkRotationDirection,
- const SkMatrix* matrix, SkPoint quadPoints[]);
+int SkBuildQuadArc(const SkVector& unitStart, const SkVector& unitStop,
+ SkRotationDirection, const SkMatrix*, SkPoint quadPoints[]);
#endif
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index d837284325..cf1d4e9ff0 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -26,28 +26,33 @@
class SkPath;
/** \class SkShader
-
- SkShader is the based class for objects that return horizontal spans of colors during drawing.
- A subclass of SkShader is installed in a SkPaint calling paint.setShader(shader). After that
- any object (other than a bitmap) that is drawn with that paint will get its color(s) from the
- shader.
-*/
+ *
+ * SkShader is the based class for objects that return horizontal spans of
+ * colors during drawing. A subclass of SkShader is installed in a SkPaint
+ * calling paint.setShader(shader). After that any object (other than a bitmap)
+ * that is drawn with that paint will get its color(s) from the shader.
+ */
class SK_API SkShader : public SkFlattenable {
public:
SkShader();
virtual ~SkShader();
- /** Return true if the shader has a non-identity local matrix.
- @param localM Optional: If not null, return the shader's local matrix
- @return true if the shader has a non-identity local matrix.
- */
+ /**
+ * Return true if the shader has a non-identity local matrix.
+ * @param localM Optional: If not null, return the shader's local matrix
+ * @return true if the shader has a non-identity local matrix.
+ */
bool getLocalMatrix(SkMatrix* localM) const;
- /** Set the shader's local matrix.
- @param localM The shader's new local matrix.
- */
+
+ /**
+ * Set the shader's local matrix.
+ * @param localM The shader's new local matrix.
+ */
void setLocalMatrix(const SkMatrix& localM);
- /** Reset the shader's local matrix to identity.
- */
+
+ /**
+ * Reset the shader's local matrix to identity.
+ */
void resetLocalMatrix();
enum TileMode {
@@ -89,59 +94,69 @@ public:
kConstInY16_Flag = 0x10
};
- /** Called sometimes before drawing with this shader.
- Return the type of alpha your shader will return.
- The default implementation returns 0. Your subclass should override if it can
- (even sometimes) report a non-zero value, since that will enable various blitters
- to perform faster.
- */
+ /**
+ * Called sometimes before drawing with this shader. Return the type of
+ * alpha your shader will return. The default implementation returns 0.
+ * Your subclass should override if it can (even sometimes) report a
+ * non-zero value, since that will enable various blitters to perform
+ * faster.
+ */
virtual uint32_t getFlags() { return 0; }
- /** Return the alpha associated with the data returned by shadeSpan16(). If
- kHasSpan16_Flag is not set, this value is meaningless.
- */
+ /**
+ * Return the alpha associated with the data returned by shadeSpan16(). If
+ * kHasSpan16_Flag is not set, this value is meaningless.
+ */
virtual uint8_t getSpan16Alpha() const { return fPaintAlpha; }
- /** Called once before drawing, with the current paint and
- device matrix. Return true if your shader supports these
- parameters, or false if not. If false is returned, nothing
- will be drawn.
- */
+ /**
+ * Called once before drawing, with the current paint and device matrix.
+ * Return true if your shader supports these parameters, or false if not.
+ * If false is returned, nothing will be drawn.
+ */
virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
const SkMatrix& matrix);
- /** Called for each span of the object being drawn. Your subclass
- should set the appropriate colors (with premultiplied alpha) that
- correspond to the specified device coordinates.
- */
+ /**
+ * Called for each span of the object being drawn. Your subclass should
+ * set the appropriate colors (with premultiplied alpha) that correspond
+ * to the specified device coordinates.
+ */
virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0;
- /** Called only for 16bit devices when getFlags() returns
- kOpaqueAlphaFlag | kHasSpan16_Flag
- */
+
+ /**
+ * Called only for 16bit devices when getFlags() returns
+ * kOpaqueAlphaFlag | kHasSpan16_Flag
+ */
virtual void shadeSpan16(int x, int y, uint16_t[], int count);
- /** Similar to shadeSpan, but only returns the alpha-channel for a span.
- The default implementation calls shadeSpan() and then extracts the alpha
- values from the returned colors.
- */
+
+ /**
+ * Similar to shadeSpan, but only returns the alpha-channel for a span.
+ * The default implementation calls shadeSpan() and then extracts the alpha
+ * values from the returned colors.
+ */
virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
- /** Helper function that returns true if this shader's shadeSpan16() method can
- be called.
- */
+ /**
+ * Helper function that returns true if this shader's shadeSpan16() method
+ * can be called.
+ */
bool canCallShadeSpan16() {
return SkShader::CanCallShadeSpan16(this->getFlags());
}
- /** Helper to check the flags to know if it is legal to call shadeSpan16()
- */
+ /**
+ * Helper to check the flags to know if it is legal to call shadeSpan16()
+ */
static bool CanCallShadeSpan16(uint32_t flags) {
return (flags & kHasSpan16_Flag) != 0;
}
- /** Called before a session using the shader begins. Some shaders override
- this to defer some of their work (like calling bitmap.lockPixels()).
- Must be balanced by a call to endSession.
- */
+ /**
+ * Called before a session using the shader begins. Some shaders override
+ * this to defer some of their work (like calling bitmap.lockPixels()).
+ * Must be balanced by a call to endSession.
+ */
virtual void beginSession();
virtual void endSession();
@@ -195,7 +210,7 @@ public:
about the first point.
*/
virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix,
- TileMode xy[2], SkScalar* twoPointRadialParams) const;
+ TileMode xy[2], SkScalar* twoPointRadialParams) const;
/**
* If the shader subclass can be represented as a gradient, asAGradient