make BC4 channel readonly

hotfix/mipmap-alpha-fix
Andrew Cassidy 3 years ago
parent 285e891bef
commit 5a272c954f

@ -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

@ -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

@ -28,20 +28,19 @@
#include "../../ndebug.h"
#include "BC4Block.h"
namespace quicktex::s3tc {
namespace quicktex::s3tc {
class BC4Decoder : public BlockDecoderTemplate<BC4Block, 4, 4> {
public:
BC4Decoder(uint8_t channel = 3) { SetChannel(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(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) {
if (channel >= 4U) throw std::invalid_argument("Channel out of range");
_channel = channel;
}
private:
uint8_t _channel;

@ -28,21 +28,19 @@
#include "../../ndebug.h"
#include "BC4Block.h"
namespace quicktex::s3tc {
namespace quicktex::s3tc {
class BC4Encoder : public BlockEncoderTemplate<BC4Block, 4, 4> {
public:
BC4Encoder(const uint8_t channel) { SetChannel(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(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) {
if (channel >= 4) throw std::invalid_argument("Channel out of range");
_channel = channel;
}
private:
uint8_t _channel;

@ -45,13 +45,13 @@ void InitBC4(py::module_ &s3tc) {
py::class_<BC4Encoder> bc4_encoder(bc4, "BC4Encoder", block_encoder);
bc4_encoder.def(py::init<uint8_t>(), 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_<BC4Decoder> bc4_decoder(bc4, "BC4Decoder", block_decoder);
bc4_decoder.def(py::init<uint8_t>(), 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
Loading…
Cancel
Save