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 13 class SkColorSpace; 14 class SkShader; 15 class SkImage; 16 struct SkGainmapInfo; 17 struct SkRect; 18 struct SkSamplingOptions; 19 20 /** 21 * A gainmap shader will apply a gainmap to an base image using the math described alongside the 22 * definition of SkGainmapInfo. 23 */ 24 class SK_API SkGainmapShader { 25 public: 26 /** 27 * Make a gainmap shader. 28 * 29 * When sampling the base image baseImage, the rectangle baseRect will be sampled to map to 30 * the rectangle dstRect. Sampling will be done according to baseSamplingOptions. 31 * 32 * When sampling the gainmap image gainmapImage, the rectangle gainmapRect will be sampled to 33 * map to the rectangle dstRect. Sampling will be done according to gainmapSamplingOptions. 34 * 35 * The gainmap will be applied according to the HDR to SDR ratio specified in dstHdrRatio. 36 * 37 * This shader must know the color space of the canvas that it will be rendered to. This color 38 * space must be specified in dstColorSpace. 39 * TODO(ccameron): Remove the need for dstColorSpace. 40 */ 41 static sk_sp<SkShader> Make(const sk_sp<const SkImage>& baseImage, 42 const SkRect& baseRect, 43 const SkSamplingOptions& baseSamplingOptions, 44 const sk_sp<const SkImage>& gainmapImage, 45 const SkRect& gainmapRect, 46 const SkSamplingOptions& gainmapSamplingOptions, 47 const SkGainmapInfo& gainmapInfo, 48 const SkRect& dstRect, 49 float dstHdrRatio, 50 sk_sp<SkColorSpace> dstColorSpace); 51 }; 52 53 #endif 54