• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
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 "core/fxge/cfx_gemodule.h"
8 
9 #include <memory>
10 #include <utility>
11 
12 #include "core/fxge/android/cfpf_skiadevicemodule.h"
13 #include "core/fxge/android/cfx_androidfontinfo.h"
14 #include "core/fxge/cfx_fontmgr.h"
15 #include "third_party/base/ptr_util.h"
16 
17 class CAndroidPlatform : public CFX_GEModule::PlatformIface {
18  public:
19   CAndroidPlatform() = default;
~CAndroidPlatform()20   ~CAndroidPlatform() override {
21     if (m_pDeviceModule)
22       m_pDeviceModule->Destroy();
23   }
24 
Init()25   void Init() override {
26     m_pDeviceModule = CFPF_GetSkiaDeviceModule();
27     CFPF_SkiaFontMgr* pFontMgr = m_pDeviceModule->GetFontMgr();
28     if (!pFontMgr)
29       return;
30 
31     auto pFontInfo = pdfium::MakeUnique<CFX_AndroidFontInfo>();
32     pFontInfo->Init(pFontMgr);
33     CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(std::move(pFontInfo));
34   }
35 
36  private:
37   CFPF_SkiaDeviceModule* m_pDeviceModule = nullptr;
38 };
39 
40 // static
41 std::unique_ptr<CFX_GEModule::PlatformIface>
Create()42 CFX_GEModule::PlatformIface::Create() {
43   return pdfium::MakeUnique<CAndroidPlatform>();
44 }
45