88 paint.setShader(shader);
102 {{-1.f, -1.f, -1.f, 1.0f}, {-1.f, -1.f, -1.f, 1.0f}},
103 {{1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 0.5f, 1.0f}},
104 {{1.0f, 0.5f, 1.0f, 1.0f}, {1.0f, 0.5f, 0.5f, 1.0f}},
105 {{0.5f, 1.0f, 1.0f, 1.0f}, {0.5f, 1.0f, 0.5f, 1.0f}},
106 {{0.5f, 0.5f, 1.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f}},
117 {{-1.f, -1.f, -1.f, 1.f}, {1.0f, 0.0f, 0.0f, 1.f}},
118 {{-1.f, -1.f, -1.f, 1.f}, {0.0f, 1.0f, 1.0f, 1.f}},
146 paint.setShader(shader);
152 constexpr float k10G = 1.353256028586302f;
154 constexpr float k05G = 0.6858361015012847f;
157 constexpr float kR10G = 1.3234778541409058f;
160 constexpr float kR05G = 0.371934685412575f;
162 {{kR10G, 1.0f, 1.0f, 1.0f}, {kR10G, 1.0f, 0.5f, 1.0f}},
163 {{kR10G, 0.5f, 1.0f, 1.0f}, {kR10G, 0.5f, 0.5f, 1.0f}},
164 {{kR05G, k10G, k10G, 1.0f}, {kR05G, k10G, k05G, 1.0f}},
165 {{kR05G, k05G, k10G, 1.0f}, {kR05G, k05G, k05G, 1.0f}},
167 for (
int y = 0;
y < 4; ++
y) {
168 for (
int x = 0;
x < 2; ++
x) {
170 const auto& expected = expectedColors[
y][
x];
173 "color (%.3f %.3f %.3f %.3f) does not match expected color (%.3f %.3f "
192 {{1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 0.5f, 1.0f}},
193 {{1.0f, 0.5f, 1.0f, 1.0f}, {1.0f, 0.5f, 0.5f, 1.0f}},
194 {{0.5f, 1.0f, 1.0f, 1.0f}, {0.5f, 1.0f, 0.5f, 1.0f}},
195 {{0.5f, 0.5f, 1.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f}},
206 {{1.0f, 0.0f, 0.0f, 1.f}},
207 {{0.0f, 1.0f, 1.0f, 1.f}},
236 paint.setShader(shader);
242 constexpr float k10G = 0.7353569830524495f;
244 constexpr float k05G = 0.3607802138332792f;
247 constexpr float kR10G = 0.6651850846308363f;
250 constexpr float kR05G = 0.371934685412575f;
252 {{kR10G, 1.0f, 1.0f, 1.0f}, {kR10G, 1.0f, 0.5f, 1.0f}},
253 {{kR10G, 0.5f, 1.0f, 1.0f}, {kR10G, 0.5f, 0.5f, 1.0f}},
254 {{kR05G, k10G, k10G, 1.0f}, {kR05G, k10G, k05G, 1.0f}},
255 {{kR05G, k05G, k10G, 1.0f}, {kR05G, k05G, k05G, 1.0f}},
257 for (
int y = 0;
y < 4; ++
y) {
258 for (
int x = 0;
x < 2; ++
x) {
260 const auto& expected = expectedColors[
y][
x];
263 "color (%.3f %.3f %.3f %.3f) does not match expected color (%.3f %.3f "
288 constexpr SkColor4f kSdrColor = {0.25f, 0.5f, 1.f, 1.f};
294 constexpr SkColor4f kExpectedColor = {0.5f, 0.5f, 1.414f, 1.f};
302 sdrImage, gainmapImage, gainmapInfo, gainmapInfo.
fDisplayRatioHdr, dstColorSpace);
308 sdrImage, gainmapImage, gainmapInfo, gainmapInfo.
fDisplayRatioHdr, dstColorSpace);
315 sdrImage, gainmapImage, gainmapInfo, gainmapInfo.
fDisplayRatioHdr, dstColorSpace);
321 constexpr SkColor4f kSdrColor = {0.25f, 0.5f, 1.f, 1.f};
328 const float kH = 5.f;
330 const SkColor4f kExpectedColor = {0.25f * (1 + (
kH - 1) * 0.0f),
331 0.50f * (1 + (
kH - 1) * 0.5f),
332 1.00f * (1 + (
kH - 1) * 1.0f),
static bool approx_equal(const SkColor4f &a, const SkColor4f &b)
static SkColor4f draw_1x1_gainmap(sk_sp< SkImage > baseImage, sk_sp< SkImage > gainmapImage, const SkGainmapInfo &gainmapInfo, float dstRatio, sk_sp< SkColorSpace > dstColorSpace=SkColorSpace::MakeSRGB())
static sk_sp< SkImage > make_1x1_image(sk_sp< SkColorSpace > imageColorSpace, SkAlphaType imageAlphaType, SkColor4f imageColor, sk_sp< SkColorSpace > imageColorColorSpace=SkColorSpace::MakeSRGBLinear())
static SkGainmapInfo simple_gainmap_info(float hdrRatioMax)
DEF_TEST(GainmapShader_rects, r)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
constexpr SkColor SK_ColorTRANSPARENT
static constexpr double kEpsilon
#define REPORTER_ASSERT(r, cond,...)
void allocPixels(const SkImageInfo &info, size_t rowBytes)
bool writePixels(const SkPixmap &src, int dstX, int dstY)
SkColor4f getColor4f(int x, int y) const
void eraseColor(SkColor4f) const
void drawRect(const SkRect &rect, const SkPaint &paint)
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkColorSpace > makeColorSpin() const
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkColorSpace > MakeSRGBLinear()
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)
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
static constexpr skcms_Matrix3x3 kSRGB
static constexpr skcms_Matrix3x3 kRec2020
static constexpr skcms_Matrix3x3 kDisplayP3
static constexpr skcms_TransferFunction k2Dot2
static constexpr skcms_TransferFunction kHLG
static constexpr skcms_TransferFunction kPQ
constexpr std::array< std::array< float, 2 >, 2 > kRect
SkSamplingOptions(SkFilterMode::kLinear))
SIN Vec< N, float > abs(const Vec< N, float > &x)
SkColor4f fGainmapRatioMax
sk_sp< SkColorSpace > fGainmapMathColorSpace
SkColor4f fGainmapRatioMin
BaseImageType fBaseImageType
sk_sp< SkColorSpace > refColorSpace() const
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)