xbmc
GUIFontTTFDX.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
16 #include "D3DResource.h"
17 #include "GUIFontTTF.h"
18 
19 #include <list>
20 #include <memory>
21 #include <vector>
22 
23 #include <wrl/client.h>
24 
29 class CGUIFontTTFDX : public CGUIFontTTF, public ID3DResource
30 {
31 public:
32  explicit CGUIFontTTFDX(const std::string& fontIdent);
33  virtual ~CGUIFontTTFDX(void);
34 
35  bool FirstBegin() override;
36  void LastEnd() override;
37  CVertexBuffer CreateVertexBuffer(const std::vector<SVertex>& vertices) const override;
38  void DestroyVertexBuffer(CVertexBuffer& bufferHandle) const override;
39 
40  void OnDestroyDevice(bool fatal) override;
41  void OnCreateDevice() override;
42 
43  static void CreateStaticIndexBuffer(void);
44  static void DestroyStaticIndexBuffer(void);
45 
46 protected:
47  std::unique_ptr<CTexture> ReallocTexture(unsigned int& newHeight) override;
48  bool CopyCharToTexture(FT_BitmapGlyph bitGlyph,
49  unsigned int x1,
50  unsigned int y1,
51  unsigned int x2,
52  unsigned int y2) override;
53  void DeleteHardwareTexture() override;
54 
55 private:
56  bool UpdateDynamicVertexBuffer(const SVertex* pSysMem, unsigned int count);
57  static void AddReference(CGUIFontTTFDX* font, CD3DBuffer* pBuffer);
58  static void ClearReference(CGUIFontTTFDX* font, CD3DBuffer* pBuffer);
59 
60  unsigned m_vertexWidth{0};
61  std::unique_ptr<CD3DTexture> m_speedupTexture; // extra texture to speed up reallocations
62  Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
63  std::list<CD3DBuffer*> m_buffers;
64 
65  static bool m_staticIndexBufferCreated;
66  static Microsoft::WRL::ComPtr<ID3D11Buffer> m_staticIndexBuffer;
67 };
Definition: GUIFontTTF.h:65
Definition: GUIFontTTF.h:76
Definition: GUIFontTTFDX.h:29
Definition: D3DResource.h:36
Definition: GUIFontCache.h:220
Definition: D3DResource.h:212