| OLD | NEW |
| 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_FGAS_CRT_FGAS_UTILS_H_ | 7 #ifndef XFA_FGAS_CRT_FGAS_UTILS_H_ |
| 8 #define XFA_FGAS_CRT_FGAS_UTILS_H_ | 8 #define XFA_FGAS_CRT_FGAS_UTILS_H_ |
| 9 | 9 |
| 10 #include "core/fxcrt/include/fx_coordinates.h" | 10 #include "core/fxcrt/include/fx_coordinates.h" |
| 11 #include "xfa/fgas/crt/fgas_memory.h" | 11 #include "xfa/fgas/crt/fgas_memory.h" |
| 12 | 12 |
| 13 class FX_BASEARRAYDATA; | 13 class FX_BASEARRAYDATA; |
| 14 | 14 |
| 15 class CFX_BaseArray : public CFX_Target { | 15 class CFX_BaseArray : public CFX_Target { |
| 16 protected: | 16 protected: |
| 17 CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); | 17 CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); |
| 18 ~CFX_BaseArray(); | 18 ~CFX_BaseArray() override; |
| 19 |
| 19 int32_t GetSize() const; | 20 int32_t GetSize() const; |
| 20 int32_t GetBlockSize() const; | 21 int32_t GetBlockSize() const; |
| 21 uint8_t* AddSpaceTo(int32_t index); | 22 uint8_t* AddSpaceTo(int32_t index); |
| 22 uint8_t* GetAt(int32_t index) const; | 23 uint8_t* GetAt(int32_t index) const; |
| 23 uint8_t* GetBuffer() const; | 24 uint8_t* GetBuffer() const; |
| 24 int32_t Append(const CFX_BaseArray& src, | 25 int32_t Append(const CFX_BaseArray& src, |
| 25 int32_t iStart = 0, | 26 int32_t iStart = 0, |
| 26 int32_t iCount = -1); | 27 int32_t iCount = -1); |
| 27 int32_t Copy(const CFX_BaseArray& src, | 28 int32_t Copy(const CFX_BaseArray& src, |
| 28 int32_t iStart = 0, | 29 int32_t iStart = 0, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 for (int32_t i = 0; i < iSize; i++) { | 178 for (int32_t i = 0; i < iSize; i++) { |
| 178 ((baseType*)GetPtrAt(i))->~baseType(); | 179 ((baseType*)GetPtrAt(i))->~baseType(); |
| 179 } | 180 } |
| 180 CFX_BaseArray::RemoveAll(bLeaveMemory); | 181 CFX_BaseArray::RemoveAll(bLeaveMemory); |
| 181 } | 182 } |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 class CFX_BaseMassArrayImp : public CFX_Target { | 185 class CFX_BaseMassArrayImp : public CFX_Target { |
| 185 public: | 186 public: |
| 186 CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize); | 187 CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize); |
| 187 ~CFX_BaseMassArrayImp(); | 188 ~CFX_BaseMassArrayImp() override; |
| 189 |
| 188 uint8_t* AddSpace() { return AddSpaceTo(m_iBlockCount); } | 190 uint8_t* AddSpace() { return AddSpaceTo(m_iBlockCount); } |
| 189 uint8_t* AddSpaceTo(int32_t index); | 191 uint8_t* AddSpaceTo(int32_t index); |
| 190 uint8_t* GetAt(int32_t index) const; | 192 uint8_t* GetAt(int32_t index) const; |
| 191 int32_t Append(const CFX_BaseMassArrayImp& src, | 193 int32_t Append(const CFX_BaseMassArrayImp& src, |
| 192 int32_t iStart = 0, | 194 int32_t iStart = 0, |
| 193 int32_t iCount = -1); | 195 int32_t iCount = -1); |
| 194 int32_t Copy(const CFX_BaseMassArrayImp& src, | 196 int32_t Copy(const CFX_BaseMassArrayImp& src, |
| 195 int32_t iStart = 0, | 197 int32_t iStart = 0, |
| 196 int32_t iCount = -1); | 198 int32_t iCount = -1); |
| 197 int32_t RemoveLast(int32_t iCount = -1); | 199 int32_t RemoveLast(int32_t iCount = -1); |
| 198 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); | 200 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); |
| 199 | 201 |
| 200 int32_t m_iChunkSize; | 202 int32_t m_iChunkSize; |
| 201 int32_t m_iBlockSize; | 203 int32_t m_iBlockSize; |
| 202 int32_t m_iChunkCount; | 204 int32_t m_iChunkCount; |
| 203 int32_t m_iBlockCount; | 205 int32_t m_iBlockCount; |
| 204 CFX_ArrayTemplate<void*>* m_pData; | 206 CFX_ArrayTemplate<void*>* m_pData; |
| 205 | 207 |
| 206 protected: | 208 protected: |
| 207 void Append(int32_t iDstStart, | 209 void Append(int32_t iDstStart, |
| 208 const CFX_BaseMassArrayImp& src, | 210 const CFX_BaseMassArrayImp& src, |
| 209 int32_t iSrcStart = 0, | 211 int32_t iSrcStart = 0, |
| 210 int32_t iSrcCount = -1); | 212 int32_t iSrcCount = -1); |
| 211 }; | 213 }; |
| 212 | 214 |
| 213 class CFX_BaseMassArray : public CFX_Target { | 215 class CFX_BaseMassArray : public CFX_Target { |
| 214 protected: | 216 protected: |
| 215 CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); | 217 CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); |
| 216 ~CFX_BaseMassArray(); | 218 ~CFX_BaseMassArray() override; |
| 219 |
| 217 int32_t GetSize() const; | 220 int32_t GetSize() const; |
| 218 uint8_t* AddSpaceTo(int32_t index); | 221 uint8_t* AddSpaceTo(int32_t index); |
| 219 uint8_t* GetAt(int32_t index) const; | 222 uint8_t* GetAt(int32_t index) const; |
| 220 int32_t Append(const CFX_BaseMassArray& src, | 223 int32_t Append(const CFX_BaseMassArray& src, |
| 221 int32_t iStart = 0, | 224 int32_t iStart = 0, |
| 222 int32_t iCount = -1); | 225 int32_t iCount = -1); |
| 223 int32_t Copy(const CFX_BaseMassArray& src, | 226 int32_t Copy(const CFX_BaseMassArray& src, |
| 224 int32_t iStart = 0, | 227 int32_t iStart = 0, |
| 225 int32_t iCount = -1); | 228 int32_t iCount = -1); |
| 226 int32_t RemoveLast(int32_t iCount = -1); | 229 int32_t RemoveLast(int32_t iCount = -1); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 for (int32_t i = 0; i < iSize; i++) { | 356 for (int32_t i = 0; i < iSize; i++) { |
| 354 ((baseType*)GetPtrAt(i))->~baseType(); | 357 ((baseType*)GetPtrAt(i))->~baseType(); |
| 355 } | 358 } |
| 356 CFX_BaseMassArray::RemoveAll(bLeaveMemory); | 359 CFX_BaseMassArray::RemoveAll(bLeaveMemory); |
| 357 } | 360 } |
| 358 }; | 361 }; |
| 359 | 362 |
| 360 class CFX_BaseDiscreteArray : public CFX_Target { | 363 class CFX_BaseDiscreteArray : public CFX_Target { |
| 361 protected: | 364 protected: |
| 362 CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); | 365 CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); |
| 363 ~CFX_BaseDiscreteArray(); | 366 ~CFX_BaseDiscreteArray() override; |
| 367 |
| 364 uint8_t* AddSpaceTo(int32_t index); | 368 uint8_t* AddSpaceTo(int32_t index); |
| 365 uint8_t* GetAt(int32_t index) const; | 369 uint8_t* GetAt(int32_t index) const; |
| 366 void RemoveAll(); | 370 void RemoveAll(); |
| 367 void* m_pData; | 371 void* m_pData; |
| 368 }; | 372 }; |
| 369 | 373 |
| 370 template <class baseType> | 374 template <class baseType> |
| 371 class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { | 375 class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { |
| 372 public: | 376 public: |
| 373 CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) | 377 CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 384 } | 388 } |
| 385 void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); } | 389 void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); } |
| 386 }; | 390 }; |
| 387 typedef CFX_DiscreteArrayTemplate<void*> CFX_PtrDiscreteArray; | 391 typedef CFX_DiscreteArrayTemplate<void*> CFX_PtrDiscreteArray; |
| 388 typedef CFX_DiscreteArrayTemplate<uint32_t> CFX_DWordDiscreteArray; | 392 typedef CFX_DiscreteArrayTemplate<uint32_t> CFX_DWordDiscreteArray; |
| 389 typedef CFX_DiscreteArrayTemplate<uint16_t> CFX_WordDiscreteArray; | 393 typedef CFX_DiscreteArrayTemplate<uint16_t> CFX_WordDiscreteArray; |
| 390 | 394 |
| 391 class CFX_BaseStack : public CFX_Target { | 395 class CFX_BaseStack : public CFX_Target { |
| 392 protected: | 396 protected: |
| 393 CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize); | 397 CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize); |
| 394 ~CFX_BaseStack(); | 398 ~CFX_BaseStack() override; |
| 399 |
| 395 uint8_t* Push(); | 400 uint8_t* Push(); |
| 396 void Pop(); | 401 void Pop(); |
| 397 uint8_t* GetTopElement() const; | 402 uint8_t* GetTopElement() const; |
| 398 int32_t GetSize() const; | 403 int32_t GetSize() const; |
| 399 uint8_t* GetAt(int32_t index) const; | 404 uint8_t* GetAt(int32_t index) const; |
| 400 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); | 405 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); |
| 401 CFX_BaseMassArrayImp* m_pData; | 406 CFX_BaseMassArrayImp* m_pData; |
| 402 }; | 407 }; |
| 403 | 408 |
| 404 template <class baseType> | 409 template <class baseType> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 483 } |
| 479 RemoveAll(TRUE); | 484 RemoveAll(TRUE); |
| 480 for (int32_t i = iStart; i < iEnd; i++) { | 485 for (int32_t i = iStart; i < iEnd; i++) { |
| 481 Push(*src.GetAt(i)); | 486 Push(*src.GetAt(i)); |
| 482 } | 487 } |
| 483 return CFX_BaseStack::GetSize(); | 488 return CFX_BaseStack::GetSize(); |
| 484 } | 489 } |
| 485 }; | 490 }; |
| 486 | 491 |
| 487 #endif // XFA_FGAS_CRT_FGAS_UTILS_H_ | 492 #endif // XFA_FGAS_CRT_FGAS_UTILS_H_ |
| OLD | NEW |