• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include <memory>
8 #include <utility>
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "core/fxge/android/cfpf_skiadevicemodule.h"
12 #include "core/fxge/android/cfx_androidfontinfo.h"
13 #include "core/fxge/cfx_fontmgr.h"
14 #include "core/fxge/cfx_gemodule.h"
15 
16 class CAndroidPlatform : public CFX_GEModule::PlatformIface {
17  public:
18   CAndroidPlatform() = default;
~CAndroidPlatform()19   ~CAndroidPlatform() override {
20     if (m_pDeviceModule)
21       m_pDeviceModule->Destroy();
22   }
23 
Init()24   void Init() override { m_pDeviceModule = CFPF_GetSkiaDeviceModule(); }
25 
CreateDefaultSystemFontInfo()26   std::unique_ptr<SystemFontInfoIface> CreateDefaultSystemFontInfo() override {
27     CFPF_SkiaFontMgr* pFontMgr = m_pDeviceModule->GetFontMgr();
28     if (!pFontMgr)
29       return nullptr;
30 
31     auto pFontInfo = std::make_unique<CFX_AndroidFontInfo>();
32     pFontInfo->Init(pFontMgr);
33     return pFontInfo;
34   }
35 
36  private:
37   UnownedPtr<CFPF_SkiaDeviceModule> m_pDeviceModule;
38 };
39 
40 // static
41 std::unique_ptr<CFX_GEModule::PlatformIface>
Create()42 CFX_GEModule::PlatformIface::Create() {
43   return std::make_unique<CAndroidPlatform>();
44 }
45