Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: xfa/fwl/theme/cfwl_widgettp.h

Issue 2609423003: Properly ref-count CFGAS_GEFont with CFX_RetainPtr. (Closed)
Patch Set: comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef XFA_FWL_THEME_CFWL_WIDGETTP_H_ 7 #ifndef XFA_FWL_THEME_CFWL_WIDGETTP_H_
8 #define XFA_FWL_THEME_CFWL_WIDGETTP_H_ 8 #define XFA_FWL_THEME_CFWL_WIDGETTP_H_
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "core/fxcrt/cfx_retain_ptr.h"
13 #include "core/fxcrt/fx_coordinates.h" 14 #include "core/fxcrt/fx_coordinates.h"
14 #include "core/fxcrt/fx_system.h" 15 #include "core/fxcrt/fx_system.h"
16 #include "xfa/fgas/font/cfgas_gefont.h"
15 #include "xfa/fwl/fwl_error.h" 17 #include "xfa/fwl/fwl_error.h"
16 #include "xfa/fwl/theme/cfwl_utils.h" 18 #include "xfa/fwl/theme/cfwl_utils.h"
17 #include "xfa/fxgraphics/cfx_graphics.h" 19 #include "xfa/fxgraphics/cfx_graphics.h"
18 20
19 class CFDE_TextOut; 21 class CFDE_TextOut;
20 class CFGAS_GEFont; 22 class CFGAS_GEFont;
21 class CFWL_ThemeBackground; 23 class CFWL_ThemeBackground;
22 class CFWL_ThemePart; 24 class CFWL_ThemePart;
23 class CFWL_ThemeText; 25 class CFWL_ThemeText;
24 class CFGAS_FontMgr; 26 class CFGAS_FontMgr;
25 class CFWL_Widget; 27 class CFWL_Widget;
26 28
27 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 29 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
28 class CFX_FontSourceEnum_File; 30 class CFX_FontSourceEnum_File;
29 #endif 31 #endif
30 32
31 class CFWL_WidgetTP { 33 class CFWL_WidgetTP {
32 public: 34 public:
33 virtual ~CFWL_WidgetTP(); 35 virtual ~CFWL_WidgetTP();
34 36
35 virtual void Initialize(); 37 virtual void Initialize();
36 virtual void Finalize(); 38 virtual void Finalize();
37 39
38 virtual void DrawBackground(CFWL_ThemeBackground* pParams); 40 virtual void DrawBackground(CFWL_ThemeBackground* pParams);
39 virtual void DrawText(CFWL_ThemeText* pParams); 41 virtual void DrawText(CFWL_ThemeText* pParams);
40 42
41 CFGAS_GEFont* GetFont() const { return m_pFDEFont; } 43 const CFX_RetainPtr<CFGAS_GEFont>& GetFont() const { return m_pFDEFont; }
42 44
43 protected: 45 protected:
44 struct CColorData { 46 struct CColorData {
45 FX_ARGB clrBorder[4]; 47 FX_ARGB clrBorder[4];
46 FX_ARGB clrStart[4]; 48 FX_ARGB clrStart[4];
47 FX_ARGB clrEnd[4]; 49 FX_ARGB clrEnd[4];
48 FX_ARGB clrSign[4]; 50 FX_ARGB clrSign[4];
49 }; 51 };
50 52
51 CFWL_WidgetTP(); 53 CFWL_WidgetTP();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 FWLTHEME_STATE eState, 89 FWLTHEME_STATE eState,
88 CFX_Matrix* pMatrix = nullptr); 90 CFX_Matrix* pMatrix = nullptr);
89 void DrawArrowBtn(CFX_Graphics* pGraphics, 91 void DrawArrowBtn(CFX_Graphics* pGraphics,
90 const CFX_RectF* pRect, 92 const CFX_RectF* pRect,
91 FWLTHEME_DIRECTION eDict, 93 FWLTHEME_DIRECTION eDict,
92 FWLTHEME_STATE eState, 94 FWLTHEME_STATE eState,
93 CFX_Matrix* pMatrix = nullptr); 95 CFX_Matrix* pMatrix = nullptr);
94 96
95 uint32_t m_dwRefCount; 97 uint32_t m_dwRefCount;
96 std::unique_ptr<CFDE_TextOut> m_pTextOut; 98 std::unique_ptr<CFDE_TextOut> m_pTextOut;
97 CFGAS_GEFont* m_pFDEFont; 99 CFX_RetainPtr<CFGAS_GEFont> m_pFDEFont;
98 std::unique_ptr<CColorData> m_pColorData; 100 std::unique_ptr<CColorData> m_pColorData;
99 }; 101 };
100 102
101 void FWLTHEME_Release(); 103 void FWLTHEME_Release();
102 104
103 class CFWL_FontData { 105 class CFWL_FontData {
104 public: 106 public:
105 CFWL_FontData(); 107 CFWL_FontData();
106 virtual ~CFWL_FontData(); 108 virtual ~CFWL_FontData();
107 109
108 bool Equal(const CFX_WideStringC& wsFontFamily, 110 bool Equal(const CFX_WideStringC& wsFontFamily,
109 uint32_t dwFontStyles, 111 uint32_t dwFontStyles,
110 uint16_t wCodePage); 112 uint16_t wCodePage);
111 bool LoadFont(const CFX_WideStringC& wsFontFamily, 113 bool LoadFont(const CFX_WideStringC& wsFontFamily,
112 uint32_t dwFontStyles, 114 uint32_t dwFontStyles,
113 uint16_t wCodePage); 115 uint16_t wCodePage);
114 CFGAS_GEFont* GetFont() const { return m_pFont.get(); } 116 CFX_RetainPtr<CFGAS_GEFont> GetFont() const { return m_pFont; }
115 117
116 protected: 118 protected:
117 CFX_WideString m_wsFamily; 119 CFX_WideString m_wsFamily;
118 uint32_t m_dwStyles; 120 uint32_t m_dwStyles;
119 uint32_t m_dwCodePage; 121 uint32_t m_dwCodePage;
120 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 122 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
121 std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource; 123 std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource;
122 #endif 124 #endif
123 std::unique_ptr<CFGAS_FontMgr> m_pFontMgr; 125 std::unique_ptr<CFGAS_FontMgr> m_pFontMgr;
124 std::unique_ptr<CFGAS_GEFont> m_pFont; 126 CFX_RetainPtr<CFGAS_GEFont> m_pFont;
125 }; 127 };
126 128
127 class CFWL_FontManager { 129 class CFWL_FontManager {
128 public: 130 public:
129 static CFWL_FontManager* GetInstance(); 131 static CFWL_FontManager* GetInstance();
130 static void DestroyInstance(); 132 static void DestroyInstance();
131 133
132 CFGAS_GEFont* FindFont(const CFX_WideStringC& wsFontFamily, 134 CFX_RetainPtr<CFGAS_GEFont> FindFont(const CFX_WideStringC& wsFontFamily,
133 uint32_t dwFontStyles, 135 uint32_t dwFontStyles,
134 uint16_t dwCodePage); 136 uint16_t dwCodePage);
135 137
136 protected: 138 protected:
137 CFWL_FontManager(); 139 CFWL_FontManager();
138 virtual ~CFWL_FontManager(); 140 virtual ~CFWL_FontManager();
139 141
140 static CFWL_FontManager* s_FontManager; 142 static CFWL_FontManager* s_FontManager;
141 std::vector<std::unique_ptr<CFWL_FontData>> m_FontsArray; 143 std::vector<std::unique_ptr<CFWL_FontData>> m_FontsArray;
142 }; 144 };
143 145
144 #endif // XFA_FWL_THEME_CFWL_WIDGETTP_H_ 146 #endif // XFA_FWL_THEME_CFWL_WIDGETTP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698