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 #include "core/fxcrt/fx_basic.h" | 7 #include "core/fxcrt/fx_basic.h" |
8 #include "core/fxcrt/fx_ext.h" | 8 #include "core/fxcrt/fx_ext.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 static_cast<uint32_t>(std::numeric_limits<int>::max()) + 1) { | 58 static_cast<uint32_t>(std::numeric_limits<int>::max()) + 1) { |
59 integer = kDefaultIntValue; | 59 integer = kDefaultIntValue; |
60 } | 60 } |
61 } else if (integer.ValueOrDefault(kDefaultIntValue) > | 61 } else if (integer.ValueOrDefault(kDefaultIntValue) > |
62 static_cast<uint32_t>(std::numeric_limits<int>::max())) { | 62 static_cast<uint32_t>(std::numeric_limits<int>::max())) { |
63 integer = kDefaultIntValue; | 63 integer = kDefaultIntValue; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 // Switch back to the int space so we can flip to a negative if we need. | 67 // Switch back to the int space so we can flip to a negative if we need. |
68 int value = static_cast<int>(integer.ValueOrDefault(kDefaultIntValue)); | 68 int value = integer.ValueOrDefault<int>(kDefaultIntValue); |
69 if (bNegative) | 69 if (bNegative) |
70 value = -value; | 70 value = -value; |
71 | 71 |
72 int* pInt = static_cast<int*>(pData); | 72 int* pInt = static_cast<int*>(pData); |
73 *pInt = value; | 73 *pInt = value; |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 static const FX_FLOAT fraction_scales[] = { | 77 static const FX_FLOAT fraction_scales[] = { |
78 0.1f, 0.01f, 0.001f, 0.0001f, | 78 0.1f, 0.01f, 0.001f, 0.0001f, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 dstShift -= 8; | 260 dstShift -= 8; |
261 result |= *dataPtr++ << dstShift; | 261 result |= *dataPtr++ << dstShift; |
262 } | 262 } |
263 if (dstShift > 0) { | 263 if (dstShift > 0) { |
264 bitShift = 8 - dstShift; | 264 bitShift = 8 - dstShift; |
265 bitMask = (1 << dstShift) - 1; | 265 bitMask = (1 << dstShift) - 1; |
266 result |= *dataPtr++ >> bitShift & bitMask; | 266 result |= *dataPtr++ >> bitShift & bitMask; |
267 } | 267 } |
268 return result; | 268 return result; |
269 } | 269 } |
OLD | NEW |