aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-08-29 06:57:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-29 06:57:28 -0700
commit2867e7648069272ad1827ebafe49bd0d22a619b3 (patch)
tree2e2b268731efe4812145e1b15240a5da88964026 /src/core
parentaa92afbf2002b8ddb51125adccd2625014234373 (diff)
change readTypeface to return sk_sp
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPaint.cpp2
-rw-r--r--src/core/SkReadBuffer.cpp5
-rw-r--r--src/core/SkReadBuffer.h7
-rw-r--r--src/core/SkValidatingReadBuffer.cpp6
-rw-r--r--src/core/SkValidatingReadBuffer.h3
5 files changed, 4 insertions, 19 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 44b2928c25..58d6a0f95c 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -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);
}
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 5356d4a6b1..43eaf20261 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -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]);
}
}
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index a8bed7be48..7c4ecc6bd3 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -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;
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
index 2dd70706db..326d0cf575 100644
--- a/src/core/SkValidatingReadBuffer.cpp
+++ b/src/core/SkValidatingReadBuffer.cpp
@@ -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)));
}
diff --git a/src/core/SkValidatingReadBuffer.h b/src/core/SkValidatingReadBuffer.h
index d8575bdb4b..bad5f2fa93 100644
--- a/src/core/SkValidatingReadBuffer.h
+++ b/src/core/SkValidatingReadBuffer.h
@@ -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;