aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients/Sk4fLinearGradient.h
blob: 30292c361f0c24cc31e0aacae5170daf5de0481b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * 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 Sk4fLinearGradient_DEFINED
#define Sk4fLinearGradient_DEFINED

#include "Sk4fGradientBase.h"
#include "SkLinearGradient.h"

class SkLinearGradient::
LinearGradient4fContext final : public GradientShaderBase4fContext {
public:
    LinearGradient4fContext(const SkLinearGradient&, const ContextRec&);

    void shadeSpan(int x, int y, SkPMColor dst[], int count) override;
    void shadeSpan4f(int x, int y, SkPM4f dst[], int count) override;

protected:
    void mapTs(int x, int y, SkScalar ts[], int count) const override;

    bool onChooseBlitProcs(const SkImageInfo&, BlitState*) override;

private:
    using INHERITED = GradientShaderBase4fContext;

    template<typename DstType, SkColorProfileType, TileMode>
    class LinearIntervalProcessor;

    template <typename DstType, SkColorProfileType, ApplyPremul>
    void shadePremulSpan(int x, int y, DstType[], int count) const;

    template <typename DstType, SkColorProfileType, ApplyPremul, SkShader::TileMode tileMode>
    void shadeSpanInternal(int x, int y, DstType[], int count) const;

    const Interval* findInterval(SkScalar fx) const;

    bool isFast() const { return fDstToPosClass == kLinear_MatrixClass; }

    static void D32_BlitBW(BlitState*, int x, int y, const SkPixmap& dst, int count);
    static void D64_BlitBW(BlitState*, int x, int y, const SkPixmap& dst, int count);

    mutable const Interval*      fCachedInterval;
};

#endif // Sk4fLinearGradient_DEFINED