chromium/third_party/skia/modules/skottie/src/effects/HueSaturationEffect.cpp

/*
 * Copyright 2019 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "include/core/SkColorFilter.h"
#include "include/core/SkData.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkString.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkTPin.h"
#include "modules/skottie/src/SkottiePriv.h"
#include "modules/skottie/src/animator/Animator.h"
#include "modules/skottie/src/effects/Effects.h"
#include "modules/sksg/include/SkSGColorFilter.h"
#include "modules/sksg/include/SkSGRenderNode.h"

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <utility>

namespace skjson {
class ArrayValue;
}

namespace skottie::internal {
namespace {

// AE Saturation semantics:
//
//   - saturation is applied as a component-wise scale (interpolation/extrapolation)
//     relative to chroma mid point
//   - the scale factor is clamped such that none of the components over/under saturates
//     (e.g. below G/R and B are constrained to low_range and high_range, respectively)
//   - the scale is also clammped to a maximum value of 126, empirically
//   - the control is mapped linearly when desaturating, and non-linearly (1/1-S) when saturating
//
// 0               G    R                  B                                   1
// |---------------+----+------------------+-----------------------------------|
//                 |           |           |
//                min         mid         max
//                  <------- chroma ------>
//  <------- low_range -------> <---------------- high_range ----------------->
//
// With some care, we can stay in premul for these calculations.
static constexpr char gSaturateSkSL[] =;

static sk_sp<SkColorFilter> make_saturate(float chroma_scale) {}

class HueSaturationEffectAdapter final : public AnimatablePropertyContainer {};

} // namespace

sk_sp<sksg::RenderNode> EffectBuilder::attachHueSaturationEffect(
        const skjson::ArrayValue& jprops, sk_sp<sksg::RenderNode> layer) const {}

} // namespace skottie::internal