mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
make BC4 channel readonly
This commit is contained in:
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
|
@ -25,6 +25,6 @@
|
||||
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
|
@ -29,20 +29,19 @@
|
||||
#include "BC4Block.h"
|
||||
|
||||
namespace quicktex::s3tc {
|
||||
|
||||
class BC4Decoder : public BlockDecoderTemplate<BC4Block, 4, 4> {
|
||||
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;
|
||||
};
|
||||
|
@ -32,18 +32,16 @@ namespace quicktex::s3tc {
|
||||
|
||||
class BC4Encoder : public BlockEncoderTemplate<BC4Block, 4, 4> {
|
||||
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;
|
||||
};
|
||||
|
@ -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…
Reference in New Issue
Block a user