From ab0d4b30afbbd16e88b297cf5002e5385ed3e94f Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Thu, 11 Mar 2021 02:18:40 -0800 Subject: [PATCH] IWYU pass --- src/rgbcx/BC1/BC1Decoder.h | 4 +++- src/rgbcx/BC1/BC1Encoder.cpp | 2 +- src/rgbcx/BC1/BC1Encoder.h | 4 +++- src/rgbcx/BC1/OrderTable.h | 2 ++ src/rgbcx/BC3/BC3Decoder.cpp | 4 ++-- src/rgbcx/BC4/BC4Encoder.cpp | 12 +++++++----- src/rgbcx/BC5/BC5Decoder.h | 3 +-- src/rgbcx/BlockDecoder.h | 3 ++- src/rgbcx/BlockEncoder.h | 3 +-- src/rgbcx/Color.cpp | 2 +- src/rgbcx/Matrix4x4.h | 2 ++ src/rgbcx/bindings/Decoders.cpp | 5 ++++- src/rgbcx/bindings/Encoders.cpp | 6 +++++- tests/run_tests.cpp | 4 ++++ 14 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/rgbcx/BC1/BC1Decoder.h b/src/rgbcx/BC1/BC1Decoder.h index 9d97817..331e06a 100644 --- a/src/rgbcx/BC1/BC1Decoder.h +++ b/src/rgbcx/BC1/BC1Decoder.h @@ -20,6 +20,7 @@ #pragma once #include +#include #include "../BlockDecoder.h" #include "../BlockView.h" @@ -32,7 +33,7 @@ class BC1Decoder final : public BlockDecoderTemplate { public: using InterpolatorPtr = std::shared_ptr; BC1Decoder(Interpolator::Type type = Interpolator::Type::Ideal, bool write_alpha = false) - : _interpolator(Interpolator::MakeInterpolator(type)), write_alpha(write_alpha) {} + : write_alpha(write_alpha), _interpolator(Interpolator::MakeInterpolator(type)) {} void DecodeBlock(Color4x4 dest, BC1Block *const block) const noexcept(ndebug) override; @@ -40,6 +41,7 @@ class BC1Decoder final : public BlockDecoderTemplate { constexpr bool WritesAlpha() const { return write_alpha; } bool write_alpha; + private: const InterpolatorPtr _interpolator; }; diff --git a/src/rgbcx/BC1/BC1Encoder.cpp b/src/rgbcx/BC1/BC1Encoder.cpp index 74d600b..9afacbb 100644 --- a/src/rgbcx/BC1/BC1Encoder.cpp +++ b/src/rgbcx/BC1/BC1Encoder.cpp @@ -29,6 +29,7 @@ #include "../BlockView.h" #include "../Color.h" +#include "../Interpolator.h" #include "../Matrix4x4.h" #include "../Vector4.h" #include "../Vector4Int.h" @@ -45,7 +46,6 @@ using namespace BC1; BC1Encoder::BC1Encoder(Interpolator::Type type, unsigned int level, bool allow_3color, bool allow_3color_black) : _interpolator(Interpolator::MakeInterpolator(type)) { - OrderTable<3>::Generate(); OrderTable<4>::Generate(); diff --git a/src/rgbcx/BC1/BC1Encoder.h b/src/rgbcx/BC1/BC1Encoder.h index 895d569..fe3bc57 100644 --- a/src/rgbcx/BC1/BC1Encoder.h +++ b/src/rgbcx/BC1/BC1Encoder.h @@ -21,17 +21,19 @@ #include #include +#include #include #include +#include #include "../BlockEncoder.h" #include "../BlockView.h" #include "../Color.h" +#include "../Interpolator.h" #include "BC1Block.h" #include "SingleColorTable.h" namespace rgbcx { -class Interpolator; class Vector4; class BC1Encoder final : public BlockEncoderTemplate { diff --git a/src/rgbcx/BC1/OrderTable.h b/src/rgbcx/BC1/OrderTable.h index c146170..7a8923e 100644 --- a/src/rgbcx/BC1/OrderTable.h +++ b/src/rgbcx/BC1/OrderTable.h @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include #include "../Vector4.h" #include "Histogram.h" diff --git a/src/rgbcx/BC3/BC3Decoder.cpp b/src/rgbcx/BC3/BC3Decoder.cpp index 2115b55..ebca076 100644 --- a/src/rgbcx/BC3/BC3Decoder.cpp +++ b/src/rgbcx/BC3/BC3Decoder.cpp @@ -19,8 +19,8 @@ #include "BC3Decoder.h" -#include "../BC1/BC1Decoder.h" -#include "../BC4/BC4Decoder.h" +#include + #include "../BlockView.h" #include "../ndebug.h" #include "BC3Block.h" diff --git a/src/rgbcx/BC4/BC4Encoder.cpp b/src/rgbcx/BC4/BC4Encoder.cpp index 17c5dd0..4b42108 100644 --- a/src/rgbcx/BC4/BC4Encoder.cpp +++ b/src/rgbcx/BC4/BC4Encoder.cpp @@ -19,12 +19,14 @@ #include "BC4Encoder.h" -#include // for minmax_element -#include // for array -#include // for uint8_t -#include // for pair +#include +#include +#include +#include -#include "BC4Block.h" // for BC4Block +#include "../BlockView.h" +#include "../ndebug.h" +#include "BC4Block.h" namespace rgbcx { void BC4Encoder::EncodeBlock(Byte4x4 pixels, BC4Block *const dest) const noexcept(ndebug) { diff --git a/src/rgbcx/BC5/BC5Decoder.h b/src/rgbcx/BC5/BC5Decoder.h index daa38f2..3ee8814 100644 --- a/src/rgbcx/BC5/BC5Decoder.h +++ b/src/rgbcx/BC5/BC5Decoder.h @@ -19,11 +19,10 @@ #pragma once -#include -#include #include #include #include +#include #include "../BC4/BC4Decoder.h" #include "../BlockDecoder.h" diff --git a/src/rgbcx/BlockDecoder.h b/src/rgbcx/BlockDecoder.h index b9245b9..2ac9812 100644 --- a/src/rgbcx/BlockDecoder.h +++ b/src/rgbcx/BlockDecoder.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "BlockView.h" #include "ndebug.h" @@ -75,7 +76,7 @@ class BlockDecoderTemplate : public BlockDecoder { assert(pixel_x + N <= image_width); unsigned top_left = pixel_x + (pixel_y * image_width); - auto dest = DecodedBlock(&decoded[top_left], image_width); + auto dest = DecodedBlock(&decoded[top_left], (int)image_width); DecodeBlock(dest, &blocks[x + block_width * y]); } diff --git a/src/rgbcx/BlockEncoder.h b/src/rgbcx/BlockEncoder.h index 6807a25..0349da7 100644 --- a/src/rgbcx/BlockEncoder.h +++ b/src/rgbcx/BlockEncoder.h @@ -55,7 +55,6 @@ template class BlockEncoderTemplate : public Block unsigned block_width = image_width / N; unsigned block_height = image_height / M; - unsigned block_count = block_width * block_height; auto blocks = reinterpret_cast(encoded); @@ -64,7 +63,7 @@ template class BlockEncoderTemplate : public Block // As a result, this is sometimes left as a serial operation despite being embarassingly parallelizable // threshold for number of blocks before multithreading is set by overriding MTThreshold() -#pragma omp parallel for if (block_count >= MTThreshold()) +#pragma omp parallel for if (block_width * block_height >= MTThreshold()) for (unsigned y = 0; y < block_height; y++) { for (unsigned x = 0; x < block_width; x++) { unsigned pixel_x = x * N; diff --git a/src/rgbcx/Color.cpp b/src/rgbcx/Color.cpp index afaeaa7..f512683 100644 --- a/src/rgbcx/Color.cpp +++ b/src/rgbcx/Color.cpp @@ -30,7 +30,7 @@ Color::Color() { SetRGBA(0, 0, 0, 0xFF); } Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { SetRGBA(r, g, b, a); } -Color::Color(Vector4Int v) { SetRGBA(v[0], v[1], v[2], v[3]); } +Color::Color(Vector4Int v) { SetRGBA((uint8_t)v[0], (uint8_t)v[1], (uint8_t)v[2], (uint8_t)v[3]); } uint16_t Color::Pack565Unscaled(uint8_t r, uint8_t g, uint8_t b) { assert5bit(r); diff --git a/src/rgbcx/Matrix4x4.h b/src/rgbcx/Matrix4x4.h index cb4729c..a198e9e 100644 --- a/src/rgbcx/Matrix4x4.h +++ b/src/rgbcx/Matrix4x4.h @@ -20,6 +20,8 @@ #pragma once #include +#include +#include #include #include "Vector4.h" diff --git a/src/rgbcx/bindings/Decoders.cpp b/src/rgbcx/bindings/Decoders.cpp index 6aa095b..d9201e1 100644 --- a/src/rgbcx/bindings/Decoders.cpp +++ b/src/rgbcx/bindings/Decoders.cpp @@ -19,14 +19,17 @@ #include +#include +#include #include +#include +#include #include "../BC1/BC1Decoder.h" #include "../BC3/BC3Decoder.h" #include "../BC4/BC4Decoder.h" #include "../BC5/BC5Decoder.h" #include "../BlockDecoder.h" -#include "../bitwiseEnums.h" namespace py = pybind11; namespace rgbcx::bindings { diff --git a/src/rgbcx/bindings/Encoders.cpp b/src/rgbcx/bindings/Encoders.cpp index 94168b5..632504e 100644 --- a/src/rgbcx/bindings/Encoders.cpp +++ b/src/rgbcx/bindings/Encoders.cpp @@ -19,11 +19,15 @@ #include +#include +#include #include +#include #include "../BC1/BC1Encoder.h" #include "../BlockEncoder.h" -#include "../bitwiseEnums.h" +#include "../Color.h" +#include "../Interpolator.h" #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/tests/run_tests.cpp b/tests/run_tests.cpp index 91508d0..3d0aeb8 100644 --- a/tests/run_tests.cpp +++ b/tests/run_tests.cpp @@ -20,6 +20,10 @@ // This file allows for easy debugging in CLion or other IDEs that dont natively support cross-debugging between Python and C++ #include + +#include +#include + namespace py = pybind11; #define STRINGIFY(x) #x