void SkProgressView::onInflate(const SkDOM& dom, const SkDOM::Node* node) { this->INHERITED::onInflate(dom, node); const char* s; SkASSERT(fOnShader == NULL); SkASSERT(fOffShader == NULL); if ((s = dom.findAttr(node, "src-on")) != NULL) fOnShader = inflate_shader(s); if ((s = dom.findAttr(node, "src-off")) != NULL) fOffShader = inflate_shader(s); (void)dom.findBool(node, "do-interp", &fDoInterp); }
void SkPaint_Inflate(SkPaint* paint, const SkDOM& dom, const SkDOM::Node* node) { SkASSERT(paint); SkASSERT(&dom); SkASSERT(node); SkScalar x; if (dom.findScalar(node, "stroke-width", &x)) paint->setStrokeWidth(x); if (dom.findScalar(node, "text-size", &x)) paint->setTextSize(x); bool b; SkASSERT("legacy: use is-stroke" && !dom.findBool(node, "is-frame", &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); const char* str = dom.findAttr(node, "color"); if (str) { SkColor c = paint->getColor(); if (SkParse::FindColor(str, &c)) paint->setColor(c); } // 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)); } 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(); }