diff options
author | Android Chromium Automerger <chromium-automerger@android> | 2013-12-17 14:49:58 +0000 |
---|---|---|
committer | Android Chromium Automerger <chromium-automerger@android> | 2013-12-17 14:49:58 +0000 |
commit | 205450ef65e8d014451503882440bb25a0c9f38b (patch) | |
tree | 13eb26b8f2da237730f316c4ea388c1852854b7f /woff2/round.h | |
parent | 62030c64c7123356cce4fabcc12a921dc8aaabc5 (diff) | |
parent | 931479d735e1121548c3b07aec866fd772cc4932 (diff) | |
download | src-205450ef65e8d014451503882440bb25a0c9f38b.tar.gz |
Merge third_party/brotli/src from https://chromium.googlesource.com/external/font-compression-reference.git at 931479d735e1121548c3b07aec866fd772cc4932
This commit was generated by merge_from_chromium.py.
Change-Id: I0ce348d2a5ef41ea7bd5d2361fa096a634e209f0
Diffstat (limited to 'woff2/round.h')
-rw-r--r-- | woff2/round.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/woff2/round.h b/woff2/round.h new file mode 100644 index 0000000..4d88862 --- /dev/null +++ b/woff2/round.h @@ -0,0 +1,33 @@ +// Copyright 2013 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Helper for rounding + +#ifndef BROTLI_WOFF2_ROUND_H_ +#define BROTLI_WOFF2_ROUND_H_ + +namespace woff2 { + +// Round a value up to the nearest multiple of 4. Don't round the value in the +// case that rounding up overflows. +template<typename T> T Round4(T value) { + if (std::numeric_limits<T>::max() - value < 3) { + return value; + } + return (value + 3) & ~3; +} + +} // namespace woff2 + +#endif // BROTLI_WOFF2_ROUND_H_ |