diff options
author | bungeman <bungeman@google.com> | 2016-10-20 16:06:52 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-20 22:00:28 +0000 |
commit | 7cfd46aebda7b7d2b88e73621ed0d1be7244c2ca (patch) | |
tree | ace6ecfe18447644e928f6ef204ab39f2767f24f /src/ports/SkFontHost_win.cpp | |
parent | 050ffa9ad5d2bafc935c0a48ce3caed47446be12 (diff) |
SkScalerContext to use smart pointers.
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot;master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN-Trybot
Change-Id: I27a714388b8ded7dfc968e322b0a587205f575f1
Reviewed-on: https://skia-review.googlesource.com/3731
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/ports/SkFontHost_win.cpp')
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 0e878bee03..380b502a30 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -16,6 +16,7 @@ #include "SkFontDescriptor.h" #include "SkGlyph.h" #include "SkHRESULT.h" +#include "SkMakeUnique.h" #include "SkMaskGamma.h" #include "SkMatrix22.h" #include "SkOTTable_maxp.h" @@ -530,7 +531,9 @@ const void* HDCOffscreen::draw(const SkGlyph& glyph, bool isBW, class SkScalerContext_GDI : public SkScalerContext { public: - SkScalerContext_GDI(SkTypeface*, const SkScalerContextEffects&, const SkDescriptor* desc); + SkScalerContext_GDI(sk_sp<LogFontTypeface>, + const SkScalerContextEffects&, + const SkDescriptor* desc); virtual ~SkScalerContext_GDI(); // Returns true if the constructor was able to complete all of its @@ -600,17 +603,17 @@ static BYTE compute_quality(const SkScalerContext::Rec& rec) { } } -SkScalerContext_GDI::SkScalerContext_GDI(SkTypeface* rawTypeface, +SkScalerContext_GDI::SkScalerContext_GDI(sk_sp<LogFontTypeface> rawTypeface, const SkScalerContextEffects& effects, const SkDescriptor* desc) - : SkScalerContext(rawTypeface, effects, desc) + : SkScalerContext(std::move(rawTypeface), effects, desc) , fDDC(0) , fSavefont(0) , fFont(0) , fSC(0) , fGlyphCount(-1) { - LogFontTypeface* typeface = reinterpret_cast<LogFontTypeface*>(rawTypeface); + LogFontTypeface* typeface = static_cast<LogFontTypeface*>(this->getTypeface()); fDDC = ::CreateCompatibleDC(nullptr); if (!fDDC) { @@ -2254,13 +2257,12 @@ size_t LogFontTypeface::onGetTableData(SkFontTableTag tag, size_t offset, SkScalerContext* LogFontTypeface::onCreateScalerContext(const SkScalerContextEffects& effects, const SkDescriptor* desc) const { - SkScalerContext_GDI* ctx = new SkScalerContext_GDI(const_cast<LogFontTypeface*>(this), - effects, desc); + auto ctx = skstd::make_unique<SkScalerContext_GDI>( + sk_ref_sp(const_cast<LogFontTypeface*>(this)), effects, desc); if (!ctx->isValid()) { - delete ctx; ctx = nullptr; } - return ctx; + return ctx.release(); } void LogFontTypeface::onFilterRec(SkScalerContextRec* rec) const { |