Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/)
This CL is part II of IV (I broke down the 1280 files into 4 CLs).
Review URL: https://codereview.appspot.com/6474054
git-svn-id: http://skia.googlecode.com/svn/trunk@5263 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/views/SkParsePaint.cpp b/src/views/SkParsePaint.cpp
index 4839439..7a305f2 100644
--- a/src/views/SkParsePaint.cpp
+++ b/src/views/SkParsePaint.cpp
@@ -13,98 +13,98 @@
static SkShader* inflate_shader(const SkDOM& dom, const SkDOM::Node* node)
{
- if ((node = dom.getFirstChild(node, "shader")) == NULL)
- return NULL;
+ if ((node = dom.getFirstChild(node, "shader")) == NULL)
+ return NULL;
- const char* str;
+ const char* str;
- if (dom.hasAttr(node, "type", "linear-gradient"))
- {
- SkColor colors[2];
- SkPoint pts[2];
+ if (dom.hasAttr(node, "type", "linear-gradient"))
+ {
+ SkColor colors[2];
+ SkPoint pts[2];
- colors[0] = colors[1] = SK_ColorBLACK; // need to initialized the alpha to opaque, since FindColor doesn't set it
- if ((str = dom.findAttr(node, "c0")) != NULL &&
- SkParse::FindColor(str, &colors[0]) &&
- (str = dom.findAttr(node, "c1")) != NULL &&
- SkParse::FindColor(str, &colors[1]) &&
- dom.findScalars(node, "p0", &pts[0].fX, 2) &&
- dom.findScalars(node, "p1", &pts[1].fX, 2))
- {
- SkShader::TileMode mode = SkShader::kClamp_TileMode;
- int index;
+ colors[0] = colors[1] = SK_ColorBLACK; // need to initialized the alpha to opaque, since FindColor doesn't set it
+ if ((str = dom.findAttr(node, "c0")) != NULL &&
+ SkParse::FindColor(str, &colors[0]) &&
+ (str = dom.findAttr(node, "c1")) != NULL &&
+ SkParse::FindColor(str, &colors[1]) &&
+ dom.findScalars(node, "p0", &pts[0].fX, 2) &&
+ dom.findScalars(node, "p1", &pts[1].fX, 2))
+ {
+ SkShader::TileMode mode = SkShader::kClamp_TileMode;
+ int index;
- if ((index = dom.findList(node, "tile-mode", "clamp,repeat,mirror")) >= 0)
- mode = (SkShader::TileMode)index;
- return SkGradientShader::CreateLinear(pts, colors, NULL, 2, mode);
- }
- }
- else if (dom.hasAttr(node, "type", "bitmap"))
- {
- if ((str = dom.findAttr(node, "src")) == NULL)
- return NULL;
+ if ((index = dom.findList(node, "tile-mode", "clamp,repeat,mirror")) >= 0)
+ mode = (SkShader::TileMode)index;
+ return SkGradientShader::CreateLinear(pts, colors, NULL, 2, mode);
+ }
+ }
+ else if (dom.hasAttr(node, "type", "bitmap"))
+ {
+ if ((str = dom.findAttr(node, "src")) == NULL)
+ return NULL;
- SkBitmap bm;
+ SkBitmap bm;
- if (SkImageDecoder::DecodeFile(str, &bm))
- {
- SkShader::TileMode mode = SkShader::kRepeat_TileMode;
- int index;
+ if (SkImageDecoder::DecodeFile(str, &bm))
+ {
+ SkShader::TileMode mode = SkShader::kRepeat_TileMode;
+ int index;
- if ((index = dom.findList(node, "tile-mode", "clamp,repeat,mirror")) >= 0)
- mode = (SkShader::TileMode)index;
+ if ((index = dom.findList(node, "tile-mode", "clamp,repeat,mirror")) >= 0)
+ mode = (SkShader::TileMode)index;
- return SkShader::CreateBitmapShader(bm, mode, mode);
- }
- }
- return NULL;
+ return SkShader::CreateBitmapShader(bm, mode, mode);
+ }
+ }
+ return NULL;
}
void SkPaint_Inflate(SkPaint* paint, const SkDOM& dom, const SkDOM::Node* node)
{
- SkASSERT(paint);
- SkASSERT(&dom);
- SkASSERT(node);
+ SkASSERT(paint);
+ SkASSERT(&dom);
+ SkASSERT(node);
- SkScalar x;
+ SkScalar x;
- if (dom.findScalar(node, "stroke-width", &x))
- paint->setStrokeWidth(x);
- if (dom.findScalar(node, "text-size", &x))
- paint->setTextSize(x);
-
- bool b;
+ if (dom.findScalar(node, "stroke-width", &x))
+ paint->setStrokeWidth(x);
+ if (dom.findScalar(node, "text-size", &x))
+ paint->setTextSize(x);
- SkASSERT("legacy: use is-stroke" && !dom.findBool(node, "is-frame", &b));
+ bool b;
- if (dom.findBool(node, "is-stroke", &b))
- paint->setStyle(b ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
- if (dom.findBool(node, "is-antialias", &b))
- paint->setAntiAlias(b);
- if (dom.findBool(node, "is-lineartext", &b))
- paint->setLinearText(b);
+ SkASSERT("legacy: use is-stroke" && !dom.findBool(node, "is-frame", &b));
- const char* str = dom.findAttr(node, "color");
- if (str)
- {
- SkColor c = paint->getColor();
- if (SkParse::FindColor(str, &c))
- paint->setColor(c);
- }
+ if (dom.findBool(node, "is-stroke", &b))
+ paint->setStyle(b ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
+ if (dom.findBool(node, "is-antialias", &b))
+ paint->setAntiAlias(b);
+ if (dom.findBool(node, "is-lineartext", &b))
+ paint->setLinearText(b);
- // do this AFTER parsing for the color
- if (dom.findScalar(node, "opacity", &x))
- {
- x = SkMaxScalar(0, SkMinScalar(x, SK_Scalar1));
- paint->setAlpha(SkScalarRound(x * 255));
- }
+ const char* str = dom.findAttr(node, "color");
+ if (str)
+ {
+ SkColor c = paint->getColor();
+ if (SkParse::FindColor(str, &c))
+ paint->setColor(c);
+ }
- int index = dom.findList(node, "text-anchor", "left,center,right");
- if (index >= 0)
- paint->setTextAlign((SkPaint::Align)index);
+ // do this AFTER parsing for the color
+ if (dom.findScalar(node, "opacity", &x))
+ {
+ x = SkMaxScalar(0, SkMinScalar(x, SK_Scalar1));
+ paint->setAlpha(SkScalarRound(x * 255));
+ }
- SkShader* shader = inflate_shader(dom, node);
- if (shader)
- paint->setShader(shader)->unref();
+ int index = dom.findList(node, "text-anchor", "left,center,right");
+ if (index >= 0)
+ paint->setTextAlign((SkPaint::Align)index);
+
+ SkShader* shader = inflate_shader(dom, node);
+ if (shader)
+ paint->setShader(shader)->unref();
}