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

Side by Side Diff: core/fpdfapi/page/fpdf_page_func.cpp

Issue 2412833002: Optimize roll operator in CPDF_PSEngine. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | no next file » | 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 #include "core/fpdfapi/page/pageint.h" 7 #include "core/fpdfapi/page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 case PSOP_INDEX: { 369 case PSOP_INDEX: {
370 int n = static_cast<int>(Pop()); 370 int n = static_cast<int>(Pop());
371 if (n < 0 || n >= static_cast<int>(m_StackCount)) 371 if (n < 0 || n >= static_cast<int>(m_StackCount))
372 break; 372 break;
373 Push(m_Stack[m_StackCount - n - 1]); 373 Push(m_Stack[m_StackCount - n - 1]);
374 break; 374 break;
375 } 375 }
376 case PSOP_ROLL: { 376 case PSOP_ROLL: {
377 int j = static_cast<int>(Pop()); 377 int j = static_cast<int>(Pop());
378 int n = static_cast<int>(Pop()); 378 int n = static_cast<int>(Pop());
379 if (m_StackCount == 0) 379 if (j == 0 || n == 0 || m_StackCount == 0)
380 break; 380 break;
381 if (n < 0 || n > static_cast<int>(m_StackCount)) 381 if (n < 0 || n > static_cast<int>(m_StackCount))
382 break; 382 break;
383
384 j %= n;
383 if (j < 0) { 385 if (j < 0) {
384 for (int i = 0; i < -j; i++) { 386 for (int i = 0; i < -j; i++) {
385 FX_FLOAT first = m_Stack[m_StackCount - n]; 387 FX_FLOAT first = m_Stack[m_StackCount - n];
386 for (int ii = 0; ii < n - 1; ii++) 388 for (int ii = 0; ii < n - 1; ii++)
387 m_Stack[m_StackCount - n + ii] = m_Stack[m_StackCount - n + ii + 1]; 389 m_Stack[m_StackCount - n + ii] = m_Stack[m_StackCount - n + ii + 1];
388 m_Stack[m_StackCount - 1] = first; 390 m_Stack[m_StackCount - 1] = first;
389 } 391 }
390 } else { 392 } else {
391 for (int i = 0; i < j; i++) { 393 for (int i = 0; i < j; i++) {
392 FX_FLOAT last = m_Stack[m_StackCount - 1]; 394 FX_FLOAT last = m_Stack[m_StackCount - 1];
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return m_Type == Type::kType2ExpotentialInterpolation 838 return m_Type == Type::kType2ExpotentialInterpolation
837 ? static_cast<const CPDF_ExpIntFunc*>(this) 839 ? static_cast<const CPDF_ExpIntFunc*>(this)
838 : nullptr; 840 : nullptr;
839 } 841 }
840 842
841 const CPDF_StitchFunc* CPDF_Function::ToStitchFunc() const { 843 const CPDF_StitchFunc* CPDF_Function::ToStitchFunc() const {
842 return m_Type == Type::kType3Stitching 844 return m_Type == Type::kType3Stitching
843 ? static_cast<const CPDF_StitchFunc*>(this) 845 ? static_cast<const CPDF_StitchFunc*>(this)
844 : nullptr; 846 : nullptr;
845 } 847 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698