mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Use pybind11-generated docstring signatures
This commit is contained in:
parent
25cd3bba24
commit
9fdbaf2909
@ -165,16 +165,12 @@ template <typename T, typename Getter, typename Setter, typename Extent> void De
|
||||
|
||||
template <typename B> py::class_<B> BindBlock(py::module_& m, const char* name) {
|
||||
const char* frombytes_doc = R"doc(
|
||||
from_bytes(b) -> {0}
|
||||
|
||||
Create a new {0} by copying a bytes-like object.
|
||||
|
||||
:param b: A bytes-like object at least the size of the block.
|
||||
)doc";
|
||||
|
||||
const char* tobytes_doc = R"doc(
|
||||
tobytes(self) -> bytes
|
||||
|
||||
Pack the {0} into a bytestring.
|
||||
|
||||
:returns: A bytes object of length {1}.
|
||||
@ -200,8 +196,6 @@ template <typename B> py::class_<B> BindBlock(py::module_& m, const char* name)
|
||||
|
||||
template <typename B> py::class_<BlockTexture<B>> BindBlockTexture(py::module_& m, const char* name) {
|
||||
const auto* const constructor_str = R"doc(
|
||||
__init__(self, width: int, height: int) -> None
|
||||
|
||||
Create a new blank {0} with the given dimensions.
|
||||
If the dimenions are not multiples of the block dimensions, enough blocks will be allocated
|
||||
to cover the entire texture, and it will be implicitly cropped during decoding.
|
||||
@ -211,8 +205,6 @@ template <typename B> py::class_<BlockTexture<B>> BindBlockTexture(py::module_&
|
||||
)doc";
|
||||
|
||||
const auto* const from_bytes_str = R"doc(
|
||||
from_bytes(b, width: int, height: int) -> {0}
|
||||
|
||||
Create a new {0} with the given dimensions, and copy a bytes-like object into it.
|
||||
If the dimenions are not multiples of the block dimensions, enough blocks will be allocated
|
||||
to cover the entire texture, and it will be implicitly cropped during decoding.
|
||||
@ -233,9 +225,6 @@ template <typename B> py::class_<BlockTexture<B>> BindBlockTexture(py::module_&
|
||||
block_texture.def_property_readonly("height_blocks", &BTex::BlocksY, "The height of the texture in blocks.");
|
||||
block_texture.def_property_readonly("dimensions_blocks", &BTex::BlocksXY, "The dimensions of the texture in blocks.");
|
||||
|
||||
block_texture.def_property_readonly_static(
|
||||
"block", [](py::object) { return py::type::of<B>(); }, "The block type used by this texture.");
|
||||
|
||||
DefSubscript2D(block_texture, &BTex::GetBlock, &BTex::SetBlock, &BTex::BlocksXY);
|
||||
|
||||
return block_texture;
|
||||
|
@ -38,8 +38,8 @@ void InitS3TC(py::module_ &m) {
|
||||
|
||||
InitInterpolator(s3tc);
|
||||
InitBC1(s3tc);
|
||||
InitBC3(s3tc);
|
||||
InitBC4(s3tc);
|
||||
InitBC3(s3tc);
|
||||
InitBC5(s3tc);
|
||||
}
|
||||
} // namespace quicktex::bindings
|
||||
|
@ -45,17 +45,12 @@ using InterpolatorPtr = std::shared_ptr<Interpolator>;
|
||||
void InitBC1(py::module_ &s3tc) {
|
||||
auto bc1 = s3tc.def_submodule("_bc1", "internal bc1 module");
|
||||
|
||||
py::options options;
|
||||
options.disable_function_signatures();
|
||||
|
||||
// region BC1Block
|
||||
auto bc1_block = BindBlock<BC1Block>(bc1, "BC1Block");
|
||||
bc1_block.doc() = "A single BC1 block.";
|
||||
|
||||
bc1_block.def(py::init<>());
|
||||
bc1_block.def(py::init<Color, Color, BC1Block::SelectorArray>(), "color0"_a, "color1"_a, "selectors"_a, R"doc(
|
||||
__init__(self, color0, color1, selectors: List[List[int]]) -> None
|
||||
|
||||
Create a new BC1Block with the specified endpoints and selectors
|
||||
|
||||
:param color0: The first endpoint
|
||||
@ -109,8 +104,6 @@ void InitBC1(py::module_ &s3tc) {
|
||||
|
||||
bc1_encoder.def(py::init<unsigned, BC1Encoder::ColorMode>(), "level"_a = 5, "color_mode"_a = BC1Encoder::ColorMode::FourColor);
|
||||
bc1_encoder.def(py::init<unsigned, BC1Encoder::ColorMode, InterpolatorPtr>(), "level"_a, "color_mode"_a, "interpolator"_a, R"doc(
|
||||
__init__(self, level: int = 5, color_mode=ColorMode.FourColor, interpolator=Interpolator()) -> None
|
||||
|
||||
Create a new BC1 encoder with the specified preset level, color mode, and interpolator.
|
||||
|
||||
:param int level: The preset level of the resulting encoder, between 0 and 18 inclusive. See :py:meth:`set_level` for more information. Default: 5.
|
||||
@ -119,8 +112,6 @@ void InitBC1(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc1_encoder.def("encode", &BC1Encoder::Encode, "texture"_a, R"doc(
|
||||
encode(self, texture: RawTexture) -> BC1Texture
|
||||
|
||||
Encode a raw texture into a new BC1Texture using the encoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
@ -128,8 +119,6 @@ void InitBC1(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc1_encoder.def("set_level", &BC1Encoder::SetLevel, "level"_a, R"doc(
|
||||
set_level(self, level : int = 5) -> None
|
||||
|
||||
Select a preset quality level, between 0 and 18 inclusive. Higher quality levels are slower, but produce blocks that are a closer match to input.
|
||||
This has no effect on the size of the resulting texture, since BC1 is a fixed-ratio compression method. For better control, see the advanced API below
|
||||
|
||||
@ -183,8 +172,6 @@ void InitBC1(py::module_ &s3tc) {
|
||||
|
||||
bc1_decoder.def(py::init<bool>(), "write_alpha"_a = false);
|
||||
bc1_decoder.def(py::init<bool, InterpolatorPtr>(), "write_alpha"_a, "interpolator"_a, R"doc(
|
||||
__init__(self, interpolator = Interpolator()) -> None
|
||||
|
||||
Create a new BC1 decoder with the specificied interpolator.
|
||||
|
||||
:param bool write_alpha: Determines if the alpha channel of the output is written to. Default: False;
|
||||
@ -192,8 +179,6 @@ void InitBC1(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc1_decoder.def("decode", &BC1Decoder::Decode, "texture"_a, R"doc(
|
||||
decode(self, texture: BC1Texture) -> RawTexture
|
||||
|
||||
Decode a BC1 texture into a new RawTexture using the decoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
|
@ -44,8 +44,6 @@ using BC1DecoderPtr = std::shared_ptr<BC1Decoder>;
|
||||
|
||||
void InitBC3(py::module_ &s3tc) {
|
||||
auto bc3 = s3tc.def_submodule("_bc3", "internal bc3 module");
|
||||
py::options options;
|
||||
options.disable_function_signatures();
|
||||
|
||||
// region BC3Block
|
||||
auto bc3_block = BindBlock<BC3Block>(bc3, "BC3Block");
|
||||
@ -53,8 +51,6 @@ void InitBC3(py::module_ &s3tc) {
|
||||
|
||||
bc3_block.def(py::init<>());
|
||||
bc3_block.def(py::init<BC4Block, BC1Block>(), "alpha_block"_a, "color_block"_a, R"doc(
|
||||
__init__(self, alpha_block: BC4Block, color_block: BC1Block) -> None
|
||||
|
||||
Create a new BC3Block out of a BC4 block and a BC1 block.
|
||||
|
||||
:param BC4Block alpha_block: The BC4 block used for alpha data.
|
||||
@ -73,15 +69,11 @@ void InitBC3(py::module_ &s3tc) {
|
||||
|
||||
// region BC3Encoder
|
||||
py::class_<BC3Encoder> bc3_encoder(bc3, "BC3Encoder", R"doc(
|
||||
Base: :py:class:`~quicktex.BlockEncoder`
|
||||
|
||||
Encodes RGBA textures to BC3
|
||||
)doc");
|
||||
|
||||
bc3_encoder.def(py::init<unsigned>(), "level"_a = 5);
|
||||
bc3_encoder.def(py::init<unsigned, InterpolatorPtr>(), "level"_a, "interpolator"_a, R"doc(
|
||||
__init__(self, level: int = 5, interpolator=Interpolator()) -> None
|
||||
|
||||
Create a new BC3 encoder with the specified preset level and interpolator.
|
||||
|
||||
:param int level: The preset level of the resulting encoder, between 0 and 18 inclusive.
|
||||
@ -90,8 +82,6 @@ void InitBC3(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc3_encoder.def("encode", &BC3Encoder::Encode, "texture"_a, R"doc(
|
||||
encode(self, texture: RawTexture) -> BC3Texture
|
||||
|
||||
Encode a raw texture into a new BC3Texture using the encoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
@ -106,23 +96,17 @@ void InitBC3(py::module_ &s3tc) {
|
||||
|
||||
// region BC3Decoder
|
||||
py::class_<BC3Decoder> bc3_decoder(bc3, "BC3Decoder", R"doc(
|
||||
Base: :py:class:`~quicktex.BlockDecoder`
|
||||
|
||||
Decodes BC3 textures to RGBA
|
||||
)doc");
|
||||
|
||||
bc3_decoder.def(py::init<>());
|
||||
bc3_decoder.def(py::init<InterpolatorPtr>(), "interpolator"_a, R"doc(
|
||||
__init__(interpolator = Interpolator()) -> None
|
||||
|
||||
Create a new BC3 decoder with the specified interpolator.
|
||||
|
||||
:param Interpolator interpolator: The interpolation mode to use for decoding. Default: :py:class:`~quicktex.s3tc.interpolator.Interpolator`.
|
||||
)doc");
|
||||
|
||||
bc3_decoder.def("decode", &BC3Decoder::Decode, "texture"_a, R"doc(
|
||||
decode(self, texture: BC3Texture) -> RawTexture
|
||||
|
||||
Decode a BC3 texture into a new RawTexture using the decoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "../../_bindings.h"
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
@ -39,8 +40,6 @@ using namespace quicktex::s3tc;
|
||||
|
||||
void InitBC4(py::module_ &s3tc) {
|
||||
auto bc4 = s3tc.def_submodule("_bc4", "internal bc4 module");
|
||||
py::options options;
|
||||
options.disable_function_signatures();
|
||||
|
||||
// region BC4Block
|
||||
auto bc4_block = BindBlock<BC4Block>(bc4, "BC4Block");
|
||||
@ -48,8 +47,6 @@ void InitBC4(py::module_ &s3tc) {
|
||||
|
||||
bc4_block.def(py::init<>());
|
||||
bc4_block.def(py::init<uint8_t, uint8_t, BC4Block::SelectorArray>(), "endpoint0"_a, "endpoint1"_a, "selectors"_a, R"doc(
|
||||
__init__(self, endpoint0: int, endpoint1: int, selectors: List[List[int]]) -> None
|
||||
|
||||
Create a new BC4Block with the specified endpoints and selectors.
|
||||
|
||||
:param int endpoint0: The first endpoint.
|
||||
@ -88,16 +85,12 @@ void InitBC4(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc4_encoder.def(py::init<uint8_t>(), py::arg("channel") = 3, R"doc(
|
||||
__init__(channel : int = 3) -> None
|
||||
|
||||
Create a new BC4 encoder with the specified channel
|
||||
|
||||
:param int channel: the channel that will be read from. 0 to 3 inclusive. Default: 3 (alpha).
|
||||
)doc");
|
||||
|
||||
bc4_encoder.def("encode", &BC4Encoder::Encode, "texture"_a, R"doc(
|
||||
encode(self, texture: RawTexture) -> BC4Texture
|
||||
|
||||
Encode a raw texture into a new BC4Texture using the encoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
@ -113,16 +106,12 @@ void InitBC4(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc4_decoder.def(py::init<uint8_t>(), py::arg("channel") = 3, R"doc(
|
||||
__init__(channel : int = 3) -> None
|
||||
|
||||
Create a new BC4 decoder with the specified channel
|
||||
|
||||
:param int channel: The channel that will be written to. 0 to 3 inclusive. Default: 3 (alpha).
|
||||
)doc");
|
||||
|
||||
bc4_decoder.def("decode", &BC4Decoder::Decode, "texture"_a, R"doc(
|
||||
decode(self, texture: BC4Texture) -> RawTexture
|
||||
|
||||
Decode a BC4 texture into a new RawTexture using the decoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
|
@ -37,8 +37,6 @@ using namespace quicktex::s3tc;
|
||||
|
||||
void InitBC5(py::module_ &s3tc) {
|
||||
auto bc5 = s3tc.def_submodule("_bc5", "internal bc5 module");
|
||||
py::options options;
|
||||
options.disable_function_signatures();
|
||||
|
||||
// region BC5Block
|
||||
auto bc5_block = BindBlock<BC5Block>(bc5, "BC5Block");
|
||||
@ -46,8 +44,6 @@ void InitBC5(py::module_ &s3tc) {
|
||||
|
||||
bc5_block.def(py::init<>());
|
||||
bc5_block.def(py::init<BC4Block, BC4Block>(), "chan0_block"_a, "chan1_block"_a, R"doc(
|
||||
__init__(self, chan0_block: BC4Block, chan1_block: BC4Block) -> None
|
||||
|
||||
Create a new BC5Block out of two BC4 blocks.
|
||||
|
||||
:param BC4Block chan0_block: The BC4 block used for the first channel.
|
||||
@ -66,14 +62,10 @@ void InitBC5(py::module_ &s3tc) {
|
||||
|
||||
// region BC5Encoder
|
||||
py::class_<BC5Encoder> bc5_encoder(bc5, "BC5Encoder", R"doc(
|
||||
Base: :py:class:`~quicktex.BlockEncoder`
|
||||
|
||||
Encodes dual-channel textures to BC5.
|
||||
)doc");
|
||||
|
||||
bc5_encoder.def(py::init<uint8_t, uint8_t>(), py::arg("chan0") = 0, py::arg("chan1") = 1, R"doc(
|
||||
__init__(chan0 : int = 0, chan1 : int = 1) -> None
|
||||
|
||||
Create a new BC5 encoder with the specified channels
|
||||
|
||||
:param int chan0: the first channel that will be read from. 0 to 3 inclusive. Default: 0 (red).
|
||||
@ -81,8 +73,6 @@ void InitBC5(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc5_encoder.def("encode", &BC5Encoder::Encode, "texture"_a, R"doc(
|
||||
encode(self, texture: RawTexture) -> BC5Texture
|
||||
|
||||
Encode a raw texture into a new BC5Texture using the encoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
@ -96,14 +86,10 @@ void InitBC5(py::module_ &s3tc) {
|
||||
|
||||
// region BC5Decoder
|
||||
py::class_<BC5Decoder> bc5_decoder(bc5, "BC5Decoder", R"doc(
|
||||
Base: :py:class:`~quicktex.BlockDecoder`
|
||||
|
||||
Decodes BC4 textures to two channels.
|
||||
)doc");
|
||||
|
||||
bc5_decoder.def(py::init<uint8_t, uint8_t>(), py::arg("chan0") = 0, py::arg("chan1") = 1, R"doc(
|
||||
__init__(chan0 : int = 0, chan1 : int = 1) -> None
|
||||
|
||||
Create a new BC5 decoder with the specified channels
|
||||
|
||||
:param int chan0: the first channel that will be written to. 0 to 3 inclusive. Default: 0 (red).
|
||||
@ -111,8 +97,6 @@ void InitBC5(py::module_ &s3tc) {
|
||||
)doc");
|
||||
|
||||
bc5_decoder.def("decode", &BC5Decoder::Decode, "texture"_a, R"doc(
|
||||
decode(self, texture: BC5Texture) -> RawTexture
|
||||
|
||||
Decode a BC5 texture into a new RawTexture using the decoder's current settings.
|
||||
|
||||
:param RawTexture texture: Input texture to encode.
|
||||
|
Loading…
Reference in New Issue
Block a user