[Android] Remove unnecessary CFPF_SkiaDeviceModule singleton Simplify Android font management having the CAndroidPlatform own the CFPF_SkiaFontMgr directly, as is the case for other plaftorms. Then delete cfpf_skiadevicemodule.h and cfpf_skiadevicemodule.cpp because they are no longer needed. Bypass-Check-License: rename below in CL chain. Change-Id: I61dd9fc0c8f7b612ea92a3bce67eec1202b4f035 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/148711 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn index 07b17cd..2c5be70 100644 --- a/core/fxge/BUILD.gn +++ b/core/fxge/BUILD.gn
@@ -165,8 +165,6 @@ if (is_android) { sources += [ - "android/cfpf_skiadevicemodule.cpp", - "android/cfpf_skiadevicemodule.h", "android/cfpf_skiafont.cpp", "android/cfpf_skiafont.h", "android/cfpf_skiafontmgr.cpp",
diff --git a/core/fxge/android/cfpf_skiadevicemodule.cpp b/core/fxge/android/cfpf_skiadevicemodule.cpp deleted file mode 100644 index 168665e..0000000 --- a/core/fxge/android/cfpf_skiadevicemodule.cpp +++ /dev/null
@@ -1,40 +0,0 @@ -// Copyright 2016 The PDFium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "core/fxge/android/cfpf_skiadevicemodule.h" - -#include <utility> - -#include "core/fxge/android/cfpf_skiafontmgr.h" -#include "core/fxge/cfx_gemodule.h" - -namespace { - -CFPF_SkiaDeviceModule* gs_pPFModule = nullptr; - -} // namespace - -// static -CFPF_SkiaDeviceModule* CFPF_SkiaDeviceModule::GetOrCreate() { - if (!gs_pPFModule) { - gs_pPFModule = new CFPF_SkiaDeviceModule(); - } - return gs_pPFModule; -} - -CFPF_SkiaDeviceModule::CFPF_SkiaDeviceModule() - : font_mgr_(std::make_unique<CFPF_SkiaFontMgr>()) {} - -CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule() = default; - -CFPF_SkiaFontMgr* CFPF_SkiaDeviceModule::GetFontMgr() { - return font_mgr_.get(); -} - -void CFPF_SkiaDeviceModule::Destroy() { - delete gs_pPFModule; - gs_pPFModule = nullptr; -}
diff --git a/core/fxge/android/cfpf_skiadevicemodule.h b/core/fxge/android/cfpf_skiadevicemodule.h deleted file mode 100644 index fcf859e..0000000 --- a/core/fxge/android/cfpf_skiadevicemodule.h +++ /dev/null
@@ -1,28 +0,0 @@ -// Copyright 2016 The PDFium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXGE_ANDROID_CFPF_SKIADEVICEMODULE_H_ -#define CORE_FXGE_ANDROID_CFPF_SKIADEVICEMODULE_H_ - -#include <memory> - -class CFPF_SkiaFontMgr; - -class CFPF_SkiaDeviceModule { - public: - static CFPF_SkiaDeviceModule* GetOrCreate(); - - void Destroy(); - CFPF_SkiaFontMgr* GetFontMgr(); - - private: - CFPF_SkiaDeviceModule(); - ~CFPF_SkiaDeviceModule(); - - std::unique_ptr<CFPF_SkiaFontMgr> font_mgr_; -}; - -#endif // CORE_FXGE_ANDROID_CFPF_SKIADEVICEMODULE_H_
diff --git a/core/fxge/android/fx_android_impl.cpp b/core/fxge/android/fx_android_impl.cpp index f6ca48a..eb32b7e 100644 --- a/core/fxge/android/fx_android_impl.cpp +++ b/core/fxge/android/fx_android_impl.cpp
@@ -8,8 +8,7 @@ #include <utility> #include "core/fxcrt/check.h" -#include "core/fxcrt/unowned_ptr.h" -#include "core/fxge/android/cfpf_skiadevicemodule.h" +#include "core/fxge/android/cfpf_skiafontmgr.h" #include "core/fxge/android/cfx_androidfontinfo.h" #include "core/fxge/cfx_fontmgr.h" #include "core/fxge/cfx_gemodule.h" @@ -20,29 +19,27 @@ ~CAndroidPlatform() override = default; void Init() override { - CHECK(!device_module_); - device_module_ = CFPF_SkiaDeviceModule::GetOrCreate(); + CHECK(!font_mgr_); + font_mgr_ = std::make_unique<CFPF_SkiaFontMgr>(); } void Terminate() override { - CHECK(device_module_); - device_module_->Destroy(); - device_module_ = nullptr; + CHECK(font_mgr_); + font_mgr_.reset(); } std::unique_ptr<SystemFontInfoIface> CreateDefaultSystemFontInfo() override { - CFPF_SkiaFontMgr* font_mgr = device_module_->GetFontMgr(); - if (!font_mgr) { + if (!font_mgr_) { return nullptr; } auto font_info = std::make_unique<CFX_AndroidFontInfo>(); - font_info->Init(font_mgr, CFX_GEModule::Get()->GetUserFontPaths()); + font_info->Init(font_mgr_.get(), CFX_GEModule::Get()->GetUserFontPaths()); return font_info; } private: - UnownedPtr<CFPF_SkiaDeviceModule> device_module_; + std::unique_ptr<CFPF_SkiaFontMgr> font_mgr_; }; // static