2016-08-03 17:21:11 +00:00
|
|
|
/*
|
|
|
|
* 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 "SkSVGTypes.h"
|
|
|
|
|
|
|
|
class SkSVGAttributeParser : public SkNoncopyable {
|
|
|
|
public:
|
|
|
|
SkSVGAttributeParser(const char[]);
|
|
|
|
|
2016-08-08 18:38:55 +00:00
|
|
|
bool parseColor(SkSVGColorType*);
|
|
|
|
bool parseNumber(SkSVGNumberType*);
|
2016-08-03 17:21:11 +00:00
|
|
|
bool parseLength(SkSVGLength*);
|
2016-08-08 18:38:55 +00:00
|
|
|
bool parseViewBox(SkSVGViewBoxType*);
|
2016-08-08 19:58:57 +00:00
|
|
|
bool parseTransform(SkSVGTransformType*);
|
2016-08-11 16:16:29 +00:00
|
|
|
bool parsePaint(SkSVGPaint*);
|
|
|
|
bool parseLineCap(SkSVGLineCap*);
|
|
|
|
bool parseLineJoin(SkSVGLineJoin*);
|
2016-08-12 19:15:33 +00:00
|
|
|
bool parsePoints(SkSVGPointsType*);
|
2016-09-13 00:06:47 +00:00
|
|
|
bool parseIRI(SkSVGStringType*);
|
2016-08-03 17:21:11 +00:00
|
|
|
|
|
|
|
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 parseExpectedStringToken(const char*);
|
|
|
|
bool parseScalarToken(SkScalar*);
|
|
|
|
bool parseHexToken(uint32_t*);
|
|
|
|
bool parseLengthUnitToken(SkSVGLength::Unit*);
|
|
|
|
bool parseNamedColorToken(SkColor*);
|
|
|
|
bool parseHexColorToken(SkColor*);
|
2016-09-13 00:06:47 +00:00
|
|
|
bool parseColorComponentToken(int32_t*);
|
|
|
|
bool parseRGBColorToken(SkColor*);
|
|
|
|
bool parseFuncIRI(SkSVGStringType*);
|
2016-08-03 17:21:11 +00:00
|
|
|
|
2016-08-08 19:58:57 +00:00
|
|
|
// 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);
|
|
|
|
|
2016-08-03 17:21:11 +00:00
|
|
|
// The current position in the input string.
|
|
|
|
const char* fCurPos;
|
|
|
|
|
|
|
|
typedef SkNoncopyable INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkSVGAttributeParser_DEFINED
|