aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/sksg/paint
diff options
context:
space:
mode:
Diffstat (limited to 'experimental/sksg/paint')
-rw-r--r--experimental/sksg/paint/SkSGColor.cpp18
-rw-r--r--experimental/sksg/paint/SkSGColor.h37
-rw-r--r--experimental/sksg/paint/SkSGGradient.cpp60
-rw-r--r--experimental/sksg/paint/SkSGGradient.h105
4 files changed, 0 insertions, 220 deletions
diff --git a/experimental/sksg/paint/SkSGColor.cpp b/experimental/sksg/paint/SkSGColor.cpp
deleted file mode 100644
index d5d4d1ce62..0000000000
--- a/experimental/sksg/paint/SkSGColor.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSGColor.h"
-
-namespace sksg {
-
-Color::Color(SkColor c) : fColor(c) {}
-
-void Color::onApplyToPaint(SkPaint* paint) const {
- paint->setColor(fColor);
-}
-
-} // namespace sksg
diff --git a/experimental/sksg/paint/SkSGColor.h b/experimental/sksg/paint/SkSGColor.h
deleted file mode 100644
index a19921cfd3..0000000000
--- a/experimental/sksg/paint/SkSGColor.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 SkSGColor_DEFINED
-#define SkSGColor_DEFINED
-
-#include "SkSGPaintNode.h"
-
-#include "SkColor.h"
-
-namespace sksg {
-
-/**
- * Concrete Paint node, wrapping an SkColor.
- */
-class Color : public PaintNode {
-public:
- static sk_sp<Color> Make(SkColor c) { return sk_sp<Color>(new Color(c)); }
-
- SG_ATTRIBUTE(Color, SkColor, fColor)
-
-protected:
- void onApplyToPaint(SkPaint*) const override;
-
-private:
- explicit Color(SkColor);
-
- SkColor fColor;
-};
-
-} // namespace sksg
-
-#endif // SkSGColor_DEFINED
diff --git a/experimental/sksg/paint/SkSGGradient.cpp b/experimental/sksg/paint/SkSGGradient.cpp
deleted file mode 100644
index 98e7f395f8..0000000000
--- a/experimental/sksg/paint/SkSGGradient.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSGGradient.h"
-
-#include "SkGradientShader.h"
-#include "SkPaint.h"
-
-namespace sksg {
-
-void Gradient::onApplyToPaint(SkPaint* paint) const {
- if (fColorStops.empty()) {
- paint->setShader(nullptr);
- return;
- }
-
- std::vector<SkColor> colors;
- std::vector<SkScalar> positions;
- colors.reserve(fColorStops.size());
- positions.reserve(fColorStops.size());
-
- SkScalar position = 0;
- for (const auto& stop : fColorStops) {
- colors.push_back(stop.fColor);
- position = SkTPin(stop.fPosition, position, 1.0f);
- positions.push_back(position);
- }
-
- // TODO: detect even stop distributions, pass null for positions.
- paint->setShader(this->onMakeShader(colors, positions));
-}
-
-sk_sp<SkShader> LinearGradient::onMakeShader(const std::vector<SkColor>& colors,
- const std::vector<SkScalar>& positions) const {
- SkASSERT(colors.size() == positions.size());
-
- const SkPoint pts[] = { fStartPoint, fEndPoint };
- return SkGradientShader::MakeLinear(pts, colors.data(), positions.data(), colors.size(),
- this->getTileMode());
-}
-
-sk_sp<SkShader> RadialGradient::onMakeShader(const std::vector<SkColor>& colors,
- const std::vector<SkScalar>& positions) const {
- SkASSERT(colors.size() == positions.size());
-
- return (fStartRadius <= 0 && fStartCenter == fEndCenter)
- ? SkGradientShader::MakeRadial(fEndCenter, fEndRadius,
- colors.data(), positions.data(), colors.size(),
- this->getTileMode())
- : SkGradientShader::MakeTwoPointConical(fStartCenter, fStartRadius,
- fEndCenter, fEndRadius,
- colors.data(), positions.data(), colors.size(),
- this->getTileMode());
-}
-
-} //namespace sksg
diff --git a/experimental/sksg/paint/SkSGGradient.h b/experimental/sksg/paint/SkSGGradient.h
deleted file mode 100644
index d69cb1495c..0000000000
--- a/experimental/sksg/paint/SkSGGradient.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkSGGradient_DEFINED
-#define SkSGGradient_DEFINED
-
-#include "SkSGPaintNode.h"
-
-#include "SkColor.h"
-#include "SkPoint.h"
-#include "SkScalar.h"
-#include "SkShader.h"
-
-#include <vector>
-
-namespace sksg {
-
-/**
- * Gradient base class.
- */
-class Gradient : public PaintNode {
-public:
- struct ColorStop {
- SkScalar fPosition;
- SkColor fColor;
-
- bool operator==(const ColorStop& other) const {
- return fPosition == other.fPosition && fColor == other.fColor;
- }
- };
-
- SG_ATTRIBUTE(ColorStops, std::vector<ColorStop>, fColorStops)
- SG_ATTRIBUTE(TileMode , SkShader::TileMode , fTileMode )
-
-protected:
- void onApplyToPaint(SkPaint*) const final;
-
- virtual sk_sp<SkShader> onMakeShader(const std::vector<SkColor>& colors,
- const std::vector<SkScalar>& positions) const = 0;
-
-protected:
- Gradient() = default;
-
-private:
- std::vector<ColorStop> fColorStops;
- SkShader::TileMode fTileMode = SkShader::kClamp_TileMode;
-
- using INHERITED = PaintNode;
-};
-
-class LinearGradient final : public Gradient {
-public:
- static sk_sp<LinearGradient> Make() {
- return sk_sp<LinearGradient>(new LinearGradient());
- }
-
- SG_ATTRIBUTE(StartPoint, SkPoint, fStartPoint)
- SG_ATTRIBUTE(EndPoint , SkPoint, fEndPoint )
-
-protected:
- sk_sp<SkShader> onMakeShader(const std::vector<SkColor>& colors,
- const std::vector<SkScalar>& positions) const override;
-
-private:
- LinearGradient() = default;
-
- SkPoint fStartPoint = SkPoint::Make(0, 0),
- fEndPoint = SkPoint::Make(0, 0);
-
- using INHERITED = Gradient;
-};
-
-class RadialGradient final : public Gradient {
-public:
- static sk_sp<RadialGradient> Make() {
- return sk_sp<RadialGradient>(new RadialGradient());
- }
-
- SG_ATTRIBUTE(StartCenter, SkPoint , fStartCenter)
- SG_ATTRIBUTE(EndCenter , SkPoint , fEndCenter )
- SG_ATTRIBUTE(StartRadius, SkScalar, fStartRadius)
- SG_ATTRIBUTE(EndRadius , SkScalar, fEndRadius )
-
-protected:
- sk_sp<SkShader> onMakeShader(const std::vector<SkColor>& colors,
- const std::vector<SkScalar>& positions) const override;
-
-private:
- RadialGradient() = default;
-
- SkPoint fStartCenter = SkPoint::Make(0, 0),
- fEndCenter = SkPoint::Make(0, 0);
- SkScalar fStartRadius = 0,
- fEndRadius = 0;
-
- using INHERITED = Gradient;
-};
-
-} // namespace sksg
-
-#endif // SkSGGradient_DEFINED