diff --git a/quicktex/s3tc/bc3/BC3Decoder.cpp b/quicktex/s3tc/bc3/BC3Decoder.cpp index 085f253..df5b31c 100644 --- a/quicktex/s3tc/bc3/BC3Decoder.cpp +++ b/quicktex/s3tc/bc3/BC3Decoder.cpp @@ -29,6 +29,6 @@ namespace quicktex::s3tc { void BC3Decoder::DecodeBlock(Color4x4 dest, BC3Block *const block) const noexcept(ndebug) { _bc1_decoder->DecodeBlock(dest, &(block->color_block), false); - _bc4_decoder->DecodeBlock(dest, &(block->alpha_block), 3); + _bc4_decoder->DecodeBlock(dest, &(block->alpha_block)); } } // namespace quicktex::s3tc \ No newline at end of file diff --git a/quicktex/s3tc/bc3/BC3Encoder.cpp b/quicktex/s3tc/bc3/BC3Encoder.cpp index 8dfd850..c36f8bd 100644 --- a/quicktex/s3tc/bc3/BC3Encoder.cpp +++ b/quicktex/s3tc/bc3/BC3Encoder.cpp @@ -22,9 +22,9 @@ #include "../../BlockView.h" #include "BC3Block.h" -namespace quicktex::s3tc { +namespace quicktex::s3tc { void BC3Encoder::EncodeBlock(Color4x4 pixels, BC3Block *dest) const { _bc1_encoder->EncodeBlock(pixels, &(dest->color_block)); - _bc4_encoder->EncodeBlock(pixels, &(dest->alpha_block), 3); + _bc4_encoder->EncodeBlock(pixels, &(dest->alpha_block)); } } // namespace quicktex::s3tc \ No newline at end of file diff --git a/quicktex/s3tc/bc4/BC4Decoder.h b/quicktex/s3tc/bc4/BC4Decoder.h index 94c0ce6..130203a 100644 --- a/quicktex/s3tc/bc4/BC4Decoder.h +++ b/quicktex/s3tc/bc4/BC4Decoder.h @@ -28,21 +28,20 @@ #include "../../ndebug.h" #include "BC4Block.h" -namespace quicktex::s3tc { +namespace quicktex::s3tc { + class BC4Decoder : public BlockDecoderTemplate { public: - BC4Decoder(uint8_t channel = 3) { SetChannel(channel); } - - void DecodeBlock(Color4x4 dest, BC4Block *const block) const noexcept(ndebug) override { DecodeBlock(dest.GetChannel(_channel), block); } - void DecodeBlock(Color4x4 dest, BC4Block *const block, uint8_t channel) const noexcept(ndebug) { DecodeBlock(dest.GetChannel(channel), block); } - void DecodeBlock(Byte4x4 dest, BC4Block *const block) const noexcept(ndebug); - - uint8_t GetChannel() const { return _channel; } - void SetChannel(uint8_t channel) { + BC4Decoder(uint8_t channel = 3) { if (channel >= 4U) throw std::invalid_argument("Channel out of range"); _channel = channel; } + void DecodeBlock(Color4x4 dest, BC4Block *const block) const noexcept(ndebug) override { DecodeBlock(dest.GetChannel(_channel), block); } + void DecodeBlock(Byte4x4 dest, BC4Block *const block) const noexcept(ndebug); + + uint8_t GetChannel() const { return _channel; } + private: uint8_t _channel; }; diff --git a/quicktex/s3tc/bc4/BC4Encoder.h b/quicktex/s3tc/bc4/BC4Encoder.h index 1b31ecc..9d5e5a6 100644 --- a/quicktex/s3tc/bc4/BC4Encoder.h +++ b/quicktex/s3tc/bc4/BC4Encoder.h @@ -28,22 +28,20 @@ #include "../../ndebug.h" #include "BC4Block.h" -namespace quicktex::s3tc { +namespace quicktex::s3tc { class BC4Encoder : public BlockEncoderTemplate { public: - BC4Encoder(const uint8_t channel) { SetChannel(channel); } - - void EncodeBlock(Color4x4 pixels, BC4Block *const dest) const override { EncodeBlock(pixels.GetChannel(_channel), dest); } - void EncodeBlock(Color4x4 pixels, BC4Block *const dest, uint8_t channel) const noexcept(ndebug) { EncodeBlock(pixels.GetChannel(channel), dest); } - void EncodeBlock(Byte4x4 pixels, BC4Block *const dest) const noexcept(ndebug); - - uint8_t GetChannel() const { return _channel; } - void SetChannel(uint8_t channel) { + BC4Encoder(const uint8_t channel) { if (channel >= 4) throw std::invalid_argument("Channel out of range"); _channel = channel; } + void EncodeBlock(Color4x4 pixels, BC4Block *const dest) const override { EncodeBlock(pixels.GetChannel(_channel), dest); } + void EncodeBlock(Byte4x4 pixels, BC4Block *const dest) const noexcept(ndebug); + + uint8_t GetChannel() const { return _channel; } + private: uint8_t _channel; }; diff --git a/quicktex/s3tc/bc4/_bindings.cpp b/quicktex/s3tc/bc4/_bindings.cpp index 3181e8b..3200b10 100644 --- a/quicktex/s3tc/bc4/_bindings.cpp +++ b/quicktex/s3tc/bc4/_bindings.cpp @@ -45,13 +45,13 @@ void InitBC4(py::module_ &s3tc) { py::class_ bc4_encoder(bc4, "BC4Encoder", block_encoder); bc4_encoder.def(py::init(), py::arg("channel") = 3); - bc4_encoder.def_property("channel", &BC4Encoder::GetChannel, &BC4Encoder::SetChannel); + bc4_encoder.def_property_readonly("channel", &BC4Encoder::GetChannel, "The channel to read from. 0 to 3 inclusive. Readonly."); // BC4Decoder py::class_ bc4_decoder(bc4, "BC4Decoder", block_decoder); bc4_decoder.def(py::init(), py::arg("channel") = 3); - bc4_decoder.def_property("channel", &BC4Decoder::GetChannel, &BC4Decoder::SetChannel); + bc4_decoder.def_property_readonly("channel", &BC4Decoder::GetChannel, "The channel to write to. 0 to 3 inclusive. Readonly."); } } // namespace quicktex::bindings \ No newline at end of file