Reland "[svg] Relocate out of experimental"
Move the SVG rendering code to modules/svg, and componentize.
Also split into include/src/utils.
As external clients still reference the old header locations,
introduce temporary forwarding headers to facilitate the migration.
This reverts commit d6cf56fd34
.
TBR=
Change-Id: Ibadd7c8dc0464ec0c27841530ade0c2098305d20
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327344
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
This commit is contained in:
parent
f1b53836b7
commit
b3418103e9
81
BUILD.gn
81
BUILD.gn
@ -1801,8 +1801,8 @@ if (skia_enable_tools) {
|
|||||||
defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ]
|
defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ]
|
||||||
}
|
}
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
|
"modules/svg",
|
||||||
]
|
]
|
||||||
public_deps = [ ":gpu_tool_utils" ]
|
public_deps = [ ":gpu_tool_utils" ]
|
||||||
}
|
}
|
||||||
@ -1866,7 +1866,6 @@ if (skia_enable_tools) {
|
|||||||
sources -= [ "//tests/FontMgrFontConfigTest.cpp" ]
|
sources -= [ "//tests/FontMgrFontConfigTest.cpp" ]
|
||||||
}
|
}
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
":skia",
|
":skia",
|
||||||
":skvm_builders",
|
":skvm_builders",
|
||||||
@ -1876,6 +1875,7 @@ if (skia_enable_tools) {
|
|||||||
"modules/skparagraph:tests",
|
"modules/skparagraph:tests",
|
||||||
"modules/sksg:tests",
|
"modules/sksg:tests",
|
||||||
"modules/skshaper",
|
"modules/skshaper",
|
||||||
|
"modules/svg",
|
||||||
"//third_party/absl",
|
"//third_party/absl",
|
||||||
"//third_party/libpng",
|
"//third_party/libpng",
|
||||||
"//third_party/libwebp",
|
"//third_party/libwebp",
|
||||||
@ -1901,52 +1901,6 @@ if (skia_enable_tools) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO(fmalita): componentize & relocate
|
|
||||||
test_lib("experimental_svg_model") {
|
|
||||||
if (skia_use_expat) {
|
|
||||||
sources = [
|
|
||||||
"experimental/svg/model/SkSVGAttribute.cpp",
|
|
||||||
"experimental/svg/model/SkSVGAttributeParser.cpp",
|
|
||||||
"experimental/svg/model/SkSVGCircle.cpp",
|
|
||||||
"experimental/svg/model/SkSVGClipPath.cpp",
|
|
||||||
"experimental/svg/model/SkSVGContainer.cpp",
|
|
||||||
"experimental/svg/model/SkSVGDOM.cpp",
|
|
||||||
"experimental/svg/model/SkSVGEllipse.cpp",
|
|
||||||
"experimental/svg/model/SkSVGGradient.cpp",
|
|
||||||
"experimental/svg/model/SkSVGLine.cpp",
|
|
||||||
"experimental/svg/model/SkSVGLinearGradient.cpp",
|
|
||||||
"experimental/svg/model/SkSVGNode.cpp",
|
|
||||||
"experimental/svg/model/SkSVGPath.cpp",
|
|
||||||
"experimental/svg/model/SkSVGPattern.cpp",
|
|
||||||
"experimental/svg/model/SkSVGPoly.cpp",
|
|
||||||
"experimental/svg/model/SkSVGRadialGradient.cpp",
|
|
||||||
"experimental/svg/model/SkSVGRect.cpp",
|
|
||||||
"experimental/svg/model/SkSVGRenderContext.cpp",
|
|
||||||
"experimental/svg/model/SkSVGSVG.cpp",
|
|
||||||
"experimental/svg/model/SkSVGShape.cpp",
|
|
||||||
"experimental/svg/model/SkSVGStop.cpp",
|
|
||||||
"experimental/svg/model/SkSVGText.cpp",
|
|
||||||
"experimental/svg/model/SkSVGTransformableNode.cpp",
|
|
||||||
"experimental/svg/model/SkSVGUse.cpp",
|
|
||||||
"experimental/svg/model/SkSVGValue.cpp",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":skia",
|
|
||||||
":xml",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skia_use_expat && !skia_use_wuffs) {
|
|
||||||
test_app("svg_tool") {
|
|
||||||
sources = [ "experimental/svg/utils/SvgTool.cpp" ]
|
|
||||||
deps = [
|
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
test_lib("experimental_xform") {
|
test_lib("experimental_xform") {
|
||||||
sources = [
|
sources = [
|
||||||
"experimental/xform/SkShape.cpp",
|
"experimental/xform/SkShape.cpp",
|
||||||
@ -1960,6 +1914,9 @@ if (skia_enable_tools) {
|
|||||||
test_app("skottie_tool") {
|
test_app("skottie_tool") {
|
||||||
deps = [ "modules/skottie:tool" ]
|
deps = [ "modules/skottie:tool" ]
|
||||||
}
|
}
|
||||||
|
test_app("svg_tool") {
|
||||||
|
deps = [ "modules/svg:tool" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test_app("make_skqp_model") {
|
test_app("make_skqp_model") {
|
||||||
@ -1975,13 +1932,13 @@ if (skia_enable_tools) {
|
|||||||
}
|
}
|
||||||
public_deps = [ ":tool_utils" ]
|
public_deps = [ ":tool_utils" ]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
":gpu_tool_utils",
|
":gpu_tool_utils",
|
||||||
":xml",
|
":xml",
|
||||||
"modules/audioplayer",
|
"modules/audioplayer",
|
||||||
"modules/skparagraph:samples",
|
"modules/skparagraph:samples",
|
||||||
"modules/skshaper",
|
"modules/skshaper",
|
||||||
|
"modules/svg",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
test_lib("hash_and_encode") {
|
test_lib("hash_and_encode") {
|
||||||
@ -2015,7 +1972,6 @@ if (skia_enable_tools) {
|
|||||||
deps = [
|
deps = [
|
||||||
":common_flags_aa",
|
":common_flags_aa",
|
||||||
":common_flags_gpu",
|
":common_flags_gpu",
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
":gm",
|
":gm",
|
||||||
":gpu_tool_utils",
|
":gpu_tool_utils",
|
||||||
@ -2026,6 +1982,7 @@ if (skia_enable_tools) {
|
|||||||
":trace",
|
":trace",
|
||||||
"modules/skottie",
|
"modules/skottie",
|
||||||
"modules/skottie:utils",
|
"modules/skottie:utils",
|
||||||
|
"modules/svg",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
test_app("dm") {
|
test_app("dm") {
|
||||||
@ -2040,7 +1997,6 @@ if (skia_enable_tools) {
|
|||||||
":common_flags_config",
|
":common_flags_config",
|
||||||
":common_flags_gpu",
|
":common_flags_gpu",
|
||||||
":common_flags_images",
|
":common_flags_images",
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
":gm",
|
":gm",
|
||||||
":gpu_tool_utils",
|
":gpu_tool_utils",
|
||||||
@ -2052,6 +2008,7 @@ if (skia_enable_tools) {
|
|||||||
"experimental/skrive",
|
"experimental/skrive",
|
||||||
"modules/skottie",
|
"modules/skottie",
|
||||||
"modules/skottie:utils",
|
"modules/skottie:utils",
|
||||||
|
"modules/svg",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2078,7 +2035,6 @@ if (skia_enable_tools) {
|
|||||||
":common_flags_config",
|
":common_flags_config",
|
||||||
":common_flags_gpu",
|
":common_flags_gpu",
|
||||||
":common_flags_images",
|
":common_flags_images",
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
":gm",
|
":gm",
|
||||||
":gpu_tool_utils",
|
":gpu_tool_utils",
|
||||||
@ -2087,6 +2043,7 @@ if (skia_enable_tools) {
|
|||||||
":trace",
|
":trace",
|
||||||
"modules/skparagraph",
|
"modules/skparagraph",
|
||||||
"modules/skshaper",
|
"modules/skshaper",
|
||||||
|
"modules/svg",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2578,7 +2535,6 @@ if (skia_enable_tools) {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":common_flags_gpu",
|
":common_flags_gpu",
|
||||||
":experimental_svg_model",
|
|
||||||
":flags",
|
":flags",
|
||||||
":gm",
|
":gm",
|
||||||
":gpu_tool_utils",
|
":gpu_tool_utils",
|
||||||
@ -2593,6 +2549,7 @@ if (skia_enable_tools) {
|
|||||||
"modules/skottie",
|
"modules/skottie",
|
||||||
"modules/skottie:utils",
|
"modules/skottie:utils",
|
||||||
"modules/sksg:samples",
|
"modules/sksg:samples",
|
||||||
|
"modules/svg",
|
||||||
"//third_party/imgui",
|
"//third_party/imgui",
|
||||||
]
|
]
|
||||||
if (skia_use_experimental_xform) {
|
if (skia_use_experimental_xform) {
|
||||||
@ -2783,7 +2740,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestSVGTypeface.cpp",
|
"tools/fonts/TestSVGTypeface.cpp",
|
||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [ ":experimental_svg_model" ]
|
deps = [ "modules/svg" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
libfuzzer_app("region_set_path") {
|
libfuzzer_app("region_set_path") {
|
||||||
@ -2803,7 +2760,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestSVGTypeface.cpp",
|
"tools/fonts/TestSVGTypeface.cpp",
|
||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [ ":experimental_svg_model" ]
|
deps = [ "modules/svg" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
libfuzzer_app("path_deserialize") {
|
libfuzzer_app("path_deserialize") {
|
||||||
@ -2840,7 +2797,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
"modules/svg",
|
||||||
"//third_party/libpng",
|
"//third_party/libpng",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2914,7 +2871,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
"modules/svg",
|
||||||
"//third_party/libpng",
|
"//third_party/libpng",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2941,7 +2898,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
"modules/svg",
|
||||||
"//third_party/libpng",
|
"//third_party/libpng",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2967,7 +2924,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
"modules/svg",
|
||||||
"//third_party/libpng",
|
"//third_party/libpng",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2991,7 +2948,7 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
"modules/svg",
|
||||||
"//third_party/libpng",
|
"//third_party/libpng",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -3029,8 +2986,8 @@ if (skia_enable_tools) {
|
|||||||
"tools/fonts/TestTypeface.cpp",
|
"tools/fonts/TestTypeface.cpp",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":experimental_svg_model",
|
|
||||||
"modules/skottie:skottie",
|
"modules/skottie:skottie",
|
||||||
|
"modules/svg",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3084,7 +3041,7 @@ if (skia_enable_tools) {
|
|||||||
|
|
||||||
libfuzzer_app("svg_dom") {
|
libfuzzer_app("svg_dom") {
|
||||||
sources = [ "fuzz/oss_fuzz/FuzzSVG.cpp" ]
|
sources = [ "fuzz/oss_fuzz/FuzzSVG.cpp" ]
|
||||||
deps = [ ":experimental_svg_model" ]
|
deps = [ "modules/svg" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
libfuzzer_app("skruntimeeffect") {
|
libfuzzer_app("skruntimeeffect") {
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#include "tools/trace/SkDebugfTracer.h"
|
#include "tools/trace/SkDebugfTracer.h"
|
||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#endif // SK_XML
|
#endif // SK_XML
|
||||||
|
|
||||||
#ifdef SK_ENABLE_ANDROID_UTILS
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
||||||
|
@ -71,8 +71,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SK_XML)
|
#if defined(SK_XML)
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/svg/SkSVGCanvas.h"
|
#include "include/svg/SkSVGCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "src/xml/SkXMLWriter.h"
|
#include "src/xml/SkXMLWriter.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2339,8 +2339,8 @@ Result ViaPicture::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkS
|
|||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
|
|
||||||
#ifdef TEST_VIA_SVG
|
#ifdef TEST_VIA_SVG
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/svg/SkSVGCanvas.h"
|
#include "include/svg/SkSVGCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "src/xml/SkXMLWriter.h"
|
#include "src/xml/SkXMLWriter.h"
|
||||||
|
|
||||||
Result ViaSVG::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
|
Result ViaSVG::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
|
||||||
|
@ -1,99 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGAttribute_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGAttribute_DEFINED
|
#include "modules/svg/include/SkSVGAttribute.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "src/core/SkTLazy.h"
|
|
||||||
|
|
||||||
class SkSVGRenderContext;
|
|
||||||
|
|
||||||
enum class SkSVGAttribute {
|
|
||||||
kClipPath,
|
|
||||||
kClipRule,
|
|
||||||
kColor,
|
|
||||||
kCx, // <circle>, <ellipse>, <radialGradient>: center x position
|
|
||||||
kCy, // <circle>, <ellipse>, <radialGradient>: center y position
|
|
||||||
kD,
|
|
||||||
kFill,
|
|
||||||
kFillOpacity,
|
|
||||||
kFillRule,
|
|
||||||
kFontFamily,
|
|
||||||
kFontSize,
|
|
||||||
kFontStyle,
|
|
||||||
kFontWeight,
|
|
||||||
kFx, // <radialGradient>: focal point x position
|
|
||||||
kFy, // <radialGradient>: focal point y position
|
|
||||||
kGradientTransform,
|
|
||||||
kHeight,
|
|
||||||
kHref,
|
|
||||||
kOffset,
|
|
||||||
kOpacity,
|
|
||||||
kPatternTransform,
|
|
||||||
kPoints,
|
|
||||||
kR, // <circle>, <radialGradient>: radius
|
|
||||||
kRx, // <ellipse>,<rect>: horizontal (corner) radius
|
|
||||||
kRy, // <ellipse>,<rect>: vertical (corner) radius
|
|
||||||
kSpreadMethod,
|
|
||||||
kStopColor,
|
|
||||||
kStopOpacity,
|
|
||||||
kStroke,
|
|
||||||
kStrokeDashArray,
|
|
||||||
kStrokeDashOffset,
|
|
||||||
kStrokeOpacity,
|
|
||||||
kStrokeLineCap,
|
|
||||||
kStrokeLineJoin,
|
|
||||||
kStrokeMiterLimit,
|
|
||||||
kStrokeWidth,
|
|
||||||
kTransform,
|
|
||||||
kText,
|
|
||||||
kTextAnchor,
|
|
||||||
kViewBox,
|
|
||||||
kVisibility,
|
|
||||||
kWidth,
|
|
||||||
kX,
|
|
||||||
kX1, // <line>: first endpoint x
|
|
||||||
kX2, // <line>: second endpoint x
|
|
||||||
kY,
|
|
||||||
kY1, // <line>: first endpoint y
|
|
||||||
kY2, // <line>: second endpoint y
|
|
||||||
|
|
||||||
kUnknown,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SkSVGPresentationAttributes {
|
|
||||||
static SkSVGPresentationAttributes MakeInitial();
|
|
||||||
|
|
||||||
// TODO: SkTLazy adds an extra ptr per attribute; refactor to reduce overhead.
|
|
||||||
|
|
||||||
SkTLazy<SkSVGPaint> fFill;
|
|
||||||
SkTLazy<SkSVGNumberType> fFillOpacity;
|
|
||||||
SkTLazy<SkSVGFillRule> fFillRule;
|
|
||||||
SkTLazy<SkSVGFillRule> fClipRule;
|
|
||||||
|
|
||||||
SkTLazy<SkSVGPaint> fStroke;
|
|
||||||
SkTLazy<SkSVGDashArray> fStrokeDashArray;
|
|
||||||
SkTLazy<SkSVGLength> fStrokeDashOffset;
|
|
||||||
SkTLazy<SkSVGLineCap> fStrokeLineCap;
|
|
||||||
SkTLazy<SkSVGLineJoin> fStrokeLineJoin;
|
|
||||||
SkTLazy<SkSVGNumberType> fStrokeMiterLimit;
|
|
||||||
SkTLazy<SkSVGNumberType> fStrokeOpacity;
|
|
||||||
SkTLazy<SkSVGLength> fStrokeWidth;
|
|
||||||
|
|
||||||
SkTLazy<SkSVGVisibility> fVisibility;
|
|
||||||
|
|
||||||
SkTLazy<SkSVGColorType> fColor;
|
|
||||||
|
|
||||||
// TODO(tdenniston): add SkSVGStopColor
|
|
||||||
|
|
||||||
// uninherited
|
|
||||||
SkTLazy<SkSVGNumberType> fOpacity;
|
|
||||||
SkTLazy<SkSVGClip> fClipPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGAttribute_DEFINED
|
|
||||||
|
@ -1,76 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGAttributeParser_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGAttributeParser_DEFINED
|
#include "modules/svg/include/SkSVGAttributeParser.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "include/private/SkNoncopyable.h"
|
|
||||||
|
|
||||||
class SkSVGAttributeParser : public SkNoncopyable {
|
|
||||||
public:
|
|
||||||
SkSVGAttributeParser(const char[]);
|
|
||||||
|
|
||||||
bool parseColor(SkSVGColorType*);
|
|
||||||
bool parseClipPath(SkSVGClip*);
|
|
||||||
bool parseFillRule(SkSVGFillRule*);
|
|
||||||
bool parseNumber(SkSVGNumberType*);
|
|
||||||
bool parseLength(SkSVGLength*);
|
|
||||||
bool parseViewBox(SkSVGViewBoxType*);
|
|
||||||
bool parseTransform(SkSVGTransformType*);
|
|
||||||
bool parsePaint(SkSVGPaint*);
|
|
||||||
bool parseLineCap(SkSVGLineCap*);
|
|
||||||
bool parseLineJoin(SkSVGLineJoin*);
|
|
||||||
bool parsePoints(SkSVGPointsType*);
|
|
||||||
bool parseIRI(SkSVGStringType*);
|
|
||||||
bool parseSpreadMethod(SkSVGSpreadMethod*);
|
|
||||||
bool parseStopColor(SkSVGStopColor*);
|
|
||||||
bool parseVisibility(SkSVGVisibility*);
|
|
||||||
bool parseDashArray(SkSVGDashArray*);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Stack-only
|
|
||||||
void* operator new(size_t) = delete;
|
|
||||||
void* operator new(size_t, void*) = delete;
|
|
||||||
|
|
||||||
template <typename F>
|
|
||||||
bool advanceWhile(F func);
|
|
||||||
|
|
||||||
bool parseWSToken();
|
|
||||||
bool parseEOSToken();
|
|
||||||
bool parseSepToken();
|
|
||||||
bool parseCommaWspToken();
|
|
||||||
bool parseExpectedStringToken(const char*);
|
|
||||||
bool parseScalarToken(SkScalar*);
|
|
||||||
bool parseHexToken(uint32_t*);
|
|
||||||
bool parseLengthUnitToken(SkSVGLength::Unit*);
|
|
||||||
bool parseNamedColorToken(SkColor*);
|
|
||||||
bool parseHexColorToken(SkColor*);
|
|
||||||
bool parseColorComponentToken(int32_t*);
|
|
||||||
bool parseRGBColorToken(SkColor*);
|
|
||||||
bool parseFuncIRI(SkSVGStringType*);
|
|
||||||
|
|
||||||
// Transform helpers
|
|
||||||
bool parseMatrixToken(SkMatrix*);
|
|
||||||
bool parseTranslateToken(SkMatrix*);
|
|
||||||
bool parseScaleToken(SkMatrix*);
|
|
||||||
bool parseRotateToken(SkMatrix*);
|
|
||||||
bool parseSkewXToken(SkMatrix*);
|
|
||||||
bool parseSkewYToken(SkMatrix*);
|
|
||||||
|
|
||||||
// Parses a sequence of 'WS* <prefix> WS* (<nested>)', where the nested sequence
|
|
||||||
// is handled by the passed functor.
|
|
||||||
template <typename Func, typename T>
|
|
||||||
bool parseParenthesized(const char* prefix, Func, T* result);
|
|
||||||
|
|
||||||
// The current position in the input string.
|
|
||||||
const char* fCurPos;
|
|
||||||
|
|
||||||
using INHERITED = SkNoncopyable;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGAttributeParser_DEFINED
|
|
||||||
|
@ -1,46 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGCircle_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGCircle_DEFINED
|
#include "modules/svg/include/SkSVGCircle.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
struct SkPoint;
|
|
||||||
|
|
||||||
class SkSVGCircle final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGCircle() override = default;
|
|
||||||
static sk_sp<SkSVGCircle> Make() { return sk_sp<SkSVGCircle>(new SkSVGCircle()); }
|
|
||||||
|
|
||||||
void setCx(const SkSVGLength&);
|
|
||||||
void setCy(const SkSVGLength&);
|
|
||||||
void setR(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGCircle();
|
|
||||||
|
|
||||||
// resolve and return the center and radius values
|
|
||||||
std::tuple<SkPoint, SkScalar> resolve(const SkSVGLengthContext&) const;
|
|
||||||
|
|
||||||
SkSVGLength fCx = SkSVGLength(0);
|
|
||||||
SkSVGLength fCy = SkSVGLength(0);
|
|
||||||
SkSVGLength fR = SkSVGLength(0);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGCircle_DEFINED
|
|
||||||
|
@ -1,26 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGClipPath_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGClipPath_DEFINED
|
#include "modules/svg/include/SkSVGClipPath.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGHiddenContainer.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
class SkSVGClipPath final : public SkSVGHiddenContainer {
|
|
||||||
public:
|
|
||||||
static sk_sp<SkSVGClipPath> Make() {
|
|
||||||
return sk_sp<SkSVGClipPath>(new SkSVGClipPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGClipPath();
|
|
||||||
|
|
||||||
using INHERITED = SkSVGHiddenContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGClipPath_DEFINED
|
|
||||||
|
@ -1,36 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGContainer_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGContainer_DEFINED
|
#include "modules/svg/include/SkSVGContainer.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGTransformableNode.h"
|
|
||||||
#include "include/private/SkTArray.h"
|
|
||||||
|
|
||||||
class SkSVGContainer : public SkSVGTransformableNode {
|
|
||||||
public:
|
|
||||||
~SkSVGContainer() override = default;
|
|
||||||
|
|
||||||
void appendChild(sk_sp<SkSVGNode>) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit SkSVGContainer(SkSVGTag);
|
|
||||||
|
|
||||||
void onRender(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
bool hasChildren() const final;
|
|
||||||
|
|
||||||
// TODO: add some sort of child iterator, and hide the container.
|
|
||||||
SkSTArray<1, sk_sp<SkSVGNode>, true> fChildren;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using INHERITED = SkSVGTransformableNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGContainer_DEFINED
|
|
||||||
|
@ -1,48 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGDOM_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGDOM_DEFINED
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGIDMapper.h"
|
|
||||||
#include "include/core/SkRefCnt.h"
|
|
||||||
#include "include/core/SkSize.h"
|
|
||||||
#include "include/private/SkTemplates.h"
|
|
||||||
|
|
||||||
class SkCanvas;
|
|
||||||
class SkDOM;
|
|
||||||
class SkStream;
|
|
||||||
class SkSVGNode;
|
|
||||||
|
|
||||||
class SkSVGDOM : public SkRefCnt {
|
|
||||||
public:
|
|
||||||
SkSVGDOM();
|
|
||||||
|
|
||||||
static sk_sp<SkSVGDOM> MakeFromDOM(const SkDOM&);
|
|
||||||
static sk_sp<SkSVGDOM> MakeFromStream(SkStream&);
|
|
||||||
|
|
||||||
const SkSize& containerSize() const;
|
|
||||||
void setContainerSize(const SkSize&);
|
|
||||||
|
|
||||||
void setRoot(sk_sp<SkSVGNode>);
|
|
||||||
|
|
||||||
// Returns the node with the given id, or nullptr if not found.
|
|
||||||
sk_sp<SkSVGNode>* findNodeById(const char* id);
|
|
||||||
|
|
||||||
void render(SkCanvas*) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSize intrinsicSize() const;
|
|
||||||
|
|
||||||
SkSize fContainerSize;
|
|
||||||
sk_sp<SkSVGNode> fRoot;
|
|
||||||
SkSVGIDMapper fIDMapper;
|
|
||||||
|
|
||||||
using INHERITED = SkRefCnt;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGDOM_DEFINED
|
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGDefs_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGDefs_DEFINED
|
#include "modules/svg/include/SkSVGDefs.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGHiddenContainer.h"
|
|
||||||
|
|
||||||
class SkSVGDefs : public SkSVGHiddenContainer {
|
|
||||||
public:
|
|
||||||
static sk_sp<SkSVGDefs> Make() { return sk_sp<SkSVGDefs>(new SkSVGDefs()); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGDefs() : INHERITED(SkSVGTag::kDefs) {}
|
|
||||||
|
|
||||||
using INHERITED = SkSVGHiddenContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGDefs_DEFINED
|
|
||||||
|
@ -1,47 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGEllipse_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGEllipse_DEFINED
|
#include "modules/svg/include/SkSVGEllipse.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
struct SkRect;
|
|
||||||
|
|
||||||
class SkSVGEllipse final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGEllipse() override = default;
|
|
||||||
static sk_sp<SkSVGEllipse> Make() { return sk_sp<SkSVGEllipse>(new SkSVGEllipse()); }
|
|
||||||
|
|
||||||
void setCx(const SkSVGLength&);
|
|
||||||
void setCy(const SkSVGLength&);
|
|
||||||
void setRx(const SkSVGLength&);
|
|
||||||
void setRy(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGEllipse();
|
|
||||||
|
|
||||||
SkRect resolve(const SkSVGLengthContext&) const;
|
|
||||||
|
|
||||||
SkSVGLength fCx = SkSVGLength(0);
|
|
||||||
SkSVGLength fCy = SkSVGLength(0);
|
|
||||||
SkSVGLength fRx = SkSVGLength(0);
|
|
||||||
SkSVGLength fRy = SkSVGLength(0);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGEllipse_DEFINED
|
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGG_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGG_DEFINED
|
#include "modules/svg/include/SkSVGG.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGContainer.h"
|
|
||||||
|
|
||||||
class SkSVGG : public SkSVGContainer {
|
|
||||||
public:
|
|
||||||
static sk_sp<SkSVGG> Make() { return sk_sp<SkSVGG>(new SkSVGG()); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGG() : INHERITED(SkSVGTag::kG) { }
|
|
||||||
|
|
||||||
using INHERITED = SkSVGContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGG_DEFINED
|
|
||||||
|
@ -1,51 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGGradient_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGGradient_DEFINED
|
#include "modules/svg/include/SkSVGGradient.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGHiddenContainer.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "include/core/SkShader.h"
|
|
||||||
|
|
||||||
class SkMatrix;
|
|
||||||
class SkSVGRenderContext;
|
|
||||||
class SkSVGStop;
|
|
||||||
|
|
||||||
class SkSVGGradient : public SkSVGHiddenContainer {
|
|
||||||
public:
|
|
||||||
~SkSVGGradient() override = default;
|
|
||||||
|
|
||||||
void setHref(const SkSVGStringType&);
|
|
||||||
void setGradientTransform(const SkSVGTransformType&);
|
|
||||||
void setSpreadMethod(const SkSVGSpreadMethod&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit SkSVGGradient(SkSVGTag t) : INHERITED(t) {}
|
|
||||||
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const final;
|
|
||||||
|
|
||||||
virtual sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
|
|
||||||
const SkColor*, const SkScalar*, int count,
|
|
||||||
SkTileMode, const SkMatrix& localMatrix) const = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using StopPositionArray = SkSTArray<2, SkScalar, true>;
|
|
||||||
using StopColorArray = SkSTArray<2, SkColor, true>;
|
|
||||||
void collectColorStops(const SkSVGRenderContext&, StopPositionArray*, StopColorArray*) const;
|
|
||||||
SkColor resolveStopColor(const SkSVGRenderContext&, const SkSVGStop&) const;
|
|
||||||
|
|
||||||
SkSVGStringType fHref;
|
|
||||||
SkSVGTransformType fGradientTransform = SkSVGTransformType(SkMatrix::I());
|
|
||||||
SkSVGSpreadMethod fSpreadMethod = SkSVGSpreadMethod(SkSVGSpreadMethod::Type::kPad);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGHiddenContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGGradient_DEFINED
|
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGHiddenContainer_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGHiddenContainer_DEFINED
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGContainer.h"
|
|
||||||
|
|
||||||
class SkSVGHiddenContainer : public SkSVGContainer {
|
|
||||||
protected:
|
|
||||||
explicit SkSVGHiddenContainer(SkSVGTag t) : INHERITED(t) {}
|
|
||||||
|
|
||||||
void onRender(const SkSVGRenderContext&) const final {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
using INHERITED = SkSVGContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGHiddenContainer_DEFINED
|
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGIDMapper_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGIDMapper_DEFINED
|
#include "modules/svg/include/SkSVGIDMapper.h"
|
||||||
|
|
||||||
#include "include/core/SkRefCnt.h"
|
|
||||||
#include "include/private/SkTHash.h"
|
|
||||||
|
|
||||||
class SkString;
|
|
||||||
class SkSVGNode;
|
|
||||||
|
|
||||||
using SkSVGIDMapper = SkTHashMap<SkString, sk_sp<SkSVGNode>>;
|
|
||||||
|
|
||||||
#endif // SkSVGIDMapper_DEFINED
|
|
||||||
|
@ -1,48 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGLine_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGLine_DEFINED
|
#include "modules/svg/include/SkSVGLine.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
struct SkPoint;
|
|
||||||
|
|
||||||
class SkSVGLine final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGLine() override = default;
|
|
||||||
static sk_sp<SkSVGLine> Make() { return sk_sp<SkSVGLine>(new SkSVGLine()); }
|
|
||||||
|
|
||||||
void setX1(const SkSVGLength&);
|
|
||||||
void setY1(const SkSVGLength&);
|
|
||||||
void setX2(const SkSVGLength&);
|
|
||||||
void setY2(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGLine();
|
|
||||||
|
|
||||||
// resolve and return the two endpoints
|
|
||||||
std::tuple<SkPoint, SkPoint> resolve(const SkSVGLengthContext&) const;
|
|
||||||
|
|
||||||
SkSVGLength fX1 = SkSVGLength(0);
|
|
||||||
SkSVGLength fY1 = SkSVGLength(0);
|
|
||||||
SkSVGLength fX2 = SkSVGLength(0);
|
|
||||||
SkSVGLength fY2 = SkSVGLength(0);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGLine_DEFINED
|
|
||||||
|
@ -1,43 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGLinearGradient_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGLinearGradient_DEFINED
|
#include "modules/svg/include/SkSVGLinearGradient.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGGradient.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
class SkSVGLinearGradient final : public SkSVGGradient {
|
|
||||||
public:
|
|
||||||
~SkSVGLinearGradient() override = default;
|
|
||||||
static sk_sp<SkSVGLinearGradient> Make() {
|
|
||||||
return sk_sp<SkSVGLinearGradient>(new SkSVGLinearGradient());
|
|
||||||
}
|
|
||||||
|
|
||||||
void setX1(const SkSVGLength&);
|
|
||||||
void setY1(const SkSVGLength&);
|
|
||||||
void setX2(const SkSVGLength&);
|
|
||||||
void setY2(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
|
|
||||||
const SkColor*, const SkScalar*, int count,
|
|
||||||
SkTileMode, const SkMatrix&) const override;
|
|
||||||
private:
|
|
||||||
SkSVGLinearGradient();
|
|
||||||
|
|
||||||
SkSVGLength fX1 = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGLength fY1 = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGLength fX2 = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGLength fY2 = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGGradient;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGLinearGradient_DEFINED
|
|
||||||
|
@ -1,103 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGNode_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGNode_DEFINED
|
#include "modules/svg/include/SkSVGNode.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGAttribute.h"
|
|
||||||
#include "include/core/SkRefCnt.h"
|
|
||||||
|
|
||||||
class SkCanvas;
|
|
||||||
class SkMatrix;
|
|
||||||
class SkPaint;
|
|
||||||
class SkPath;
|
|
||||||
class SkSVGRenderContext;
|
|
||||||
class SkSVGValue;
|
|
||||||
|
|
||||||
enum class SkSVGTag {
|
|
||||||
kCircle,
|
|
||||||
kClipPath,
|
|
||||||
kDefs,
|
|
||||||
kEllipse,
|
|
||||||
kG,
|
|
||||||
kLine,
|
|
||||||
kLinearGradient,
|
|
||||||
kPath,
|
|
||||||
kPattern,
|
|
||||||
kPolygon,
|
|
||||||
kPolyline,
|
|
||||||
kRadialGradient,
|
|
||||||
kRect,
|
|
||||||
kStop,
|
|
||||||
kSvg,
|
|
||||||
kText,
|
|
||||||
kUse
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGNode : public SkRefCnt {
|
|
||||||
public:
|
|
||||||
~SkSVGNode() override;
|
|
||||||
|
|
||||||
SkSVGTag tag() const { return fTag; }
|
|
||||||
|
|
||||||
virtual void appendChild(sk_sp<SkSVGNode>) = 0;
|
|
||||||
|
|
||||||
void render(const SkSVGRenderContext&) const;
|
|
||||||
bool asPaint(const SkSVGRenderContext&, SkPaint*) const;
|
|
||||||
SkPath asPath(const SkSVGRenderContext&) const;
|
|
||||||
|
|
||||||
void setAttribute(SkSVGAttribute, const SkSVGValue&);
|
|
||||||
bool setAttribute(const char* attributeName, const char* attributeValue);
|
|
||||||
|
|
||||||
void setClipPath(const SkSVGClip&);
|
|
||||||
void setClipRule(const SkSVGFillRule&);
|
|
||||||
void setColor(const SkSVGColorType&);
|
|
||||||
void setFill(const SkSVGPaint&);
|
|
||||||
void setFillOpacity(const SkSVGNumberType&);
|
|
||||||
void setFillRule(const SkSVGFillRule&);
|
|
||||||
void setOpacity(const SkSVGNumberType&);
|
|
||||||
void setStroke(const SkSVGPaint&);
|
|
||||||
void setStrokeDashArray(const SkSVGDashArray&);
|
|
||||||
void setStrokeDashOffset(const SkSVGLength&);
|
|
||||||
void setStrokeOpacity(const SkSVGNumberType&);
|
|
||||||
void setStrokeLineCap(const SkSVGLineCap&);
|
|
||||||
void setStrokeLineJoin(const SkSVGLineJoin&);
|
|
||||||
void setStrokeMiterLimit(const SkSVGNumberType&);
|
|
||||||
void setStrokeWidth(const SkSVGLength&);
|
|
||||||
void setVisibility(const SkSVGVisibility&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SkSVGNode(SkSVGTag);
|
|
||||||
|
|
||||||
// Called before onRender(), to apply local attributes to the context. Unlike onRender(),
|
|
||||||
// onPrepareToRender() bubbles up the inheritance chain: overriders should always call
|
|
||||||
// INHERITED::onPrepareToRender(), unless they intend to short-circuit rendering
|
|
||||||
// (return false).
|
|
||||||
// Implementations are expected to return true if rendering is to continue, or false if
|
|
||||||
// the node/subtree rendering is disabled.
|
|
||||||
virtual bool onPrepareToRender(SkSVGRenderContext*) const;
|
|
||||||
|
|
||||||
virtual void onRender(const SkSVGRenderContext&) const = 0;
|
|
||||||
|
|
||||||
virtual bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const { return false; }
|
|
||||||
|
|
||||||
virtual SkPath onAsPath(const SkSVGRenderContext&) const = 0;
|
|
||||||
|
|
||||||
virtual void onSetAttribute(SkSVGAttribute, const SkSVGValue&);
|
|
||||||
|
|
||||||
virtual bool hasChildren() const { return false; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGTag fTag;
|
|
||||||
|
|
||||||
// FIXME: this should be sparse
|
|
||||||
SkSVGPresentationAttributes fPresentationAttributes;
|
|
||||||
|
|
||||||
using INHERITED = SkRefCnt;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGNode_DEFINED
|
|
||||||
|
@ -1,37 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGPath_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGPath_DEFINED
|
#include "modules/svg/include/SkSVGPath.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "include/core/SkPath.h"
|
|
||||||
|
|
||||||
class SkSVGPath final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGPath() override = default;
|
|
||||||
static sk_sp<SkSVGPath> Make() { return sk_sp<SkSVGPath>(new SkSVGPath()); }
|
|
||||||
|
|
||||||
void setPath(const SkPath& path) { fPath = path; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGPath();
|
|
||||||
|
|
||||||
mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
|
|
||||||
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGPath_DEFINED
|
|
||||||
|
@ -1,59 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGPattern_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGPattern_DEFINED
|
#include "modules/svg/include/SkSVGPattern.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGHiddenContainer.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
class SkSVGRenderContext;
|
|
||||||
|
|
||||||
class SkSVGPattern final : public SkSVGHiddenContainer {
|
|
||||||
public:
|
|
||||||
~SkSVGPattern() override = default;
|
|
||||||
|
|
||||||
static sk_sp<SkSVGPattern> Make() {
|
|
||||||
return sk_sp<SkSVGPattern>(new SkSVGPattern());
|
|
||||||
}
|
|
||||||
|
|
||||||
void setX(const SkSVGLength&);
|
|
||||||
void setY(const SkSVGLength&);
|
|
||||||
void setWidth(const SkSVGLength&);
|
|
||||||
void setHeight(const SkSVGLength&);
|
|
||||||
void setHref(const SkSVGStringType&);
|
|
||||||
void setPatternTransform(const SkSVGTransformType&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SkSVGPattern();
|
|
||||||
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct PatternAttributes {
|
|
||||||
SkTLazy<SkSVGLength> fX,
|
|
||||||
fY,
|
|
||||||
fWidth,
|
|
||||||
fHeight;
|
|
||||||
SkTLazy<SkSVGTransformType> fPatternTransform;
|
|
||||||
} fAttributes;
|
|
||||||
|
|
||||||
SkSVGStringType fHref;
|
|
||||||
|
|
||||||
const SkSVGPattern* resolveHref(const SkSVGRenderContext&, PatternAttributes*) const;
|
|
||||||
const SkSVGPattern* hrefTarget(const SkSVGRenderContext&) const;
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// - patternUnits
|
|
||||||
// - patternContentUnits
|
|
||||||
|
|
||||||
using INHERITED = SkSVGHiddenContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGPattern_DEFINED
|
|
||||||
|
@ -1,45 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGPoly_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGPoly_DEFINED
|
#include "modules/svg/include/SkSVGPoly.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "include/core/SkPath.h"
|
|
||||||
|
|
||||||
// Handles <polygon> and <polyline> elements.
|
|
||||||
class SkSVGPoly final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGPoly() override = default;
|
|
||||||
|
|
||||||
static sk_sp<SkSVGPoly> MakePolygon() {
|
|
||||||
return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolygon));
|
|
||||||
}
|
|
||||||
|
|
||||||
static sk_sp<SkSVGPoly> MakePolyline() {
|
|
||||||
return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolyline));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPoints(const SkSVGPointsType&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGPoly(SkSVGTag);
|
|
||||||
|
|
||||||
mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
|
|
||||||
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGPoly_DEFINED
|
|
||||||
|
@ -1,46 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGRadialGradient_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGRadialGradient_DEFINED
|
#include "modules/svg/include/SkSVGRadialGradient.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGGradient.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
class SkSVGRadialGradient final : public SkSVGGradient {
|
|
||||||
public:
|
|
||||||
~SkSVGRadialGradient() override = default;
|
|
||||||
static sk_sp<SkSVGRadialGradient> Make() {
|
|
||||||
return sk_sp<SkSVGRadialGradient>(new SkSVGRadialGradient());
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCx(const SkSVGLength&);
|
|
||||||
void setCy(const SkSVGLength&);
|
|
||||||
void setR(const SkSVGLength&);
|
|
||||||
void setFx(const SkSVGLength&);
|
|
||||||
void setFy(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
|
|
||||||
const SkColor*, const SkScalar*, int count,
|
|
||||||
SkTileMode, const SkMatrix&) const override;
|
|
||||||
private:
|
|
||||||
SkSVGRadialGradient();
|
|
||||||
|
|
||||||
SkSVGLength fCx = SkSVGLength(50, SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGLength fCy = SkSVGLength(50, SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGLength fR = SkSVGLength(50, SkSVGLength::Unit::kPercentage);
|
|
||||||
SkTLazy<SkSVGLength> fFx;
|
|
||||||
SkTLazy<SkSVGLength> fFy;
|
|
||||||
|
|
||||||
|
|
||||||
using INHERITED = SkSVGGradient;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGRadialGradient_DEFINED
|
|
||||||
|
@ -1,54 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGRect_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGRect_DEFINED
|
#include "modules/svg/include/SkSVGRect.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
class SkRRect;
|
|
||||||
|
|
||||||
class SkSVGRect final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGRect() override = default;
|
|
||||||
static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); }
|
|
||||||
|
|
||||||
void setX(const SkSVGLength&);
|
|
||||||
void setY(const SkSVGLength&);
|
|
||||||
void setWidth(const SkSVGLength&);
|
|
||||||
void setHeight(const SkSVGLength&);
|
|
||||||
void setRx(const SkSVGLength&);
|
|
||||||
void setRy(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGRect();
|
|
||||||
|
|
||||||
SkRRect resolve(const SkSVGLengthContext&) const;
|
|
||||||
|
|
||||||
SkSVGLength fX = SkSVGLength(0);
|
|
||||||
SkSVGLength fY = SkSVGLength(0);
|
|
||||||
SkSVGLength fWidth = SkSVGLength(0);
|
|
||||||
SkSVGLength fHeight = SkSVGLength(0);
|
|
||||||
|
|
||||||
// The x radius for rounded rects.
|
|
||||||
SkSVGLength fRx = SkSVGLength(0);
|
|
||||||
// The y radius for rounded rects.
|
|
||||||
SkSVGLength fRy = SkSVGLength(0);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGRect_DEFINED
|
|
||||||
|
@ -1,144 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGRenderContext_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGRenderContext_DEFINED
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGAttribute.h"
|
|
||||||
#include "experimental/svg/model/SkSVGIDMapper.h"
|
|
||||||
#include "include/core/SkPaint.h"
|
|
||||||
#include "include/core/SkPath.h"
|
|
||||||
#include "include/core/SkRect.h"
|
|
||||||
#include "include/core/SkSize.h"
|
|
||||||
#include "include/core/SkTypes.h"
|
|
||||||
#include "src/core/SkTLazy.h"
|
|
||||||
|
|
||||||
class SkCanvas;
|
|
||||||
class SkSVGLength;
|
|
||||||
|
|
||||||
class SkSVGLengthContext {
|
|
||||||
public:
|
|
||||||
SkSVGLengthContext(const SkSize& viewport, SkScalar dpi = 90)
|
|
||||||
: fViewport(viewport), fDPI(dpi) {}
|
|
||||||
|
|
||||||
enum class LengthType {
|
|
||||||
kHorizontal,
|
|
||||||
kVertical,
|
|
||||||
kOther,
|
|
||||||
};
|
|
||||||
|
|
||||||
const SkSize& viewPort() const { return fViewport; }
|
|
||||||
void setViewPort(const SkSize& viewport) { fViewport = viewport; }
|
|
||||||
|
|
||||||
SkScalar resolve(const SkSVGLength&, LengthType) const;
|
|
||||||
SkRect resolveRect(const SkSVGLength& x, const SkSVGLength& y,
|
|
||||||
const SkSVGLength& w, const SkSVGLength& h) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSize fViewport;
|
|
||||||
SkScalar fDPI;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SkSVGPresentationContext {
|
|
||||||
SkSVGPresentationContext();
|
|
||||||
SkSVGPresentationContext(const SkSVGPresentationContext&) = default;
|
|
||||||
SkSVGPresentationContext& operator=(const SkSVGPresentationContext&) = default;
|
|
||||||
|
|
||||||
// Inherited presentation attributes, computed for the current node.
|
|
||||||
SkSVGPresentationAttributes fInherited;
|
|
||||||
|
|
||||||
// Cached paints, reflecting the current presentation attributes.
|
|
||||||
SkPaint fFillPaint;
|
|
||||||
SkPaint fStrokePaint;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGRenderContext {
|
|
||||||
public:
|
|
||||||
SkSVGRenderContext(SkCanvas*, const SkSVGIDMapper&, const SkSVGLengthContext&,
|
|
||||||
const SkSVGPresentationContext&);
|
|
||||||
SkSVGRenderContext(const SkSVGRenderContext&);
|
|
||||||
SkSVGRenderContext(const SkSVGRenderContext&, SkCanvas*);
|
|
||||||
~SkSVGRenderContext();
|
|
||||||
|
|
||||||
const SkSVGLengthContext& lengthContext() const { return *fLengthContext; }
|
|
||||||
SkSVGLengthContext* writableLengthContext() { return fLengthContext.writable(); }
|
|
||||||
|
|
||||||
const SkSVGPresentationContext& presentationContext() const { return *fPresentationContext; }
|
|
||||||
|
|
||||||
SkCanvas* canvas() const { return fCanvas; }
|
|
||||||
void saveOnce();
|
|
||||||
|
|
||||||
enum ApplyFlags {
|
|
||||||
kLeaf = 1 << 0, // the target node doesn't have descendants
|
|
||||||
};
|
|
||||||
void applyPresentationAttributes(const SkSVGPresentationAttributes&, uint32_t flags);
|
|
||||||
|
|
||||||
// Scoped wrapper that temporarily clears the original node reference.
|
|
||||||
class BorrowedNode {
|
|
||||||
public:
|
|
||||||
explicit BorrowedNode(sk_sp<SkSVGNode>* node)
|
|
||||||
: fOwner(node) {
|
|
||||||
if (fOwner) {
|
|
||||||
fBorrowed = std::move(*fOwner);
|
|
||||||
*fOwner = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~BorrowedNode() {
|
|
||||||
if (fOwner) {
|
|
||||||
*fOwner = std::move(fBorrowed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const SkSVGNode* get() const { return fBorrowed.get(); }
|
|
||||||
const SkSVGNode* operator->() const { return fBorrowed.get(); }
|
|
||||||
const SkSVGNode& operator*() const { return *fBorrowed; }
|
|
||||||
|
|
||||||
operator bool() const { return !!fBorrowed; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// noncopyable
|
|
||||||
BorrowedNode(const BorrowedNode&) = delete;
|
|
||||||
BorrowedNode& operator=(BorrowedNode&) = delete;
|
|
||||||
|
|
||||||
sk_sp<SkSVGNode>* fOwner;
|
|
||||||
sk_sp<SkSVGNode> fBorrowed;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Note: the id->node association is cleared for the lifetime of the returned value
|
|
||||||
// (effectively breaks reference cycles, assuming appropriate return value scoping).
|
|
||||||
BorrowedNode findNodeById(const SkString&) const;
|
|
||||||
|
|
||||||
const SkPaint* fillPaint() const;
|
|
||||||
const SkPaint* strokePaint() const;
|
|
||||||
|
|
||||||
// The local computed clip path (not inherited).
|
|
||||||
const SkPath* clipPath() const { return fClipPath.getMaybeNull(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Stack-only
|
|
||||||
void* operator new(size_t) = delete;
|
|
||||||
void* operator new(size_t, void*) = delete;
|
|
||||||
SkSVGRenderContext& operator=(const SkSVGRenderContext&) = delete;
|
|
||||||
|
|
||||||
void applyOpacity(SkScalar opacity, uint32_t flags);
|
|
||||||
void applyClip(const SkSVGClip&);
|
|
||||||
void updatePaintsWithCurrentColor(const SkSVGPresentationAttributes&);
|
|
||||||
|
|
||||||
const SkSVGIDMapper& fIDMapper;
|
|
||||||
SkTCopyOnFirstWrite<SkSVGLengthContext> fLengthContext;
|
|
||||||
SkTCopyOnFirstWrite<SkSVGPresentationContext> fPresentationContext;
|
|
||||||
SkCanvas* fCanvas;
|
|
||||||
// The save count on 'fCanvas' at construction time.
|
|
||||||
// A restoreToCount() will be issued on destruction.
|
|
||||||
int fCanvasSaveCount;
|
|
||||||
|
|
||||||
// clipPath, if present for the current context (not inherited).
|
|
||||||
SkTLazy<SkPath> fClipPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGRenderContext_DEFINED
|
|
||||||
|
@ -1,49 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGSVG_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGSVG_DEFINED
|
#include "modules/svg/include/SkSVGSVG.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGContainer.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "src/core/SkTLazy.h"
|
|
||||||
|
|
||||||
class SkSVGLengthContext;
|
|
||||||
|
|
||||||
class SkSVGSVG : public SkSVGContainer {
|
|
||||||
public:
|
|
||||||
~SkSVGSVG() override = default;
|
|
||||||
|
|
||||||
static sk_sp<SkSVGSVG> Make() { return sk_sp<SkSVGSVG>(new SkSVGSVG()); }
|
|
||||||
|
|
||||||
void setX(const SkSVGLength&);
|
|
||||||
void setY(const SkSVGLength&);
|
|
||||||
void setWidth(const SkSVGLength&);
|
|
||||||
void setHeight(const SkSVGLength&);
|
|
||||||
void setViewBox(const SkSVGViewBoxType&);
|
|
||||||
|
|
||||||
SkSize intrinsicSize(const SkSVGLengthContext&) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool onPrepareToRender(SkSVGRenderContext*) const override;
|
|
||||||
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGSVG();
|
|
||||||
|
|
||||||
SkSVGLength fX = SkSVGLength(0);
|
|
||||||
SkSVGLength fY = SkSVGLength(0);
|
|
||||||
SkSVGLength fWidth = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGLength fHeight = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
|
|
||||||
|
|
||||||
SkTLazy<SkSVGViewBoxType> fViewBox;
|
|
||||||
|
|
||||||
using INHERITED = SkSVGContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGSVG_DEFINED
|
|
||||||
|
@ -1,35 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGShape_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGShape_DEFINED
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGTransformableNode.h"
|
|
||||||
#include "include/core/SkPath.h"
|
|
||||||
|
|
||||||
class SkSVGLengthContext;
|
|
||||||
class SkPaint;
|
|
||||||
|
|
||||||
class SkSVGShape : public SkSVGTransformableNode {
|
|
||||||
public:
|
|
||||||
~SkSVGShape() override = default;
|
|
||||||
|
|
||||||
void appendChild(sk_sp<SkSVGNode>) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SkSVGShape(SkSVGTag);
|
|
||||||
|
|
||||||
void onRender(const SkSVGRenderContext&) const final;
|
|
||||||
|
|
||||||
virtual void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using INHERITED = SkSVGTransformableNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGShape_DEFINED
|
|
||||||
|
@ -1,44 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGStop_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGStop_DEFINED
|
#include "modules/svg/include/SkSVGStop.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGHiddenContainer.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
class SkSVGLengthContext;
|
|
||||||
|
|
||||||
class SkSVGStop : public SkSVGHiddenContainer {
|
|
||||||
public:
|
|
||||||
~SkSVGStop() override = default;
|
|
||||||
static sk_sp<SkSVGStop> Make() {
|
|
||||||
return sk_sp<SkSVGStop>(new SkSVGStop());
|
|
||||||
}
|
|
||||||
|
|
||||||
const SkSVGLength& offset() const { return fOffset; }
|
|
||||||
const SkSVGStopColor& stopColor() const { return fStopColor; }
|
|
||||||
const SkSVGNumberType& stopOpacity() const { return fStopOpacity; }
|
|
||||||
|
|
||||||
void setOffset(const SkSVGLength&);
|
|
||||||
void setStopColor(const SkSVGStopColor&);
|
|
||||||
void setStopOpacity(const SkSVGNumberType&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGStop();
|
|
||||||
|
|
||||||
SkSVGLength fOffset = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
|
||||||
SkSVGStopColor fStopColor = SkSVGStopColor(SK_ColorBLACK);
|
|
||||||
SkSVGNumberType fStopOpacity = SkSVGNumberType(1);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGHiddenContainer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGStop_DEFINED
|
|
||||||
|
@ -1,57 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGText_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGText_DEFINED
|
#include "modules/svg/include/SkSVGText.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "include/core/SkFont.h"
|
|
||||||
#include "include/utils/SkTextUtils.h"
|
|
||||||
|
|
||||||
class SkRRect;
|
|
||||||
|
|
||||||
class SkSVGText final : public SkSVGShape {
|
|
||||||
public:
|
|
||||||
~SkSVGText() override = default;
|
|
||||||
static sk_sp<SkSVGText> Make() {
|
|
||||||
return sk_sp<SkSVGText>(new SkSVGText()); }
|
|
||||||
|
|
||||||
void setX(const SkSVGLength&);
|
|
||||||
void setY(const SkSVGLength&);
|
|
||||||
void setFontFamily(const SkSVGStringType&);
|
|
||||||
void setFontSize(const SkSVGLength&);
|
|
||||||
void setFontStyle(const SkSVGStringType&);
|
|
||||||
void setFontWeight(const SkSVGStringType&);
|
|
||||||
void setText(const SkSVGStringType&);
|
|
||||||
void setTextAnchor(const SkSVGStringType&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
|
||||||
SkPathFillType) const override;
|
|
||||||
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
void loadFont();
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGText();
|
|
||||||
SkSVGLength fX = SkSVGLength(0);
|
|
||||||
SkSVGLength fY = SkSVGLength(0);
|
|
||||||
SkSVGStringType fText;
|
|
||||||
sk_sp<SkTypeface> fTypeface;
|
|
||||||
SkSVGLength fFontSize;
|
|
||||||
SkSVGStringType fFontFamily;
|
|
||||||
SkSVGStringType fFontStyle;
|
|
||||||
SkSVGStringType fFontWeight;
|
|
||||||
SkTextUtils::Align fTextAlign = SkTextUtils::Align::kLeft_Align;
|
|
||||||
using INHERITED = SkSVGShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGText_DEFINED
|
|
||||||
|
@ -1,36 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGTransformableNode_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGTransformableNode_DEFINED
|
#include "modules/svg/include/SkSVGTransformableNode.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGNode.h"
|
|
||||||
#include "include/core/SkMatrix.h"
|
|
||||||
|
|
||||||
class SkSVGTransformableNode : public SkSVGNode {
|
|
||||||
public:
|
|
||||||
~SkSVGTransformableNode() override = default;
|
|
||||||
|
|
||||||
void setTransform(const SkSVGTransformType& t) { fTransform = t; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SkSVGTransformableNode(SkSVGTag);
|
|
||||||
|
|
||||||
bool onPrepareToRender(SkSVGRenderContext*) const override;
|
|
||||||
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
void mapToParent(SkPath*) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// FIXME: should be sparse
|
|
||||||
SkSVGTransformType fTransform;
|
|
||||||
|
|
||||||
using INHERITED = SkSVGNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGTransformableNode_DEFINED
|
|
||||||
|
@ -1,311 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGTypes_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGTypes_DEFINED
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
#include "include/core/SkColor.h"
|
|
||||||
#include "include/core/SkMatrix.h"
|
|
||||||
#include "include/core/SkPath.h"
|
|
||||||
#include "include/core/SkPoint.h"
|
|
||||||
#include "include/core/SkRect.h"
|
|
||||||
#include "include/core/SkScalar.h"
|
|
||||||
#include "include/core/SkString.h"
|
|
||||||
#include "include/core/SkTypes.h"
|
|
||||||
#include "include/private/SkTDArray.h"
|
|
||||||
|
|
||||||
using SkSVGColorType = SkColor;
|
|
||||||
using SkSVGNumberType = SkScalar;
|
|
||||||
using SkSVGStringType = SkString;
|
|
||||||
using SkSVGViewBoxType = SkRect;
|
|
||||||
using SkSVGTransformType = SkMatrix;
|
|
||||||
using SkSVGPointsType = SkTDArray<SkPoint>;
|
|
||||||
|
|
||||||
class SkSVGLength {
|
|
||||||
public:
|
|
||||||
enum class Unit {
|
|
||||||
kUnknown,
|
|
||||||
kNumber,
|
|
||||||
kPercentage,
|
|
||||||
kEMS,
|
|
||||||
kEXS,
|
|
||||||
kPX,
|
|
||||||
kCM,
|
|
||||||
kMM,
|
|
||||||
kIN,
|
|
||||||
kPT,
|
|
||||||
kPC,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SkSVGLength() : fValue(0), fUnit(Unit::kUnknown) {}
|
|
||||||
explicit constexpr SkSVGLength(SkScalar v, Unit u = Unit::kNumber)
|
|
||||||
: fValue(v), fUnit(u) {}
|
|
||||||
SkSVGLength(const SkSVGLength&) = default;
|
|
||||||
SkSVGLength& operator=(const SkSVGLength&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGLength& other) const {
|
|
||||||
return fUnit == other.fUnit && fValue == other.fValue;
|
|
||||||
}
|
|
||||||
bool operator!=(const SkSVGLength& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
const SkScalar& value() const { return fValue; }
|
|
||||||
const Unit& unit() const { return fUnit; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkScalar fValue;
|
|
||||||
Unit fUnit;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGPaint {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kNone,
|
|
||||||
kCurrentColor,
|
|
||||||
kColor,
|
|
||||||
kInherit,
|
|
||||||
kIRI,
|
|
||||||
};
|
|
||||||
|
|
||||||
SkSVGPaint() : fType(Type::kInherit), fColor(SK_ColorBLACK) {}
|
|
||||||
explicit SkSVGPaint(Type t) : fType(t), fColor(SK_ColorBLACK) {}
|
|
||||||
explicit SkSVGPaint(const SkSVGColorType& c) : fType(Type::kColor), fColor(c) {}
|
|
||||||
explicit SkSVGPaint(const SkString& iri)
|
|
||||||
: fType(Type::kIRI), fColor(SK_ColorBLACK), fIRI(iri) {}
|
|
||||||
|
|
||||||
SkSVGPaint(const SkSVGPaint&) = default;
|
|
||||||
SkSVGPaint& operator=(const SkSVGPaint&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGPaint& other) const {
|
|
||||||
return fType == other.fType && fColor == other.fColor && fIRI == other.fIRI;
|
|
||||||
}
|
|
||||||
bool operator!=(const SkSVGPaint& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
const SkSVGColorType& color() const { SkASSERT(fType == Type::kColor); return fColor; }
|
|
||||||
const SkString& iri() const { SkASSERT(fType == Type::kIRI); return fIRI; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
|
|
||||||
// Logical union.
|
|
||||||
SkSVGColorType fColor;
|
|
||||||
SkString fIRI;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGClip {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kNone,
|
|
||||||
kInherit,
|
|
||||||
kIRI,
|
|
||||||
};
|
|
||||||
|
|
||||||
SkSVGClip() : fType(Type::kNone) {}
|
|
||||||
explicit SkSVGClip(Type t) : fType(t) {}
|
|
||||||
explicit SkSVGClip(const SkString& iri) : fType(Type::kIRI), fIRI(iri) {}
|
|
||||||
|
|
||||||
SkSVGClip(const SkSVGClip&) = default;
|
|
||||||
SkSVGClip& operator=(const SkSVGClip&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGClip& other) const {
|
|
||||||
return fType == other.fType && fIRI == other.fIRI;
|
|
||||||
}
|
|
||||||
bool operator!=(const SkSVGClip& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
const SkString& iri() const { SkASSERT(fType == Type::kIRI); return fIRI; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
SkString fIRI;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGLineCap {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kButt,
|
|
||||||
kRound,
|
|
||||||
kSquare,
|
|
||||||
kInherit,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SkSVGLineCap() : fType(Type::kInherit) {}
|
|
||||||
constexpr explicit SkSVGLineCap(Type t) : fType(t) {}
|
|
||||||
|
|
||||||
SkSVGLineCap(const SkSVGLineCap&) = default;
|
|
||||||
SkSVGLineCap& operator=(const SkSVGLineCap&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGLineCap& other) const { return fType == other.fType; }
|
|
||||||
bool operator!=(const SkSVGLineCap& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGLineJoin {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kMiter,
|
|
||||||
kRound,
|
|
||||||
kBevel,
|
|
||||||
kInherit,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SkSVGLineJoin() : fType(Type::kInherit) {}
|
|
||||||
constexpr explicit SkSVGLineJoin(Type t) : fType(t) {}
|
|
||||||
|
|
||||||
SkSVGLineJoin(const SkSVGLineJoin&) = default;
|
|
||||||
SkSVGLineJoin& operator=(const SkSVGLineJoin&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGLineJoin& other) const { return fType == other.fType; }
|
|
||||||
bool operator!=(const SkSVGLineJoin& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGSpreadMethod {
|
|
||||||
public:
|
|
||||||
// These values must match Skia's SkShader::TileMode enum.
|
|
||||||
enum class Type {
|
|
||||||
kPad, // kClamp_TileMode
|
|
||||||
kRepeat, // kRepeat_TileMode
|
|
||||||
kReflect, // kMirror_TileMode
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SkSVGSpreadMethod() : fType(Type::kPad) {}
|
|
||||||
constexpr explicit SkSVGSpreadMethod(Type t) : fType(t) {}
|
|
||||||
|
|
||||||
SkSVGSpreadMethod(const SkSVGSpreadMethod&) = default;
|
|
||||||
SkSVGSpreadMethod& operator=(const SkSVGSpreadMethod&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGSpreadMethod& other) const { return fType == other.fType; }
|
|
||||||
bool operator!=(const SkSVGSpreadMethod& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGFillRule {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kNonZero,
|
|
||||||
kEvenOdd,
|
|
||||||
kInherit,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SkSVGFillRule() : fType(Type::kInherit) {}
|
|
||||||
constexpr explicit SkSVGFillRule(Type t) : fType(t) {}
|
|
||||||
|
|
||||||
SkSVGFillRule(const SkSVGFillRule&) = default;
|
|
||||||
SkSVGFillRule& operator=(const SkSVGFillRule&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGFillRule& other) const { return fType == other.fType; }
|
|
||||||
bool operator!=(const SkSVGFillRule& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
SkPathFillType asFillType() const {
|
|
||||||
SkASSERT(fType != Type::kInherit); // should never be called for unresolved values.
|
|
||||||
return fType == Type::kEvenOdd ? SkPathFillType::kEvenOdd : SkPathFillType::kWinding;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGVisibility {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kVisible,
|
|
||||||
kHidden,
|
|
||||||
kCollapse,
|
|
||||||
kInherit,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SkSVGVisibility() : fType(Type::kVisible) {}
|
|
||||||
constexpr explicit SkSVGVisibility(Type t) : fType(t) {}
|
|
||||||
|
|
||||||
SkSVGVisibility(const SkSVGVisibility&) = default;
|
|
||||||
SkSVGVisibility& operator=(const SkSVGVisibility&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGVisibility& other) const { return fType == other.fType; }
|
|
||||||
bool operator!=(const SkSVGVisibility& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGDashArray {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kNone,
|
|
||||||
kDashArray,
|
|
||||||
kInherit,
|
|
||||||
};
|
|
||||||
|
|
||||||
SkSVGDashArray() : fType(Type::kNone) {}
|
|
||||||
explicit SkSVGDashArray(Type t) : fType(t) {}
|
|
||||||
explicit SkSVGDashArray(SkTDArray<SkSVGLength>&& dashArray)
|
|
||||||
: fType(Type::kDashArray)
|
|
||||||
, fDashArray(std::move(dashArray)) {}
|
|
||||||
|
|
||||||
SkSVGDashArray(const SkSVGDashArray&) = default;
|
|
||||||
SkSVGDashArray& operator=(const SkSVGDashArray&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGDashArray& other) const {
|
|
||||||
return fType == other.fType && fDashArray == other.fDashArray;
|
|
||||||
}
|
|
||||||
bool operator!=(const SkSVGDashArray& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
const SkTDArray<SkSVGLength>& dashArray() const { return fDashArray; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
SkTDArray<SkSVGLength> fDashArray;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SkSVGStopColor {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kColor,
|
|
||||||
kCurrentColor,
|
|
||||||
kICCColor,
|
|
||||||
kInherit,
|
|
||||||
};
|
|
||||||
|
|
||||||
SkSVGStopColor() : fType(Type::kColor), fColor(SK_ColorBLACK) {}
|
|
||||||
explicit SkSVGStopColor(Type t) : fType(t), fColor(SK_ColorBLACK) {}
|
|
||||||
explicit SkSVGStopColor(const SkSVGColorType& c) : fType(Type::kColor), fColor(c) {}
|
|
||||||
|
|
||||||
SkSVGStopColor(const SkSVGStopColor&) = default;
|
|
||||||
SkSVGStopColor& operator=(const SkSVGStopColor&) = default;
|
|
||||||
|
|
||||||
bool operator==(const SkSVGStopColor& other) const {
|
|
||||||
return fType == other.fType && fColor == other.fColor;
|
|
||||||
}
|
|
||||||
bool operator!=(const SkSVGStopColor& other) const { return !(*this == other); }
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
const SkSVGColorType& color() const { SkASSERT(fType == Type::kColor); return fColor; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
SkSVGColorType fColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGTypes_DEFINED
|
|
||||||
|
@ -1,47 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGUse_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGUse_DEFINED
|
#include "modules/svg/include/SkSVGUse.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGTransformableNode.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements support for <use> (reference) elements.
|
|
||||||
* (https://www.w3.org/TR/SVG11/struct.html#UseElement)
|
|
||||||
*/
|
|
||||||
class SkSVGUse final : public SkSVGTransformableNode {
|
|
||||||
public:
|
|
||||||
~SkSVGUse() override = default;
|
|
||||||
|
|
||||||
static sk_sp<SkSVGUse> Make() { return sk_sp<SkSVGUse>(new SkSVGUse()); }
|
|
||||||
|
|
||||||
void appendChild(sk_sp<SkSVGNode>) override;
|
|
||||||
|
|
||||||
void setHref(const SkSVGStringType&);
|
|
||||||
void setX(const SkSVGLength&);
|
|
||||||
void setY(const SkSVGLength&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
|
||||||
|
|
||||||
bool onPrepareToRender(SkSVGRenderContext*) const override;
|
|
||||||
void onRender(const SkSVGRenderContext&) const override;
|
|
||||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkSVGUse();
|
|
||||||
|
|
||||||
SkSVGStringType fHref;
|
|
||||||
SkSVGLength fX = SkSVGLength(0);
|
|
||||||
SkSVGLength fY = SkSVGLength(0);
|
|
||||||
|
|
||||||
using INHERITED = SkSVGTransformableNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SkSVGUse_DEFINED
|
|
||||||
|
@ -1,97 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Google Inc.
|
* Copyright 2020 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SkSVGValue_DEFINED
|
// Transitional forwarding header. To be removed.
|
||||||
#define SkSVGValue_DEFINED
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "include/core/SkColor.h"
|
|
||||||
#include "include/core/SkMatrix.h"
|
|
||||||
#include "include/core/SkPath.h"
|
|
||||||
#include "include/core/SkTypes.h"
|
|
||||||
#include "include/private/SkNoncopyable.h"
|
|
||||||
|
|
||||||
class SkSVGValue : public SkNoncopyable {
|
|
||||||
public:
|
|
||||||
enum class Type {
|
|
||||||
kClip,
|
|
||||||
kColor,
|
|
||||||
kDashArray,
|
|
||||||
kFillRule,
|
|
||||||
kLength,
|
|
||||||
kLineCap,
|
|
||||||
kLineJoin,
|
|
||||||
kNumber,
|
|
||||||
kPaint,
|
|
||||||
kPath,
|
|
||||||
kPoints,
|
|
||||||
kSpreadMethod,
|
|
||||||
kStopColor,
|
|
||||||
kString,
|
|
||||||
kTransform,
|
|
||||||
kViewBox,
|
|
||||||
kVisibility,
|
|
||||||
};
|
|
||||||
|
|
||||||
Type type() const { return fType; }
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
const T* as() const {
|
|
||||||
return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SkSVGValue(Type t) : fType(t) { }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type fType;
|
|
||||||
|
|
||||||
using INHERITED = SkNoncopyable;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, SkSVGValue::Type ValueType>
|
|
||||||
class SkSVGWrapperValue final : public SkSVGValue {
|
|
||||||
public:
|
|
||||||
static constexpr Type TYPE = ValueType;
|
|
||||||
|
|
||||||
explicit SkSVGWrapperValue(const T& v)
|
|
||||||
: INHERITED(ValueType)
|
|
||||||
, fWrappedValue(v) { }
|
|
||||||
|
|
||||||
operator const T&() const { return fWrappedValue; }
|
|
||||||
const T* operator->() const { return &fWrappedValue; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Stack-only
|
|
||||||
void* operator new(size_t) = delete;
|
|
||||||
void* operator new(size_t, void*) = delete;
|
|
||||||
|
|
||||||
const T& fWrappedValue;
|
|
||||||
|
|
||||||
using INHERITED = SkSVGValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
using SkSVGClipValue = SkSVGWrapperValue<SkSVGClip , SkSVGValue::Type::kClip >;
|
|
||||||
using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue::Type::kColor >;
|
|
||||||
using SkSVGFillRuleValue = SkSVGWrapperValue<SkSVGFillRule , SkSVGValue::Type::kFillRule >;
|
|
||||||
using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue::Type::kLength >;
|
|
||||||
using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::kPath >;
|
|
||||||
using SkSVGTransformValue = SkSVGWrapperValue<SkSVGTransformType, SkSVGValue::Type::kTransform >;
|
|
||||||
using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType , SkSVGValue::Type::kViewBox >;
|
|
||||||
using SkSVGPaintValue = SkSVGWrapperValue<SkSVGPaint , SkSVGValue::Type::kPaint >;
|
|
||||||
using SkSVGLineCapValue = SkSVGWrapperValue<SkSVGLineCap , SkSVGValue::Type::kLineCap >;
|
|
||||||
using SkSVGLineJoinValue = SkSVGWrapperValue<SkSVGLineJoin , SkSVGValue::Type::kLineJoin >;
|
|
||||||
using SkSVGNumberValue = SkSVGWrapperValue<SkSVGNumberType , SkSVGValue::Type::kNumber >;
|
|
||||||
using SkSVGPointsValue = SkSVGWrapperValue<SkSVGPointsType , SkSVGValue::Type::kPoints >;
|
|
||||||
using SkSVGStringValue = SkSVGWrapperValue<SkSVGStringType , SkSVGValue::Type::kString >;
|
|
||||||
using SkSVGSpreadMethodValue = SkSVGWrapperValue<SkSVGSpreadMethod ,
|
|
||||||
SkSVGValue::Type::kSpreadMethod>;
|
|
||||||
using SkSVGStopColorValue = SkSVGWrapperValue<SkSVGStopColor , SkSVGValue::Type::kStopColor >;
|
|
||||||
using SkSVGVisibilityValue = SkSVGWrapperValue<SkSVGVisibility , SkSVGValue::Type::kVisibility>;
|
|
||||||
using SkSVGDashArrayValue = SkSVGWrapperValue<SkSVGDashArray , SkSVGValue::Type::kDashArray >;
|
|
||||||
|
|
||||||
#endif // SkSVGValue_DEFINED
|
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/core/SkData.h"
|
#include "include/core/SkData.h"
|
||||||
#include "include/core/SkStream.h"
|
#include "include/core/SkStream.h"
|
||||||
#include "include/core/SkSurface.h"
|
#include "include/core/SkSurface.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
|
|
||||||
void FuzzSVG(sk_sp<SkData> bytes) {
|
void FuzzSVG(sk_sp<SkData> bytes) {
|
||||||
uint8_t w = 100;
|
uint8_t w = 100;
|
||||||
|
@ -37,7 +37,7 @@ def GrabDependentValues(js, name, value_type, list_to_extend, exclude):
|
|||||||
for dep in js['targets'][name]['deps']:
|
for dep in js['targets'][name]['deps']:
|
||||||
if 'modules' in dep:
|
if 'modules' in dep:
|
||||||
skip = True
|
skip = True
|
||||||
for include in ['skshaper', 'skparagraph']:
|
for include in ['skshaper', 'skparagraph', 'svg']:
|
||||||
if include in dep:
|
if include in dep:
|
||||||
skip = False
|
skip = False
|
||||||
if skip:
|
if skip:
|
||||||
|
@ -26,6 +26,7 @@ declare_args() {
|
|||||||
skia_enable_skrive = true
|
skia_enable_skrive = true
|
||||||
skia_enable_sksl_interpreter = is_skia_dev_build
|
skia_enable_sksl_interpreter = is_skia_dev_build
|
||||||
skia_enable_skvm_jit_when_possible = is_skia_dev_build
|
skia_enable_skvm_jit_when_possible = is_skia_dev_build
|
||||||
|
skia_enable_svg = true
|
||||||
skia_enable_tools = is_skia_dev_build
|
skia_enable_tools = is_skia_dev_build
|
||||||
skia_enable_gpu_debug_layers = is_skia_dev_build && is_debug
|
skia_enable_gpu_debug_layers = is_skia_dev_build && is_debug
|
||||||
skia_generate_workarounds = false
|
skia_generate_workarounds = false
|
||||||
|
@ -85,8 +85,8 @@ if (skia_enable_skottie) {
|
|||||||
]
|
]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"../..:experimental_svg_model",
|
|
||||||
"../..:skia",
|
"../..:skia",
|
||||||
|
"../svg",
|
||||||
]
|
]
|
||||||
|
|
||||||
public_deps = [ ":skottie" ]
|
public_deps = [ ":skottie" ]
|
||||||
|
43
modules/svg/BUILD.gn
Normal file
43
modules/svg/BUILD.gn
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Copyright 2020 Google Inc.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
import("../../gn/skia.gni")
|
||||||
|
|
||||||
|
if (skia_enable_svg) {
|
||||||
|
config("public_config") {
|
||||||
|
defines = [ "SK_ENABLE_SVG" ]
|
||||||
|
include_dirs = [ "include" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
component("svg") {
|
||||||
|
check_includes = false
|
||||||
|
import("svg.gni")
|
||||||
|
public_configs = [ ":public_config" ]
|
||||||
|
public = skia_svg_public
|
||||||
|
sources = skia_svg_sources
|
||||||
|
configs += [ "../../:skia_private" ]
|
||||||
|
deps = [ "../..:skia" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skia_enable_tools && defined(is_skia_standalone)) {
|
||||||
|
source_set("tool") {
|
||||||
|
check_includes = false
|
||||||
|
testonly = true
|
||||||
|
|
||||||
|
configs += [ "../..:skia_private" ]
|
||||||
|
sources = [ "utils/SvgTool.cpp" ]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"../..:flags",
|
||||||
|
"../..:skia",
|
||||||
|
]
|
||||||
|
|
||||||
|
public_deps = [ ":svg" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
group("svg") {
|
||||||
|
}
|
||||||
|
}
|
99
modules/svg/include/SkSVGAttribute.h
Normal file
99
modules/svg/include/SkSVGAttribute.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGAttribute_DEFINED
|
||||||
|
#define SkSVGAttribute_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
#include "src/core/SkTLazy.h"
|
||||||
|
|
||||||
|
class SkSVGRenderContext;
|
||||||
|
|
||||||
|
enum class SkSVGAttribute {
|
||||||
|
kClipPath,
|
||||||
|
kClipRule,
|
||||||
|
kColor,
|
||||||
|
kCx, // <circle>, <ellipse>, <radialGradient>: center x position
|
||||||
|
kCy, // <circle>, <ellipse>, <radialGradient>: center y position
|
||||||
|
kD,
|
||||||
|
kFill,
|
||||||
|
kFillOpacity,
|
||||||
|
kFillRule,
|
||||||
|
kFontFamily,
|
||||||
|
kFontSize,
|
||||||
|
kFontStyle,
|
||||||
|
kFontWeight,
|
||||||
|
kFx, // <radialGradient>: focal point x position
|
||||||
|
kFy, // <radialGradient>: focal point y position
|
||||||
|
kGradientTransform,
|
||||||
|
kHeight,
|
||||||
|
kHref,
|
||||||
|
kOffset,
|
||||||
|
kOpacity,
|
||||||
|
kPatternTransform,
|
||||||
|
kPoints,
|
||||||
|
kR, // <circle>, <radialGradient>: radius
|
||||||
|
kRx, // <ellipse>,<rect>: horizontal (corner) radius
|
||||||
|
kRy, // <ellipse>,<rect>: vertical (corner) radius
|
||||||
|
kSpreadMethod,
|
||||||
|
kStopColor,
|
||||||
|
kStopOpacity,
|
||||||
|
kStroke,
|
||||||
|
kStrokeDashArray,
|
||||||
|
kStrokeDashOffset,
|
||||||
|
kStrokeOpacity,
|
||||||
|
kStrokeLineCap,
|
||||||
|
kStrokeLineJoin,
|
||||||
|
kStrokeMiterLimit,
|
||||||
|
kStrokeWidth,
|
||||||
|
kTransform,
|
||||||
|
kText,
|
||||||
|
kTextAnchor,
|
||||||
|
kViewBox,
|
||||||
|
kVisibility,
|
||||||
|
kWidth,
|
||||||
|
kX,
|
||||||
|
kX1, // <line>: first endpoint x
|
||||||
|
kX2, // <line>: second endpoint x
|
||||||
|
kY,
|
||||||
|
kY1, // <line>: first endpoint y
|
||||||
|
kY2, // <line>: second endpoint y
|
||||||
|
|
||||||
|
kUnknown,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SkSVGPresentationAttributes {
|
||||||
|
static SkSVGPresentationAttributes MakeInitial();
|
||||||
|
|
||||||
|
// TODO: SkTLazy adds an extra ptr per attribute; refactor to reduce overhead.
|
||||||
|
|
||||||
|
SkTLazy<SkSVGPaint> fFill;
|
||||||
|
SkTLazy<SkSVGNumberType> fFillOpacity;
|
||||||
|
SkTLazy<SkSVGFillRule> fFillRule;
|
||||||
|
SkTLazy<SkSVGFillRule> fClipRule;
|
||||||
|
|
||||||
|
SkTLazy<SkSVGPaint> fStroke;
|
||||||
|
SkTLazy<SkSVGDashArray> fStrokeDashArray;
|
||||||
|
SkTLazy<SkSVGLength> fStrokeDashOffset;
|
||||||
|
SkTLazy<SkSVGLineCap> fStrokeLineCap;
|
||||||
|
SkTLazy<SkSVGLineJoin> fStrokeLineJoin;
|
||||||
|
SkTLazy<SkSVGNumberType> fStrokeMiterLimit;
|
||||||
|
SkTLazy<SkSVGNumberType> fStrokeOpacity;
|
||||||
|
SkTLazy<SkSVGLength> fStrokeWidth;
|
||||||
|
|
||||||
|
SkTLazy<SkSVGVisibility> fVisibility;
|
||||||
|
|
||||||
|
SkTLazy<SkSVGColorType> fColor;
|
||||||
|
|
||||||
|
// TODO(tdenniston): add SkSVGStopColor
|
||||||
|
|
||||||
|
// uninherited
|
||||||
|
SkTLazy<SkSVGNumberType> fOpacity;
|
||||||
|
SkTLazy<SkSVGClip> fClipPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGAttribute_DEFINED
|
76
modules/svg/include/SkSVGAttributeParser.h
Normal file
76
modules/svg/include/SkSVGAttributeParser.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGAttributeParser_DEFINED
|
||||||
|
#define SkSVGAttributeParser_DEFINED
|
||||||
|
|
||||||
|
#include "include/private/SkNoncopyable.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGAttributeParser : public SkNoncopyable {
|
||||||
|
public:
|
||||||
|
SkSVGAttributeParser(const char[]);
|
||||||
|
|
||||||
|
bool parseColor(SkSVGColorType*);
|
||||||
|
bool parseClipPath(SkSVGClip*);
|
||||||
|
bool parseFillRule(SkSVGFillRule*);
|
||||||
|
bool parseNumber(SkSVGNumberType*);
|
||||||
|
bool parseLength(SkSVGLength*);
|
||||||
|
bool parseViewBox(SkSVGViewBoxType*);
|
||||||
|
bool parseTransform(SkSVGTransformType*);
|
||||||
|
bool parsePaint(SkSVGPaint*);
|
||||||
|
bool parseLineCap(SkSVGLineCap*);
|
||||||
|
bool parseLineJoin(SkSVGLineJoin*);
|
||||||
|
bool parsePoints(SkSVGPointsType*);
|
||||||
|
bool parseIRI(SkSVGStringType*);
|
||||||
|
bool parseSpreadMethod(SkSVGSpreadMethod*);
|
||||||
|
bool parseStopColor(SkSVGStopColor*);
|
||||||
|
bool parseVisibility(SkSVGVisibility*);
|
||||||
|
bool parseDashArray(SkSVGDashArray*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Stack-only
|
||||||
|
void* operator new(size_t) = delete;
|
||||||
|
void* operator new(size_t, void*) = delete;
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
bool advanceWhile(F func);
|
||||||
|
|
||||||
|
bool parseWSToken();
|
||||||
|
bool parseEOSToken();
|
||||||
|
bool parseSepToken();
|
||||||
|
bool parseCommaWspToken();
|
||||||
|
bool parseExpectedStringToken(const char*);
|
||||||
|
bool parseScalarToken(SkScalar*);
|
||||||
|
bool parseHexToken(uint32_t*);
|
||||||
|
bool parseLengthUnitToken(SkSVGLength::Unit*);
|
||||||
|
bool parseNamedColorToken(SkColor*);
|
||||||
|
bool parseHexColorToken(SkColor*);
|
||||||
|
bool parseColorComponentToken(int32_t*);
|
||||||
|
bool parseRGBColorToken(SkColor*);
|
||||||
|
bool parseFuncIRI(SkSVGStringType*);
|
||||||
|
|
||||||
|
// Transform helpers
|
||||||
|
bool parseMatrixToken(SkMatrix*);
|
||||||
|
bool parseTranslateToken(SkMatrix*);
|
||||||
|
bool parseScaleToken(SkMatrix*);
|
||||||
|
bool parseRotateToken(SkMatrix*);
|
||||||
|
bool parseSkewXToken(SkMatrix*);
|
||||||
|
bool parseSkewYToken(SkMatrix*);
|
||||||
|
|
||||||
|
// Parses a sequence of 'WS* <prefix> WS* (<nested>)', where the nested sequence
|
||||||
|
// is handled by the passed functor.
|
||||||
|
template <typename Func, typename T>
|
||||||
|
bool parseParenthesized(const char* prefix, Func, T* result);
|
||||||
|
|
||||||
|
// The current position in the input string.
|
||||||
|
const char* fCurPos;
|
||||||
|
|
||||||
|
using INHERITED = SkNoncopyable;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGAttributeParser_DEFINED
|
46
modules/svg/include/SkSVGCircle.h
Normal file
46
modules/svg/include/SkSVGCircle.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGCircle_DEFINED
|
||||||
|
#define SkSVGCircle_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
struct SkPoint;
|
||||||
|
|
||||||
|
class SkSVGCircle final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGCircle() override = default;
|
||||||
|
static sk_sp<SkSVGCircle> Make() { return sk_sp<SkSVGCircle>(new SkSVGCircle()); }
|
||||||
|
|
||||||
|
void setCx(const SkSVGLength&);
|
||||||
|
void setCy(const SkSVGLength&);
|
||||||
|
void setR(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGCircle();
|
||||||
|
|
||||||
|
// resolve and return the center and radius values
|
||||||
|
std::tuple<SkPoint, SkScalar> resolve(const SkSVGLengthContext&) const;
|
||||||
|
|
||||||
|
SkSVGLength fCx = SkSVGLength(0);
|
||||||
|
SkSVGLength fCy = SkSVGLength(0);
|
||||||
|
SkSVGLength fR = SkSVGLength(0);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGCircle_DEFINED
|
26
modules/svg/include/SkSVGClipPath.h
Normal file
26
modules/svg/include/SkSVGClipPath.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGClipPath_DEFINED
|
||||||
|
#define SkSVGClipPath_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGClipPath final : public SkSVGHiddenContainer {
|
||||||
|
public:
|
||||||
|
static sk_sp<SkSVGClipPath> Make() {
|
||||||
|
return sk_sp<SkSVGClipPath>(new SkSVGClipPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGClipPath();
|
||||||
|
|
||||||
|
using INHERITED = SkSVGHiddenContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGClipPath_DEFINED
|
36
modules/svg/include/SkSVGContainer.h
Normal file
36
modules/svg/include/SkSVGContainer.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGContainer_DEFINED
|
||||||
|
#define SkSVGContainer_DEFINED
|
||||||
|
|
||||||
|
#include "include/private/SkTArray.h"
|
||||||
|
#include "modules/svg/include/SkSVGTransformableNode.h"
|
||||||
|
|
||||||
|
class SkSVGContainer : public SkSVGTransformableNode {
|
||||||
|
public:
|
||||||
|
~SkSVGContainer() override = default;
|
||||||
|
|
||||||
|
void appendChild(sk_sp<SkSVGNode>) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit SkSVGContainer(SkSVGTag);
|
||||||
|
|
||||||
|
void onRender(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
bool hasChildren() const final;
|
||||||
|
|
||||||
|
// TODO: add some sort of child iterator, and hide the container.
|
||||||
|
SkSTArray<1, sk_sp<SkSVGNode>, true> fChildren;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using INHERITED = SkSVGTransformableNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGContainer_DEFINED
|
48
modules/svg/include/SkSVGDOM.h
Normal file
48
modules/svg/include/SkSVGDOM.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGDOM_DEFINED
|
||||||
|
#define SkSVGDOM_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkRefCnt.h"
|
||||||
|
#include "include/core/SkSize.h"
|
||||||
|
#include "include/private/SkTemplates.h"
|
||||||
|
#include "modules/svg/include/SkSVGIDMapper.h"
|
||||||
|
|
||||||
|
class SkCanvas;
|
||||||
|
class SkDOM;
|
||||||
|
class SkStream;
|
||||||
|
class SkSVGNode;
|
||||||
|
|
||||||
|
class SkSVGDOM : public SkRefCnt {
|
||||||
|
public:
|
||||||
|
SkSVGDOM();
|
||||||
|
|
||||||
|
static sk_sp<SkSVGDOM> MakeFromDOM(const SkDOM&);
|
||||||
|
static sk_sp<SkSVGDOM> MakeFromStream(SkStream&);
|
||||||
|
|
||||||
|
const SkSize& containerSize() const;
|
||||||
|
void setContainerSize(const SkSize&);
|
||||||
|
|
||||||
|
void setRoot(sk_sp<SkSVGNode>);
|
||||||
|
|
||||||
|
// Returns the node with the given id, or nullptr if not found.
|
||||||
|
sk_sp<SkSVGNode>* findNodeById(const char* id);
|
||||||
|
|
||||||
|
void render(SkCanvas*) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSize intrinsicSize() const;
|
||||||
|
|
||||||
|
SkSize fContainerSize;
|
||||||
|
sk_sp<SkSVGNode> fRoot;
|
||||||
|
SkSVGIDMapper fIDMapper;
|
||||||
|
|
||||||
|
using INHERITED = SkRefCnt;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGDOM_DEFINED
|
23
modules/svg/include/SkSVGDefs.h
Normal file
23
modules/svg/include/SkSVGDefs.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGDefs_DEFINED
|
||||||
|
#define SkSVGDefs_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
||||||
|
|
||||||
|
class SkSVGDefs : public SkSVGHiddenContainer {
|
||||||
|
public:
|
||||||
|
static sk_sp<SkSVGDefs> Make() { return sk_sp<SkSVGDefs>(new SkSVGDefs()); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGDefs() : INHERITED(SkSVGTag::kDefs) {}
|
||||||
|
|
||||||
|
using INHERITED = SkSVGHiddenContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGDefs_DEFINED
|
47
modules/svg/include/SkSVGEllipse.h
Normal file
47
modules/svg/include/SkSVGEllipse.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGEllipse_DEFINED
|
||||||
|
#define SkSVGEllipse_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
struct SkRect;
|
||||||
|
|
||||||
|
class SkSVGEllipse final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGEllipse() override = default;
|
||||||
|
static sk_sp<SkSVGEllipse> Make() { return sk_sp<SkSVGEllipse>(new SkSVGEllipse()); }
|
||||||
|
|
||||||
|
void setCx(const SkSVGLength&);
|
||||||
|
void setCy(const SkSVGLength&);
|
||||||
|
void setRx(const SkSVGLength&);
|
||||||
|
void setRy(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGEllipse();
|
||||||
|
|
||||||
|
SkRect resolve(const SkSVGLengthContext&) const;
|
||||||
|
|
||||||
|
SkSVGLength fCx = SkSVGLength(0);
|
||||||
|
SkSVGLength fCy = SkSVGLength(0);
|
||||||
|
SkSVGLength fRx = SkSVGLength(0);
|
||||||
|
SkSVGLength fRy = SkSVGLength(0);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGEllipse_DEFINED
|
23
modules/svg/include/SkSVGG.h
Normal file
23
modules/svg/include/SkSVGG.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGG_DEFINED
|
||||||
|
#define SkSVGG_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGContainer.h"
|
||||||
|
|
||||||
|
class SkSVGG : public SkSVGContainer {
|
||||||
|
public:
|
||||||
|
static sk_sp<SkSVGG> Make() { return sk_sp<SkSVGG>(new SkSVGG()); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGG() : INHERITED(SkSVGTag::kG) { }
|
||||||
|
|
||||||
|
using INHERITED = SkSVGContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGG_DEFINED
|
51
modules/svg/include/SkSVGGradient.h
Normal file
51
modules/svg/include/SkSVGGradient.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGGradient_DEFINED
|
||||||
|
#define SkSVGGradient_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkShader.h"
|
||||||
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkMatrix;
|
||||||
|
class SkSVGRenderContext;
|
||||||
|
class SkSVGStop;
|
||||||
|
|
||||||
|
class SkSVGGradient : public SkSVGHiddenContainer {
|
||||||
|
public:
|
||||||
|
~SkSVGGradient() override = default;
|
||||||
|
|
||||||
|
void setHref(const SkSVGStringType&);
|
||||||
|
void setGradientTransform(const SkSVGTransformType&);
|
||||||
|
void setSpreadMethod(const SkSVGSpreadMethod&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit SkSVGGradient(SkSVGTag t) : INHERITED(t) {}
|
||||||
|
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const final;
|
||||||
|
|
||||||
|
virtual sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
|
||||||
|
const SkColor*, const SkScalar*, int count,
|
||||||
|
SkTileMode, const SkMatrix& localMatrix) const = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using StopPositionArray = SkSTArray<2, SkScalar, true>;
|
||||||
|
using StopColorArray = SkSTArray<2, SkColor, true>;
|
||||||
|
void collectColorStops(const SkSVGRenderContext&, StopPositionArray*, StopColorArray*) const;
|
||||||
|
SkColor resolveStopColor(const SkSVGRenderContext&, const SkSVGStop&) const;
|
||||||
|
|
||||||
|
SkSVGStringType fHref;
|
||||||
|
SkSVGTransformType fGradientTransform = SkSVGTransformType(SkMatrix::I());
|
||||||
|
SkSVGSpreadMethod fSpreadMethod = SkSVGSpreadMethod(SkSVGSpreadMethod::Type::kPad);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGHiddenContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGGradient_DEFINED
|
23
modules/svg/include/SkSVGHiddenContainer.h
Normal file
23
modules/svg/include/SkSVGHiddenContainer.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGHiddenContainer_DEFINED
|
||||||
|
#define SkSVGHiddenContainer_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGContainer.h"
|
||||||
|
|
||||||
|
class SkSVGHiddenContainer : public SkSVGContainer {
|
||||||
|
protected:
|
||||||
|
explicit SkSVGHiddenContainer(SkSVGTag t) : INHERITED(t) {}
|
||||||
|
|
||||||
|
void onRender(const SkSVGRenderContext&) const final {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
using INHERITED = SkSVGContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGHiddenContainer_DEFINED
|
19
modules/svg/include/SkSVGIDMapper.h
Normal file
19
modules/svg/include/SkSVGIDMapper.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGIDMapper_DEFINED
|
||||||
|
#define SkSVGIDMapper_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkRefCnt.h"
|
||||||
|
#include "include/private/SkTHash.h"
|
||||||
|
|
||||||
|
class SkString;
|
||||||
|
class SkSVGNode;
|
||||||
|
|
||||||
|
using SkSVGIDMapper = SkTHashMap<SkString, sk_sp<SkSVGNode>>;
|
||||||
|
|
||||||
|
#endif // SkSVGIDMapper_DEFINED
|
48
modules/svg/include/SkSVGLine.h
Normal file
48
modules/svg/include/SkSVGLine.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGLine_DEFINED
|
||||||
|
#define SkSVGLine_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
struct SkPoint;
|
||||||
|
|
||||||
|
class SkSVGLine final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGLine() override = default;
|
||||||
|
static sk_sp<SkSVGLine> Make() { return sk_sp<SkSVGLine>(new SkSVGLine()); }
|
||||||
|
|
||||||
|
void setX1(const SkSVGLength&);
|
||||||
|
void setY1(const SkSVGLength&);
|
||||||
|
void setX2(const SkSVGLength&);
|
||||||
|
void setY2(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGLine();
|
||||||
|
|
||||||
|
// resolve and return the two endpoints
|
||||||
|
std::tuple<SkPoint, SkPoint> resolve(const SkSVGLengthContext&) const;
|
||||||
|
|
||||||
|
SkSVGLength fX1 = SkSVGLength(0);
|
||||||
|
SkSVGLength fY1 = SkSVGLength(0);
|
||||||
|
SkSVGLength fX2 = SkSVGLength(0);
|
||||||
|
SkSVGLength fY2 = SkSVGLength(0);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGLine_DEFINED
|
43
modules/svg/include/SkSVGLinearGradient.h
Normal file
43
modules/svg/include/SkSVGLinearGradient.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGLinearGradient_DEFINED
|
||||||
|
#define SkSVGLinearGradient_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGGradient.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGLinearGradient final : public SkSVGGradient {
|
||||||
|
public:
|
||||||
|
~SkSVGLinearGradient() override = default;
|
||||||
|
static sk_sp<SkSVGLinearGradient> Make() {
|
||||||
|
return sk_sp<SkSVGLinearGradient>(new SkSVGLinearGradient());
|
||||||
|
}
|
||||||
|
|
||||||
|
void setX1(const SkSVGLength&);
|
||||||
|
void setY1(const SkSVGLength&);
|
||||||
|
void setX2(const SkSVGLength&);
|
||||||
|
void setY2(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
|
||||||
|
const SkColor*, const SkScalar*, int count,
|
||||||
|
SkTileMode, const SkMatrix&) const override;
|
||||||
|
private:
|
||||||
|
SkSVGLinearGradient();
|
||||||
|
|
||||||
|
SkSVGLength fX1 = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGLength fY1 = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGLength fX2 = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGLength fY2 = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGGradient;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGLinearGradient_DEFINED
|
103
modules/svg/include/SkSVGNode.h
Normal file
103
modules/svg/include/SkSVGNode.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGNode_DEFINED
|
||||||
|
#define SkSVGNode_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkRefCnt.h"
|
||||||
|
#include "modules/svg/include/SkSVGAttribute.h"
|
||||||
|
|
||||||
|
class SkCanvas;
|
||||||
|
class SkMatrix;
|
||||||
|
class SkPaint;
|
||||||
|
class SkPath;
|
||||||
|
class SkSVGRenderContext;
|
||||||
|
class SkSVGValue;
|
||||||
|
|
||||||
|
enum class SkSVGTag {
|
||||||
|
kCircle,
|
||||||
|
kClipPath,
|
||||||
|
kDefs,
|
||||||
|
kEllipse,
|
||||||
|
kG,
|
||||||
|
kLine,
|
||||||
|
kLinearGradient,
|
||||||
|
kPath,
|
||||||
|
kPattern,
|
||||||
|
kPolygon,
|
||||||
|
kPolyline,
|
||||||
|
kRadialGradient,
|
||||||
|
kRect,
|
||||||
|
kStop,
|
||||||
|
kSvg,
|
||||||
|
kText,
|
||||||
|
kUse
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGNode : public SkRefCnt {
|
||||||
|
public:
|
||||||
|
~SkSVGNode() override;
|
||||||
|
|
||||||
|
SkSVGTag tag() const { return fTag; }
|
||||||
|
|
||||||
|
virtual void appendChild(sk_sp<SkSVGNode>) = 0;
|
||||||
|
|
||||||
|
void render(const SkSVGRenderContext&) const;
|
||||||
|
bool asPaint(const SkSVGRenderContext&, SkPaint*) const;
|
||||||
|
SkPath asPath(const SkSVGRenderContext&) const;
|
||||||
|
|
||||||
|
void setAttribute(SkSVGAttribute, const SkSVGValue&);
|
||||||
|
bool setAttribute(const char* attributeName, const char* attributeValue);
|
||||||
|
|
||||||
|
void setClipPath(const SkSVGClip&);
|
||||||
|
void setClipRule(const SkSVGFillRule&);
|
||||||
|
void setColor(const SkSVGColorType&);
|
||||||
|
void setFill(const SkSVGPaint&);
|
||||||
|
void setFillOpacity(const SkSVGNumberType&);
|
||||||
|
void setFillRule(const SkSVGFillRule&);
|
||||||
|
void setOpacity(const SkSVGNumberType&);
|
||||||
|
void setStroke(const SkSVGPaint&);
|
||||||
|
void setStrokeDashArray(const SkSVGDashArray&);
|
||||||
|
void setStrokeDashOffset(const SkSVGLength&);
|
||||||
|
void setStrokeOpacity(const SkSVGNumberType&);
|
||||||
|
void setStrokeLineCap(const SkSVGLineCap&);
|
||||||
|
void setStrokeLineJoin(const SkSVGLineJoin&);
|
||||||
|
void setStrokeMiterLimit(const SkSVGNumberType&);
|
||||||
|
void setStrokeWidth(const SkSVGLength&);
|
||||||
|
void setVisibility(const SkSVGVisibility&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SkSVGNode(SkSVGTag);
|
||||||
|
|
||||||
|
// Called before onRender(), to apply local attributes to the context. Unlike onRender(),
|
||||||
|
// onPrepareToRender() bubbles up the inheritance chain: overriders should always call
|
||||||
|
// INHERITED::onPrepareToRender(), unless they intend to short-circuit rendering
|
||||||
|
// (return false).
|
||||||
|
// Implementations are expected to return true if rendering is to continue, or false if
|
||||||
|
// the node/subtree rendering is disabled.
|
||||||
|
virtual bool onPrepareToRender(SkSVGRenderContext*) const;
|
||||||
|
|
||||||
|
virtual void onRender(const SkSVGRenderContext&) const = 0;
|
||||||
|
|
||||||
|
virtual bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const { return false; }
|
||||||
|
|
||||||
|
virtual SkPath onAsPath(const SkSVGRenderContext&) const = 0;
|
||||||
|
|
||||||
|
virtual void onSetAttribute(SkSVGAttribute, const SkSVGValue&);
|
||||||
|
|
||||||
|
virtual bool hasChildren() const { return false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGTag fTag;
|
||||||
|
|
||||||
|
// FIXME: this should be sparse
|
||||||
|
SkSVGPresentationAttributes fPresentationAttributes;
|
||||||
|
|
||||||
|
using INHERITED = SkRefCnt;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGNode_DEFINED
|
37
modules/svg/include/SkSVGPath.h
Normal file
37
modules/svg/include/SkSVGPath.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGPath_DEFINED
|
||||||
|
#define SkSVGPath_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkPath.h"
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
|
||||||
|
class SkSVGPath final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGPath() override = default;
|
||||||
|
static sk_sp<SkSVGPath> Make() { return sk_sp<SkSVGPath>(new SkSVGPath()); }
|
||||||
|
|
||||||
|
void setPath(const SkPath& path) { fPath = path; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGPath();
|
||||||
|
|
||||||
|
mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
|
||||||
|
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGPath_DEFINED
|
59
modules/svg/include/SkSVGPattern.h
Normal file
59
modules/svg/include/SkSVGPattern.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGPattern_DEFINED
|
||||||
|
#define SkSVGPattern_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGRenderContext;
|
||||||
|
|
||||||
|
class SkSVGPattern final : public SkSVGHiddenContainer {
|
||||||
|
public:
|
||||||
|
~SkSVGPattern() override = default;
|
||||||
|
|
||||||
|
static sk_sp<SkSVGPattern> Make() {
|
||||||
|
return sk_sp<SkSVGPattern>(new SkSVGPattern());
|
||||||
|
}
|
||||||
|
|
||||||
|
void setX(const SkSVGLength&);
|
||||||
|
void setY(const SkSVGLength&);
|
||||||
|
void setWidth(const SkSVGLength&);
|
||||||
|
void setHeight(const SkSVGLength&);
|
||||||
|
void setHref(const SkSVGStringType&);
|
||||||
|
void setPatternTransform(const SkSVGTransformType&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SkSVGPattern();
|
||||||
|
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PatternAttributes {
|
||||||
|
SkTLazy<SkSVGLength> fX,
|
||||||
|
fY,
|
||||||
|
fWidth,
|
||||||
|
fHeight;
|
||||||
|
SkTLazy<SkSVGTransformType> fPatternTransform;
|
||||||
|
} fAttributes;
|
||||||
|
|
||||||
|
SkSVGStringType fHref;
|
||||||
|
|
||||||
|
const SkSVGPattern* resolveHref(const SkSVGRenderContext&, PatternAttributes*) const;
|
||||||
|
const SkSVGPattern* hrefTarget(const SkSVGRenderContext&) const;
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - patternUnits
|
||||||
|
// - patternContentUnits
|
||||||
|
|
||||||
|
using INHERITED = SkSVGHiddenContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGPattern_DEFINED
|
45
modules/svg/include/SkSVGPoly.h
Normal file
45
modules/svg/include/SkSVGPoly.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGPoly_DEFINED
|
||||||
|
#define SkSVGPoly_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkPath.h"
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
|
||||||
|
// Handles <polygon> and <polyline> elements.
|
||||||
|
class SkSVGPoly final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGPoly() override = default;
|
||||||
|
|
||||||
|
static sk_sp<SkSVGPoly> MakePolygon() {
|
||||||
|
return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolygon));
|
||||||
|
}
|
||||||
|
|
||||||
|
static sk_sp<SkSVGPoly> MakePolyline() {
|
||||||
|
return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolyline));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPoints(const SkSVGPointsType&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGPoly(SkSVGTag);
|
||||||
|
|
||||||
|
mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
|
||||||
|
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGPoly_DEFINED
|
46
modules/svg/include/SkSVGRadialGradient.h
Normal file
46
modules/svg/include/SkSVGRadialGradient.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGRadialGradient_DEFINED
|
||||||
|
#define SkSVGRadialGradient_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGGradient.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGRadialGradient final : public SkSVGGradient {
|
||||||
|
public:
|
||||||
|
~SkSVGRadialGradient() override = default;
|
||||||
|
static sk_sp<SkSVGRadialGradient> Make() {
|
||||||
|
return sk_sp<SkSVGRadialGradient>(new SkSVGRadialGradient());
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCx(const SkSVGLength&);
|
||||||
|
void setCy(const SkSVGLength&);
|
||||||
|
void setR(const SkSVGLength&);
|
||||||
|
void setFx(const SkSVGLength&);
|
||||||
|
void setFy(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
|
||||||
|
const SkColor*, const SkScalar*, int count,
|
||||||
|
SkTileMode, const SkMatrix&) const override;
|
||||||
|
private:
|
||||||
|
SkSVGRadialGradient();
|
||||||
|
|
||||||
|
SkSVGLength fCx = SkSVGLength(50, SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGLength fCy = SkSVGLength(50, SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGLength fR = SkSVGLength(50, SkSVGLength::Unit::kPercentage);
|
||||||
|
SkTLazy<SkSVGLength> fFx;
|
||||||
|
SkTLazy<SkSVGLength> fFy;
|
||||||
|
|
||||||
|
|
||||||
|
using INHERITED = SkSVGGradient;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGRadialGradient_DEFINED
|
54
modules/svg/include/SkSVGRect.h
Normal file
54
modules/svg/include/SkSVGRect.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGRect_DEFINED
|
||||||
|
#define SkSVGRect_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkRRect;
|
||||||
|
|
||||||
|
class SkSVGRect final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGRect() override = default;
|
||||||
|
static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); }
|
||||||
|
|
||||||
|
void setX(const SkSVGLength&);
|
||||||
|
void setY(const SkSVGLength&);
|
||||||
|
void setWidth(const SkSVGLength&);
|
||||||
|
void setHeight(const SkSVGLength&);
|
||||||
|
void setRx(const SkSVGLength&);
|
||||||
|
void setRy(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGRect();
|
||||||
|
|
||||||
|
SkRRect resolve(const SkSVGLengthContext&) const;
|
||||||
|
|
||||||
|
SkSVGLength fX = SkSVGLength(0);
|
||||||
|
SkSVGLength fY = SkSVGLength(0);
|
||||||
|
SkSVGLength fWidth = SkSVGLength(0);
|
||||||
|
SkSVGLength fHeight = SkSVGLength(0);
|
||||||
|
|
||||||
|
// The x radius for rounded rects.
|
||||||
|
SkSVGLength fRx = SkSVGLength(0);
|
||||||
|
// The y radius for rounded rects.
|
||||||
|
SkSVGLength fRy = SkSVGLength(0);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGRect_DEFINED
|
144
modules/svg/include/SkSVGRenderContext.h
Normal file
144
modules/svg/include/SkSVGRenderContext.h
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGRenderContext_DEFINED
|
||||||
|
#define SkSVGRenderContext_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkPaint.h"
|
||||||
|
#include "include/core/SkPath.h"
|
||||||
|
#include "include/core/SkRect.h"
|
||||||
|
#include "include/core/SkSize.h"
|
||||||
|
#include "include/core/SkTypes.h"
|
||||||
|
#include "modules/svg/include/SkSVGAttribute.h"
|
||||||
|
#include "modules/svg/include/SkSVGIDMapper.h"
|
||||||
|
#include "src/core/SkTLazy.h"
|
||||||
|
|
||||||
|
class SkCanvas;
|
||||||
|
class SkSVGLength;
|
||||||
|
|
||||||
|
class SkSVGLengthContext {
|
||||||
|
public:
|
||||||
|
SkSVGLengthContext(const SkSize& viewport, SkScalar dpi = 90)
|
||||||
|
: fViewport(viewport), fDPI(dpi) {}
|
||||||
|
|
||||||
|
enum class LengthType {
|
||||||
|
kHorizontal,
|
||||||
|
kVertical,
|
||||||
|
kOther,
|
||||||
|
};
|
||||||
|
|
||||||
|
const SkSize& viewPort() const { return fViewport; }
|
||||||
|
void setViewPort(const SkSize& viewport) { fViewport = viewport; }
|
||||||
|
|
||||||
|
SkScalar resolve(const SkSVGLength&, LengthType) const;
|
||||||
|
SkRect resolveRect(const SkSVGLength& x, const SkSVGLength& y,
|
||||||
|
const SkSVGLength& w, const SkSVGLength& h) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSize fViewport;
|
||||||
|
SkScalar fDPI;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SkSVGPresentationContext {
|
||||||
|
SkSVGPresentationContext();
|
||||||
|
SkSVGPresentationContext(const SkSVGPresentationContext&) = default;
|
||||||
|
SkSVGPresentationContext& operator=(const SkSVGPresentationContext&) = default;
|
||||||
|
|
||||||
|
// Inherited presentation attributes, computed for the current node.
|
||||||
|
SkSVGPresentationAttributes fInherited;
|
||||||
|
|
||||||
|
// Cached paints, reflecting the current presentation attributes.
|
||||||
|
SkPaint fFillPaint;
|
||||||
|
SkPaint fStrokePaint;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGRenderContext {
|
||||||
|
public:
|
||||||
|
SkSVGRenderContext(SkCanvas*, const SkSVGIDMapper&, const SkSVGLengthContext&,
|
||||||
|
const SkSVGPresentationContext&);
|
||||||
|
SkSVGRenderContext(const SkSVGRenderContext&);
|
||||||
|
SkSVGRenderContext(const SkSVGRenderContext&, SkCanvas*);
|
||||||
|
~SkSVGRenderContext();
|
||||||
|
|
||||||
|
const SkSVGLengthContext& lengthContext() const { return *fLengthContext; }
|
||||||
|
SkSVGLengthContext* writableLengthContext() { return fLengthContext.writable(); }
|
||||||
|
|
||||||
|
const SkSVGPresentationContext& presentationContext() const { return *fPresentationContext; }
|
||||||
|
|
||||||
|
SkCanvas* canvas() const { return fCanvas; }
|
||||||
|
void saveOnce();
|
||||||
|
|
||||||
|
enum ApplyFlags {
|
||||||
|
kLeaf = 1 << 0, // the target node doesn't have descendants
|
||||||
|
};
|
||||||
|
void applyPresentationAttributes(const SkSVGPresentationAttributes&, uint32_t flags);
|
||||||
|
|
||||||
|
// Scoped wrapper that temporarily clears the original node reference.
|
||||||
|
class BorrowedNode {
|
||||||
|
public:
|
||||||
|
explicit BorrowedNode(sk_sp<SkSVGNode>* node)
|
||||||
|
: fOwner(node) {
|
||||||
|
if (fOwner) {
|
||||||
|
fBorrowed = std::move(*fOwner);
|
||||||
|
*fOwner = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~BorrowedNode() {
|
||||||
|
if (fOwner) {
|
||||||
|
*fOwner = std::move(fBorrowed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const SkSVGNode* get() const { return fBorrowed.get(); }
|
||||||
|
const SkSVGNode* operator->() const { return fBorrowed.get(); }
|
||||||
|
const SkSVGNode& operator*() const { return *fBorrowed; }
|
||||||
|
|
||||||
|
operator bool() const { return !!fBorrowed; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// noncopyable
|
||||||
|
BorrowedNode(const BorrowedNode&) = delete;
|
||||||
|
BorrowedNode& operator=(BorrowedNode&) = delete;
|
||||||
|
|
||||||
|
sk_sp<SkSVGNode>* fOwner;
|
||||||
|
sk_sp<SkSVGNode> fBorrowed;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Note: the id->node association is cleared for the lifetime of the returned value
|
||||||
|
// (effectively breaks reference cycles, assuming appropriate return value scoping).
|
||||||
|
BorrowedNode findNodeById(const SkString&) const;
|
||||||
|
|
||||||
|
const SkPaint* fillPaint() const;
|
||||||
|
const SkPaint* strokePaint() const;
|
||||||
|
|
||||||
|
// The local computed clip path (not inherited).
|
||||||
|
const SkPath* clipPath() const { return fClipPath.getMaybeNull(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Stack-only
|
||||||
|
void* operator new(size_t) = delete;
|
||||||
|
void* operator new(size_t, void*) = delete;
|
||||||
|
SkSVGRenderContext& operator=(const SkSVGRenderContext&) = delete;
|
||||||
|
|
||||||
|
void applyOpacity(SkScalar opacity, uint32_t flags);
|
||||||
|
void applyClip(const SkSVGClip&);
|
||||||
|
void updatePaintsWithCurrentColor(const SkSVGPresentationAttributes&);
|
||||||
|
|
||||||
|
const SkSVGIDMapper& fIDMapper;
|
||||||
|
SkTCopyOnFirstWrite<SkSVGLengthContext> fLengthContext;
|
||||||
|
SkTCopyOnFirstWrite<SkSVGPresentationContext> fPresentationContext;
|
||||||
|
SkCanvas* fCanvas;
|
||||||
|
// The save count on 'fCanvas' at construction time.
|
||||||
|
// A restoreToCount() will be issued on destruction.
|
||||||
|
int fCanvasSaveCount;
|
||||||
|
|
||||||
|
// clipPath, if present for the current context (not inherited).
|
||||||
|
SkTLazy<SkPath> fClipPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGRenderContext_DEFINED
|
49
modules/svg/include/SkSVGSVG.h
Normal file
49
modules/svg/include/SkSVGSVG.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGSVG_DEFINED
|
||||||
|
#define SkSVGSVG_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGContainer.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
#include "src/core/SkTLazy.h"
|
||||||
|
|
||||||
|
class SkSVGLengthContext;
|
||||||
|
|
||||||
|
class SkSVGSVG : public SkSVGContainer {
|
||||||
|
public:
|
||||||
|
~SkSVGSVG() override = default;
|
||||||
|
|
||||||
|
static sk_sp<SkSVGSVG> Make() { return sk_sp<SkSVGSVG>(new SkSVGSVG()); }
|
||||||
|
|
||||||
|
void setX(const SkSVGLength&);
|
||||||
|
void setY(const SkSVGLength&);
|
||||||
|
void setWidth(const SkSVGLength&);
|
||||||
|
void setHeight(const SkSVGLength&);
|
||||||
|
void setViewBox(const SkSVGViewBoxType&);
|
||||||
|
|
||||||
|
SkSize intrinsicSize(const SkSVGLengthContext&) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onPrepareToRender(SkSVGRenderContext*) const override;
|
||||||
|
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGSVG();
|
||||||
|
|
||||||
|
SkSVGLength fX = SkSVGLength(0);
|
||||||
|
SkSVGLength fY = SkSVGLength(0);
|
||||||
|
SkSVGLength fWidth = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGLength fHeight = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
|
||||||
|
|
||||||
|
SkTLazy<SkSVGViewBoxType> fViewBox;
|
||||||
|
|
||||||
|
using INHERITED = SkSVGContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGSVG_DEFINED
|
35
modules/svg/include/SkSVGShape.h
Normal file
35
modules/svg/include/SkSVGShape.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGShape_DEFINED
|
||||||
|
#define SkSVGShape_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkPath.h"
|
||||||
|
#include "modules/svg/include/SkSVGTransformableNode.h"
|
||||||
|
|
||||||
|
class SkSVGLengthContext;
|
||||||
|
class SkPaint;
|
||||||
|
|
||||||
|
class SkSVGShape : public SkSVGTransformableNode {
|
||||||
|
public:
|
||||||
|
~SkSVGShape() override = default;
|
||||||
|
|
||||||
|
void appendChild(sk_sp<SkSVGNode>) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SkSVGShape(SkSVGTag);
|
||||||
|
|
||||||
|
void onRender(const SkSVGRenderContext&) const final;
|
||||||
|
|
||||||
|
virtual void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using INHERITED = SkSVGTransformableNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGShape_DEFINED
|
44
modules/svg/include/SkSVGStop.h
Normal file
44
modules/svg/include/SkSVGStop.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGStop_DEFINED
|
||||||
|
#define SkSVGStop_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGLengthContext;
|
||||||
|
|
||||||
|
class SkSVGStop : public SkSVGHiddenContainer {
|
||||||
|
public:
|
||||||
|
~SkSVGStop() override = default;
|
||||||
|
static sk_sp<SkSVGStop> Make() {
|
||||||
|
return sk_sp<SkSVGStop>(new SkSVGStop());
|
||||||
|
}
|
||||||
|
|
||||||
|
const SkSVGLength& offset() const { return fOffset; }
|
||||||
|
const SkSVGStopColor& stopColor() const { return fStopColor; }
|
||||||
|
const SkSVGNumberType& stopOpacity() const { return fStopOpacity; }
|
||||||
|
|
||||||
|
void setOffset(const SkSVGLength&);
|
||||||
|
void setStopColor(const SkSVGStopColor&);
|
||||||
|
void setStopOpacity(const SkSVGNumberType&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGStop();
|
||||||
|
|
||||||
|
SkSVGLength fOffset = SkSVGLength(0 , SkSVGLength::Unit::kPercentage);
|
||||||
|
SkSVGStopColor fStopColor = SkSVGStopColor(SK_ColorBLACK);
|
||||||
|
SkSVGNumberType fStopOpacity = SkSVGNumberType(1);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGHiddenContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGStop_DEFINED
|
57
modules/svg/include/SkSVGText.h
Normal file
57
modules/svg/include/SkSVGText.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGText_DEFINED
|
||||||
|
#define SkSVGText_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkFont.h"
|
||||||
|
#include "include/utils/SkTextUtils.h"
|
||||||
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkRRect;
|
||||||
|
|
||||||
|
class SkSVGText final : public SkSVGShape {
|
||||||
|
public:
|
||||||
|
~SkSVGText() override = default;
|
||||||
|
static sk_sp<SkSVGText> Make() {
|
||||||
|
return sk_sp<SkSVGText>(new SkSVGText()); }
|
||||||
|
|
||||||
|
void setX(const SkSVGLength&);
|
||||||
|
void setY(const SkSVGLength&);
|
||||||
|
void setFontFamily(const SkSVGStringType&);
|
||||||
|
void setFontSize(const SkSVGLength&);
|
||||||
|
void setFontStyle(const SkSVGStringType&);
|
||||||
|
void setFontWeight(const SkSVGStringType&);
|
||||||
|
void setText(const SkSVGStringType&);
|
||||||
|
void setTextAnchor(const SkSVGStringType&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
|
||||||
|
SkPathFillType) const override;
|
||||||
|
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
void loadFont();
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGText();
|
||||||
|
SkSVGLength fX = SkSVGLength(0);
|
||||||
|
SkSVGLength fY = SkSVGLength(0);
|
||||||
|
SkSVGStringType fText;
|
||||||
|
sk_sp<SkTypeface> fTypeface;
|
||||||
|
SkSVGLength fFontSize;
|
||||||
|
SkSVGStringType fFontFamily;
|
||||||
|
SkSVGStringType fFontStyle;
|
||||||
|
SkSVGStringType fFontWeight;
|
||||||
|
SkTextUtils::Align fTextAlign = SkTextUtils::Align::kLeft_Align;
|
||||||
|
using INHERITED = SkSVGShape;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGText_DEFINED
|
36
modules/svg/include/SkSVGTransformableNode.h
Normal file
36
modules/svg/include/SkSVGTransformableNode.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGTransformableNode_DEFINED
|
||||||
|
#define SkSVGTransformableNode_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkMatrix.h"
|
||||||
|
#include "modules/svg/include/SkSVGNode.h"
|
||||||
|
|
||||||
|
class SkSVGTransformableNode : public SkSVGNode {
|
||||||
|
public:
|
||||||
|
~SkSVGTransformableNode() override = default;
|
||||||
|
|
||||||
|
void setTransform(const SkSVGTransformType& t) { fTransform = t; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SkSVGTransformableNode(SkSVGTag);
|
||||||
|
|
||||||
|
bool onPrepareToRender(SkSVGRenderContext*) const override;
|
||||||
|
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
void mapToParent(SkPath*) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// FIXME: should be sparse
|
||||||
|
SkSVGTransformType fTransform;
|
||||||
|
|
||||||
|
using INHERITED = SkSVGNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGTransformableNode_DEFINED
|
311
modules/svg/include/SkSVGTypes.h
Normal file
311
modules/svg/include/SkSVGTypes.h
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGTypes_DEFINED
|
||||||
|
#define SkSVGTypes_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkColor.h"
|
||||||
|
#include "include/core/SkMatrix.h"
|
||||||
|
#include "include/core/SkPath.h"
|
||||||
|
#include "include/core/SkPoint.h"
|
||||||
|
#include "include/core/SkRect.h"
|
||||||
|
#include "include/core/SkScalar.h"
|
||||||
|
#include "include/core/SkString.h"
|
||||||
|
#include "include/core/SkTypes.h"
|
||||||
|
#include "include/private/SkTDArray.h"
|
||||||
|
|
||||||
|
using SkSVGColorType = SkColor;
|
||||||
|
using SkSVGNumberType = SkScalar;
|
||||||
|
using SkSVGStringType = SkString;
|
||||||
|
using SkSVGViewBoxType = SkRect;
|
||||||
|
using SkSVGTransformType = SkMatrix;
|
||||||
|
using SkSVGPointsType = SkTDArray<SkPoint>;
|
||||||
|
|
||||||
|
class SkSVGLength {
|
||||||
|
public:
|
||||||
|
enum class Unit {
|
||||||
|
kUnknown,
|
||||||
|
kNumber,
|
||||||
|
kPercentage,
|
||||||
|
kEMS,
|
||||||
|
kEXS,
|
||||||
|
kPX,
|
||||||
|
kCM,
|
||||||
|
kMM,
|
||||||
|
kIN,
|
||||||
|
kPT,
|
||||||
|
kPC,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr SkSVGLength() : fValue(0), fUnit(Unit::kUnknown) {}
|
||||||
|
explicit constexpr SkSVGLength(SkScalar v, Unit u = Unit::kNumber)
|
||||||
|
: fValue(v), fUnit(u) {}
|
||||||
|
SkSVGLength(const SkSVGLength&) = default;
|
||||||
|
SkSVGLength& operator=(const SkSVGLength&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGLength& other) const {
|
||||||
|
return fUnit == other.fUnit && fValue == other.fValue;
|
||||||
|
}
|
||||||
|
bool operator!=(const SkSVGLength& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
const SkScalar& value() const { return fValue; }
|
||||||
|
const Unit& unit() const { return fUnit; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkScalar fValue;
|
||||||
|
Unit fUnit;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGPaint {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kNone,
|
||||||
|
kCurrentColor,
|
||||||
|
kColor,
|
||||||
|
kInherit,
|
||||||
|
kIRI,
|
||||||
|
};
|
||||||
|
|
||||||
|
SkSVGPaint() : fType(Type::kInherit), fColor(SK_ColorBLACK) {}
|
||||||
|
explicit SkSVGPaint(Type t) : fType(t), fColor(SK_ColorBLACK) {}
|
||||||
|
explicit SkSVGPaint(const SkSVGColorType& c) : fType(Type::kColor), fColor(c) {}
|
||||||
|
explicit SkSVGPaint(const SkString& iri)
|
||||||
|
: fType(Type::kIRI), fColor(SK_ColorBLACK), fIRI(iri) {}
|
||||||
|
|
||||||
|
SkSVGPaint(const SkSVGPaint&) = default;
|
||||||
|
SkSVGPaint& operator=(const SkSVGPaint&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGPaint& other) const {
|
||||||
|
return fType == other.fType && fColor == other.fColor && fIRI == other.fIRI;
|
||||||
|
}
|
||||||
|
bool operator!=(const SkSVGPaint& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
const SkSVGColorType& color() const { SkASSERT(fType == Type::kColor); return fColor; }
|
||||||
|
const SkString& iri() const { SkASSERT(fType == Type::kIRI); return fIRI; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
|
||||||
|
// Logical union.
|
||||||
|
SkSVGColorType fColor;
|
||||||
|
SkString fIRI;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGClip {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kNone,
|
||||||
|
kInherit,
|
||||||
|
kIRI,
|
||||||
|
};
|
||||||
|
|
||||||
|
SkSVGClip() : fType(Type::kNone) {}
|
||||||
|
explicit SkSVGClip(Type t) : fType(t) {}
|
||||||
|
explicit SkSVGClip(const SkString& iri) : fType(Type::kIRI), fIRI(iri) {}
|
||||||
|
|
||||||
|
SkSVGClip(const SkSVGClip&) = default;
|
||||||
|
SkSVGClip& operator=(const SkSVGClip&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGClip& other) const {
|
||||||
|
return fType == other.fType && fIRI == other.fIRI;
|
||||||
|
}
|
||||||
|
bool operator!=(const SkSVGClip& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
const SkString& iri() const { SkASSERT(fType == Type::kIRI); return fIRI; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
SkString fIRI;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGLineCap {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kButt,
|
||||||
|
kRound,
|
||||||
|
kSquare,
|
||||||
|
kInherit,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr SkSVGLineCap() : fType(Type::kInherit) {}
|
||||||
|
constexpr explicit SkSVGLineCap(Type t) : fType(t) {}
|
||||||
|
|
||||||
|
SkSVGLineCap(const SkSVGLineCap&) = default;
|
||||||
|
SkSVGLineCap& operator=(const SkSVGLineCap&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGLineCap& other) const { return fType == other.fType; }
|
||||||
|
bool operator!=(const SkSVGLineCap& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGLineJoin {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kMiter,
|
||||||
|
kRound,
|
||||||
|
kBevel,
|
||||||
|
kInherit,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr SkSVGLineJoin() : fType(Type::kInherit) {}
|
||||||
|
constexpr explicit SkSVGLineJoin(Type t) : fType(t) {}
|
||||||
|
|
||||||
|
SkSVGLineJoin(const SkSVGLineJoin&) = default;
|
||||||
|
SkSVGLineJoin& operator=(const SkSVGLineJoin&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGLineJoin& other) const { return fType == other.fType; }
|
||||||
|
bool operator!=(const SkSVGLineJoin& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGSpreadMethod {
|
||||||
|
public:
|
||||||
|
// These values must match Skia's SkShader::TileMode enum.
|
||||||
|
enum class Type {
|
||||||
|
kPad, // kClamp_TileMode
|
||||||
|
kRepeat, // kRepeat_TileMode
|
||||||
|
kReflect, // kMirror_TileMode
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr SkSVGSpreadMethod() : fType(Type::kPad) {}
|
||||||
|
constexpr explicit SkSVGSpreadMethod(Type t) : fType(t) {}
|
||||||
|
|
||||||
|
SkSVGSpreadMethod(const SkSVGSpreadMethod&) = default;
|
||||||
|
SkSVGSpreadMethod& operator=(const SkSVGSpreadMethod&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGSpreadMethod& other) const { return fType == other.fType; }
|
||||||
|
bool operator!=(const SkSVGSpreadMethod& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGFillRule {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kNonZero,
|
||||||
|
kEvenOdd,
|
||||||
|
kInherit,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr SkSVGFillRule() : fType(Type::kInherit) {}
|
||||||
|
constexpr explicit SkSVGFillRule(Type t) : fType(t) {}
|
||||||
|
|
||||||
|
SkSVGFillRule(const SkSVGFillRule&) = default;
|
||||||
|
SkSVGFillRule& operator=(const SkSVGFillRule&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGFillRule& other) const { return fType == other.fType; }
|
||||||
|
bool operator!=(const SkSVGFillRule& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
SkPathFillType asFillType() const {
|
||||||
|
SkASSERT(fType != Type::kInherit); // should never be called for unresolved values.
|
||||||
|
return fType == Type::kEvenOdd ? SkPathFillType::kEvenOdd : SkPathFillType::kWinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGVisibility {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kVisible,
|
||||||
|
kHidden,
|
||||||
|
kCollapse,
|
||||||
|
kInherit,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr SkSVGVisibility() : fType(Type::kVisible) {}
|
||||||
|
constexpr explicit SkSVGVisibility(Type t) : fType(t) {}
|
||||||
|
|
||||||
|
SkSVGVisibility(const SkSVGVisibility&) = default;
|
||||||
|
SkSVGVisibility& operator=(const SkSVGVisibility&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGVisibility& other) const { return fType == other.fType; }
|
||||||
|
bool operator!=(const SkSVGVisibility& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGDashArray {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kNone,
|
||||||
|
kDashArray,
|
||||||
|
kInherit,
|
||||||
|
};
|
||||||
|
|
||||||
|
SkSVGDashArray() : fType(Type::kNone) {}
|
||||||
|
explicit SkSVGDashArray(Type t) : fType(t) {}
|
||||||
|
explicit SkSVGDashArray(SkTDArray<SkSVGLength>&& dashArray)
|
||||||
|
: fType(Type::kDashArray)
|
||||||
|
, fDashArray(std::move(dashArray)) {}
|
||||||
|
|
||||||
|
SkSVGDashArray(const SkSVGDashArray&) = default;
|
||||||
|
SkSVGDashArray& operator=(const SkSVGDashArray&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGDashArray& other) const {
|
||||||
|
return fType == other.fType && fDashArray == other.fDashArray;
|
||||||
|
}
|
||||||
|
bool operator!=(const SkSVGDashArray& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
const SkTDArray<SkSVGLength>& dashArray() const { return fDashArray; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
SkTDArray<SkSVGLength> fDashArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkSVGStopColor {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kColor,
|
||||||
|
kCurrentColor,
|
||||||
|
kICCColor,
|
||||||
|
kInherit,
|
||||||
|
};
|
||||||
|
|
||||||
|
SkSVGStopColor() : fType(Type::kColor), fColor(SK_ColorBLACK) {}
|
||||||
|
explicit SkSVGStopColor(Type t) : fType(t), fColor(SK_ColorBLACK) {}
|
||||||
|
explicit SkSVGStopColor(const SkSVGColorType& c) : fType(Type::kColor), fColor(c) {}
|
||||||
|
|
||||||
|
SkSVGStopColor(const SkSVGStopColor&) = default;
|
||||||
|
SkSVGStopColor& operator=(const SkSVGStopColor&) = default;
|
||||||
|
|
||||||
|
bool operator==(const SkSVGStopColor& other) const {
|
||||||
|
return fType == other.fType && fColor == other.fColor;
|
||||||
|
}
|
||||||
|
bool operator!=(const SkSVGStopColor& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
const SkSVGColorType& color() const { SkASSERT(fType == Type::kColor); return fColor; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
SkSVGColorType fColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGTypes_DEFINED
|
47
modules/svg/include/SkSVGUse.h
Normal file
47
modules/svg/include/SkSVGUse.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGUse_DEFINED
|
||||||
|
#define SkSVGUse_DEFINED
|
||||||
|
|
||||||
|
#include "modules/svg/include/SkSVGTransformableNode.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements support for <use> (reference) elements.
|
||||||
|
* (https://www.w3.org/TR/SVG11/struct.html#UseElement)
|
||||||
|
*/
|
||||||
|
class SkSVGUse final : public SkSVGTransformableNode {
|
||||||
|
public:
|
||||||
|
~SkSVGUse() override = default;
|
||||||
|
|
||||||
|
static sk_sp<SkSVGUse> Make() { return sk_sp<SkSVGUse>(new SkSVGUse()); }
|
||||||
|
|
||||||
|
void appendChild(sk_sp<SkSVGNode>) override;
|
||||||
|
|
||||||
|
void setHref(const SkSVGStringType&);
|
||||||
|
void setX(const SkSVGLength&);
|
||||||
|
void setY(const SkSVGLength&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
|
||||||
|
|
||||||
|
bool onPrepareToRender(SkSVGRenderContext*) const override;
|
||||||
|
void onRender(const SkSVGRenderContext&) const override;
|
||||||
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkSVGUse();
|
||||||
|
|
||||||
|
SkSVGStringType fHref;
|
||||||
|
SkSVGLength fX = SkSVGLength(0);
|
||||||
|
SkSVGLength fY = SkSVGLength(0);
|
||||||
|
|
||||||
|
using INHERITED = SkSVGTransformableNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SkSVGUse_DEFINED
|
97
modules/svg/include/SkSVGValue.h
Normal file
97
modules/svg/include/SkSVGValue.h
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SkSVGValue_DEFINED
|
||||||
|
#define SkSVGValue_DEFINED
|
||||||
|
|
||||||
|
#include "include/core/SkColor.h"
|
||||||
|
#include "include/core/SkMatrix.h"
|
||||||
|
#include "include/core/SkPath.h"
|
||||||
|
#include "include/core/SkTypes.h"
|
||||||
|
#include "include/private/SkNoncopyable.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
|
class SkSVGValue : public SkNoncopyable {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
kClip,
|
||||||
|
kColor,
|
||||||
|
kDashArray,
|
||||||
|
kFillRule,
|
||||||
|
kLength,
|
||||||
|
kLineCap,
|
||||||
|
kLineJoin,
|
||||||
|
kNumber,
|
||||||
|
kPaint,
|
||||||
|
kPath,
|
||||||
|
kPoints,
|
||||||
|
kSpreadMethod,
|
||||||
|
kStopColor,
|
||||||
|
kString,
|
||||||
|
kTransform,
|
||||||
|
kViewBox,
|
||||||
|
kVisibility,
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type() const { return fType; }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
const T* as() const {
|
||||||
|
return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SkSVGValue(Type t) : fType(t) { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type fType;
|
||||||
|
|
||||||
|
using INHERITED = SkNoncopyable;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, SkSVGValue::Type ValueType>
|
||||||
|
class SkSVGWrapperValue final : public SkSVGValue {
|
||||||
|
public:
|
||||||
|
static constexpr Type TYPE = ValueType;
|
||||||
|
|
||||||
|
explicit SkSVGWrapperValue(const T& v)
|
||||||
|
: INHERITED(ValueType)
|
||||||
|
, fWrappedValue(v) { }
|
||||||
|
|
||||||
|
operator const T&() const { return fWrappedValue; }
|
||||||
|
const T* operator->() const { return &fWrappedValue; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Stack-only
|
||||||
|
void* operator new(size_t) = delete;
|
||||||
|
void* operator new(size_t, void*) = delete;
|
||||||
|
|
||||||
|
const T& fWrappedValue;
|
||||||
|
|
||||||
|
using INHERITED = SkSVGValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
using SkSVGClipValue = SkSVGWrapperValue<SkSVGClip , SkSVGValue::Type::kClip >;
|
||||||
|
using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue::Type::kColor >;
|
||||||
|
using SkSVGFillRuleValue = SkSVGWrapperValue<SkSVGFillRule , SkSVGValue::Type::kFillRule >;
|
||||||
|
using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue::Type::kLength >;
|
||||||
|
using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::kPath >;
|
||||||
|
using SkSVGTransformValue = SkSVGWrapperValue<SkSVGTransformType, SkSVGValue::Type::kTransform >;
|
||||||
|
using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType , SkSVGValue::Type::kViewBox >;
|
||||||
|
using SkSVGPaintValue = SkSVGWrapperValue<SkSVGPaint , SkSVGValue::Type::kPaint >;
|
||||||
|
using SkSVGLineCapValue = SkSVGWrapperValue<SkSVGLineCap , SkSVGValue::Type::kLineCap >;
|
||||||
|
using SkSVGLineJoinValue = SkSVGWrapperValue<SkSVGLineJoin , SkSVGValue::Type::kLineJoin >;
|
||||||
|
using SkSVGNumberValue = SkSVGWrapperValue<SkSVGNumberType , SkSVGValue::Type::kNumber >;
|
||||||
|
using SkSVGPointsValue = SkSVGWrapperValue<SkSVGPointsType , SkSVGValue::Type::kPoints >;
|
||||||
|
using SkSVGStringValue = SkSVGWrapperValue<SkSVGStringType , SkSVGValue::Type::kString >;
|
||||||
|
using SkSVGSpreadMethodValue = SkSVGWrapperValue<SkSVGSpreadMethod ,
|
||||||
|
SkSVGValue::Type::kSpreadMethod>;
|
||||||
|
using SkSVGStopColorValue = SkSVGWrapperValue<SkSVGStopColor , SkSVGValue::Type::kStopColor >;
|
||||||
|
using SkSVGVisibilityValue = SkSVGWrapperValue<SkSVGVisibility , SkSVGValue::Type::kVisibility>;
|
||||||
|
using SkSVGDashArrayValue = SkSVGWrapperValue<SkSVGDashArray , SkSVGValue::Type::kDashArray >;
|
||||||
|
|
||||||
|
#endif // SkSVGValue_DEFINED
|
@ -5,7 +5,7 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGAttribute.h"
|
#include "modules/svg/include/SkSVGAttribute.h"
|
||||||
|
|
||||||
SkSVGPresentationAttributes SkSVGPresentationAttributes::MakeInitial() {
|
SkSVGPresentationAttributes SkSVGPresentationAttributes::MakeInitial() {
|
||||||
SkSVGPresentationAttributes result;
|
SkSVGPresentationAttributes result;
|
@ -5,9 +5,9 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGAttributeParser.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "include/utils/SkParse.h"
|
#include "include/utils/SkParse.h"
|
||||||
|
#include "modules/svg/include/SkSVGAttributeParser.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGCircle.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGCircle.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGCircle::SkSVGCircle() : INHERITED(SkSVGTag::kCircle) {}
|
SkSVGCircle::SkSVGCircle() : INHERITED(SkSVGTag::kCircle) {}
|
||||||
|
|
@ -5,6 +5,6 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGClipPath.h"
|
#include "modules/svg/include/SkSVGClipPath.h"
|
||||||
|
|
||||||
SkSVGClipPath::SkSVGClipPath() : INHERITED(SkSVGTag::kClipPath) {}
|
SkSVGClipPath::SkSVGClipPath() : INHERITED(SkSVGTag::kClipPath) {}
|
@ -5,7 +5,7 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGContainer.h"
|
#include "modules/svg/include/SkSVGContainer.h"
|
||||||
|
|
||||||
#include "include/core/SkPath.h"
|
#include "include/core/SkPath.h"
|
||||||
#include "include/pathops/SkPathOps.h"
|
#include "include/pathops/SkPathOps.h"
|
@ -5,32 +5,32 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGAttributeParser.h"
|
|
||||||
#include "experimental/svg/model/SkSVGCircle.h"
|
|
||||||
#include "experimental/svg/model/SkSVGClipPath.h"
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "experimental/svg/model/SkSVGDefs.h"
|
|
||||||
#include "experimental/svg/model/SkSVGEllipse.h"
|
|
||||||
#include "experimental/svg/model/SkSVGG.h"
|
|
||||||
#include "experimental/svg/model/SkSVGLine.h"
|
|
||||||
#include "experimental/svg/model/SkSVGLinearGradient.h"
|
|
||||||
#include "experimental/svg/model/SkSVGNode.h"
|
|
||||||
#include "experimental/svg/model/SkSVGPath.h"
|
|
||||||
#include "experimental/svg/model/SkSVGPattern.h"
|
|
||||||
#include "experimental/svg/model/SkSVGPoly.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRadialGradient.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRect.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGSVG.h"
|
|
||||||
#include "experimental/svg/model/SkSVGStop.h"
|
|
||||||
#include "experimental/svg/model/SkSVGText.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "experimental/svg/model/SkSVGUse.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkString.h"
|
#include "include/core/SkString.h"
|
||||||
#include "include/private/SkTo.h"
|
#include "include/private/SkTo.h"
|
||||||
#include "include/utils/SkParsePath.h"
|
#include "include/utils/SkParsePath.h"
|
||||||
|
#include "modules/svg/include/SkSVGAttributeParser.h"
|
||||||
|
#include "modules/svg/include/SkSVGCircle.h"
|
||||||
|
#include "modules/svg/include/SkSVGClipPath.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
|
#include "modules/svg/include/SkSVGDefs.h"
|
||||||
|
#include "modules/svg/include/SkSVGEllipse.h"
|
||||||
|
#include "modules/svg/include/SkSVGG.h"
|
||||||
|
#include "modules/svg/include/SkSVGLine.h"
|
||||||
|
#include "modules/svg/include/SkSVGLinearGradient.h"
|
||||||
|
#include "modules/svg/include/SkSVGNode.h"
|
||||||
|
#include "modules/svg/include/SkSVGPath.h"
|
||||||
|
#include "modules/svg/include/SkSVGPattern.h"
|
||||||
|
#include "modules/svg/include/SkSVGPoly.h"
|
||||||
|
#include "modules/svg/include/SkSVGRadialGradient.h"
|
||||||
|
#include "modules/svg/include/SkSVGRect.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGSVG.h"
|
||||||
|
#include "modules/svg/include/SkSVGStop.h"
|
||||||
|
#include "modules/svg/include/SkSVGText.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
#include "modules/svg/include/SkSVGUse.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
#include "src/core/SkTSearch.h"
|
#include "src/core/SkTSearch.h"
|
||||||
#include "src/xml/SkDOM.h"
|
#include "src/xml/SkDOM.h"
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGEllipse.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGEllipse.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGEllipse::SkSVGEllipse() : INHERITED(SkSVGTag::kEllipse) {}
|
SkSVGEllipse::SkSVGEllipse() : INHERITED(SkSVGTag::kEllipse) {}
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGGradient.h"
|
#include "modules/svg/include/SkSVGGradient.h"
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
#include "experimental/svg/model/SkSVGStop.h"
|
#include "modules/svg/include/SkSVGStop.h"
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
void SkSVGGradient::setHref(const SkSVGStringType& href) {
|
void SkSVGGradient::setHref(const SkSVGStringType& href) {
|
||||||
fHref = std::move(href);
|
fHref = std::move(href);
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGLine.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGLine.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGLine::SkSVGLine() : INHERITED(SkSVGTag::kLine) {}
|
SkSVGLine::SkSVGLine() : INHERITED(SkSVGTag::kLine) {}
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGLinearGradient.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/effects/SkGradientShader.h"
|
#include "include/effects/SkGradientShader.h"
|
||||||
|
#include "modules/svg/include/SkSVGLinearGradient.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGLinearGradient::SkSVGLinearGradient() : INHERITED(SkSVGTag::kLinearGradient) {}
|
SkSVGLinearGradient::SkSVGLinearGradient() : INHERITED(SkSVGTag::kLinearGradient) {}
|
||||||
|
|
@ -5,12 +5,12 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGNode.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkMatrix.h"
|
#include "include/core/SkMatrix.h"
|
||||||
#include "include/pathops/SkPathOps.h"
|
#include "include/pathops/SkPathOps.h"
|
||||||
|
#include "modules/svg/include/SkSVGNode.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
#include "src/core/SkTLazy.h"
|
#include "src/core/SkTLazy.h"
|
||||||
|
|
||||||
SkSVGNode::SkSVGNode(SkSVGTag t) : fTag(t) { }
|
SkSVGNode::SkSVGNode(SkSVGTag t) : fTag(t) { }
|
@ -5,11 +5,11 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGPath.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkPaint.h"
|
#include "include/core/SkPaint.h"
|
||||||
|
#include "modules/svg/include/SkSVGPath.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGPath::SkSVGPath() : INHERITED(SkSVGTag::kPath) { }
|
SkSVGPath::SkSVGPath() : INHERITED(SkSVGTag::kPath) { }
|
||||||
|
|
@ -5,12 +5,12 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGPattern.h"
|
#include "modules/svg/include/SkSVGPattern.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkPictureRecorder.h"
|
#include "include/core/SkPictureRecorder.h"
|
||||||
#include "include/core/SkShader.h"
|
#include "include/core/SkShader.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGPattern::SkSVGPattern() : INHERITED(SkSVGTag::kPattern) {}
|
SkSVGPattern::SkSVGPattern() : INHERITED(SkSVGTag::kPattern) {}
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGPoly.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGPoly.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
#include "src/core/SkTLazy.h"
|
#include "src/core/SkTLazy.h"
|
||||||
|
|
||||||
SkSVGPoly::SkSVGPoly(SkSVGTag t) : INHERITED(t) {}
|
SkSVGPoly::SkSVGPoly(SkSVGTag t) : INHERITED(t) {}
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRadialGradient.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/effects/SkGradientShader.h"
|
#include "include/effects/SkGradientShader.h"
|
||||||
|
#include "modules/svg/include/SkSVGRadialGradient.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGRadialGradient::SkSVGRadialGradient() : INHERITED(SkSVGTag::kRadialGradient) {}
|
SkSVGRadialGradient::SkSVGRadialGradient() : INHERITED(SkSVGTag::kRadialGradient) {}
|
||||||
|
|
@ -5,11 +5,11 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRect.h"
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkRect.h"
|
#include "include/core/SkRect.h"
|
||||||
|
#include "modules/svg/include/SkSVGRect.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGRect::SkSVGRect() : INHERITED(SkSVGTag::kRect) {}
|
SkSVGRect::SkSVGRect() : INHERITED(SkSVGTag::kRect) {}
|
||||||
|
|
@ -5,15 +5,15 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGAttribute.h"
|
|
||||||
#include "experimental/svg/model/SkSVGNode.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTypes.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkPath.h"
|
#include "include/core/SkPath.h"
|
||||||
#include "include/effects/SkDashPathEffect.h"
|
#include "include/effects/SkDashPathEffect.h"
|
||||||
#include "include/private/SkTo.h"
|
#include "include/private/SkTo.h"
|
||||||
|
#include "modules/svg/include/SkSVGAttribute.h"
|
||||||
|
#include "modules/svg/include/SkSVGNode.h"
|
||||||
|
#include "modules/svg/include/SkSVGTypes.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGSVG.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGSVG.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGSVG::SkSVGSVG() : INHERITED(SkSVGTag::kSvg) { }
|
SkSVGSVG::SkSVGSVG() : INHERITED(SkSVGTag::kSvg) { }
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
#include "experimental/svg/model/SkSVGShape.h"
|
#include "modules/svg/include/SkSVGShape.h"
|
||||||
|
|
||||||
SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {}
|
SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {}
|
||||||
|
|
@ -5,9 +5,9 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
#include "experimental/svg/model/SkSVGStop.h"
|
#include "modules/svg/include/SkSVGStop.h"
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGStop::SkSVGStop() : INHERITED(SkSVGTag::kStop) {}
|
SkSVGStop::SkSVGStop() : INHERITED(SkSVGTag::kStop) {}
|
||||||
|
|
@ -5,13 +5,13 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGText.h"
|
#include "modules/svg/include/SkSVGText.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkFontStyle.h"
|
#include "include/core/SkFontStyle.h"
|
||||||
#include "include/core/SkString.h"
|
#include "include/core/SkString.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGText::SkSVGText() : INHERITED(SkSVGTag::kText) {}
|
SkSVGText::SkSVGText() : INHERITED(SkSVGTag::kText) {}
|
||||||
|
|
@ -5,10 +5,10 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGTransformableNode.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGTransformableNode.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGTransformableNode::SkSVGTransformableNode(SkSVGTag tag)
|
SkSVGTransformableNode::SkSVGTransformableNode(SkSVGTag tag)
|
||||||
: INHERITED(tag)
|
: INHERITED(tag)
|
@ -5,11 +5,11 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGUse.h"
|
#include "modules/svg/include/SkSVGUse.h"
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGRenderContext.h"
|
|
||||||
#include "experimental/svg/model/SkSVGValue.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGRenderContext.h"
|
||||||
|
#include "modules/svg/include/SkSVGValue.h"
|
||||||
|
|
||||||
SkSVGUse::SkSVGUse() : INHERITED(SkSVGTag::kUse) {}
|
SkSVGUse::SkSVGUse() : INHERITED(SkSVGTag::kUse) {}
|
||||||
|
|
67
modules/svg/svg.gni
Normal file
67
modules/svg/svg.gni
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Copyright 2020 Google Inc.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
# Things are easiest for everyone if these source paths are absolute.
|
||||||
|
_src = get_path_info("src", "abspath")
|
||||||
|
_include = get_path_info("include", "abspath")
|
||||||
|
|
||||||
|
skia_svg_public = [
|
||||||
|
"$_include/SkSVGAttribute.h",
|
||||||
|
"$_include/SkSVGAttributeParser.h",
|
||||||
|
"$_include/SkSVGCircle.h",
|
||||||
|
"$_include/SkSVGClipPath.h",
|
||||||
|
"$_include/SkSVGContainer.h",
|
||||||
|
"$_include/SkSVGDefs.h",
|
||||||
|
"$_include/SkSVGDOM.h",
|
||||||
|
"$_include/SkSVGEllipse.h",
|
||||||
|
"$_include/SkSVGG.h",
|
||||||
|
"$_include/SkSVGGradient.h",
|
||||||
|
"$_include/SkSVGHiddenContainer.h",
|
||||||
|
"$_include/SkSVGIDMapper.h",
|
||||||
|
"$_include/SkSVGLinearGradient.h",
|
||||||
|
"$_include/SkSVGLine.h",
|
||||||
|
"$_include/SkSVGNode.h",
|
||||||
|
"$_include/SkSVGPath.h",
|
||||||
|
"$_include/SkSVGPattern.h",
|
||||||
|
"$_include/SkSVGPoly.h",
|
||||||
|
"$_include/SkSVGRadialGradient.h",
|
||||||
|
"$_include/SkSVGRect.h",
|
||||||
|
"$_include/SkSVGRenderContext.h",
|
||||||
|
"$_include/SkSVGShape.h",
|
||||||
|
"$_include/SkSVGStop.h",
|
||||||
|
"$_include/SkSVGSVG.h",
|
||||||
|
"$_include/SkSVGText.h",
|
||||||
|
"$_include/SkSVGTransformableNode.h",
|
||||||
|
"$_include/SkSVGTypes.h",
|
||||||
|
"$_include/SkSVGUse.h",
|
||||||
|
"$_include/SkSVGValue.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
skia_svg_sources = [
|
||||||
|
"$_src/SkSVGAttribute.cpp",
|
||||||
|
"$_src/SkSVGAttributeParser.cpp",
|
||||||
|
"$_src/SkSVGCircle.cpp",
|
||||||
|
"$_src/SkSVGClipPath.cpp",
|
||||||
|
"$_src/SkSVGContainer.cpp",
|
||||||
|
"$_src/SkSVGDOM.cpp",
|
||||||
|
"$_src/SkSVGEllipse.cpp",
|
||||||
|
"$_src/SkSVGGradient.cpp",
|
||||||
|
"$_src/SkSVGLine.cpp",
|
||||||
|
"$_src/SkSVGLinearGradient.cpp",
|
||||||
|
"$_src/SkSVGNode.cpp",
|
||||||
|
"$_src/SkSVGPath.cpp",
|
||||||
|
"$_src/SkSVGPattern.cpp",
|
||||||
|
"$_src/SkSVGPoly.cpp",
|
||||||
|
"$_src/SkSVGRadialGradient.cpp",
|
||||||
|
"$_src/SkSVGRect.cpp",
|
||||||
|
"$_src/SkSVGRenderContext.cpp",
|
||||||
|
"$_src/SkSVGSVG.cpp",
|
||||||
|
"$_src/SkSVGShape.cpp",
|
||||||
|
"$_src/SkSVGStop.cpp",
|
||||||
|
"$_src/SkSVGText.cpp",
|
||||||
|
"$_src/SkSVGTransformableNode.cpp",
|
||||||
|
"$_src/SkSVGUse.cpp",
|
||||||
|
"$_src/SkSVGValue.cpp",
|
||||||
|
]
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/core/SkMatrix.h"
|
#include "include/core/SkMatrix.h"
|
||||||
#include "include/core/SkStream.h"
|
#include "include/core/SkStream.h"
|
||||||
#include "include/core/SkSurface.h"
|
#include "include/core/SkSurface.h"
|
||||||
#include "include/encode/SkPngEncoder.h"
|
#include "include/encode/SkPngEncoder.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "tools/flags/CommandLineFlags.h"
|
#include "tools/flags/CommandLineFlags.h"
|
||||||
|
|
||||||
static DEFINE_string2(input , i, nullptr, "Input SVG file.");
|
static DEFINE_string2(input , i, nullptr, "Input SVG file.");
|
15
public.bzl
15
public.bzl
@ -566,12 +566,13 @@ DM_SRCS_ALL = struct(
|
|||||||
"dm/*.h",
|
"dm/*.h",
|
||||||
"experimental/pipe/*.cpp",
|
"experimental/pipe/*.cpp",
|
||||||
"experimental/pipe/*.h",
|
"experimental/pipe/*.h",
|
||||||
"experimental/svg/model/*.cpp",
|
|
||||||
"experimental/svg/model/*.h",
|
|
||||||
"gm/*.cpp",
|
"gm/*.cpp",
|
||||||
"gm/*.h",
|
"gm/*.h",
|
||||||
"gm/verifiers/*.cpp",
|
"gm/verifiers/*.cpp",
|
||||||
"gm/verifiers/*.h",
|
"gm/verifiers/*.h",
|
||||||
|
# TODO(fmalita): SVG sources should not be included here
|
||||||
|
"modules/svg/include/*.h",
|
||||||
|
"modules/svg/src/*.cpp",
|
||||||
"src/utils/SkMultiPictureDocument.cpp",
|
"src/utils/SkMultiPictureDocument.cpp",
|
||||||
"src/xml/*.cpp",
|
"src/xml/*.cpp",
|
||||||
"tests/*.cpp",
|
"tests/*.cpp",
|
||||||
@ -987,17 +988,21 @@ SKOTTIE_IOS_LIB_SDK_FRAMEWORKS = [
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def svg_lib_hdrs():
|
def svg_lib_hdrs():
|
||||||
return native.glob(["experimental/svg/model/*.h"])
|
return native.glob([
|
||||||
|
# transitional headers, to be removed
|
||||||
|
"experimental/svg/model/*.h",
|
||||||
|
"modules/svg/include/*.h",
|
||||||
|
])
|
||||||
|
|
||||||
def svg_lib_srcs():
|
def svg_lib_srcs():
|
||||||
return native.glob(["experimental/svg/model/*.cpp"])
|
return native.glob(["modules/svg/src/*.cpp"])
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## svg_tool
|
## svg_tool
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
SVG_TOOL_SRCS = [
|
SVG_TOOL_SRCS = [
|
||||||
"experimental/svg/utils/SvgTool.cpp",
|
"modules/svg/utils/SvgTool.cpp",
|
||||||
# TODO(benjaminwagner): Add "flags" target.
|
# TODO(benjaminwagner): Add "flags" target.
|
||||||
"tools/flags/CommandLineFlags.cpp",
|
"tools/flags/CommandLineFlags.cpp",
|
||||||
"tools/flags/CommandLineFlags.h",
|
"tools/flags/CommandLineFlags.h",
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkRect.h"
|
#include "include/core/SkRect.h"
|
||||||
#include "include/core/SkStream.h"
|
#include "include/core/SkStream.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "samplecode/Sample.h"
|
#include "samplecode/Sample.h"
|
||||||
#include "src/core/SkOSFile.h"
|
#include "src/core/SkOSFile.h"
|
||||||
#include "src/utils/SkOSPath.h"
|
#include "src/utils/SkOSPath.h"
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkStream.h"
|
#include "include/core/SkStream.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "samplecode/Sample.h"
|
#include "samplecode/Sample.h"
|
||||||
#include "src/core/SkOSFile.h"
|
#include "src/core/SkOSFile.h"
|
||||||
#include "src/utils/SkOSPath.h"
|
#include "src/utils/SkOSPath.h"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright 2019 Google LLC.
|
// Copyright 2019 Google LLC.
|
||||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "gm/gm.h"
|
#include "gm/gm.h"
|
||||||
#include "include/codec/SkCodec.h"
|
#include "include/codec/SkCodec.h"
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
@ -13,6 +12,7 @@
|
|||||||
#include "include/gpu/GrContextOptions.h"
|
#include "include/gpu/GrContextOptions.h"
|
||||||
#include "include/gpu/GrDirectContext.h"
|
#include "include/gpu/GrDirectContext.h"
|
||||||
#include "include/private/SkTHash.h"
|
#include "include/private/SkTHash.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "src/core/SkColorSpacePriv.h"
|
#include "src/core/SkColorSpacePriv.h"
|
||||||
#include "src/core/SkMD5.h"
|
#include "src/core/SkMD5.h"
|
||||||
#include "src/core/SkOSFile.h"
|
#include "src/core/SkOSFile.h"
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
|
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
|
||||||
#include "include/core/SkBitmap.h"
|
#include "include/core/SkBitmap.h"
|
||||||
#include "include/core/SkCanvas.h"
|
#include "include/core/SkCanvas.h"
|
||||||
#include "include/core/SkColor.h"
|
#include "include/core/SkColor.h"
|
||||||
@ -30,6 +29,7 @@
|
|||||||
#include "include/private/SkTDArray.h"
|
#include "include/private/SkTDArray.h"
|
||||||
#include "include/private/SkTemplates.h"
|
#include "include/private/SkTemplates.h"
|
||||||
#include "include/utils/SkNoDrawCanvas.h"
|
#include "include/utils/SkNoDrawCanvas.h"
|
||||||
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "src/core/SkAdvancedTypefaceMetrics.h"
|
#include "src/core/SkAdvancedTypefaceMetrics.h"
|
||||||
#include "src/core/SkFontDescriptor.h"
|
#include "src/core/SkFontDescriptor.h"
|
||||||
#include "src/core/SkFontPriv.h"
|
#include "src/core/SkFontPriv.h"
|
||||||
|
@ -39,7 +39,8 @@ roots = [
|
|||||||
# Don't count our local Vulkan headers as Skia headers;
|
# Don't count our local Vulkan headers as Skia headers;
|
||||||
# we don't want #include <vulkan/vulkan_foo.h> rewritten to point to them.
|
# we don't want #include <vulkan/vulkan_foo.h> rewritten to point to them.
|
||||||
# Nor do we care about things in node_modules, used by *Kits.
|
# Nor do we care about things in node_modules, used by *Kits.
|
||||||
ignorelist = ['include/third_party/vulkan', 'node_modules']
|
# Also ignore transitional SVG headers.
|
||||||
|
ignorelist = ['include/third_party/vulkan', 'node_modules', 'experimental/svg/model']
|
||||||
|
|
||||||
assert '/' in [os.sep, os.altsep]
|
assert '/' in [os.sep, os.altsep]
|
||||||
def fix_path(p):
|
def fix_path(p):
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "tools/gpu/GrContextFactory.h"
|
#include "tools/gpu/GrContextFactory.h"
|
||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "src/xml/SkDOM.h"
|
#include "src/xml/SkDOM.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
#include "experimental/svg/model/SkSVGDOM.h"
|
#include "modules/svg/include/SkSVGDOM.h"
|
||||||
#include "src/xml/SkDOM.h"
|
#include "src/xml/SkDOM.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user