637 {
640
641
642
644
646
647 int curTypeface = 0,
648 curStrike = 0;
649
650 auto postError = [&](
int line) {
651 SkDebugf(
"Read Error Posted %s : %d", __FILE__, line);
653 memorySize,
655 SkTo<uint64_t>(curTypeface),
656 SkTo<uint64_t>(curStrike),
657 SkTo<uint64_t>(0),
658 SkTo<uint64_t>(0)};
660 };
661
662
663 const int typefaceCount =
buffer.readInt();
664 for (curTypeface = 0; curTypeface < typefaceCount; ++curTypeface) {
666 if (proto) {
667 this->addTypeface(proto.value());
668 } else {
669 postError(__LINE__);
670 return false;
671 }
672 }
673
674
675 const int stirkeCount =
buffer.readInt();
676 for (curStrike = 0; curStrike < stirkeCount; ++curStrike) {
677
679 if (serverTypefaceID == 0 && !
buffer.isValid()) {
680 postError(__LINE__);
681 return false;
682 }
683
685 if (discardableHandleID == 0 && !
buffer.isValid()) {
686 postError(__LINE__);
687 return false;
688 }
689
691 if (!
buffer.validate(serverDescriptor.has_value())) {
692 postError(__LINE__);
693 return false;
694 }
695
696 const bool fontMetricsInitialized =
buffer.readBool();
697 if (!fontMetricsInitialized && !
buffer.isValid()) {
698 postError(__LINE__);
699 return false;
700 }
701
702 std::optional<SkFontMetrics> fontMetrics;
703 if (!fontMetricsInitialized) {
705 if (!fontMetrics || !
buffer.isValid()) {
706 postError(__LINE__);
707 return false;
708 }
709 }
710
711 auto* clientTypeface = fServerTypefaceIdToTypeface.
find(serverTypefaceID);
712 if (clientTypeface == nullptr) {
713 postError(__LINE__);
714 return false;
715 }
716
718 postError(__LINE__);
719 return false;
720 }
721
722 SkDescriptor* clientDescriptor = serverDescriptor->getDesc();
723 auto strike = fStrikeCache->
findStrike(*clientDescriptor);
724
725 if (strike == nullptr) {
726
727
728 if (fontMetricsInitialized) {
729 postError(__LINE__);
730 return false;
731 }
732 SkStrikeSpec strikeSpec{*clientDescriptor, *clientTypeface};
734 strikeSpec, &fontMetrics.value(),
735 std::make_unique<DiscardableStrikePinner>(
736 discardableHandleID, fDiscardableHandleManager));
737 }
738
739
741
742 if (!strike->mergeFromBuffer(
buffer)) {
743 postError(__LINE__);
744 return false;
745 }
746 }
747
748 return true;
749}
uint32_t SkDiscardableHandleId
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static std::optional< SkAutoDescriptor > MakeFromBuffer(SkReadBuffer &buffer)
static std::optional< SkFontMetrics > MakeFromBuffer(SkReadBuffer &buffer)
void setAllowSkSL(bool allow)
sk_sp< SkStrike > createStrike(const SkStrikeSpec &strikeSpec, SkFontMetrics *maybeMetrics=nullptr, std::unique_ptr< SkStrikePinner >=nullptr) SK_EXCLUDES(fLock)
sk_sp< SkStrike > findStrike(const SkDescriptor &desc) SK_EXCLUDES(fLock)
bool translateTypefaceID(SkAutoDescriptor *descriptor) const
virtual void notifyReadFailure(const ReadFailureData &data)
void verifyPinnedStrike() const
static std::optional< SkTypefaceProxyPrototype > MakeFromBuffer(SkReadBuffer &buffer)
V * find(const K &key) const
static const uint8_t buffer[]
AutoTArray< uint8_t > data((int) size)