change readTypeface to return sk_sp
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2290653002 TBR=mtklein Review-Url: https://codereview.chromium.org/2290653002
This commit is contained in:
parent
aa92afbf20
commit
2867e76480
@ -1958,7 +1958,7 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
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);
|
||||
}
|
||||
|
@ -297,14 +297,13 @@ sk_sp<SkImage> SkReadBuffer::readImage() {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,14 +166,9 @@ public:
|
||||
// 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;
|
||||
|
@ -210,12 +210,6 @@ uint32_t SkValidatingReadBuffer::getArrayCount() {
|
||||
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)));
|
||||
}
|
||||
|
@ -62,9 +62,6 @@ public:
|
||||
// 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user