2017-10-09 19:14:13 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "experimental/svg/model/SkSVGHiddenContainer.h"
|
|
|
|
#include "experimental/svg/model/SkSVGTypes.h"
|
|
|
|
#include "include/core/SkShader.h"
|
2017-10-09 19:14:13 +00:00
|
|
|
|
|
|
|
class SkMatrix;
|
|
|
|
class SkSVGRenderContext;
|
|
|
|
|
|
|
|
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,
|
2019-04-03 14:27:45 +00:00
|
|
|
SkTileMode, const SkMatrix& localMatrix) const = 0;
|
2017-10-09 19:14:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
using StopPositionArray = SkSTArray<2, SkScalar, true>;
|
|
|
|
using StopColorArray = SkSTArray<2, SkColor, true>;
|
|
|
|
void collectColorStops(const SkSVGRenderContext&, StopPositionArray*, StopColorArray*) const;
|
|
|
|
|
|
|
|
SkSVGStringType fHref;
|
|
|
|
SkSVGTransformType fGradientTransform = SkSVGTransformType(SkMatrix::I());
|
|
|
|
SkSVGSpreadMethod fSpreadMethod = SkSVGSpreadMethod(SkSVGSpreadMethod::Type::kPad);
|
|
|
|
|
|
|
|
typedef SkSVGHiddenContainer INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkSVGGradient_DEFINED
|