summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/include/private/SkGainmapShader.h
blob: f490ab96a4cfc9a8cbc4aaa1707353e887f125d4 (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
50
51
52
53
/*
 * Copyright 2023 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkGainmapShader_DEFINED
#define SkGainmapShader_DEFINED

#include "include/core/SkRefCnt.h"

class SkColorSpace;
class SkShader;
class SkImage;
struct SkGainmapInfo;
struct SkRect;
struct SkSamplingOptions;

/**
 *  A gainmap shader will apply a gainmap to an base image using the math described alongside the
 *  definition of SkGainmapInfo.
 */
class SK_API SkGainmapShader {
public:
    /**
     *  Make a gainmap shader.
     *
     *  When sampling the base image baseImage, the rectangle baseRect will be sampled to map to
     *  the rectangle dstRect. Sampling will be done according to baseSamplingOptions.
     *
     *  When sampling the gainmap image gainmapImage, the rectangle gainmapRect will be sampled to
     *  map to the rectangle dstRect. Sampling will be done according to gainmapSamplingOptions.
     *
     *  The gainmap will be applied according to the HDR to SDR ratio specified in dstHdrRatio.
     *
     *  This shader must know the color space of the canvas that it will be rendered to. This color
     *  space must be specified in dstColorSpace.
     *  TODO(ccameron): Remove the need for dstColorSpace.
     */
    static sk_sp<SkShader> Make(const sk_sp<const SkImage>& baseImage,
                                const SkRect& baseRect,
                                const SkSamplingOptions& baseSamplingOptions,
                                const sk_sp<const SkImage>& gainmapImage,
                                const SkRect& gainmapRect,
                                const SkSamplingOptions& gainmapSamplingOptions,
                                const SkGainmapInfo& gainmapInfo,
                                const SkRect& dstRect,
                                float dstHdrRatio,
                                sk_sp<SkColorSpace> dstColorSpace);
};

#endif