code style
git-svn-id: http://skia.googlecode.com/svn/trunk@1160 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp
index 27d765f..158cefa 100644
--- a/src/effects/SkCornerPathEffect.cpp
+++ b/src/effects/SkCornerPathEffect.cpp
@@ -28,8 +28,8 @@
{
}
-static bool ComputeStep(const SkPoint& a, const SkPoint& b, SkScalar radius, SkPoint* step)
-{
+static bool ComputeStep(const SkPoint& a, const SkPoint& b, SkScalar radius,
+ SkPoint* step) {
SkScalar dist = SkPoint::Distance(a, b);
step->set(b.fX - a.fX, b.fY - a.fY);
@@ -37,17 +37,17 @@
if (dist <= radius * 2) {
step->scale(SK_ScalarHalf);
return false;
- }
- else {
+ } else {
step->scale(SkScalarDiv(radius, dist));
return true;
}
}
-bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
-{
- if (fRadius == 0)
+bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
+ SkScalar* width) {
+ if (fRadius == 0) {
return false;
+ }
SkPath::Iter iter(src, false);
SkPath::Verb verb, prevVerb = (SkPath::Verb)-1;
@@ -65,97 +65,91 @@
for (;;) {
switch (verb = iter.next(pts)) {
- case SkPath::kMove_Verb:
- // close out the previous (open) contour
- if (SkPath::kLine_Verb == prevVerb) {
- dst->lineTo(lastCorner);
- }
- closed = iter.isClosedContour();
- if (closed) {
- moveTo = pts[0];
- prevIsValid = false;
- }
- else {
- dst->moveTo(pts[0]);
- prevIsValid = true;
- }
- break;
- case SkPath::kLine_Verb:
- {
+ case SkPath::kMove_Verb:
+ // close out the previous (open) contour
+ if (SkPath::kLine_Verb == prevVerb) {
+ dst->lineTo(lastCorner);
+ }
+ closed = iter.isClosedContour();
+ if (closed) {
+ moveTo = pts[0];
+ prevIsValid = false;
+ } else {
+ dst->moveTo(pts[0]);
+ prevIsValid = true;
+ }
+ break;
+ case SkPath::kLine_Verb: {
bool drawSegment = ComputeStep(pts[0], pts[1], fRadius, &step);
// prev corner
if (!prevIsValid) {
dst->moveTo(moveTo + step);
prevIsValid = true;
- }
- else {
- dst->quadTo(pts[0].fX, pts[0].fY, pts[0].fX + step.fX, pts[0].fY + step.fY);
+ } else {
+ dst->quadTo(pts[0].fX, pts[0].fY, pts[0].fX + step.fX,
+ pts[0].fY + step.fY);
}
if (drawSegment) {
dst->lineTo(pts[1].fX - step.fX, pts[1].fY - step.fY);
}
lastCorner = pts[1];
prevIsValid = true;
+ break;
}
- break;
- case SkPath::kQuad_Verb:
- // TBD - just replicate the curve for now
- if (!prevIsValid)
- {
- dst->moveTo(pts[0]);
- prevIsValid = true;
- }
- dst->quadTo(pts[1], pts[2]);
- lastCorner = pts[2];
- firstStep.set(0, 0);
- break;
- case SkPath::kCubic_Verb:
- if (!prevIsValid)
- {
- dst->moveTo(pts[0]);
- prevIsValid = true;
- }
- // TBD - just replicate the curve for now
- dst->cubicTo(pts[1], pts[2], pts[3]);
- lastCorner = pts[3];
- firstStep.set(0, 0);
- break;
- case SkPath::kClose_Verb:
- if (firstStep.fX || firstStep.fY)
- dst->quadTo(lastCorner.fX, lastCorner.fY,
- lastCorner.fX + firstStep.fX,
- lastCorner.fY + firstStep.fY);
- dst->close();
- break;
- case SkPath::kDone_Verb:
- goto DONE;
+ case SkPath::kQuad_Verb:
+ // TBD - just replicate the curve for now
+ if (!prevIsValid) {
+ dst->moveTo(pts[0]);
+ prevIsValid = true;
+ }
+ dst->quadTo(pts[1], pts[2]);
+ lastCorner = pts[2];
+ firstStep.set(0, 0);
+ break;
+ case SkPath::kCubic_Verb:
+ if (!prevIsValid) {
+ dst->moveTo(pts[0]);
+ prevIsValid = true;
+ }
+ // TBD - just replicate the curve for now
+ dst->cubicTo(pts[1], pts[2], pts[3]);
+ lastCorner = pts[3];
+ firstStep.set(0, 0);
+ break;
+ case SkPath::kClose_Verb:
+ if (firstStep.fX || firstStep.fY) {
+ dst->quadTo(lastCorner.fX, lastCorner.fY,
+ lastCorner.fX + firstStep.fX,
+ lastCorner.fY + firstStep.fY);
+ }
+ dst->close();
+ break;
+ case SkPath::kDone_Verb:
+ goto DONE;
}
- if (SkPath::kMove_Verb == prevVerb)
+ if (SkPath::kMove_Verb == prevVerb) {
firstStep = step;
+ }
prevVerb = verb;
}
DONE:
return true;
}
-SkFlattenable::Factory SkCornerPathEffect::getFactory()
-{
+SkFlattenable::Factory SkCornerPathEffect::getFactory() {
return CreateProc;
}
-void SkCornerPathEffect::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkCornerPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.writeScalar(fRadius);
}
-SkFlattenable* SkCornerPathEffect::CreateProc(SkFlattenableReadBuffer& buffer)
-{
+SkFlattenable* SkCornerPathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkCornerPathEffect, (buffer));
}
-SkCornerPathEffect::SkCornerPathEffect(SkFlattenableReadBuffer& buffer)
-{
+SkCornerPathEffect::SkCornerPathEffect(SkFlattenableReadBuffer& buffer) {
fRadius = buffer.readScalar();
}
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index 48581b5..82f357c 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -19,24 +19,24 @@
#include "SkBuffer.h"
#include "SkPathMeasure.h"
-static inline int is_even(int x)
-{
+static inline int is_even(int x) {
return (~x) << 31;
}
-static SkScalar FindFirstInterval(const SkScalar intervals[], SkScalar phase, int32_t* index)
-{
+static SkScalar FindFirstInterval(const SkScalar intervals[], SkScalar phase,
+ int32_t* index) {
int i;
- for (i = 0; phase > intervals[i]; i++)
+ for (i = 0; phase > intervals[i]; i++) {
phase -= intervals[i];
+ }
*index = i;
return intervals[i] - phase;
}
-SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit)
- : fScaleToFit(scaleToFit)
-{
+SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count,
+ SkScalar phase, bool scaleToFit)
+ : fScaleToFit(scaleToFit) {
SkASSERT(intervals);
SkASSERT(count > 1 && SkAlign2(count) == count);
@@ -44,46 +44,44 @@
fCount = count;
SkScalar len = 0;
- for (int i = 0; i < count; i++)
- {
+ for (int i = 0; i < count; i++) {
SkASSERT(intervals[i] >= 0);
fIntervals[i] = intervals[i];
len += intervals[i];
}
fIntervalLength = len;
- if (len > 0) // we don't handle 0 length dash arrays
- {
- if (phase < 0)
- {
+ if (len > 0) { // we don't handle 0 length dash arrays
+ if (phase < 0) {
phase = -phase;
- if (phase > len)
+ if (phase > len) {
phase = SkScalarMod(phase, len);
+ }
phase = len - phase;
- }
- else if (phase >= len)
+ } else if (phase >= len) {
phase = SkScalarMod(phase, len);
+ }
SkASSERT(phase >= 0 && phase < len);
fInitialDashLength = FindFirstInterval(intervals, phase, &fInitialDashIndex);
SkASSERT(fInitialDashLength >= 0);
SkASSERT(fInitialDashIndex >= 0 && fInitialDashIndex < fCount);
- }
- else
+ } else {
fInitialDashLength = -1; // signal bad dash intervals
+ }
}
-SkDashPathEffect::~SkDashPathEffect()
-{
+SkDashPathEffect::~SkDashPathEffect() {
sk_free(fIntervals);
}
-bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
-{
+bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
+ SkScalar* width) {
// we do nothing if the src wants to be filled, or if our dashlength is 0
- if (*width < 0 || fInitialDashLength < 0)
+ if (*width < 0 || fInitialDashLength < 0) {
return false;
+ }
SkPathMeasure meas(src, false);
const SkScalar* intervals = fIntervals;
@@ -95,12 +93,10 @@
int index = fInitialDashIndex;
SkScalar scale = SK_Scalar1;
- if (fScaleToFit)
- {
- if (fIntervalLength >= length)
+ if (fScaleToFit) {
+ if (fIntervalLength >= length) {
scale = SkScalarDiv(length, fIntervalLength);
- else
- {
+ } else {
SkScalar div = SkScalarDiv(length, fIntervalLength);
int n = SkScalarFloor(div);
scale = SkScalarDiv(length, n * fIntervalLength);
@@ -110,12 +106,10 @@
SkScalar distance = 0;
SkScalar dlen = SkScalarMul(fInitialDashLength, scale);
- while (distance < length)
- {
+ while (distance < length) {
SkASSERT(dlen >= 0);
addedSegment = false;
- if (is_even(index) && dlen > 0 && !skipFirstSegment)
- {
+ if (is_even(index) && dlen > 0 && !skipFirstSegment) {
addedSegment = true;
meas.getSegment(distance, distance + dlen, dst, true);
}
@@ -127,27 +121,28 @@
// wrap around our intervals array if necessary
index += 1;
SkASSERT(index <= fCount);
- if (index == fCount)
+ if (index == fCount) {
index = 0;
+ }
// fetch our next dlen
dlen = SkScalarMul(intervals[index], scale);
}
// extend if we ended on a segment and we need to join up with the (skipped) initial segment
- if (meas.isClosed() && is_even(fInitialDashIndex) && fInitialDashLength > 0)
+ if (meas.isClosed() && is_even(fInitialDashIndex) &&
+ fInitialDashLength > 0) {
meas.getSegment(0, SkScalarMul(fInitialDashLength, scale), dst, !addedSegment);
+ }
} while (meas.nextContour());
return true;
}
-SkFlattenable::Factory SkDashPathEffect::getFactory()
-{
+SkFlattenable::Factory SkDashPathEffect::getFactory() {
return fInitialDashLength < 0 ? NULL : CreateProc;
}
-void SkDashPathEffect::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkDashPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
SkASSERT(fInitialDashLength >= 0);
buffer.write32(fCount);
@@ -158,13 +153,11 @@
buffer.writeMul4(fIntervals, fCount * sizeof(fIntervals[0]));
}
-SkFlattenable* SkDashPathEffect::CreateProc(SkFlattenableReadBuffer& buffer)
-{
+SkFlattenable* SkDashPathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkDashPathEffect, (buffer));
}
-SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer)
-{
+SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) {
fCount = buffer.readS32();
fInitialDashIndex = buffer.readS32();
fInitialDashLength = buffer.readScalar();
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index 6286045..3b8d48e 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -20,8 +20,7 @@
#include "SkPathMeasure.h"
#include "SkRandom.h"
-static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale)
-{
+static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) {
SkVector normal = tangent;
normal.rotateCCW();
normal.setLength(scale);
@@ -34,8 +33,8 @@
{
}
-bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
-{
+bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
+ SkScalar* width) {
bool doFill = *width < 0;
SkPathMeasure meas(src, doFill);
@@ -48,58 +47,49 @@
do {
SkScalar length = meas.getLength();
- if (fSegLength * (2 + doFill) > length)
- {
+ if (fSegLength * (2 + doFill) > length) {
meas.getSegment(0, length, dst, true); // to short for us to mangle
- }
- else
- {
+ } else {
int n = SkScalarRound(SkScalarDiv(length, fSegLength));
SkScalar delta = length / n;
SkScalar distance = 0;
- if (meas.isClosed())
- {
+ if (meas.isClosed()) {
n -= 1;
distance += delta/2;
}
meas.getPosTan(distance, &p, &v);
Perterb(&p, v, SkScalarMul(rand.nextSScalar1(), scale));
dst->moveTo(p);
- while (--n >= 0)
- {
+ while (--n >= 0) {
distance += delta;
meas.getPosTan(distance, &p, &v);
Perterb(&p, v, SkScalarMul(rand.nextSScalar1(), scale));
dst->lineTo(p);
}
- if (meas.isClosed())
+ if (meas.isClosed()) {
dst->close();
+ }
}
} while (meas.nextContour());
return true;
}
-SkFlattenable::Factory SkDiscretePathEffect::getFactory()
-{
+SkFlattenable::Factory SkDiscretePathEffect::getFactory() {
return CreateProc;
}
-SkFlattenable* SkDiscretePathEffect::CreateProc(SkFlattenableReadBuffer& buffer)
-{
+SkFlattenable* SkDiscretePathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkDiscretePathEffect, (buffer));
}
-void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.writeScalar(fSegLength);
buffer.writeScalar(fPerterb);
}
-SkDiscretePathEffect::SkDiscretePathEffect(SkFlattenableReadBuffer& buffer)
-{
+SkDiscretePathEffect::SkDiscretePathEffect(SkFlattenableReadBuffer& buffer) {
fSegLength = buffer.readScalar();
fPerterb = buffer.readScalar();
}
-
diff --git a/src/effects/SkEmbossMask.cpp b/src/effects/SkEmbossMask.cpp
index fd11f54..742ccd2 100644
--- a/src/effects/SkEmbossMask.cpp
+++ b/src/effects/SkEmbossMask.cpp
@@ -17,8 +17,7 @@
#include "SkEmbossMask.h"
-static inline int nonzero_to_one(int x)
-{
+static inline int nonzero_to_one(int x) {
#if 0
return x != 0;
#else
@@ -26,8 +25,7 @@
#endif
}
-static inline int neq_to_one(int x, int max)
-{
+static inline int neq_to_one(int x, int max) {
#if 0
return x != max;
#else
@@ -36,8 +34,7 @@
#endif
}
-static inline int neq_to_mask(int x, int max)
-{
+static inline int neq_to_mask(int x, int max) {
#if 0
return -(x != max);
#else
@@ -46,8 +43,7 @@
#endif
}
-static inline unsigned div255(unsigned x)
-{
+static inline unsigned div255(unsigned x) {
SkASSERT(x <= (255*255));
return x * ((1 << 24) / 255) >> 24;
}
@@ -60,28 +56,27 @@
#include <stdio.h>
-void SkEmbossMask_BuildTable()
-{
+void SkEmbossMask_BuildTable() {
// build it 0..127 x 0..127, so we use 2^15 - 1 in the numerator for our "fixed" table
FILE* file = ::fopen("SkEmbossMask_Table.h", "w");
SkASSERT(file);
::fprintf(file, "#include \"SkTypes.h\"\n\n");
::fprintf(file, "static const U16 gInvSqrtTable[128 * 128] = {\n");
- for (int dx = 0; dx <= 255/2; dx++)
- {
- for (int dy = 0; dy <= 255/2; dy++)
- {
+ for (int dx = 0; dx <= 255/2; dx++) {
+ for (int dy = 0; dy <= 255/2; dy++) {
if ((dy & 15) == 0)
::fprintf(file, "\t");
uint16_t value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4));
::fprintf(file, "0x%04X", value);
- if (dx * 128 + dy < 128*128-1)
+ if (dx * 128 + dy < 128*128-1) {
::fprintf(file, ", ");
- if ((dy & 15) == 15)
+ }
+ if ((dy & 15) == 15) {
::fprintf(file, "\n");
+ }
}
}
::fprintf(file, "};\n#define kDeltaUsedToBuildTable\t%d\n", kDelta);
@@ -90,8 +85,7 @@
#endif
-void SkEmbossMask::Emboss(SkMask* mask, const SkEmbossMaskFilter::Light& light)
-{
+void SkEmbossMask::Emboss(SkMask* mask, const SkEmbossMaskFilter::Light& light) {
SkASSERT(kDelta == kDeltaUsedToBuildTable);
SkASSERT(mask->fFormat == SkMask::k3D_Format);
@@ -114,14 +108,11 @@
int maxx = mask->fBounds.width() - 1;
int prev_row = 0;
- for (int y = 0; y <= maxy; y++)
- {
+ for (int y = 0; y <= maxy; y++) {
int next_row = neq_to_mask(y, maxy) & rowBytes;
- for (int x = 0; x <= maxx; x++)
- {
- if (alpha[x])
- {
+ for (int x = 0; x <= maxx; x++) {
+ if (alpha[x]) {
int nx = alpha[x + neq_to_one(x, maxx)] - alpha[x - nonzero_to_one(x)];
int ny = alpha[x + next_row] - alpha[x - prev_row];
@@ -129,8 +120,7 @@
int mul = ambient;
int add = 0;
- if (numer > 0) // preflight when numer/denom will be <= 0
- {
+ if (numer > 0) { // preflight when numer/denom will be <= 0
#if 0
int denom = SkSqrt32(nx * nx + ny * ny + kDelta*kDelta);
SkFixed dot = numer / denom;
@@ -150,8 +140,7 @@
// hilite = R * Eye(0, 0, 1)
int hilite = (2 * dot - lz_dot8) * lz_dot8 >> 8;
- if (hilite > 0)
- {
+ if (hilite > 0) {
// pin hilite to 255, since our fast math is also a little sloppy
hilite = SkClampMax(hilite, 255);
@@ -160,8 +149,9 @@
// and then possibly cache a 256 table for a given specular
// value in the light, and just pass that in to this function.
add = hilite;
- for (int i = specular >> 4; i > 0; --i)
+ for (int i = specular >> 4; i > 0; --i) {
add = div255(add * hilite);
+ }
}
}
multiply[x] = SkToU8(mul);
diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp
index 9d585ff..51c19b2 100644
--- a/src/effects/SkEmbossMaskFilter.cpp
+++ b/src/effects/SkEmbossMaskFilter.cpp
@@ -21,22 +21,27 @@
#include "SkEmbossMask.h"
#include "SkBuffer.h"
+static inline int pin2byte(int n) {
+ if (n < 0) {
+ n = 0;
+ } else if (n > 0xFF) {
+ n = 0xFF;
+ }
+ return n;
+}
+
SkMaskFilter* SkBlurMaskFilter::CreateEmboss(const SkScalar direction[3],
SkScalar ambient, SkScalar specular,
- SkScalar blurRadius)
-{
- if (direction == NULL)
+ SkScalar blurRadius) {
+ if (direction == NULL) {
return NULL;
+ }
// ambient should be 0...1 as a scalar
- int am = SkScalarToFixed(ambient) >> 8;
- if (am < 0) am = 0;
- else if (am > 0xFF) am = 0xFF;
+ int am = pin2byte(SkScalarToFixed(ambient) >> 8);
// specular should be 0..15.99 as a scalar
- int sp = SkScalarToFixed(specular) >> 12;
- if (sp < 0) sp = 0;
- else if (sp > 0xFF) sp = 0xFF;
+ int sp = pin2byte(SkScalarToFixed(specular) >> 12);
SkEmbossMaskFilter::Light light;
@@ -47,41 +52,43 @@
return SkNEW_ARGS(SkEmbossMaskFilter, (light, blurRadius));
}
-/////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-static void normalize(SkScalar v[3])
-{
+static void normalize(SkScalar v[3]) {
SkScalar mag = SkScalarSquare(v[0]) + SkScalarSquare(v[1]) + SkScalarSquare(v[2]);
mag = SkScalarSqrt(mag);
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
v[i] = SkScalarDiv(v[i], mag);
+ }
}
SkEmbossMaskFilter::SkEmbossMaskFilter(const Light& light, SkScalar blurRadius)
- : fLight(light), fBlurRadius(blurRadius)
-{
+ : fLight(light), fBlurRadius(blurRadius) {
normalize(fLight.fDirection);
}
-SkMask::Format SkEmbossMaskFilter::getFormat()
-{
+SkMask::Format SkEmbossMaskFilter::getFormat() {
return SkMask::k3D_Format;
}
-bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkIPoint* margin)
-{
+bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src,
+ const SkMatrix& matrix, SkIPoint* margin) {
SkScalar radius = matrix.mapRadius(fBlurRadius);
- if (!SkBlurMask::Blur(dst, src, radius, SkBlurMask::kInner_Style, SkBlurMask::kLow_Quality))
+ if (!SkBlurMask::Blur(dst, src, radius, SkBlurMask::kInner_Style,
+ SkBlurMask::kLow_Quality)) {
return false;
+ }
dst->fFormat = SkMask::k3D_Format;
- if (margin)
+ if (margin) {
margin->set(SkScalarCeil(radius), SkScalarCeil(radius));
+ }
- if (src.fImage == NULL)
+ if (src.fImage == NULL) {
return true;
+ }
// create a larger buffer for the other two channels (should force fBlur to do this for us)
@@ -98,7 +105,8 @@
// run the light direction through the matrix...
Light light = fLight;
- matrix.mapVectors((SkVector*)(void*)light.fDirection, (SkVector*)(void*)fLight.fDirection, 1);
+ matrix.mapVectors((SkVector*)(void*)light.fDirection,
+ (SkVector*)(void*)fLight.fDirection, 1);
// now restore the length of the XY component
// cast to SkVector so we can call setLength (this double cast silences alias warnings)
@@ -115,25 +123,22 @@
return true;
}
-SkFlattenable* SkEmbossMaskFilter::CreateProc(SkFlattenableReadBuffer& buffer)
-{
+SkFlattenable* SkEmbossMaskFilter::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkEmbossMaskFilter, (buffer));
}
-SkFlattenable::Factory SkEmbossMaskFilter::getFactory()
-{
+SkFlattenable::Factory SkEmbossMaskFilter::getFactory() {
return CreateProc;
}
-SkEmbossMaskFilter::SkEmbossMaskFilter(SkFlattenableReadBuffer& buffer) : SkMaskFilter(buffer)
-{
+SkEmbossMaskFilter::SkEmbossMaskFilter(SkFlattenableReadBuffer& buffer)
+ : SkMaskFilter(buffer) {
buffer.read(&fLight, sizeof(fLight));
SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean
fBlurRadius = buffer.readScalar();
}
-void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
fLight.fPad = 0; // for the font-cache lookup to be clean
diff --git a/src/effects/SkKernel33MaskFilter.cpp b/src/effects/SkKernel33MaskFilter.cpp
index 429e120..5051f71 100644
--- a/src/effects/SkKernel33MaskFilter.cpp
+++ b/src/effects/SkKernel33MaskFilter.cpp
@@ -1,21 +1,21 @@
#include "SkKernel33MaskFilter.h"
#include "SkColorPriv.h"
-SkMask::Format SkKernel33ProcMaskFilter::getFormat()
-{
+SkMask::Format SkKernel33ProcMaskFilter::getFormat() {
return SkMask::kA8_Format;
}
-bool SkKernel33ProcMaskFilter::filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin)
-{
+bool SkKernel33ProcMaskFilter::filterMask(SkMask* dst, const SkMask& src,
+ const SkMatrix&, SkIPoint* margin) {
// margin???
dst->fImage = NULL;
dst->fBounds = src.fBounds;
dst->fBounds.inset(-1, -1);
dst->fFormat = SkMask::kA8_Format;
- if (NULL == src.fImage)
+ if (NULL == src.fImage) {
return true;
+ }
dst->fRowBytes = dst->fBounds.width();
size_t size = dst->computeImageSize();
@@ -39,28 +39,26 @@
unsigned scale = fPercent256;
- for (int y = -1; y <= h; y++)
- {
+ for (int y = -1; y <= h; y++) {
uint8_t* dstRow = dstImage;
- for (int x = -1; x <= w; x++)
- {
+ for (int x = -1; x <= w; x++) {
memset(storage, 0, sizeof(storage));
uint8_t* storagePtr = &storage[0][0];
- for (int ky = y - 1; ky <= y + 1; ky++)
- {
+ for (int ky = y - 1; ky <= y + 1; ky++) {
const uint8_t* srcRow = srcImage + ky * srcRB; // may be out-of-range
- for (int kx = x - 1; kx <= x + 1; kx++)
- {
- if ((unsigned)ky < (unsigned)h && (unsigned)kx < (unsigned)w)
+ for (int kx = x - 1; kx <= x + 1; kx++) {
+ if ((unsigned)ky < (unsigned)h && (unsigned)kx < (unsigned)w) {
*storagePtr = srcRow[kx];
+ }
storagePtr++;
}
}
int value = this->computeValue(srcRows);
- if (scale < 256)
+ if (scale < 256) {
value = SkAlphaBlend(value, srcRows[1][1], scale);
+ }
*dstRow++ = SkToU8(value);
}
dstImage += dst->fRowBytes;
@@ -68,57 +66,53 @@
return true;
}
-void SkKernel33ProcMaskFilter::flatten(SkFlattenableWriteBuffer& wb)
-{
+void SkKernel33ProcMaskFilter::flatten(SkFlattenableWriteBuffer& wb) {
this->INHERITED::flatten(wb);
wb.write32(fPercent256);
}
SkKernel33ProcMaskFilter::SkKernel33ProcMaskFilter(SkFlattenableReadBuffer& rb)
- : SkMaskFilter(rb)
-{
+ : SkMaskFilter(rb) {
fPercent256 = rb.readS32();
}
///////////////////////////////////////////////////////////////////////////////
-uint8_t SkKernel33MaskFilter::computeValue(uint8_t* const* srcRows)
-{
+uint8_t SkKernel33MaskFilter::computeValue(uint8_t* const* srcRows) {
int value = 0;
- for (int i = 0; i < 3; i++)
- for (int j = 0; j < 3; j++)
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
value += fKernel[i][j] * srcRows[i][j];
+ }
+ }
value >>= fShift;
- if (value < 0)
+ if (value < 0) {
value = 0;
- else if (value > 255)
+ } else if (value > 255) {
value = 255;
+ }
return (uint8_t)value;
}
-void SkKernel33MaskFilter::flatten(SkFlattenableWriteBuffer& wb)
-{
+void SkKernel33MaskFilter::flatten(SkFlattenableWriteBuffer& wb) {
this->INHERITED::flatten(wb);
wb.writeMul4(fKernel, 9 * sizeof(int));
wb.write32(fShift);
}
-SkFlattenable::Factory SkKernel33MaskFilter::getFactory()
-{
+SkFlattenable::Factory SkKernel33MaskFilter::getFactory() {
return Create;
}
-SkFlattenable* SkKernel33MaskFilter::Create(SkFlattenableReadBuffer& rb)
-{
+SkFlattenable* SkKernel33MaskFilter::Create(SkFlattenableReadBuffer& rb) {
return new SkKernel33MaskFilter(rb);
}
SkKernel33MaskFilter::SkKernel33MaskFilter(SkFlattenableReadBuffer& rb)
- : SkKernel33ProcMaskFilter(rb)
-{
+ : SkKernel33ProcMaskFilter(rb) {
rb.read(fKernel, 9 * sizeof(int));
fShift = rb.readS32();
}
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index 851f418..27683ef 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -35,8 +35,7 @@
{
}
-SkLayerRasterizer::~SkLayerRasterizer()
-{
+SkLayerRasterizer::~SkLayerRasterizer() {
SkDeque::F2BIter iter(fLayers);
SkLayerRasterizer_Rec* rec;
@@ -44,35 +43,34 @@
rec->fPaint.~SkPaint();
}
-void SkLayerRasterizer::addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy)
-{
+void SkLayerRasterizer::addLayer(const SkPaint& paint, SkScalar dx,
+ SkScalar dy) {
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers.push_back();
new (&rec->fPaint) SkPaint(paint);
rec->fOffset.set(dx, dy);
}
-static bool compute_bounds(const SkDeque& layers, const SkPath& path, const SkMatrix& matrix,
- const SkIRect* clipBounds, SkIRect* bounds)
-{
+static bool compute_bounds(const SkDeque& layers, const SkPath& path,
+ const SkMatrix& matrix,
+ const SkIRect* clipBounds, SkIRect* bounds) {
SkDeque::F2BIter iter(layers);
SkLayerRasterizer_Rec* rec;
bounds->set(SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32);
- while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL)
- {
+ while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) {
const SkPaint& paint = rec->fPaint;
SkPath fillPath, devPath;
const SkPath* p = &path;
- if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style)
- {
+ if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) {
paint.getFillPath(path, &fillPath);
p = &fillPath;
}
- if (p->isEmpty())
+ if (p->isEmpty()) {
continue;
+ }
// apply the matrix and offset
{
@@ -82,9 +80,11 @@
}
SkMask mask;
- if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(), &matrix,
- &mask, SkMask::kJustComputeBounds_CreateMode))
+ if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(),
+ &matrix, &mask,
+ SkMask::kJustComputeBounds_CreateMode)) {
return false;
+ }
bounds->join(mask.fBounds);
}
@@ -93,19 +93,17 @@
bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds,
- SkMask* mask, SkMask::CreateMode mode)
-{
- if (fLayers.empty())
+ SkMask* mask, SkMask::CreateMode mode) {
+ if (fLayers.empty()) {
return false;
+ }
- if (SkMask::kJustRenderImage_CreateMode != mode)
- {
+ if (SkMask::kJustRenderImage_CreateMode != mode) {
if (!compute_bounds(fLayers, path, matrix, clipBounds, &mask->fBounds))
return false;
}
- if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode)
- {
+ if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) {
mask->fFormat = SkMask::kA8_Format;
mask->fRowBytes = mask->fBounds.width();
size_t size = mask->computeImageSize();
@@ -116,8 +114,7 @@
memset(mask->fImage, 0, size);
}
- if (SkMask::kJustComputeBounds_CreateMode != mode)
- {
+ if (SkMask::kJustComputeBounds_CreateMode != mode) {
SkBitmap device;
SkDraw draw;
SkMatrix translatedMatrix; // this translates us to our local pixels
@@ -153,14 +150,12 @@
/////////// Routines for flattening /////////////////
-static void paint_read(SkPaint* paint, SkFlattenableReadBuffer& buffer)
-{
+static void paint_read(SkPaint* paint, SkFlattenableReadBuffer& buffer) {
paint->setAntiAlias(buffer.readBool());
paint->setStyle((SkPaint::Style)buffer.readU8());
paint->setAlpha(buffer.readU8());
- if (paint->getStyle() != SkPaint::kFill_Style)
- {
+ if (paint->getStyle() != SkPaint::kFill_Style) {
paint->setStrokeWidth(buffer.readScalar());
paint->setStrokeMiter(buffer.readScalar());
paint->setStrokeCap((SkPaint::Cap)buffer.readU8());
@@ -173,14 +168,12 @@
SkSafeUnref(paint->setXfermode((SkXfermode*)buffer.readFlattenable()));
}
-static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer)
-{
+static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer) {
buffer.writeBool(paint.isAntiAlias());
buffer.write8(paint.getStyle());
buffer.write8(paint.getAlpha());
- if (paint.getStyle() != SkPaint::kFill_Style)
- {
+ if (paint.getStyle() != SkPaint::kFill_Style) {
buffer.writeScalar(paint.getStrokeWidth());
buffer.writeScalar(paint.getStrokeMiter());
buffer.write8(paint.getStrokeCap());
@@ -194,12 +187,10 @@
}
SkLayerRasterizer::SkLayerRasterizer(SkFlattenableReadBuffer& buffer)
- : SkRasterizer(buffer), fLayers(sizeof(SkLayerRasterizer_Rec))
-{
+ : SkRasterizer(buffer), fLayers(sizeof(SkLayerRasterizer_Rec)) {
int count = buffer.readS32();
- for (int i = 0; i < count; i++)
- {
+ for (int i = 0; i < count; i++) {
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers.push_back();
#if 0
@@ -213,8 +204,7 @@
}
}
-void SkLayerRasterizer::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkLayerRasterizer::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
buffer.write32(fLayers.count());
@@ -222,8 +212,7 @@
SkDeque::F2BIter iter(fLayers);
const SkLayerRasterizer_Rec* rec;
- while ((rec = (const SkLayerRasterizer_Rec*)iter.next()) != NULL)
- {
+ while ((rec = (const SkLayerRasterizer_Rec*)iter.next()) != NULL) {
#if 0
rec->fPaint.flatten(buffer);
#else
@@ -234,13 +223,11 @@
}
}
-SkFlattenable* SkLayerRasterizer::CreateProc(SkFlattenableReadBuffer& buffer)
-{
+SkFlattenable* SkLayerRasterizer::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkLayerRasterizer, (buffer));
}
-SkFlattenable::Factory SkLayerRasterizer::getFactory()
-{
+SkFlattenable::Factory SkLayerRasterizer::getFactory() {
return CreateProc;
}
diff --git a/src/effects/SkPaintFlagsDrawFilter.cpp b/src/effects/SkPaintFlagsDrawFilter.cpp
index 62eb53a..9b7cff1 100644
--- a/src/effects/SkPaintFlagsDrawFilter.cpp
+++ b/src/effects/SkPaintFlagsDrawFilter.cpp
@@ -1,3 +1,19 @@
+/*
+ Copyright 2011 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
#include "SkPaintFlagsDrawFilter.h"
#include "SkPaint.h"
diff --git a/src/effects/SkPixelXorXfermode.cpp b/src/effects/SkPixelXorXfermode.cpp
index a5599e2..0fb0494 100644
--- a/src/effects/SkPixelXorXfermode.cpp
+++ b/src/effects/SkPixelXorXfermode.cpp
@@ -1,36 +1,45 @@
+/*
+ Copyright 2011 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
#include "SkPixelXorXfermode.h"
#include "SkColorPriv.h"
// we always return an opaque color, 'cause I don't know what to do with
// the alpha-component and still return a valid premultiplied color.
-SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst)
-{
+SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) {
SkPMColor res = src ^ dst ^ fOpColor;
res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque
return res;
}
-void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb)
-{
+void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb) {
this->INHERITED::flatten(wb);
wb.write32(fOpColor);
}
SkPixelXorXfermode::SkPixelXorXfermode(SkFlattenableReadBuffer& rb)
- : SkXfermode(rb)
-{
+ : SkXfermode(rb) {
fOpColor = rb.readU32();
}
-SkFlattenable::Factory SkPixelXorXfermode::getFactory()
-{
+SkFlattenable::Factory SkPixelXorXfermode::getFactory() {
return Create;
}
-SkFlattenable* SkPixelXorXfermode::Create(SkFlattenableReadBuffer& rb)
-{
+SkFlattenable* SkPixelXorXfermode::Create(SkFlattenableReadBuffer& rb) {
return SkNEW_ARGS(SkPixelXorXfermode, (rb));
}
-
-
diff --git a/src/effects/SkPorterDuff.cpp b/src/effects/SkPorterDuff.cpp
index 980ce29..fd3e1c0 100644
--- a/src/effects/SkPorterDuff.cpp
+++ b/src/effects/SkPorterDuff.cpp
@@ -1,3 +1,19 @@
+/*
+ Copyright 2011 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
#include "SkPorterDuff.h"
#include "SkXfermode.h"
diff --git a/src/effects/SkRectShape.cpp b/src/effects/SkRectShape.cpp
index 8a38a1e..47520f0 100644
--- a/src/effects/SkRectShape.cpp
+++ b/src/effects/SkRectShape.cpp
@@ -1,3 +1,19 @@
+/*
+ Copyright 2011 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
#include "SkRectShape.h"
#include "SkCanvas.h"
diff --git a/src/effects/SkTableMaskFilter.cpp b/src/effects/SkTableMaskFilter.cpp
index aea939f..8edbf7e 100644
--- a/src/effects/SkTableMaskFilter.cpp
+++ b/src/effects/SkTableMaskFilter.cpp
@@ -1,3 +1,19 @@
+/*
+ Copyright 2011 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
#include "SkTableMaskFilter.h"
SkTableMaskFilter::SkTableMaskFilter() {
diff --git a/src/effects/SkTransparentShader.cpp b/src/effects/SkTransparentShader.cpp
index 6b79839f..c6caba3 100644
--- a/src/effects/SkTransparentShader.cpp
+++ b/src/effects/SkTransparentShader.cpp
@@ -20,63 +20,56 @@
bool SkTransparentShader::setContext(const SkBitmap& device,
const SkPaint& paint,
- const SkMatrix& matrix)
-{
+ const SkMatrix& matrix) {
fDevice = &device;
fAlpha = paint.getAlpha();
return this->INHERITED::setContext(device, paint, matrix);
}
-uint32_t SkTransparentShader::getFlags()
-{
+uint32_t SkTransparentShader::getFlags() {
uint32_t flags = this->INHERITED::getFlags();
switch (fDevice->getConfig()) {
- case SkBitmap::kRGB_565_Config:
- flags |= kHasSpan16_Flag;
- if (fAlpha == 255)
- flags |= kOpaqueAlpha_Flag;
- break;
- case SkBitmap::kARGB_8888_Config:
- case SkBitmap::kARGB_4444_Config:
- if (fAlpha == 255 && fDevice->isOpaque())
- flags |= kOpaqueAlpha_Flag;
- break;
- default:
- break;
+ case SkBitmap::kRGB_565_Config:
+ flags |= kHasSpan16_Flag;
+ if (fAlpha == 255)
+ flags |= kOpaqueAlpha_Flag;
+ break;
+ case SkBitmap::kARGB_8888_Config:
+ case SkBitmap::kARGB_4444_Config:
+ if (fAlpha == 255 && fDevice->isOpaque())
+ flags |= kOpaqueAlpha_Flag;
+ break;
+ default:
+ break;
}
return flags;
}
-void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count)
-{
+void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
unsigned scale = SkAlpha255To256(fAlpha);
switch (fDevice->getConfig()) {
- case SkBitmap::kARGB_8888_Config:
- if (scale == 256)
- memcpy(span, fDevice->getAddr32(x, y), count * sizeof(SkPMColor));
- else
- {
- const SkPMColor* src = fDevice->getAddr32(x, y);
- for (int i = count - 1; i >= 0; --i)
- span[i] = SkAlphaMulQ(src[i], scale);
- }
- break;
- case SkBitmap::kRGB_565_Config:
- {
- const uint16_t* src = fDevice->getAddr16(x, y);
- if (scale == 256)
- {
- for (int i = count - 1; i >= 0; --i)
- span[i] = SkPixel16ToPixel32(src[i]);
+ case SkBitmap::kARGB_8888_Config:
+ if (scale == 256) {
+ memcpy(span, fDevice->getAddr32(x, y), count * sizeof(SkPMColor));
+ } else {
+ const SkPMColor* src = fDevice->getAddr32(x, y);
+ for (int i = count - 1; i >= 0; --i) {
+ span[i] = SkAlphaMulQ(src[i], scale);
+ }
}
- else
- {
+ break;
+ case SkBitmap::kRGB_565_Config: {
+ const uint16_t* src = fDevice->getAddr16(x, y);
+ if (scale == 256) {
+ for (int i = count - 1; i >= 0; --i) {
+ span[i] = SkPixel16ToPixel32(src[i]);
+ }
+ } else {
unsigned alpha = fAlpha;
- for (int i = count - 1; i >= 0; --i)
- {
+ for (int i = count - 1; i >= 0; --i) {
uint16_t c = src[i];
unsigned r = SkPacked16ToR32(c);
unsigned g = SkPacked16ToG32(c);
@@ -88,55 +81,48 @@
SkAlphaMul(b, scale));
}
}
+ break;
}
- break;
- case SkBitmap::kARGB_4444_Config:
- {
+ case SkBitmap::kARGB_4444_Config: {
const uint16_t* src = fDevice->getAddr16(x, y);
- if (scale == 256)
- {
- for (int i = count - 1; i >= 0; --i)
+ if (scale == 256) {
+ for (int i = count - 1; i >= 0; --i) {
span[i] = SkPixel4444ToPixel32(src[i]);
- }
- else
- {
+ }
+ } else {
unsigned scale16 = scale >> 4;
- for (int i = count - 1; i >= 0; --i)
- {
+ for (int i = count - 1; i >= 0; --i) {
uint32_t c = SkExpand_4444(src[i]) * scale16;
span[i] = SkCompact_8888(c);
}
}
- }
break;
- case SkBitmap::kIndex8_Config:
- SkASSERT(!"index8 not supported as a destination device");
- break;
- case SkBitmap::kA8_Config:
- {
- const uint8_t* src = fDevice->getAddr8(x, y);
- if (scale == 256)
- {
- for (int i = count - 1; i >= 0; --i)
- span[i] = SkPackARGB32(src[i], 0, 0, 0);
- }
- else
- {
- for (int i = count - 1; i >= 0; --i)
- span[i] = SkPackARGB32(SkAlphaMul(src[i], scale), 0, 0, 0);
- }
}
- break;
- case SkBitmap::kA1_Config:
- SkASSERT(!"kA1_Config umimplemented at this time");
- break;
- default: // to avoid warnings
- break;
+ case SkBitmap::kIndex8_Config:
+ SkASSERT(!"index8 not supported as a destination device");
+ break;
+ case SkBitmap::kA8_Config: {
+ const uint8_t* src = fDevice->getAddr8(x, y);
+ if (scale == 256) {
+ for (int i = count - 1; i >= 0; --i) {
+ span[i] = SkPackARGB32(src[i], 0, 0, 0);
+ }
+ } else {
+ for (int i = count - 1; i >= 0; --i) {
+ span[i] = SkPackARGB32(SkAlphaMul(src[i], scale), 0, 0, 0);
+ }
+ }
+ break;
+ }
+ case SkBitmap::kA1_Config:
+ SkASSERT(!"kA1_Config umimplemented at this time");
+ break;
+ default: // to avoid warnings
+ break;
}
}
-void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count)
-{
+void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count) {
SkASSERT(fDevice->getConfig() == SkBitmap::kRGB_565_Config);
memcpy(span, fDevice->getAddr16(x, y), count << 1);