566 {
567
568 const char* namespaces[1] = {nullptr};
569 const char* uris[1] = {"http://ns.adobe.com/hdr-gain-map/1.0/"};
572 if (!findUriNamespaces(1, uris, namespaces, &
dom, &node)) {
573 return false;
574 }
576
577
579 if (!version) {
581 return false;
582 }
583 if (strcmp(version, "1.0") != 0) {
585 return false;
586 }
587
588
589 bool baseRenditionIsHDR = false;
590 SkColor4f gainMapMin = {0.f, 0.f, 0.f, 1.f};
591 SkColor4f gainMapMax = {1.f, 1.f, 1.f, 1.f};
593 SkColor4f offsetSdr = {1.f / 64.f, 1.f / 64.f, 1.f / 64.f, 0.f};
594 SkColor4f offsetHdr = {1.f / 64.f, 1.f / 64.f, 1.f / 64.f, 0.f};
597
598
599 get_attr_bool(
dom, node, hdrgmPrefix,
"BaseRenditionIsHDR", &baseRenditionIsHDR);
607
608
609 const float kLog2 = std::log(2.f);
610 outGainmapInfo->fGainmapRatioMin = {std::exp(gainMapMin.fR * kLog2),
611 std::exp(gainMapMin.fG * kLog2),
612 std::exp(gainMapMin.fB * kLog2),
613 1.f};
614 outGainmapInfo->fGainmapRatioMax = {std::exp(gainMapMax.fR * kLog2),
615 std::exp(gainMapMax.fG * kLog2),
616 std::exp(gainMapMax.fB * kLog2),
617 1.f};
618 outGainmapInfo->fGainmapGamma = {1.f / gamma.fR, 1.f / gamma.fG, 1.f / gamma.fB, 1.f};
619 outGainmapInfo->fEpsilonSdr = offsetSdr;
620 outGainmapInfo->fEpsilonHdr = offsetHdr;
621 outGainmapInfo->fDisplayRatioSdr = std::exp(hdrCapacityMin * kLog2);
622 outGainmapInfo->fDisplayRatioHdr = std::exp(hdrCapacityMax * kLog2);
623 if (baseRenditionIsHDR) {
625 } else {
627 }
628 return true;
629}
static bool get_attr_bool(const SkDOM *dom, const SkDOM::Node *node, const std::string &prefix, const std::string &key, bool *outValue)
static bool get_attr_float3(const SkDOM *dom, const SkDOM::Node *node, const std::string &prefix, const std::string &key, SkColor4f *outValue)
static bool get_attr_float(const SkDOM *dom, const SkDOM::Node *node, const std::string &prefix, const std::string &key, float *outValue)