Free form gourad triangle shading

This commit is contained in:
Jakub Melka
2019-09-15 16:50:34 +02:00
parent 40290fd2ec
commit dc6bc3e96c
7 changed files with 433 additions and 23 deletions

View File

@ -78,21 +78,29 @@ class PDFBitReader
public:
using Value = uint64_t;
explicit PDFBitReader(QDataStream* stream, Value bitsPerComponent);
explicit PDFBitReader(const QByteArray* stream, Value bitsPerComponent);
/// Returns maximal value of n-bit unsigned integer.
Value max() const { return m_maximalValue; }
/// Reads single n-bit value from the stream. If stream hasn't enough data,
/// then exception is thrown.
Value read();
Value read() { return read(m_bitsPerComponent); }
/// Reads single n-bit value from the stream. If stream hasn't enough data,
/// then exception is thrown.
Value read(Value bits);
/// Seeks the desired position in the data stream. If position can't be seeked,
/// then exception is thrown.
void seek(qint64 position);
/// Seeks data to the byte boundary (number of processed bits is divisible by 8)
void alignToBytes();
private:
QDataStream* m_stream;
const QByteArray* m_stream;
int m_position;
const Value m_bitsPerComponent;
const Value m_maximalValue;
@ -128,6 +136,12 @@ private:
Value* m_value;
};
template<typename T>
bool contains(T value, std::initializer_list<T> list)
{
return (std::find(list.begin(), list.end(), value) != list.end());
}
/// Performs linear mapping of value x in interval [x_min, x_max] to the interval [y_min, y_max].
/// \param x Value to be linearly remapped from interval [x_min, x_max] to the interval [y_min, y_max].
/// \param x_min Start of the input interval