Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: src/core/SkFontDescriptor.h

Issue 2343933002: Revert of SkFontData to use smart pointers. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/animator/SkAnimator.cpp ('k') | src/core/SkFontDescriptor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFontDescriptor.h
diff --git a/src/core/SkFontDescriptor.h b/src/core/SkFontDescriptor.h
index de1462177bc949c3d3a8975a9279e71a2d85657a..cb8d2f4f03562484755e4147ca7b3fd85e4adfab 100644
--- a/src/core/SkFontDescriptor.h
+++ b/src/core/SkFontDescriptor.h
@@ -15,9 +15,9 @@
class SkFontData {
public:
- /** Makes a copy of the data in 'axis'. */
- SkFontData(std::unique_ptr<SkStreamAsset> stream, int index, const SkFixed axis[],int axisCount)
- : fStream(std::move(stream)), fIndex(index), fAxisCount(axisCount), fAxis(axisCount)
+ /** This takes ownership of 'stream'. Makes a copy of the data in 'axis'. */
+ SkFontData(SkStreamAsset* stream, int index, const SkFixed axis[], int axisCount)
+ : fStream(stream), fIndex(index), fAxisCount(axisCount), fAxis(axisCount)
{
for (int i = 0; i < axisCount; ++i) {
fAxis[i] = axis[i];
@@ -34,15 +34,15 @@
}
}
bool hasStream() const { return fStream.get() != nullptr; }
- std::unique_ptr<SkStreamAsset> detachStream() { return std::move(fStream); }
+ SkStreamAsset* duplicateStream() const { return fStream->duplicate(); }
+ SkStreamAsset* detachStream() { return fStream.release(); }
SkStreamAsset* getStream() { return fStream.get(); }
- SkStreamAsset const* getStream() const { return fStream.get(); }
int getIndex() const { return fIndex; }
int getAxisCount() const { return fAxisCount; }
const SkFixed* getAxis() const { return fAxis.get(); }
private:
- std::unique_ptr<SkStreamAsset> fStream;
+ SkAutoTDelete<SkStreamAsset> fStream;
int fIndex;
int fAxisCount;
SkAutoSTMalloc<4, SkFixed> fAxis;
@@ -63,19 +63,20 @@
const char* getFullName() const { return fFullName.c_str(); }
const char* getPostscriptName() const { return fPostscriptName.c_str(); }
bool hasFontData() const { return fFontData.get() != nullptr; }
- std::unique_ptr<SkFontData> detachFontData() { return std::move(fFontData); }
+ SkFontData* detachFontData() { return fFontData.release(); }
void setFamilyName(const char* name) { fFamilyName.set(name); }
void setFullName(const char* name) { fFullName.set(name); }
void setPostscriptName(const char* name) { fPostscriptName.set(name); }
- /** Set the font data only if it is necessary for serialization. */
- void setFontData(std::unique_ptr<SkFontData> data) { fFontData = std::move(data); }
+ /** Set the font data only if it is necessary for serialization.
+ * This method takes ownership of the font data. */
+ void setFontData(SkFontData* data) { fFontData.reset(data); }
private:
SkString fFamilyName;
SkString fFullName;
SkString fPostscriptName;
- std::unique_ptr<SkFontData> fFontData;
+ SkAutoTDelete<SkFontData> fFontData;
SkFontStyle fStyle;
};
« no previous file with comments | « src/animator/SkAnimator.cpp ('k') | src/core/SkFontDescriptor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698