Commit 9d8ada9a authored by bungeman's avatar bungeman Committed by Commit bot

SkFontConfigInterface createTypeface to makeTypeface.

The createTypeface method (which returned a bare pointer to a reference
counted object) is being replaced with makeTypeface (which returns a
smart pointer to a reference counted object). This removes some manual
reference counting in Chromium and allows for removing the deprecated
createTypeface method.

Review-Url: https://codereview.chromium.org/2037133002
Cr-Commit-Position: refs/heads/master@{#397794}
parent dfec07b7
......@@ -15,6 +15,7 @@
#include <functional>
#include <memory>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
......@@ -158,21 +159,21 @@ SkStreamAsset* FontConfigIPC::openStream(const FontIdentity& identity) {
return mapFileDescriptorToStream(result_fd);
}
SkTypeface* FontConfigIPC::createTypeface(
sk_sp<SkTypeface> FontConfigIPC::makeTypeface(
const SkFontConfigInterface::FontIdentity& identity) {
base::AutoLock lock(lock_);
auto mapped_typefaces_it = mapped_typefaces_.Get(identity);
if (mapped_typefaces_it != mapped_typefaces_.end())
return SkSafeRef(mapped_typefaces_it->second.get());
return mapped_typefaces_it->second;
SkStreamAsset* typeface_stream = openStream(identity);
if (!typeface_stream)
return nullptr;
sk_sp<SkTypeface> typeface_from_stream(
SkTypeface::CreateFromStream(typeface_stream, identity.fTTCIndex));
SkTypeface::MakeFromStream(typeface_stream, identity.fTTCIndex));
auto mapped_typefaces_insert_it =
mapped_typefaces_.Put(identity, typeface_from_stream);
return SkSafeRef(mapped_typefaces_insert_it->second.get());
mapped_typefaces_.Put(identity, std::move(typeface_from_stream));
return mapped_typefaces_insert_it->second;
}
} // namespace content
......@@ -41,7 +41,7 @@ class FontConfigIPC : public SkFontConfigInterface {
// Returns a new SkTypeface instance or a ref'ed one from the cache. The
// caller should adopt the pointer.
SkTypeface* createTypeface(const FontIdentity& identity) override
sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity) override
WARN_UNUSED_RESULT;
enum Method {
......
......@@ -38,6 +38,7 @@
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/FontFaceCreationParams.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/graphics/skia/SkiaUtils.h"
#include "public/platform/Platform.h"
#include "public/platform/linux/WebSandboxSupport.h"
#include "wtf/Assertions.h"
......@@ -54,7 +55,7 @@ static PassRefPtr<SkTypeface> typefaceForFontconfigInterfaceIdAndTtcIndex(int fo
SkFontConfigInterface::FontIdentity fontIdentity;
fontIdentity.fID = fontconfigInterfaceId;
fontIdentity.fTTCIndex = ttcIndex;
return adoptRef(fci->createTypeface(fontIdentity));
return blink::fromSkSp(fci->makeTypeface(fontIdentity));
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment