this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
if (flatFlags & kHasTypeface_FlatFlag) {
- this->setTypeface(sk_ref_sp(buffer.readTypeface()));
+ this->setTypeface(buffer.readTypeface());
} else {
this->setTypeface(nullptr);
}
return image ? image : MakeEmptyImage(width, height);
}
-SkTypeface* SkReadBuffer::readTypeface() {
-
+sk_sp<SkTypeface> SkReadBuffer::readTypeface() {
uint32_t index = fReader.readU32();
if (0 == index || index > (unsigned)fTFCount) {
return nullptr;
} else {
SkASSERT(fTFArray);
- return fTFArray[index - 1];
+ return sk_ref_sp(fTFArray[index - 1]);
}
}
// helpers to get info about arrays and binary data
virtual uint32_t getArrayCount();
- /**
- * Returns false if the image could not be completely read. In that case, it will be set
- * to have width/height, but no pixels.
- */
sk_sp<SkImage> readBitmapAsImage();
sk_sp<SkImage> readImage();
-
- virtual SkTypeface* readTypeface();
+ virtual sk_sp<SkTypeface> readTypeface();
void setTypefaceArray(SkTypeface* array[], int count) {
fTFArray = array;
return fError ? 0 : *(uint32_t*)fReader.peek();
}
-SkTypeface* SkValidatingReadBuffer::readTypeface() {
- SkASSERT(false);
- // TODO: Implement this (securely) when needed
- return nullptr;
-}
-
bool SkValidatingReadBuffer::validateAvailable(size_t size) {
return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast<uint32_t>(size)));
}
// helpers to get info about arrays and binary data
uint32_t getArrayCount() override;
- // TODO: Implement this (securely) when needed
- SkTypeface* readTypeface() override;
-
bool validate(bool isValid) override;
bool isValid() const override;