#include "third_party/blink/renderer/platform/graphics/gradient.h"
#include <algorithm>
#include <optional>
#include "third_party/blink/renderer/platform/geometry/blend.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_settings_builder.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_shader.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
namespace blink {
Gradient::Gradient(Type type,
GradientSpreadMethod spread_method,
ColorInterpolation interpolation,
DegenerateHandling degenerate_handling)
: … { … }
Gradient::~Gradient() = default;
static inline bool CompareStops(const Gradient::ColorStop& a,
const Gradient::ColorStop& b) { … }
void Gradient::AddColorStop(const Gradient::ColorStop& stop) { … }
void Gradient::AddColorStops(const Vector<Gradient::ColorStop>& stops) { … }
void Gradient::SortStopsIfNecessary() const { … }
static SkColor4f ResolveStopColorWithMissingParams(
const Color& color,
const Color& neighbor,
Color::ColorSpace color_space,
const cc::ColorFilter* color_filter) { … }
void Gradient::FillSkiaStops(ColorBuffer& colors, OffsetBuffer& pos) const { … }
SkGradientShader::Interpolation Gradient::ResolveSkInterpolation() const { … }
sk_sp<PaintShader> Gradient::CreateShaderInternal(
const SkMatrix& local_matrix) { … }
void Gradient::ApplyToFlags(cc::PaintFlags& flags,
const SkMatrix& local_matrix,
const ImageDrawOptions& draw_options) { … }
DarkModeFilter& Gradient::EnsureDarkModeFilter() { … }
namespace {
class LinearGradient final : public Gradient { … };
class RadialGradient final : public Gradient { … };
class ConicGradient final : public Gradient { … };
}
scoped_refptr<Gradient> Gradient::CreateLinear(
const gfx::PointF& p0,
const gfx::PointF& p1,
GradientSpreadMethod spread_method,
ColorInterpolation interpolation,
DegenerateHandling degenerate_handling) { … }
scoped_refptr<Gradient> Gradient::CreateRadial(
const gfx::PointF& p0,
float r0,
const gfx::PointF& p1,
float r1,
float aspect_ratio,
GradientSpreadMethod spread_method,
ColorInterpolation interpolation,
DegenerateHandling degenerate_handling) { … }
scoped_refptr<Gradient> Gradient::CreateConic(
const gfx::PointF& position,
float rotation,
float start_angle,
float end_angle,
GradientSpreadMethod spread_method,
ColorInterpolation interpolation,
DegenerateHandling degenerate_handling) { … }
}