| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2016 Google Inc. | 2  * Copyright 2016 Google Inc. | 
| 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 #include "SkCanvas.h" | 8 #include "SkCanvas.h" | 
| 9 #include "SkDOM.h" | 9 #include "SkDOM.h" | 
| 10 #include "SkParsePath.h" | 10 #include "SkParsePath.h" | 
| 11 #include "SkString.h" | 11 #include "SkString.h" | 
| 12 #include "SkSVGAttributeParser.h" | 12 #include "SkSVGAttributeParser.h" | 
|  | 13 #include "SkSVGCircle.h" | 
| 13 #include "SkSVGDOM.h" | 14 #include "SkSVGDOM.h" | 
|  | 15 #include "SkSVGEllipse.h" | 
| 14 #include "SkSVGG.h" | 16 #include "SkSVGG.h" | 
| 15 #include "SkSVGNode.h" | 17 #include "SkSVGNode.h" | 
| 16 #include "SkSVGPath.h" | 18 #include "SkSVGPath.h" | 
| 17 #include "SkSVGPoly.h" | 19 #include "SkSVGPoly.h" | 
| 18 #include "SkSVGRect.h" | 20 #include "SkSVGRect.h" | 
| 19 #include "SkSVGRenderContext.h" | 21 #include "SkSVGRenderContext.h" | 
| 20 #include "SkSVGSVG.h" | 22 #include "SkSVGSVG.h" | 
| 21 #include "SkSVGTypes.h" | 23 #include "SkSVGTypes.h" | 
| 22 #include "SkSVGValue.h" | 24 #include "SkSVGValue.h" | 
| 23 #include "SkTSearch.h" | 25 #include "SkTSearch.h" | 
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 206     const char* fKey; | 208     const char* fKey; | 
| 207     const T     fValue; | 209     const T     fValue; | 
| 208 }; | 210 }; | 
| 209 | 211 | 
| 210 struct AttrParseInfo { | 212 struct AttrParseInfo { | 
| 211     SkSVGAttribute fAttr; | 213     SkSVGAttribute fAttr; | 
| 212     bool (*fSetter)(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, const cha
     r* stringValue); | 214     bool (*fSetter)(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, const cha
     r* stringValue); | 
| 213 }; | 215 }; | 
| 214 | 216 | 
| 215 SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = { | 217 SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = { | 
|  | 218     { "cx"             , { SkSVGAttribute::kCx            , SetLengthAttribute  
       }}, | 
|  | 219     { "cy"             , { SkSVGAttribute::kCy            , SetLengthAttribute  
       }}, | 
| 216     { "d"              , { SkSVGAttribute::kD             , SetPathDataAttribute
       }}, | 220     { "d"              , { SkSVGAttribute::kD             , SetPathDataAttribute
       }}, | 
| 217     { "fill"           , { SkSVGAttribute::kFill          , SetPaintAttribute   
       }}, | 221     { "fill"           , { SkSVGAttribute::kFill          , SetPaintAttribute   
       }}, | 
| 218     { "fill-opacity"   , { SkSVGAttribute::kFillOpacity   , SetNumberAttribute  
       }}, | 222     { "fill-opacity"   , { SkSVGAttribute::kFillOpacity   , SetNumberAttribute  
       }}, | 
| 219     { "height"         , { SkSVGAttribute::kHeight        , SetLengthAttribute  
       }}, | 223     { "height"         , { SkSVGAttribute::kHeight        , SetLengthAttribute  
       }}, | 
| 220     { "opacity"        , { SkSVGAttribute::kOpacity       , SetNumberAttribute  
       }}, | 224     { "opacity"        , { SkSVGAttribute::kOpacity       , SetNumberAttribute  
       }}, | 
| 221     { "points"         , { SkSVGAttribute::kPoints        , SetPointsAttribute  
       }}, | 225     { "points"         , { SkSVGAttribute::kPoints        , SetPointsAttribute  
       }}, | 
|  | 226     { "r"              , { SkSVGAttribute::kR             , SetLengthAttribute  
       }}, | 
| 222     { "rx"             , { SkSVGAttribute::kRx            , SetLengthAttribute  
       }}, | 227     { "rx"             , { SkSVGAttribute::kRx            , SetLengthAttribute  
       }}, | 
| 223     { "ry"             , { SkSVGAttribute::kRy            , SetLengthAttribute  
       }}, | 228     { "ry"             , { SkSVGAttribute::kRy            , SetLengthAttribute  
       }}, | 
| 224     { "stroke"         , { SkSVGAttribute::kStroke        , SetPaintAttribute   
       }}, | 229     { "stroke"         , { SkSVGAttribute::kStroke        , SetPaintAttribute   
       }}, | 
| 225     { "stroke-linecap" , { SkSVGAttribute::kStrokeLineCap , SetLineCapAttribute 
       }}, | 230     { "stroke-linecap" , { SkSVGAttribute::kStrokeLineCap , SetLineCapAttribute 
       }}, | 
| 226     { "stroke-linejoin", { SkSVGAttribute::kStrokeLineJoin, SetLineJoinAttribute
       }}, | 231     { "stroke-linejoin", { SkSVGAttribute::kStrokeLineJoin, SetLineJoinAttribute
       }}, | 
| 227     { "stroke-opacity" , { SkSVGAttribute::kStrokeOpacity , SetNumberAttribute  
       }}, | 232     { "stroke-opacity" , { SkSVGAttribute::kStrokeOpacity , SetNumberAttribute  
       }}, | 
| 228     { "stroke-width"   , { SkSVGAttribute::kStrokeWidth   , SetLengthAttribute  
       }}, | 233     { "stroke-width"   , { SkSVGAttribute::kStrokeWidth   , SetLengthAttribute  
       }}, | 
| 229     { "style"          , { SkSVGAttribute::kUnknown       , SetStyleAttributes  
       }}, | 234     { "style"          , { SkSVGAttribute::kUnknown       , SetStyleAttributes  
       }}, | 
| 230     { "transform"      , { SkSVGAttribute::kTransform     , SetTransformAttribut
     e }}, | 235     { "transform"      , { SkSVGAttribute::kTransform     , SetTransformAttribut
     e }}, | 
| 231     { "viewBox"        , { SkSVGAttribute::kViewBox       , SetViewBoxAttribute 
       }}, | 236     { "viewBox"        , { SkSVGAttribute::kViewBox       , SetViewBoxAttribute 
       }}, | 
| 232     { "width"          , { SkSVGAttribute::kWidth         , SetLengthAttribute  
       }}, | 237     { "width"          , { SkSVGAttribute::kWidth         , SetLengthAttribute  
       }}, | 
| 233     { "x"              , { SkSVGAttribute::kX             , SetLengthAttribute  
       }}, | 238     { "x"              , { SkSVGAttribute::kX             , SetLengthAttribute  
       }}, | 
| 234     { "y"              , { SkSVGAttribute::kY             , SetLengthAttribute  
       }}, | 239     { "y"              , { SkSVGAttribute::kY             , SetLengthAttribute  
       }}, | 
| 235 }; | 240 }; | 
| 236 | 241 | 
| 237 SortedDictionaryEntry<sk_sp<SkSVGNode>(*)()> gTagFactories[] = { | 242 SortedDictionaryEntry<sk_sp<SkSVGNode>(*)()> gTagFactories[] = { | 
|  | 243     { "circle"  , []() -> sk_sp<SkSVGNode> { return SkSVGCircle::Make();       }
     }, | 
|  | 244     { "ellipse" , []() -> sk_sp<SkSVGNode> { return SkSVGEllipse::Make();      }
     }, | 
| 238     { "g"       , []() -> sk_sp<SkSVGNode> { return SkSVGG::Make();            }
     }, | 245     { "g"       , []() -> sk_sp<SkSVGNode> { return SkSVGG::Make();            }
     }, | 
| 239     { "path"    , []() -> sk_sp<SkSVGNode> { return SkSVGPath::Make();         }
     }, | 246     { "path"    , []() -> sk_sp<SkSVGNode> { return SkSVGPath::Make();         }
     }, | 
| 240     { "polygon" , []() -> sk_sp<SkSVGNode> { return SkSVGPoly::MakePolygon();  }
     }, | 247     { "polygon" , []() -> sk_sp<SkSVGNode> { return SkSVGPoly::MakePolygon();  }
     }, | 
| 241     { "polyline", []() -> sk_sp<SkSVGNode> { return SkSVGPoly::MakePolyline(); }
     }, | 248     { "polyline", []() -> sk_sp<SkSVGNode> { return SkSVGPoly::MakePolyline(); }
     }, | 
| 242     { "rect"    , []() -> sk_sp<SkSVGNode> { return SkSVGRect::Make();         }
     }, | 249     { "rect"    , []() -> sk_sp<SkSVGNode> { return SkSVGRect::Make();         }
     }, | 
| 243     { "svg"     , []() -> sk_sp<SkSVGNode> { return SkSVGSVG::Make();          }
     }, | 250     { "svg"     , []() -> sk_sp<SkSVGNode> { return SkSVGSVG::Make();          }
     }, | 
| 244 }; | 251 }; | 
| 245 | 252 | 
| 246 struct ConstructionContext { | 253 struct ConstructionContext { | 
| 247     ConstructionContext() : fParent(nullptr) { } | 254     ConstructionContext() : fParent(nullptr) { } | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 353 } | 360 } | 
| 354 | 361 | 
| 355 void SkSVGDOM::setContainerSize(const SkSize& containerSize) { | 362 void SkSVGDOM::setContainerSize(const SkSize& containerSize) { | 
| 356     // TODO: inval | 363     // TODO: inval | 
| 357     fContainerSize = containerSize; | 364     fContainerSize = containerSize; | 
| 358 } | 365 } | 
| 359 | 366 | 
| 360 void SkSVGDOM::setRoot(sk_sp<SkSVGNode> root) { | 367 void SkSVGDOM::setRoot(sk_sp<SkSVGNode> root) { | 
| 361     fRoot = std::move(root); | 368     fRoot = std::move(root); | 
| 362 } | 369 } | 
| OLD | NEW | 
|---|