mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Refactor and rebind constructors
This commit is contained in:
parent
64919ab55a
commit
70ebb43017
@ -1 +1,2 @@
|
||||
"""this is my docs"""
|
||||
from _quicktex import *
|
@ -50,8 +50,8 @@ For most applications, :py:attr:`~quicktex.s3tc.InterpolatorType.Ideal` should b
|
||||
|
||||
InitInterpolator(s3tc);
|
||||
InitBC1(s3tc);
|
||||
InitBC3(s3tc);
|
||||
InitBC4(s3tc);
|
||||
InitBC5(s3tc);
|
||||
// InitBC3(s3tc);
|
||||
// InitBC4(s3tc);
|
||||
// InitBC5(s3tc);
|
||||
}
|
||||
} // namespace quicktex::bindings
|
||||
|
@ -32,8 +32,12 @@ namespace quicktex::s3tc {
|
||||
class BC1Decoder final : public BlockDecoderTemplate<BC1Block, 4, 4> {
|
||||
public:
|
||||
using InterpolatorPtr = std::shared_ptr<Interpolator>;
|
||||
BC1Decoder(InterpolatorPtr interpolator = std::make_shared<Interpolator>(), bool write_alpha = false)
|
||||
: write_alpha(write_alpha), _interpolator(interpolator) {}
|
||||
|
||||
BC1Decoder(bool write_alpha, InterpolatorPtr interpolator) : write_alpha(write_alpha), _interpolator(interpolator) {}
|
||||
|
||||
BC1Decoder(bool write_alpha = false) : BC1Decoder(write_alpha, std::make_shared<Interpolator>()) {}
|
||||
|
||||
BC1Decoder(InterpolatorPtr interpolator) : BC1Decoder(false, interpolator) {}
|
||||
|
||||
void DecodeBlock(Color4x4 dest, BC1Block *const block) const noexcept(ndebug) override;
|
||||
|
||||
|
@ -43,8 +43,7 @@ namespace quicktex::s3tc {
|
||||
|
||||
// constructors
|
||||
|
||||
BC1Encoder::BC1Encoder(InterpolatorPtr interpolator, unsigned int level, bool allow_3color, bool allow_3color_black)
|
||||
: _interpolator(interpolator) {
|
||||
BC1Encoder::BC1Encoder(unsigned int level, bool allow_3color, bool allow_3color_black, InterpolatorPtr interpolator) : _interpolator(interpolator) {
|
||||
OrderTable<3>::Generate();
|
||||
OrderTable<4>::Generate();
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace quicktex {
|
||||
class Vector4;
|
||||
}
|
||||
|
||||
namespace quicktex::s3tc {
|
||||
namespace quicktex::s3tc {
|
||||
|
||||
class BC1Encoder final : public BlockEncoderTemplate<BC1Block, 4, 4> {
|
||||
public:
|
||||
@ -111,7 +111,10 @@ class BC1Encoder final : public BlockEncoderTemplate<BC1Block, 4, 4> {
|
||||
PCA
|
||||
};
|
||||
|
||||
BC1Encoder(InterpolatorPtr interpolator = std::make_shared<Interpolator>(), unsigned level = 5, bool allow_3color = true, bool allow_3color_black = true);
|
||||
BC1Encoder(unsigned level, bool allow_3color, bool allow_3color_black, InterpolatorPtr interpolator);
|
||||
|
||||
BC1Encoder(unsigned int level = 5, bool allow_3color = true, bool allow_3color_black = true)
|
||||
: BC1Encoder(level, allow_3color, allow_3color_black, std::make_shared<Interpolator>()) {}
|
||||
|
||||
Interpolator::Type GetInterpolatorType() const { return _interpolator->GetType(); }
|
||||
|
||||
|
@ -35,6 +35,8 @@ namespace py = pybind11;
|
||||
namespace quicktex::bindings {
|
||||
|
||||
using namespace quicktex::s3tc;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
using InterpolatorPtr = std::shared_ptr<Interpolator>;
|
||||
|
||||
void InitBC1(py::module_ &s3tc) {
|
||||
@ -45,8 +47,9 @@ void InitBC1(py::module_ &s3tc) {
|
||||
// BC1Encoder
|
||||
py::class_<BC1Encoder> bc1_encoder(bc1, "BC1Encoder", block_encoder);
|
||||
|
||||
bc1_encoder.def(py::init<InterpolatorPtr, unsigned, bool, bool>(), py::arg("interpolator") = std::make_shared<Interpolator>(), py::arg("level") = 5,
|
||||
py::arg("use_3color") = true, py::arg("use_3color_black") = true);
|
||||
bc1_encoder.def(py::init<unsigned, bool, bool>(), "level"_a = 5, "use_3color"_a = true, "use_3color_black"_a = true);
|
||||
bc1_encoder.def(py::init<unsigned, bool, bool, InterpolatorPtr>(), "level"_a, "use_3color"_a, "use_3color_black"_a, "interpolator"_a);
|
||||
|
||||
bc1_encoder.def("set_level", &BC1Encoder::SetLevel);
|
||||
bc1_encoder.def_property_readonly("interpolator_type", &BC1Encoder::GetInterpolatorType);
|
||||
bc1_encoder.def_property("flags", &BC1Encoder::GetFlags, &BC1Encoder::SetFlags);
|
||||
@ -89,7 +92,9 @@ void InitBC1(py::module_ &s3tc) {
|
||||
// BC1Decoder
|
||||
py::class_<BC1Decoder> bc1_decoder(bc1, "BC1Decoder", block_decoder);
|
||||
|
||||
bc1_decoder.def(py::init<InterpolatorPtr, bool>(), py::arg("interpolator") = std::make_shared<Interpolator>(), py::arg("write_alpha") = false);
|
||||
bc1_decoder.def(py::init<bool>(), "write_alpha"_a = false);
|
||||
bc1_decoder.def(py::init<bool, InterpolatorPtr>(), "write_alpha"_a, "interpolator"_a);
|
||||
|
||||
bc1_decoder.def_property_readonly("interpolator_type", &BC1Decoder::GetInterpolatorType);
|
||||
bc1_decoder.def_readwrite("write_alpha", &BC1Decoder::write_alpha);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "../interpolator/Interpolator.h"
|
||||
#include "BC3Block.h"
|
||||
|
||||
namespace quicktex::s3tc {
|
||||
namespace quicktex::s3tc {
|
||||
|
||||
class BC3Decoder : public BlockDecoderTemplate<BC3Block, 4, 4> {
|
||||
public:
|
||||
@ -37,8 +37,9 @@ class BC3Decoder : public BlockDecoderTemplate<BC3Block, 4, 4> {
|
||||
using BC4DecoderPtr = std::shared_ptr<BC4Decoder>;
|
||||
using InterpolatorPtr = std::shared_ptr<Interpolator>;
|
||||
|
||||
BC3Decoder(InterpolatorPtr interpolator = std::make_shared<Interpolator>()) : BC3Decoder(std::make_shared<BC1Decoder>(interpolator), std::make_shared<BC4Decoder>(3)) {}
|
||||
BC3Decoder(BC1DecoderPtr bc1_decoder, BC4DecoderPtr bc4_decoder = std::make_shared<BC4Decoder>()) : _bc1_decoder(bc1_decoder), _bc4_decoder(bc4_decoder) {}
|
||||
BC3Decoder(BC1DecoderPtr bc1_decoder) : _bc1_decoder(bc1_decoder), _bc4_decoder(std::make_shared<BC4Decoder>(3)) {}
|
||||
|
||||
BC3Decoder(InterpolatorPtr interpolator = std::make_shared<Interpolator>()) : BC3Decoder(std::make_shared<BC1Decoder>(interpolator)) {}
|
||||
|
||||
void DecodeBlock(Color4x4 dest, BC3Block *const block) const noexcept(ndebug) override;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "../interpolator/Interpolator.h"
|
||||
#include "BC3Block.h"
|
||||
|
||||
namespace quicktex::s3tc {
|
||||
namespace quicktex::s3tc {
|
||||
|
||||
class BC3Encoder : public BlockEncoderTemplate<BC3Block, 4, 4> {
|
||||
public:
|
||||
@ -36,8 +36,13 @@ class BC3Encoder : public BlockEncoderTemplate<BC3Block, 4, 4> {
|
||||
using BC4EncoderPtr = std::shared_ptr<BC4Encoder>;
|
||||
using InterpolatorPtr = std::shared_ptr<Interpolator>;
|
||||
|
||||
BC3Encoder(InterpolatorPtr interpolator = std::make_shared<Interpolator>(), unsigned level = 5, bool allow_3color = true, bool allow_3color_black = true)
|
||||
: _bc1_encoder(std::make_shared<BC1Encoder>(interpolator, level, allow_3color, allow_3color_black)), _bc4_encoder(std::make_shared<BC4Encoder>(3)) {}
|
||||
BC3Encoder(BC1EncoderPtr bc1_encoder) : _bc1_encoder(bc1_encoder), _bc4_encoder(std::make_shared<BC4Encoder>(3)) {}
|
||||
|
||||
BC3Encoder(unsigned level, bool allow_3color, bool allow_3color_black, InterpolatorPtr interpolator)
|
||||
: BC3Encoder(std::make_shared<BC1Encoder>(level, allow_3color, allow_3color_black, interpolator)) {}
|
||||
|
||||
BC3Encoder(unsigned level = 5, bool allow_3color = true, bool allow_3color_black = true)
|
||||
: BC3Encoder(std::make_shared<BC1Encoder>(level, allow_3color, allow_3color_black, std::make_shared<Interpolator>())) {}
|
||||
|
||||
void EncodeBlock(Color4x4 pixels, BC3Block *dest) const override;
|
||||
|
||||
|
@ -35,7 +35,11 @@ namespace py = pybind11;
|
||||
namespace quicktex::bindings {
|
||||
|
||||
using namespace quicktex::s3tc;
|
||||
using namespace pybind11::literals;
|
||||
using InterpolatorPtr = std::shared_ptr<Interpolator>;
|
||||
using BC1EncoderPtr = std::shared_ptr<BC1Encoder>;
|
||||
using BC1DecoderPtr = std::shared_ptr<BC1Decoder>;
|
||||
|
||||
|
||||
void InitBC3(py::module_ &s3tc) {
|
||||
auto bc3 = s3tc.def_submodule("_bc3", "BC3 encoding/decoding module");
|
||||
@ -45,15 +49,20 @@ void InitBC3(py::module_ &s3tc) {
|
||||
// BC3Encoder
|
||||
py::class_<BC3Encoder> bc3_encoder(bc3, "BC3Encoder", block_encoder);
|
||||
|
||||
bc3_encoder.def(py::init<InterpolatorPtr, unsigned, bool, bool>(), py::arg("interpolator") = std::make_shared<Interpolator>(), py::arg("level") = 5,
|
||||
py::arg("use_3color") = true, py::arg("use_3color_black") = true);
|
||||
bc3_encoder.def(py::init<BC1EncoderPtr>(), "bc1_encoder"_a);
|
||||
bc3_encoder.def(py::init<unsigned, bool, bool>(), "level"_a = 5, "use_3color"_a = true, "use_3color_black"_a = true);
|
||||
bc3_encoder.def(py::init<unsigned, bool, bool, InterpolatorPtr>(), "level"_a, "use_3color"_a, "use_3color_black"_a, "interpolator"_a);
|
||||
|
||||
bc3_encoder.def_property_readonly("bc1_encoder", &BC3Encoder::GetBC1Encoder);
|
||||
bc3_encoder.def_property_readonly("bc4_encoder", &BC3Encoder::GetBC4Encoder);
|
||||
|
||||
// BC3Decoder
|
||||
py::class_<BC3Decoder> bc3_decoder(bc3, "BC3Decoder", block_decoder);
|
||||
|
||||
bc3_decoder.def(py::init<InterpolatorPtr>(), py::arg("interpolator") = std::make_shared<Interpolator>());
|
||||
bc3_decoder.def(py::init<>());
|
||||
bc3_decoder.def(py::init<BC1DecoderPtr>(), "bc1_decoder"_a);
|
||||
bc3_decoder.def(py::init<InterpolatorPtr>(), "interpolator"_a);
|
||||
|
||||
bc3_decoder.def_property_readonly("bc1_decoder", &BC3Decoder::GetBC1Decoder);
|
||||
bc3_decoder.def_property_readonly("bc4_decoder", &BC3Decoder::GetBC4Decoder);
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
# from _quicktex._s3tc._interpolator import *
|
||||
from _quicktex._s3tc._interpolator import *
|
Loading…
Reference in New Issue
Block a user