Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/imbuf/intern/dds/PixelFormat.h
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/imbuf/intern/dds/PixelFormat.h')
-rw-r--r--source/blender/imbuf/intern/dds/PixelFormat.h142
1 files changed, 70 insertions, 72 deletions
diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h
index 7c50245858f..07912b86f47 100644
--- a/source/blender/imbuf/intern/dds/PixelFormat.h
+++ b/source/blender/imbuf/intern/dds/PixelFormat.h
@@ -18,7 +18,6 @@
* \ingroup imbdds
*/
-
/*
* This file is based on a similar file from the NVIDIA texture tools
* (http://nvidia-texture-tools.googlecode.com/)
@@ -54,79 +53,78 @@
#include <Common.h>
- namespace PixelFormat
- {
-
- // Convert component \a c having \a inbits to the returned value having \a outbits.
- inline uint convert(uint c, uint inbits, uint outbits)
- {
- if (inbits == 0) {
- return 0;
- }
- else if (inbits >= outbits) {
- // truncate
- return c >> (inbits - outbits);
- }
- else {
- // bitexpand
- return (c << (outbits - inbits)) | convert(c, inbits, outbits - inbits);
- }
- }
-
- // Get pixel component shift and size given its mask.
- inline void maskShiftAndSize(uint mask, uint *shift, uint *size)
- {
- if (!mask) {
- *shift = 0;
- *size = 0;
- return;
- }
-
- *shift = 0;
- while ((mask & 1) == 0) {
- ++(*shift);
- mask >>= 1;
- }
-
- *size = 0;
- while ((mask & 1) == 1) {
- ++(*size);
- mask >>= 1;
- }
- }
-
- inline float quantizeCeil(float f, int inbits, int outbits)
- {
- //uint i = f * (float(1 << inbits) - 1);
- //i = convert(i, inbits, outbits);
- //float result = float(i) / (float(1 << outbits) - 1);
- //nvCheck(result >= f);
- float result;
- int offset = 0;
- do {
- uint i = offset + uint(f * (float(1 << inbits) - 1));
- i = convert(i, inbits, outbits);
- result = float(i) / (float(1 << outbits) - 1);
- offset++;
- } while (result < f);
-
- return result;
- }
+namespace PixelFormat {
+
+// Convert component \a c having \a inbits to the returned value having \a outbits.
+inline uint convert(uint c, uint inbits, uint outbits)
+{
+ if (inbits == 0) {
+ return 0;
+ }
+ else if (inbits >= outbits) {
+ // truncate
+ return c >> (inbits - outbits);
+ }
+ else {
+ // bitexpand
+ return (c << (outbits - inbits)) | convert(c, inbits, outbits - inbits);
+ }
+}
+
+// Get pixel component shift and size given its mask.
+inline void maskShiftAndSize(uint mask, uint *shift, uint *size)
+{
+ if (!mask) {
+ *shift = 0;
+ *size = 0;
+ return;
+ }
+
+ *shift = 0;
+ while ((mask & 1) == 0) {
+ ++(*shift);
+ mask >>= 1;
+ }
+
+ *size = 0;
+ while ((mask & 1) == 1) {
+ ++(*size);
+ mask >>= 1;
+ }
+}
+
+inline float quantizeCeil(float f, int inbits, int outbits)
+{
+ //uint i = f * (float(1 << inbits) - 1);
+ //i = convert(i, inbits, outbits);
+ //float result = float(i) / (float(1 << outbits) - 1);
+ //nvCheck(result >= f);
+ float result;
+ int offset = 0;
+ do {
+ uint i = offset + uint(f * (float(1 << inbits) - 1));
+ i = convert(i, inbits, outbits);
+ result = float(i) / (float(1 << outbits) - 1);
+ offset++;
+ } while (result < f);
+
+ return result;
+}
#if 0
- inline float quantizeRound(float f, int bits)
- {
- float scale = float(1 << bits);
- return fround(f * scale) / scale;
- }
-
- inline float quantizeFloor(float f, int bits)
- {
- float scale = float(1 << bits);
- return floor(f * scale) / scale;
- }
+ inline float quantizeRound(float f, int bits)
+ {
+ float scale = float(1 << bits);
+ return fround(f * scale) / scale;
+ }
+
+ inline float quantizeFloor(float f, int bits)
+ {
+ float scale = float(1 << bits);
+ return floor(f * scale) / scale;
+ }
#endif
- } // PixelFormat namespace
+} // namespace PixelFormat
-#endif /* __PIXELFORMAT_H__ */
+#endif /* __PIXELFORMAT_H__ */