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

Side by Side Diff: core/fpdfapi/page/cpdf_streamcontentparser.h

Issue 2520133002: Remove some WrapUnique() calls by returing unique_ptrs (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fpdfapi/page/cpdf_streamcontentparser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ 7 #ifndef CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ 8 #define CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
9 9
10 #include <memory> 10 #include <memory>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost); 45 uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost);
46 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } 46 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; }
47 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } 47 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); }
48 bool IsColored() const { return m_bColored; } 48 bool IsColored() const { return m_bColored; }
49 const FX_FLOAT* GetType3Data() const { return m_Type3Data; } 49 const FX_FLOAT* GetType3Data() const { return m_Type3Data; }
50 CPDF_Font* FindFont(const CFX_ByteString& name); 50 CPDF_Font* FindFont(const CFX_ByteString& name);
51 51
52 private: 52 private:
53 struct ContentParam { 53 struct ContentParam {
54 enum Type { OBJECT = 0, NUMBER, NAME }; 54 enum Type { OBJECT = 0, NUMBER, NAME };
55
56 ContentParam();
57 ~ContentParam();
58
55 Type m_Type; 59 Type m_Type;
56 union { 60 std::unique_ptr<CPDF_Object> m_pObject;
57 struct { 61 struct {
58 bool m_bInteger; 62 bool m_bInteger;
59 union { 63 union {
60 int m_Integer; 64 int m_Integer;
61 FX_FLOAT m_Float; 65 FX_FLOAT m_Float;
62 }; 66 };
63 } m_Number; 67 } m_Number;
64 CPDF_Object* m_pObject; 68 struct {
65 struct { 69 int m_Len;
66 int m_Len; 70 char m_Buffer[32];
67 char m_Buffer[32]; 71 } m_Name;
68 } m_Name;
69 };
70 }; 72 };
71 73
72 static const int kParamBufSize = 16; 74 static const int kParamBufSize = 16;
73 75
74 using OpCodes = 76 using OpCodes =
75 std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>; 77 std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>;
76 static OpCodes InitializeOpCodes(); 78 static OpCodes InitializeOpCodes();
77 79
78 void AddNumberParam(const FX_CHAR* str, int len); 80 void AddNumberParam(const FX_CHAR* str, int len);
79 void AddObjectParam(CPDF_Object* pObj); 81 void AddObjectParam(std::unique_ptr<CPDF_Object> pObj);
80 void AddNameParam(const FX_CHAR* name, int size); 82 void AddNameParam(const FX_CHAR* name, int size);
81 int GetNextParamPos(); 83 int GetNextParamPos();
82 void ClearAllParams(); 84 void ClearAllParams();
83 CPDF_Object* GetObject(uint32_t index); 85 CPDF_Object* GetObject(uint32_t index);
84 CFX_ByteString GetString(uint32_t index); 86 CFX_ByteString GetString(uint32_t index);
85 FX_FLOAT GetNumber(uint32_t index); 87 FX_FLOAT GetNumber(uint32_t index);
86 int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); } 88 int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); }
87 void OnOperator(const FX_CHAR* op); 89 void OnOperator(const FX_CHAR* op);
88 void AddTextObject(CFX_ByteString* pText, 90 void AddTextObject(CFX_ByteString* pText,
89 FX_FLOAT fInitKerning, 91 FX_FLOAT fInitKerning,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 CPDF_Image* m_pLastImage; 218 CPDF_Image* m_pLastImage;
217 CPDF_Dictionary* m_pLastImageDict; 219 CPDF_Dictionary* m_pLastImageDict;
218 CPDF_Dictionary* m_pLastCloneImageDict; 220 CPDF_Dictionary* m_pLastCloneImageDict;
219 bool m_bColored; 221 bool m_bColored;
220 FX_FLOAT m_Type3Data[6]; 222 FX_FLOAT m_Type3Data[6];
221 bool m_bResourceMissing; 223 bool m_bResourceMissing;
222 std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack; 224 std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack;
223 }; 225 };
224 226
225 #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ 227 #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fpdfapi/page/cpdf_streamcontentparser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698