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

Side by Side Diff: fpdfsdk/include/fsdk_mgr.h

Issue 1652613002: Remove CGW_ArrayTemplate and its O(n^2 log n) sort. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Another pointless empty() check. Created 4 years, 10 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
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | fpdfsdk/src/fsdk_baseform.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 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 FPDFSDK_INCLUDE_FSDK_MGR_H_ 7 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_
8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_ 8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 private: 285 private:
286 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; 286 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap;
287 UnderlyingDocumentType* m_pDoc; 287 UnderlyingDocumentType* m_pDoc;
288 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; 288 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
289 CPDFSDK_Annot* m_pFocusAnnot; 289 CPDFSDK_Annot* m_pFocusAnnot;
290 CPDFDoc_Environment* m_pEnv; 290 CPDFDoc_Environment* m_pEnv;
291 std::unique_ptr<CPDF_OCContext> m_pOccontent; 291 std::unique_ptr<CPDF_OCContext> m_pOccontent;
292 FX_BOOL m_bChangeMask; 292 FX_BOOL m_bChangeMask;
293 FX_BOOL m_bBeingDestroyed; 293 FX_BOOL m_bBeingDestroyed;
294 }; 294 };
295
295 class CPDFSDK_PageView final { 296 class CPDFSDK_PageView final {
296 public: 297 public:
297 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); 298 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
298 ~CPDFSDK_PageView(); 299 ~CPDFSDK_PageView();
299 void PageView_OnDraw(CFX_RenderDevice* pDevice, 300 void PageView_OnDraw(CFX_RenderDevice* pDevice,
300 CFX_Matrix* pUser2Device, 301 CFX_Matrix* pUser2Device,
301 CPDF_RenderOptions* pOptions); 302 CPDF_RenderOptions* pOptions);
302 const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 303 const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
303 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 304 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
304 const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 305 const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 CPDFSDK_Document* m_pSDKDoc; 362 CPDFSDK_Document* m_pSDKDoc;
362 CPDFSDK_Widget* m_CaptureWidget; 363 CPDFSDK_Widget* m_CaptureWidget;
363 FX_BOOL m_bEnterWidget; 364 FX_BOOL m_bEnterWidget;
364 FX_BOOL m_bExitWidget; 365 FX_BOOL m_bExitWidget;
365 FX_BOOL m_bOnWidget; 366 FX_BOOL m_bOnWidget;
366 FX_BOOL m_bValid; 367 FX_BOOL m_bValid;
367 FX_BOOL m_bLocked; 368 FX_BOOL m_bLocked;
368 FX_BOOL m_bTakeOverPage; 369 FX_BOOL m_bTakeOverPage;
369 }; 370 };
370 371
371 template <class TYPE>
372 class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
373 public:
374 CGW_ArrayTemplate() {}
375 ~CGW_ArrayTemplate() {}
376
377 typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
378
379 void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) {
380 int nSize = this->GetSize();
381 QuickSort(0, nSize - 1, bAscent, pCompare);
382 }
383
384 private:
385 void QuickSort(FX_UINT nStartPos,
386 FX_UINT nStopPos,
387 FX_BOOL bAscend,
388 LP_COMPARE pCompare) {
389 if (nStartPos >= nStopPos)
390 return;
391
392 if ((nStopPos - nStartPos) == 1) {
393 TYPE Value1 = this->GetAt(nStartPos);
394 TYPE Value2 = this->GetAt(nStopPos);
395
396 int iGreate = (*pCompare)(Value1, Value2);
397 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) {
398 this->SetAt(nStartPos, Value2);
399 this->SetAt(nStopPos, Value1);
400 }
401 return;
402 }
403
404 FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
405 FX_UINT i = nStartPos;
406
407 TYPE Value = this->GetAt(m);
408
409 while (i < m) {
410 TYPE temp = this->GetAt(i);
411
412 int iGreate = (*pCompare)(temp, Value);
413 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) {
414 this->InsertAt(m + 1, temp);
415 this->RemoveAt(i);
416 m--;
417 } else {
418 i++;
419 }
420 }
421
422 FX_UINT j = nStopPos;
423
424 while (j > m) {
425 TYPE temp = this->GetAt(j);
426
427 int iGreate = (*pCompare)(temp, Value);
428 if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) {
429 this->RemoveAt(j);
430 this->InsertAt(m, temp);
431 m++;
432 } else {
433 j--;
434 }
435 }
436
437 if (nStartPos < m)
438 QuickSort(nStartPos, m, bAscend, pCompare);
439 if (nStopPos > m)
440 QuickSort(m, nStopPos, bAscend, pCompare);
441 }
442 };
443
444 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ 372 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698