xref: /aosp_15_r20/external/skia/include/private/SkGainmapShader.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkGainmapShader_DEFINED
9 #define SkGainmapShader_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/private/base/SkAPI.h"
13 
14 class SkColorSpace;
15 class SkShader;
16 class SkImage;
17 struct SkGainmapInfo;
18 struct SkRect;
19 struct SkSamplingOptions;
20 
21 /**
22  *  A gainmap shader will apply a gainmap to an base image using the math described alongside the
23  *  definition of SkGainmapInfo.
24  */
25 class SK_API SkGainmapShader {
26 public:
27     /**
28      *  Make a gainmap shader.
29      *
30      *  When sampling the base image baseImage, the rectangle baseRect will be sampled to map to
31      *  the rectangle dstRect. Sampling will be done according to baseSamplingOptions.
32      *
33      *  When sampling the gainmap image gainmapImage, the rectangle gainmapRect will be sampled to
34      *  map to the rectangle dstRect. Sampling will be done according to gainmapSamplingOptions.
35      *
36      *  The gainmap will be applied according to the HDR to SDR ratio specified in dstHdrRatio.
37      *
38      *  This shader must know the color space of the canvas that it will be rendered to. This color
39      *  space must be specified in dstColorSpace.
40      *  TODO(ccameron): Remove the need for dstColorSpace.
41      */
42     static sk_sp<SkShader> Make(const sk_sp<const SkImage>& baseImage,
43                                 const SkRect& baseRect,
44                                 const SkSamplingOptions& baseSamplingOptions,
45                                 const sk_sp<const SkImage>& gainmapImage,
46                                 const SkRect& gainmapRect,
47                                 const SkSamplingOptions& gainmapSamplingOptions,
48                                 const SkGainmapInfo& gainmapInfo,
49                                 const SkRect& dstRect,
50                                 float dstHdrRatio,
51                                 sk_sp<SkColorSpace> dstColorSpace);
52 };
53 
54 #endif
55