Enable gcc wall and werror.
This commit is contained in:
parent
990cde402b
commit
3fad113178
64 changed files with 347 additions and 314 deletions
|
@ -15,12 +15,13 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
||||||
elseif(FALSE)
|
elseif(CMAKE_COMPILER_IS_GNUCC)
|
||||||
set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
|
#set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
|
||||||
set(GCC_COVERAGE_LINK_FLAGS "-lgcov")
|
#set(GCC_COVERAGE_LINK_FLAGS "-lgcov")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#include "Terminal.h"
|
#include "Terminal.h"
|
||||||
|
|
||||||
Terminal::Terminal(TerminalType type, const std::string& label)
|
Terminal::Terminal(TerminalType type, const std::string& label)
|
||||||
: mType(type),
|
: mLabel(label),
|
||||||
mLabel(label)
|
mType(type)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,4 +16,4 @@ Wire* Terminal::getConnection() const
|
||||||
void Terminal::setConnection(Wire* connection)
|
void Terminal::setConnection(Wire* connection)
|
||||||
{
|
{
|
||||||
mConnection = connection;
|
mConnection = connection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ int MidiChannelEventAdapter::readEvent(std::ifstream* file, char firstByte, Midi
|
||||||
int second_four_bits = 0xF;
|
int second_four_bits = 0xF;
|
||||||
int event_type = (firstByte & first_four_bits) >> 4;
|
int event_type = (firstByte & first_four_bits) >> 4;
|
||||||
int midi_channel = (firstByte & second_four_bits) >> 4;
|
int midi_channel = (firstByte & second_four_bits) >> 4;
|
||||||
|
|
||||||
|
(void) event_type;
|
||||||
|
(void) midi_channel;
|
||||||
|
|
||||||
unsigned byteCount = 0;
|
unsigned byteCount = 0;
|
||||||
//std::cout << "Channel: " << midi_channel << std::endl;
|
//std::cout << "Channel: " << midi_channel << std::endl;
|
||||||
|
|
||||||
|
@ -45,6 +49,7 @@ int MidiChannelEventAdapter::readEvent(std::ifstream* file, char firstByte, Midi
|
||||||
case MidiChannelEvent::Type::PROGRAM:
|
case MidiChannelEvent::Type::PROGRAM:
|
||||||
{
|
{
|
||||||
int value0 = *BinaryStream::getNextByteAsInt(file);
|
int value0 = *BinaryStream::getNextByteAsInt(file);
|
||||||
|
(void) value0;
|
||||||
byteCount ++;
|
byteCount ++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ int MidiMetaEventAdapter::ReadEvent(std::ifstream* file, MetaMidiEvent* event, i
|
||||||
case MetaMidiEvent::Type::END_TRACK:
|
case MetaMidiEvent::Type::END_TRACK:
|
||||||
{
|
{
|
||||||
int length = *BinaryStream::getNextByteAsInt(file);
|
int length = *BinaryStream::getNextByteAsInt(file);
|
||||||
|
(void) length;
|
||||||
byteCount ++;
|
byteCount ++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +158,7 @@ int MidiMetaEventAdapter::ReadKeySignatureEvent(std::ifstream* file, MetaMidiEve
|
||||||
{
|
{
|
||||||
unsigned byteCount = 0;
|
unsigned byteCount = 0;
|
||||||
int length = *BinaryStream::getNextByteAsInt(file);
|
int length = *BinaryStream::getNextByteAsInt(file);
|
||||||
|
(void)length;
|
||||||
byteCount++;
|
byteCount++;
|
||||||
|
|
||||||
MidiKeySignature keySig;
|
MidiKeySignature keySig;
|
||||||
|
@ -170,6 +172,7 @@ int MidiMetaEventAdapter::ReadTimeCodeEvent(std::ifstream* file, MetaMidiEvent*
|
||||||
{
|
{
|
||||||
unsigned byteCount = 0;
|
unsigned byteCount = 0;
|
||||||
int length = *BinaryStream::getNextByteAsInt(file);
|
int length = *BinaryStream::getNextByteAsInt(file);
|
||||||
|
(void)length;
|
||||||
byteCount++;
|
byteCount++;
|
||||||
|
|
||||||
MidiSmtpeTimecode timeCode;
|
MidiSmtpeTimecode timeCode;
|
||||||
|
|
|
@ -9,4 +9,5 @@ TEST_CASE(TestReadMidi, "audio")
|
||||||
reader.read(TestUtils::getTestDataDir() / "test.mid");
|
reader.read(TestUtils::getTestDataDir() / "test.mid");
|
||||||
|
|
||||||
auto document = reader.getDocument();
|
auto document = reader.getDocument();
|
||||||
|
(void)document;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ void CyclicRedundancyChecker::createTable()
|
||||||
{
|
{
|
||||||
mTable = std::vector<unsigned long>(TABLE_SIZE, 0);
|
mTable = std::vector<unsigned long>(TABLE_SIZE, 0);
|
||||||
unsigned long c{0};
|
unsigned long c{0};
|
||||||
for (int n = 0; n < TABLE_SIZE; n++)
|
for (std::size_t n = 0; n < TABLE_SIZE; n++)
|
||||||
{
|
{
|
||||||
c = (unsigned long) n;
|
c = (unsigned long) n;
|
||||||
for (int k = 0; k < 8; k++)
|
for (int k = 0; k < 8; k++)
|
||||||
|
|
|
@ -77,7 +77,7 @@ unsigned Lz77Encoder::lookAheadForMatchingChars(unsigned distance)
|
||||||
search_char = getSearchBufferItem(static_cast<unsigned>(search_offset));
|
search_char = getSearchBufferItem(static_cast<unsigned>(search_offset));
|
||||||
}
|
}
|
||||||
unsigned char lookahead_char = mLookaheadBuffer.getItem(idx);
|
unsigned char lookahead_char = mLookaheadBuffer.getItem(idx);
|
||||||
if ((lookahead_char != search_char) || (idx == mMaxLookAheadBufferIndex))
|
if ((lookahead_char != search_char) || (static_cast<int>(idx) == mMaxLookAheadBufferIndex))
|
||||||
{
|
{
|
||||||
if (idx + 1>= mMinLengthMatchSize)
|
if (idx + 1>= mMinLengthMatchSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,6 +164,7 @@ bool ZlibEncoder::decode()
|
||||||
unsigned char byte3 = *mInputStream->readNextByte();
|
unsigned char byte3 = *mInputStream->readNextByte();
|
||||||
|
|
||||||
uint32_t adler32 = (byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3;
|
uint32_t adler32 = (byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3;
|
||||||
|
(void)adler32;
|
||||||
//std::cout << "Got adler 32 checksum " << adler32 << std::endl;
|
//std::cout << "Got adler 32 checksum " << adler32 << std::endl;
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
|
|
|
@ -38,6 +38,7 @@ bool DeflateBlock::isFinalBlock() const
|
||||||
bool DeflateBlock::read()
|
bool DeflateBlock::read()
|
||||||
{
|
{
|
||||||
auto working_byte = *mInputStream->readNextByte();
|
auto working_byte = *mInputStream->readNextByte();
|
||||||
|
(void)working_byte;
|
||||||
|
|
||||||
//std::cout << mInputStream->logNextNBytes(60);
|
//std::cout << mInputStream->logNextNBytes(60);
|
||||||
//std::cout << "DeflateBlock::read location " << mInputStream->logLocation();
|
//std::cout << "DeflateBlock::read location " << mInputStream->logLocation();
|
||||||
|
@ -77,6 +78,7 @@ bool DeflateBlock::readUncompressedStream()
|
||||||
auto byte2 = *mInputStream->readNextByte();
|
auto byte2 = *mInputStream->readNextByte();
|
||||||
auto byte3 = *mInputStream->readNextByte();
|
auto byte3 = *mInputStream->readNextByte();
|
||||||
uint16_t len_check = (byte2 << 8) | byte3;
|
uint16_t len_check = (byte2 << 8) | byte3;
|
||||||
|
(void) len_check;
|
||||||
|
|
||||||
//std::cout << "Check block 2: " << ByteUtils::toString(byte2) << std::endl;
|
//std::cout << "Check block 2: " << ByteUtils::toString(byte2) << std::endl;
|
||||||
//std::cout << "Check block 3: " << ByteUtils::toString(byte3) << std::endl;
|
//std::cout << "Check block 3: " << ByteUtils::toString(byte3) << std::endl;
|
||||||
|
|
|
@ -13,10 +13,10 @@ void HuffmanCodeLengthTable::buildCompressedLengthSequence()
|
||||||
RunLengthEncoder rl_encoder;
|
RunLengthEncoder rl_encoder;
|
||||||
auto rle_encoded = rl_encoder.encode(mInputLengthSequence);
|
auto rle_encoded = rl_encoder.encode(mInputLengthSequence);
|
||||||
|
|
||||||
for (const auto& entry : rle_encoded)
|
//for (const auto& entry : rle_encoded)
|
||||||
{
|
//{
|
||||||
//std::cout << "Got rle " << static_cast<int>(entry.first) << " | " << entry.second << std::endl;
|
//std::cout << "Got rle " << static_cast<int>(entry.first) << " | " << entry.second << std::endl;
|
||||||
}
|
//}
|
||||||
mCompressedLengthSequence.clear();
|
mCompressedLengthSequence.clear();
|
||||||
|
|
||||||
for (const auto& entry : rle_encoded)
|
for (const auto& entry : rle_encoded)
|
||||||
|
@ -117,7 +117,7 @@ bool HuffmanCodeLengthTable::readNextSymbol(unsigned& result, BitStream* stream)
|
||||||
|
|
||||||
while(!found)
|
while(!found)
|
||||||
{
|
{
|
||||||
auto valid = stream->readNextNBits(delta, buffer);
|
stream->readNextNBits(delta, buffer);
|
||||||
//std::cout << "Got buffer " << ByteUtils::toString(buffer) << std::endl;;
|
//std::cout << "Got buffer " << ByteUtils::toString(buffer) << std::endl;;
|
||||||
|
|
||||||
unsigned hold = buffer;
|
unsigned hold = buffer;
|
||||||
|
|
|
@ -17,6 +17,7 @@ void HuffmanEncoder::dumpNode(RawNode<CountPair>* node, unsigned depth) const
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data = node->getData();
|
auto data = node->getData();
|
||||||
|
(void)data;
|
||||||
|
|
||||||
std::string prefix(depth, '_');
|
std::string prefix(depth, '_');
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ void HuffmanStream::readSymbols()
|
||||||
else if (symbol <= 264)
|
else if (symbol <= 264)
|
||||||
{
|
{
|
||||||
auto length = 3 + symbol - 257;
|
auto length = 3 + symbol - 257;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
else if (symbol <= 268)
|
else if (symbol <= 268)
|
||||||
|
@ -220,7 +220,7 @@ void HuffmanStream::readSymbols()
|
||||||
mInputStream->readNextNBits(1, extra);
|
mInputStream->readNextNBits(1, extra);
|
||||||
|
|
||||||
auto length = 11 + 2*(symbol - 265) + extra;
|
auto length = 11 + 2*(symbol - 265) + extra;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
else if (symbol <= 272)
|
else if (symbol <= 272)
|
||||||
|
@ -229,7 +229,7 @@ void HuffmanStream::readSymbols()
|
||||||
mInputStream->readNextNBits(2, extra);
|
mInputStream->readNextNBits(2, extra);
|
||||||
|
|
||||||
auto length = 19 + 4*(symbol - 269) + extra;
|
auto length = 19 + 4*(symbol - 269) + extra;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
else if (symbol <= 276)
|
else if (symbol <= 276)
|
||||||
|
@ -238,7 +238,7 @@ void HuffmanStream::readSymbols()
|
||||||
mInputStream->readNextNBits(3, extra);
|
mInputStream->readNextNBits(3, extra);
|
||||||
|
|
||||||
auto length = 35 + 8*(symbol - 273) + extra;
|
auto length = 35 + 8*(symbol - 273) + extra;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
else if (symbol <= 280)
|
else if (symbol <= 280)
|
||||||
|
@ -247,7 +247,7 @@ void HuffmanStream::readSymbols()
|
||||||
mInputStream->readNextNBits(4, extra);
|
mInputStream->readNextNBits(4, extra);
|
||||||
|
|
||||||
auto length = 67 + 16*(symbol - 277) + extra;
|
auto length = 67 + 16*(symbol - 277) + extra;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
else if (symbol <= 284)
|
else if (symbol <= 284)
|
||||||
|
@ -256,13 +256,13 @@ void HuffmanStream::readSymbols()
|
||||||
mInputStream->readNextNBits(5, extra);
|
mInputStream->readNextNBits(5, extra);
|
||||||
|
|
||||||
auto length = 131 + 32*(symbol - 281) + extra;
|
auto length = 131 + 32*(symbol - 281) + extra;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
else if (symbol == 285)
|
else if (symbol == 285)
|
||||||
{
|
{
|
||||||
auto length = 258;
|
auto length = 258;
|
||||||
const auto valid_dist = readNextDistanceSymbol(distance);
|
readNextDistanceSymbol(distance);
|
||||||
copyFromBuffer(length, distance);
|
copyFromBuffer(length, distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
|
|
||||||
HttpHeader::HttpHeader()
|
HttpHeader::HttpHeader()
|
||||||
: mContentType("text / html"),
|
: mHttpVersion("1.1"),
|
||||||
mHttpVersion("1.1")
|
mContentType("text / html")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
bool BufferBitStream::isFinished() const
|
bool BufferBitStream::isFinished() const
|
||||||
{
|
{
|
||||||
return mByteOffset == mBuffer.size() - 1;
|
return mByteOffset == static_cast<int>(mBuffer.size()) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned char> BufferBitStream::peekNextNBytes(unsigned n) const
|
std::vector<unsigned char> BufferBitStream::peekNextNBytes(unsigned n) const
|
||||||
|
@ -35,7 +35,7 @@ std::vector<unsigned char> BufferBitStream::peekNextNBytes(unsigned n) const
|
||||||
|
|
||||||
std::optional<unsigned char> BufferBitStream::readNextByte()
|
std::optional<unsigned char> BufferBitStream::readNextByte()
|
||||||
{
|
{
|
||||||
if (mByteOffset + 1 == mBuffer.size())
|
if (mByteOffset + 1 == static_cast<int>(mBuffer.size()))
|
||||||
{
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -76,3 +76,19 @@ void BufferBitStream::writeByte(unsigned char data, bool checkOverflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BufferBitStream::writeBytes(const std::vector<unsigned char> data)
|
||||||
|
{
|
||||||
|
std::copy(data.begin(), data.end(), std::back_inserter(mBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<unsigned char>& BufferBitStream::getBuffer() const
|
||||||
|
{
|
||||||
|
return mBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BufferBitStream::reset()
|
||||||
|
{
|
||||||
|
BitStream::reset();
|
||||||
|
mBuffer.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,31 +8,21 @@
|
||||||
class BufferBitStream : public BitStream
|
class BufferBitStream : public BitStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
const std::vector<unsigned char>& getBuffer() const;
|
||||||
|
|
||||||
bool isFinished() const override;
|
bool isFinished() const override;
|
||||||
|
|
||||||
std::vector<unsigned char> peekNextNBytes(unsigned n) const override;
|
std::vector<unsigned char> peekNextNBytes(unsigned n) const override;
|
||||||
|
|
||||||
std::optional<unsigned char> readNextByte() override;
|
std::optional<unsigned char> readNextByte() override;
|
||||||
|
|
||||||
|
void reset() override;
|
||||||
|
|
||||||
void setBuffer(const std::vector<unsigned char>& data);
|
void setBuffer(const std::vector<unsigned char>& data);
|
||||||
|
|
||||||
void writeByte(unsigned char data, bool checkOverflow = true) override;
|
void writeByte(unsigned char data, bool checkOverflow = true) override;
|
||||||
|
|
||||||
void writeBytes(const std::vector<unsigned char> data) override
|
void writeBytes(const std::vector<unsigned char> data) override;
|
||||||
{
|
|
||||||
std::copy(data.begin(), data.end(), std::back_inserter(mBuffer));
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<unsigned char>& getBuffer() const
|
|
||||||
{
|
|
||||||
return mBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() override
|
|
||||||
{
|
|
||||||
BitStream::reset();
|
|
||||||
mBuffer.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned mBufferSize{0};
|
unsigned mBufferSize{0};
|
||||||
|
|
|
@ -12,9 +12,9 @@ using LS = XmlParser::LineState;
|
||||||
using DS = XmlParser::DocumentState;
|
using DS = XmlParser::DocumentState;
|
||||||
|
|
||||||
XmlParser::XmlParser()
|
XmlParser::XmlParser()
|
||||||
: mDocument(XmlDocument::Create()),
|
: mDocumentState(XmlParser::DocumentState::Await_Prolog),
|
||||||
mDocumentState(XmlParser::DocumentState::Await_Prolog),
|
|
||||||
mLineState(XmlParser::LineState::Await_Tag_Open),
|
mLineState(XmlParser::LineState::Await_Tag_Open),
|
||||||
|
mDocument(XmlDocument::Create()),
|
||||||
mWorkingElements()
|
mWorkingElements()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,31 @@
|
||||||
#include "Circle.h"
|
#include "Circle.h"
|
||||||
|
|
||||||
Circle::Circle(const Point& centre, double radius)
|
Circle::Circle(const Point& centre, double radius)
|
||||||
: mCentre(centre),
|
: mRadius(radius),
|
||||||
mRadius(radius)
|
mCentre(centre)
|
||||||
|
|
||||||
{
|
{
|
||||||
mMinorRadius = mRadius;
|
mMinorRadius = mRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Point& Circle::getLocation() const
|
const Point& Circle::getLocation() const
|
||||||
{
|
{
|
||||||
return mCentre;
|
return mCentre;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Circle::getRadius() const
|
double Circle::getRadius() const
|
||||||
{
|
{
|
||||||
return mRadius;
|
return mRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Circle::getMinorRadius() const
|
double Circle::getMinorRadius() const
|
||||||
{
|
{
|
||||||
return mMinorRadius;
|
return mMinorRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Circle::setMinorRadius(double radius)
|
void Circle::setMinorRadius(double radius)
|
||||||
{
|
{
|
||||||
mMinorRadius = radius;
|
mMinorRadius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Circle::sample(SparseGrid<bool>* grid) const
|
void Circle::sample(SparseGrid<bool>* grid) const
|
||||||
|
@ -34,19 +35,19 @@ void Circle::sample(SparseGrid<bool>* grid) const
|
||||||
|
|
||||||
bool Circle::isEllipse() const
|
bool Circle::isEllipse() const
|
||||||
{
|
{
|
||||||
return mRadius != mMinorRadius;
|
return mRadius != mMinorRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bounds Circle::getBounds() const
|
Bounds Circle::getBounds() const
|
||||||
{
|
{
|
||||||
double minX = mCentre.getX() - mRadius;
|
double minX = mCentre.getX() - mRadius;
|
||||||
double maxX = mCentre.getX() + mRadius;
|
double maxX = mCentre.getX() + mRadius;
|
||||||
double minY = mCentre.getY() - mMinorRadius;
|
double minY = mCentre.getY() - mMinorRadius;
|
||||||
double maxY = mCentre.getY() + mMinorRadius;
|
double maxY = mCentre.getY() + mMinorRadius;
|
||||||
return { minX, maxX, minY, maxY };
|
return { minX, maxX, minY, maxY };
|
||||||
}
|
}
|
||||||
|
|
||||||
Circle::Type Circle::getType() const
|
Circle::Type Circle::getType() const
|
||||||
{
|
{
|
||||||
return Type::CIRCLE;
|
return Type::CIRCLE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,26 +6,26 @@
|
||||||
class Circle : public AbstractGeometricItem
|
class Circle : public AbstractGeometricItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Circle(const Point& centre, double radius = 0.5);
|
Circle(const Point& centre, double radius = 0.5);
|
||||||
|
|
||||||
const Point& getLocation() const override;
|
const Point& getLocation() const override;
|
||||||
|
|
||||||
double getRadius() const;
|
double getRadius() const;
|
||||||
|
|
||||||
double getMinorRadius() const;
|
double getMinorRadius() const;
|
||||||
|
|
||||||
Bounds getBounds() const override;
|
Bounds getBounds() const override;
|
||||||
|
|
||||||
Type getType() const override;
|
Type getType() const override;
|
||||||
|
|
||||||
bool isEllipse() const;
|
bool isEllipse() const;
|
||||||
|
|
||||||
void setMinorRadius(double radius);
|
void setMinorRadius(double radius);
|
||||||
|
|
||||||
void sample(SparseGrid<bool>* grid) const override;
|
void sample(SparseGrid<bool>* grid) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mMinorRadius{ 0.5 };
|
double mMinorRadius{ 0.5 };
|
||||||
double mRadius{ 0.5 };
|
double mRadius{ 0.5 };
|
||||||
Point mCentre;
|
Point mCentre;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,9 +9,10 @@ namespace ntk {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle::Rectangle(const Point& bottomLeft, double width, double height)
|
Rectangle::Rectangle(const Point& bottomLeft, double width, double height)
|
||||||
: mBottomLeft(bottomLeft),
|
: mBottomLeft(bottomLeft),
|
||||||
mHeight(height),
|
mWidth(width),
|
||||||
mWidth(width)
|
mHeight(height)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "UnixSocketInterface.h"
|
#include "UnixSocketInterface.h"
|
||||||
#else
|
#else
|
||||||
#include "Win32WebServer.h"
|
#include "Win32WebServer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
NetworkManager::NetworkManager()
|
NetworkManager::NetworkManager()
|
||||||
: mActiveSockets(),
|
: mActiveSockets(),
|
||||||
mSocketInterface()
|
mSocketInterface()
|
||||||
|
@ -44,9 +43,9 @@ void NetworkManager::runHttpServer(AbstractWebApp* webApp)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto socket = Socket::Create();
|
auto socket = Socket::Create();
|
||||||
mSocketInterface->InitializeSocket(socket);
|
mSocketInterface->initializeSocket(socket);
|
||||||
mSocketInterface->Listen(socket);
|
mSocketInterface->socketListen(socket);
|
||||||
mSocketInterface->Run(socket);
|
mSocketInterface->run(socket);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +62,8 @@ void NetworkManager::runHttpClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
auto socket = Socket::Create();
|
auto socket = Socket::Create();
|
||||||
mSocketInterface->InitializeSocket(socket, "127.0.0.1");
|
mSocketInterface->initializeSocket(socket, "127.0.0.1");
|
||||||
mSocketInterface->Write(socket, "Hello Friend");
|
mSocketInterface->socketWrite(socket, "Hello Friend");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::shutDown()
|
void NetworkManager::shutDown()
|
||||||
|
|
|
@ -11,7 +11,6 @@ class AbstractWebApp;
|
||||||
class NetworkManager
|
class NetworkManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NetworkManager();
|
NetworkManager();
|
||||||
|
|
||||||
~NetworkManager();
|
~NetworkManager();
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
|
|
||||||
Socket::Socket()
|
Socket::Socket()
|
||||||
: mPort(8888),
|
: mHandle(-1),
|
||||||
mMessage(),
|
mPort(8888),
|
||||||
mHandle(-1)
|
mMessage()
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,12 +14,12 @@ Socket::~Socket()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::SetHandle(SocketHandle handle)
|
void Socket::setHandle(SocketHandle handle)
|
||||||
{
|
{
|
||||||
mHandle = handle;
|
mHandle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket::SocketHandle Socket::GetHandle() const
|
Socket::SocketHandle Socket::getHandle() const
|
||||||
{
|
{
|
||||||
return mHandle;
|
return mHandle;
|
||||||
}
|
}
|
||||||
|
@ -28,33 +29,33 @@ std::unique_ptr<Socket> Socket::Create()
|
||||||
return std::make_unique<Socket>();
|
return std::make_unique<Socket>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Socket::GetMessage() const
|
std::string Socket::getMessage() const
|
||||||
{
|
{
|
||||||
return mMessage;
|
return mMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::SetMessage(const std::string& message)
|
void Socket::setMessage(const std::string& message)
|
||||||
{
|
{
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::SetPort(unsigned port)
|
void Socket::setPort(unsigned port)
|
||||||
{
|
{
|
||||||
mPort = port;
|
mPort = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Socket::GetPort() const
|
unsigned Socket::getPort() const
|
||||||
{
|
{
|
||||||
return mPort;
|
return mPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Socket::getAddress() const
|
std::string Socket::getAddress() const
|
||||||
{
|
{
|
||||||
return mAddress;
|
return mAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Socket::setAddress(const std::string& address)
|
void Socket::setAddress(const std::string& address)
|
||||||
{
|
{
|
||||||
mAddress = address;
|
mAddress = address;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,23 +14,23 @@ public:
|
||||||
|
|
||||||
static std::unique_ptr<Socket> Create();
|
static std::unique_ptr<Socket> Create();
|
||||||
|
|
||||||
void SetPort(unsigned port);
|
|
||||||
|
|
||||||
void SetHandle(SocketHandle handle);
|
|
||||||
|
|
||||||
SocketHandle GetHandle() const;
|
|
||||||
|
|
||||||
unsigned GetPort() const;
|
|
||||||
|
|
||||||
std::string GetMessage() const;
|
|
||||||
|
|
||||||
void SetMessage(const std::string& message);
|
|
||||||
|
|
||||||
std::string getAddress() const;
|
std::string getAddress() const;
|
||||||
|
|
||||||
|
SocketHandle getHandle() const;
|
||||||
|
|
||||||
|
unsigned getPort() const;
|
||||||
|
|
||||||
|
std::string getMessage() const;
|
||||||
|
|
||||||
|
void setPort(unsigned port);
|
||||||
|
|
||||||
|
void setHandle(SocketHandle handle);
|
||||||
|
|
||||||
|
void setMessage(const std::string& message);
|
||||||
|
|
||||||
void setAddress(const std::string& address);
|
void setAddress(const std::string& address);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SocketHandle mHandle;
|
SocketHandle mHandle;
|
||||||
unsigned mPort{0};
|
unsigned mPort{0};
|
||||||
std::string mMessage;
|
std::string mMessage;
|
||||||
|
|
|
@ -8,16 +8,15 @@ using SocketPtr = std::unique_ptr<Socket>;
|
||||||
class ISocketInterface
|
class ISocketInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ISocketInterface() = default;
|
ISocketInterface() = default;
|
||||||
|
|
||||||
virtual ~ISocketInterface() = default;
|
virtual ~ISocketInterface() = default;
|
||||||
|
|
||||||
virtual void InitializeSocket(const SocketPtr& socket, const std::string& address = {}) = 0;
|
virtual void initializeSocket(const SocketPtr& socket, const std::string& address = {}) = 0;
|
||||||
virtual void Listen(const SocketPtr& socket) = 0;
|
virtual void socketListen(const SocketPtr& socket) = 0;
|
||||||
virtual void Run(const SocketPtr& socket) = 0;
|
virtual void run(const SocketPtr& socket) = 0;
|
||||||
|
|
||||||
virtual void Write(const SocketPtr& socket, const std::string& message) = 0;
|
virtual void socketWrite(const SocketPtr& socket, const std::string& message) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ISocketInterfaceUPtr = std::unique_ptr<ISocketInterface>;
|
using ISocketInterfaceUPtr = std::unique_ptr<ISocketInterface>;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
UnixSocketInterface::UnixSocketInterface()
|
UnixSocketInterface::UnixSocketInterface()
|
||||||
: mBufferSize(1024)
|
: mBufferSize(1024)
|
||||||
{
|
{
|
||||||
mMessageHandler = std::make_unique<HttpMessageHandler>();
|
mMessageHandler = std::make_unique<HttpMessageHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<UnixSocketInterface> UnixSocketInterface::Create()
|
std::unique_ptr<UnixSocketInterface> UnixSocketInterface::Create()
|
||||||
|
@ -29,26 +29,26 @@ UnixSocketInterface::~UnixSocketInterface()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixSocketInterface::InitializeSocket(const SocketPtr& socketPtr, const std::string& address)
|
void UnixSocketInterface::initializeSocket(const SocketPtr& socketPtr, const std::string& address)
|
||||||
{
|
{
|
||||||
auto handle = ::socket(AF_INET, SOCK_STREAM, 0);
|
auto handle = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||||
socketPtr->SetHandle(handle);
|
socketPtr->setHandle(handle);
|
||||||
|
|
||||||
if (!address.empty())
|
if (!address.empty())
|
||||||
{
|
{
|
||||||
socketPtr->setAddress(address);
|
socketPtr->setAddress(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixSocketInterface::Write(const SocketPtr& socket, const std::string& message)
|
void UnixSocketInterface::socketWrite(const SocketPtr& socket, const std::string& message)
|
||||||
{
|
{
|
||||||
if(socket->GetHandle() < 0)
|
if(socket->getHandle() < 0)
|
||||||
{
|
{
|
||||||
MLOG_ERROR("Error opening socket" );
|
MLOG_ERROR("Error opening socket" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto port = static_cast<int>(socket->GetPort());
|
const auto port = static_cast<int>(socket->getPort());
|
||||||
struct sockaddr_in serv_addr;
|
struct sockaddr_in serv_addr;
|
||||||
memset(&serv_addr, 0, sizeof(serv_addr));
|
memset(&serv_addr, 0, sizeof(serv_addr));
|
||||||
serv_addr.sin_family = AF_INET;
|
serv_addr.sin_family = AF_INET;
|
||||||
|
@ -56,14 +56,14 @@ void UnixSocketInterface::Write(const SocketPtr& socket, const std::string& mess
|
||||||
inet_aton(socket->getAddress().c_str(), &serv_addr.sin_addr);
|
inet_aton(socket->getAddress().c_str(), &serv_addr.sin_addr);
|
||||||
serv_addr.sin_port = htons(port);
|
serv_addr.sin_port = htons(port);
|
||||||
|
|
||||||
int result = connect(socket->GetHandle(), (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
int result = connect(socket->getHandle(), (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||||
if(result< 0)
|
if(result< 0)
|
||||||
{
|
{
|
||||||
MLOG_ERROR("Error connecting to socket" );
|
MLOG_ERROR("Error connecting to socket" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto n = write(socket->GetHandle(), message.c_str(), message.length());
|
auto n = write(socket->getHandle(), message.c_str(), message.length());
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error on write" << std::endl;
|
std::cerr << "Error on write" << std::endl;
|
||||||
|
@ -71,44 +71,44 @@ void UnixSocketInterface::Write(const SocketPtr& socket, const std::string& mess
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[BUFFER_SIZE] = {0};
|
char buffer[BUFFER_SIZE] = {0};
|
||||||
int res = read(socket->GetHandle(), buffer, BUFFER_SIZE);
|
int res = read(socket->getHandle(), buffer, BUFFER_SIZE);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error on read" << std::endl;
|
std::cerr << "Error on read" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
socket->SetMessage(buffer);
|
socket->setMessage(buffer);
|
||||||
std::cout << "Here is the message: " << buffer << std::endl;
|
std::cout << "Here is the message: " << buffer << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixSocketInterface::Listen(const SocketPtr& socket)
|
void UnixSocketInterface::socketListen(const SocketPtr& socket)
|
||||||
{
|
{
|
||||||
if(socket->GetHandle() < 0)
|
if(socket->getHandle() < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error opening socket" << std::endl;
|
std::cerr << "Error opening socket" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto port = static_cast<int>(socket->GetPort());
|
const auto port = static_cast<int>(socket->getPort());
|
||||||
struct sockaddr_in serv_addr;
|
struct sockaddr_in serv_addr;
|
||||||
memset(&serv_addr, 0, sizeof(serv_addr));
|
memset(&serv_addr, 0, sizeof(serv_addr));
|
||||||
serv_addr.sin_family = AF_INET;
|
serv_addr.sin_family = AF_INET;
|
||||||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
serv_addr.sin_port = htons(port);
|
serv_addr.sin_port = htons(port);
|
||||||
|
|
||||||
int result = bind(socket->GetHandle(), (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
int result = bind(socket->getHandle(), (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||||
if(result< 0)
|
if(result< 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error binding socket" << std::endl;
|
std::cerr << "Error binding socket" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
listen(socket->GetHandle(), 5);
|
listen(socket->getHandle(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixSocketInterface::Run(const SocketPtr& socket)
|
void UnixSocketInterface::run(const SocketPtr& socket)
|
||||||
{
|
{
|
||||||
if(socket->GetHandle() < 0)
|
if(socket->getHandle() < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error opening socket" << std::endl;
|
std::cerr << "Error opening socket" << std::endl;
|
||||||
return;
|
return;
|
||||||
|
@ -118,7 +118,7 @@ void UnixSocketInterface::Run(const SocketPtr& socket)
|
||||||
socklen_t clilen = sizeof(cli_addr);
|
socklen_t clilen = sizeof(cli_addr);
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
const auto new_socket_handle = accept(socket->GetHandle(), (struct sockaddr *) &cli_addr, &clilen);
|
const auto new_socket_handle = accept(socket->getHandle(), (struct sockaddr *) &cli_addr, &clilen);
|
||||||
if (new_socket_handle < 0)
|
if (new_socket_handle < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error on accept" << std::endl;
|
std::cerr << "Error on accept" << std::endl;
|
||||||
|
@ -132,7 +132,7 @@ void UnixSocketInterface::Run(const SocketPtr& socket)
|
||||||
std::cerr << "Error on read" << std::endl;
|
std::cerr << "Error on read" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
socket->SetMessage(buffer);
|
socket->setMessage(buffer);
|
||||||
std::cout << "Here is the message: " << buffer << std::endl;
|
std::cout << "Here is the message: " << buffer << std::endl;
|
||||||
|
|
||||||
const auto response = mMessageHandler->onMessage(buffer);
|
const auto response = mMessageHandler->onMessage(buffer);
|
||||||
|
|
|
@ -10,25 +10,22 @@ class ISocketMessageHandler;
|
||||||
|
|
||||||
class UnixSocketInterface : public ISocketInterface
|
class UnixSocketInterface : public ISocketInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UnixSocketInterface();
|
UnixSocketInterface();
|
||||||
|
|
||||||
virtual ~UnixSocketInterface();
|
virtual ~UnixSocketInterface();
|
||||||
|
|
||||||
static std::unique_ptr<UnixSocketInterface> Create();
|
static std::unique_ptr<UnixSocketInterface> Create();
|
||||||
|
|
||||||
void InitializeSocket(const SocketPtr& socket, const std::string& address = {}) override;
|
void initializeSocket(const SocketPtr& socket, const std::string& address = {}) override;
|
||||||
|
|
||||||
void Listen(const SocketPtr& socket) override;
|
void socketListen(const SocketPtr& socket) override;
|
||||||
|
|
||||||
void Write(const SocketPtr& socket, const std::string& message) override;
|
void socketWrite(const SocketPtr& socket, const std::string& message) override;
|
||||||
|
|
||||||
void Run(const SocketPtr& socket) override;
|
void run(const SocketPtr& socket) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static constexpr unsigned BUFFER_SIZE{1024};
|
static constexpr unsigned BUFFER_SIZE{1024};
|
||||||
std::size_t mBufferSize { 0 };
|
std::size_t mBufferSize { 0 };
|
||||||
std::unique_ptr<ISocketMessageHandler> mMessageHandler;
|
std::unique_ptr<ISocketMessageHandler> mMessageHandler;
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
MainApplication::MainApplication()
|
MainApplication::MainApplication()
|
||||||
: mDatabaseManager(),
|
: mCommandLineArgs(),
|
||||||
mCommandLineArgs()
|
mDatabaseManager()
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,10 +148,11 @@ void AlsaInterface::play(AudioDevice* device, AudioSample* sample, unsigned dura
|
||||||
const auto data = sample->getChannelData(0);
|
const auto data = sample->getChannelData(0);
|
||||||
|
|
||||||
int numFrames = mPeriodSize >> 2;
|
int numFrames = mPeriodSize >> 2;
|
||||||
for(int count = 0; count < duration; count++)
|
for(unsigned count = 0; count < duration; count++)
|
||||||
{
|
{
|
||||||
const auto offset= count*4*numFrames;
|
const auto offset= count*4*numFrames;
|
||||||
unsigned char frame[4] = {data[offset], data[offset+1], data[offset+2], data[offset+3]};
|
unsigned char frame[4] = {static_cast<unsigned char>(data[offset]),
|
||||||
|
static_cast<unsigned char>(data[offset+1]), static_cast<unsigned char>(data[offset+2]), static_cast<unsigned char>(data[offset+3])};
|
||||||
while ((snd_pcm_writei(mHandle, frame, numFrames)) < 0)
|
while ((snd_pcm_writei(mHandle, frame, numFrames)) < 0)
|
||||||
{
|
{
|
||||||
snd_pcm_prepare(mHandle);
|
snd_pcm_prepare(mHandle);
|
||||||
|
|
|
@ -11,7 +11,7 @@ ImageBitStream::ImageBitStream(Image* image)
|
||||||
|
|
||||||
bool ImageBitStream::isFinished() const
|
bool ImageBitStream::isFinished() const
|
||||||
{
|
{
|
||||||
return mByteOffset == mImage->getGrid()->getDataSize();
|
return mByteOffset == static_cast<int>(mImage->getGrid()->getDataSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned char> ImageBitStream::peekNextNBytes(unsigned n) const
|
std::vector<unsigned char> ImageBitStream::peekNextNBytes(unsigned n) const
|
||||||
|
|
|
@ -118,7 +118,7 @@ void BasicPngWriter::writeDataChunks(const BufferBitStream& buffer)
|
||||||
std::size_t max_bytes{ 32000 };
|
std::size_t max_bytes{ 32000 };
|
||||||
|
|
||||||
auto num_dat_chunks = num_bytes / max_bytes + 1;
|
auto num_dat_chunks = num_bytes / max_bytes + 1;
|
||||||
std::size_t offset = 0;
|
//std::size_t offset = 0;
|
||||||
for (std::size_t idx = 0; idx < num_dat_chunks; idx++)
|
for (std::size_t idx = 0; idx < num_dat_chunks; idx++)
|
||||||
{
|
{
|
||||||
auto length = max_bytes;
|
auto length = max_bytes;
|
||||||
|
@ -126,6 +126,7 @@ void BasicPngWriter::writeDataChunks(const BufferBitStream& buffer)
|
||||||
{
|
{
|
||||||
length = num_bytes - num_dat_chunks * num_bytes;
|
length = num_bytes - num_dat_chunks * num_bytes;
|
||||||
}
|
}
|
||||||
|
(void)length;
|
||||||
|
|
||||||
//std::cout << "Writing idat length " << num_bytes << std::endl;
|
//std::cout << "Writing idat length " << num_bytes << std::endl;
|
||||||
mOutStream->write(static_cast<uint32_t>(num_bytes));
|
mOutStream->write(static_cast<uint32_t>(num_bytes));
|
||||||
|
@ -213,4 +214,4 @@ void BasicPngWriter::write(const Path& path, Image* image)
|
||||||
writeDataChunks(zlib_out_stream);
|
writeDataChunks(zlib_out_stream);
|
||||||
|
|
||||||
writeEndChunk();
|
writeEndChunk();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ bool PngReader::readChunk()
|
||||||
decodeData();
|
decodeData();
|
||||||
}
|
}
|
||||||
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->getInHandle());
|
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||||
|
(void) crcCheck;
|
||||||
}
|
}
|
||||||
else if(chunkType == "IDAT")
|
else if(chunkType == "IDAT")
|
||||||
{
|
{
|
||||||
|
@ -96,6 +97,7 @@ bool PngReader::readChunk()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->getInHandle());
|
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||||
|
(void) crcCheck;
|
||||||
}
|
}
|
||||||
return !lastChunk;
|
return !lastChunk;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +195,7 @@ std::unique_ptr<Image> PngReader::read()
|
||||||
PngFilter filter(mOutputStream.get(), image_bit_stream.get());
|
PngFilter filter(mOutputStream.get(), image_bit_stream.get());
|
||||||
filter.decode();
|
filter.decode();
|
||||||
|
|
||||||
return std::move(image);
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PngReader::decodeData()
|
void PngReader::decodeData()
|
||||||
|
|
|
@ -56,12 +56,13 @@ std::string GlyphRunOutlines::toPostScriptPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
FontGlyph::FontGlyph(unsigned width, unsigned height, int bearingX, int bearingY, int advanceX, std::unique_ptr<Image> image)
|
FontGlyph::FontGlyph(unsigned width, unsigned height, int bearingX, int bearingY, int advanceX, std::unique_ptr<Image> image)
|
||||||
: mImage(std::move(image)),
|
:
|
||||||
mWidth(width),
|
mWidth(width),
|
||||||
mHeight(height),
|
mHeight(height),
|
||||||
mBearingX(bearingX),
|
mBearingX(bearingX),
|
||||||
mBearingY(bearingY),
|
mBearingY(bearingY),
|
||||||
mAdvanceX(advanceX)
|
mAdvanceX(advanceX),
|
||||||
|
mImage(std::move(image))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#include "FontItem.h"
|
#include "FontItem.h"
|
||||||
|
|
||||||
FontItem::FontItem(const std::string& faceName, float size)
|
FontItem::FontItem(const std::string& faceName, float size)
|
||||||
: mFaceName(faceName),
|
: mSize(size),
|
||||||
mSize(size)
|
mFaceName(faceName)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,4 +31,4 @@ const std::string& FontItem::getFaceName() const
|
||||||
float FontItem::getSize() const
|
float FontItem::getSize() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
|
||||||
DrawingContext::DrawingContext(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode)
|
DrawingContext::DrawingContext(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode)
|
||||||
: mSurface(surface),
|
: mDrawingMode(requestedDrawingMode),
|
||||||
mDrawingMode(requestedDrawingMode),
|
mFontsManager(fontsManager),
|
||||||
mFontsManager(fontsManager)
|
mSurface(surface)
|
||||||
{
|
{
|
||||||
mPainter = PainterFactory::Create(this, mDrawingMode);
|
mPainter = PainterFactory::Create(this, mDrawingMode);
|
||||||
|
|
||||||
|
@ -47,4 +47,4 @@ void DrawingContext::paint()
|
||||||
AbstractPainter* DrawingContext::getPainter() const
|
AbstractPainter* DrawingContext::getPainter() const
|
||||||
{
|
{
|
||||||
return mPainter.get();
|
return mPainter.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
|
||||||
Edge::Edge(Node* node0, Node* node1, std::size_t id)
|
Edge::Edge(Node* node0, Node* node1, std::size_t id)
|
||||||
: mNode0(node0),
|
: mId(id),
|
||||||
mNode1(node1),
|
mNode0(node0),
|
||||||
mId(id)
|
mNode1(node1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ std::unique_ptr<TriMesh> MeshPrimitives::buildCircleAsTriMesh(std::size_t numSeg
|
||||||
std::unique_ptr<LineMesh> MeshPrimitives::buildCircleAsLineMesh(std::size_t numSegments)
|
std::unique_ptr<LineMesh> MeshPrimitives::buildCircleAsLineMesh(std::size_t numSegments)
|
||||||
{
|
{
|
||||||
VecPoints locations(numSegments);
|
VecPoints locations(numSegments);
|
||||||
const double delta_theta = (2.0*M_PI)/double(numSegments);
|
//const double delta_theta = (2.0*M_PI)/double(numSegments);
|
||||||
double theta = 0.0;
|
double theta = 0.0;
|
||||||
for(unsigned idx=0; idx<numSegments; idx++)
|
for(unsigned idx=0; idx<numSegments; idx++)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +176,7 @@ std::unique_ptr<TriMesh> MeshPrimitives::buildRoundedRectangleAsTriMesh(double r
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inner rect edges
|
// Inner rect edges
|
||||||
std::size_t edge_offset = num_edges_per_fan*num_fans;
|
// std::size_t edge_offset = num_edges_per_fan*num_fans;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ Node::~Node()
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::Node(const Point& p, std::size_t index)
|
Node::Node(const Point& p, std::size_t index)
|
||||||
: mPoint(p),
|
: mIndex(index),
|
||||||
mIndex(index)
|
mPoint(p)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ void GridNode::update(SceneInfo* sceneInfo)
|
||||||
|
|
||||||
if (mDataDirty)
|
if (mDataDirty)
|
||||||
{
|
{
|
||||||
auto difference = mNumberX*mNumberY - mData.size();
|
//auto difference = mNumberX*mNumberY - mData.size();
|
||||||
mData.resize(mNumberX*mNumberY, {});
|
mData.resize(mNumberX*mNumberY, {});
|
||||||
|
|
||||||
auto node_data = std::vector<std::vector<double> >(4*mNumberX*mNumberY);
|
auto node_data = std::vector<std::vector<double> >(4*mNumberX*mNumberY);
|
||||||
|
@ -128,7 +128,7 @@ void GridNode::update(SceneInfo* sceneInfo)
|
||||||
|
|
||||||
if (mTransformIsDirty)
|
if (mTransformIsDirty)
|
||||||
{
|
{
|
||||||
auto size = mHeight > mWidth ? mWidth : mHeight;
|
//auto size = mHeight > mWidth ? mWidth : mHeight;
|
||||||
|
|
||||||
//mBackgroundModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
//mBackgroundModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
||||||
//mOutlineModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
//mOutlineModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
||||||
|
|
|
@ -81,7 +81,7 @@ void MeshNode::update(SceneInfo* sceneInfo)
|
||||||
|
|
||||||
if (mTransformIsDirty)
|
if (mTransformIsDirty)
|
||||||
{
|
{
|
||||||
auto size = mHeight > mWidth ? mWidth : mHeight;
|
//auto size = mHeight > mWidth ? mWidth : mHeight;
|
||||||
//mModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
//mModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
||||||
mTransformIsDirty = false;
|
mTransformIsDirty = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
Scene::Scene()
|
Scene::Scene()
|
||||||
: mRootNode(std::make_unique<RootNode>()),
|
: mBackGroundColor(Color(255, 255, 255)),
|
||||||
mSceneInfo(std::make_unique<SceneInfo>()),
|
mRootNode(std::make_unique<RootNode>()),
|
||||||
mBackGroundColor(Color(255, 255, 255))
|
mSceneInfo(std::make_unique<SceneInfo>())
|
||||||
|
|
||||||
{
|
{
|
||||||
mRootNode->setName("Scene_RootNode");
|
mRootNode->setName("Scene_RootNode");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,139 +7,139 @@
|
||||||
#include "SvgShapeElements.h"
|
#include "SvgShapeElements.h"
|
||||||
|
|
||||||
SvgNode::SvgNode(const Transform& transform)
|
SvgNode::SvgNode(const Transform& transform)
|
||||||
: MaterialNode(transform)
|
: MaterialNode(transform)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgNode::setContent(std::unique_ptr<SvgDocument> doc)
|
void SvgNode::setContent(std::unique_ptr<SvgDocument> doc)
|
||||||
{
|
{
|
||||||
mContent = std::move(doc);
|
mContent = std::move(doc);
|
||||||
mContentDirty = true;
|
mContentDirty = true;
|
||||||
|
|
||||||
mChildren.clear();
|
mChildren.clear();
|
||||||
mGeometryNodes.clear();
|
mGeometryNodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned SvgNode::getContentWidth() const
|
unsigned SvgNode::getContentWidth() const
|
||||||
{
|
{
|
||||||
return mContentWidth;
|
return mContentWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned SvgNode::getContentHeight() const
|
unsigned SvgNode::getContentHeight() const
|
||||||
{
|
{
|
||||||
return mContentHeight;
|
return mContentHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
void SvgNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||||
{
|
{
|
||||||
if (!mContent->getRoot())
|
if (!mContent->getRoot())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto viewbox = mContent->getViewBox();
|
//auto viewbox = mContent->getViewBox();
|
||||||
|
|
||||||
for (const auto& svg_element : mContent->getRoot()->getChildren())
|
for (const auto& svg_element : mContent->getRoot()->getChildren())
|
||||||
{
|
{
|
||||||
std::unique_ptr<GeometryNode> geom_node;
|
std::unique_ptr<GeometryNode> geom_node;
|
||||||
|
|
||||||
if (svg_element->getTagName() == "circle")
|
if (svg_element->getTagName() == "circle")
|
||||||
{
|
{
|
||||||
onCircle(svg_element.get(), geom_node);
|
onCircle(svg_element.get(), geom_node);
|
||||||
}
|
}
|
||||||
else if (svg_element->getTagName() == "path")
|
else if (svg_element->getTagName() == "path")
|
||||||
{
|
{
|
||||||
onPath(svg_element.get(), geom_node);
|
onPath(svg_element.get(), geom_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractVisualNode* raw_node{ nullptr };
|
AbstractVisualNode* raw_node{ nullptr };
|
||||||
if (geom_node)
|
if (geom_node)
|
||||||
{
|
{
|
||||||
raw_node = geom_node.get();
|
raw_node = geom_node.get();
|
||||||
mGeometryNodes.push_back(std::move(geom_node));
|
mGeometryNodes.push_back(std::move(geom_node));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raw_node)
|
if (raw_node)
|
||||||
{
|
{
|
||||||
addChild(raw_node);
|
addChild(raw_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgNode::update(SceneInfo* sceneInfo)
|
void SvgNode::update(SceneInfo* sceneInfo)
|
||||||
{
|
{
|
||||||
if (mContent && mContentDirty)
|
if (mContent && mContentDirty)
|
||||||
{
|
{
|
||||||
createOrUpdateGeometry(sceneInfo);
|
createOrUpdateGeometry(sceneInfo);
|
||||||
mContentDirty = false;
|
mContentDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMaterialIsDirty)
|
if (mMaterialIsDirty)
|
||||||
{
|
{
|
||||||
if (mHasFillColor)
|
if (mHasFillColor)
|
||||||
{
|
{
|
||||||
for (const auto& geom_node : mGeometryNodes)
|
for (const auto& geom_node : mGeometryNodes)
|
||||||
{
|
{
|
||||||
geom_node->setFillColor(mFillColor);
|
geom_node->setFillColor(mFillColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (const auto& geom_node : mGeometryNodes)
|
for (const auto& geom_node : mGeometryNodes)
|
||||||
{
|
{
|
||||||
geom_node->setHasFillColor(false);
|
geom_node->setHasFillColor(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHasStrokeColor)
|
if (mHasStrokeColor)
|
||||||
{
|
{
|
||||||
for (const auto& geom_node : mGeometryNodes)
|
for (const auto& geom_node : mGeometryNodes)
|
||||||
{
|
{
|
||||||
geom_node->setStrokeColor(mStrokeColor);
|
geom_node->setStrokeColor(mStrokeColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (const auto& geom_node : mGeometryNodes)
|
for (const auto& geom_node : mGeometryNodes)
|
||||||
{
|
{
|
||||||
geom_node->setHasStrokeColor(false);
|
geom_node->setHasStrokeColor(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mMaterialIsDirty = false;
|
mMaterialIsDirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgNode::onCircle(XmlElement* element, std::unique_ptr<GeometryNode>& node)
|
void SvgNode::onCircle(XmlElement* element, std::unique_ptr<GeometryNode>& node)
|
||||||
{
|
{
|
||||||
auto svg_circle = dynamic_cast<SvgCircle*>(element);
|
auto svg_circle = dynamic_cast<SvgCircle*>(element);
|
||||||
auto loc = svg_circle->getLocation();
|
auto loc = svg_circle->getLocation();
|
||||||
auto radius = svg_circle->getRadius();
|
auto radius = svg_circle->getRadius();
|
||||||
auto minor_radius = radius;
|
auto minor_radius = radius;
|
||||||
|
|
||||||
if (svg_circle->getType() == SvgCircle::Type::ELLIPSE)
|
if (svg_circle->getType() == SvgCircle::Type::ELLIPSE)
|
||||||
{
|
{
|
||||||
minor_radius = svg_circle->getMinorRadius();
|
minor_radius = svg_circle->getMinorRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element->hasAttribute("transform"))
|
if (element->hasAttribute("transform"))
|
||||||
{
|
{
|
||||||
const auto transform = svg_circle->getTransform();
|
const auto transform = svg_circle->getTransform();
|
||||||
loc.move(transform.getLocation().getX(), transform.getLocation().getY());
|
loc.move(transform.getLocation().getX(), transform.getLocation().getY());
|
||||||
radius *= transform.getScaleX();
|
radius *= transform.getScaleX();
|
||||||
minor_radius *= transform.getScaleY();
|
minor_radius *= transform.getScaleY();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto circle_node = std::make_unique<CircleNode>(loc, radius);
|
auto circle_node = std::make_unique<CircleNode>(loc, radius);
|
||||||
circle_node->setMinorRadius(minor_radius);
|
circle_node->setMinorRadius(minor_radius);
|
||||||
node = std::move(circle_node);
|
node = std::move(circle_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgNode::onPath(XmlElement* element, std::unique_ptr<GeometryNode>& node)
|
void SvgNode::onPath(XmlElement* element, std::unique_ptr<GeometryNode>& node)
|
||||||
{
|
{
|
||||||
auto svg_path = dynamic_cast<SvgPath*>(element);
|
auto svg_path = dynamic_cast<SvgPath*>(element);
|
||||||
|
|
||||||
Point loc;
|
Point loc;
|
||||||
auto path_node = std::make_unique<PathNode>(loc, svg_path->getPath());
|
auto path_node = std::make_unique<PathNode>(loc, svg_path->getPath());
|
||||||
node = std::move(path_node);
|
node = std::move(path_node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ std::unique_ptr<SvgDocument> SvgPainter::paint(Scene* scene, double width, doubl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::move(doc);
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgPainter::paintMesh(SvgDocument* document, SceneModel* model, bool showOutline) const
|
void SvgPainter::paintMesh(SvgDocument* document, SceneModel* model, bool showOutline) const
|
||||||
|
@ -161,7 +161,6 @@ void SvgPainter::paintCircle(SvgDocument* document, SceneModel* model) const
|
||||||
{
|
{
|
||||||
auto model_circle = dynamic_cast<Circle*>(model->getGeometry());
|
auto model_circle = dynamic_cast<Circle*>(model->getGeometry());
|
||||||
|
|
||||||
auto is_ellipse = model_circle->getMinorRadius() != model_circle->getRadius();
|
|
||||||
auto circle = std::make_unique<SvgCircle>(model_circle->isEllipse() ? SvgCircle::Type::ELLIPSE : SvgCircle::Type::REGULAR);
|
auto circle = std::make_unique<SvgCircle>(model_circle->isEllipse() ? SvgCircle::Type::ELLIPSE : SvgCircle::Type::REGULAR);
|
||||||
circle->setRadius(model_circle->getRadius());
|
circle->setRadius(model_circle->getRadius());
|
||||||
if (model_circle->isEllipse())
|
if (model_circle->isEllipse())
|
||||||
|
@ -223,5 +222,5 @@ std::unique_ptr<XmlAttribute> SvgPainter::toTransform(const Transform& transform
|
||||||
}
|
}
|
||||||
svg_transform->setValue(ops);
|
svg_transform->setValue(ops);
|
||||||
|
|
||||||
return std::move(svg_transform);
|
return svg_transform;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ class TopBarMenu : public Widget
|
||||||
public:
|
public:
|
||||||
void popupFrom(Widget* parent)
|
void popupFrom(Widget* parent)
|
||||||
{
|
{
|
||||||
auto window = parent->getTopLevelWindow();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ void VerticalSpacer::updateChildLocations()
|
||||||
{
|
{
|
||||||
double scaleSum = std::accumulate(mScales.begin(), mScales.end(), 0.0);
|
double scaleSum = std::accumulate(mScales.begin(), mScales.end(), 0.0);
|
||||||
double offset = 0;
|
double offset = 0;
|
||||||
unsigned delta = mSize.mWidth / unsigned(mChildren.size());
|
|
||||||
for(std::size_t idx=0; idx<mChildren.size(); idx++)
|
for(std::size_t idx=0; idx<mChildren.size(); idx++)
|
||||||
{
|
{
|
||||||
auto& child = mChildren[idx];
|
auto& child = mChildren[idx];
|
||||||
|
|
|
@ -29,5 +29,5 @@ std::unique_ptr<SvgNode> MediaResourceManager::getSvgIconNode(Resource::Icon::Sv
|
||||||
|
|
||||||
auto svg_node = std::make_unique<SvgNode>(Point(0.0, 0.0));
|
auto svg_node = std::make_unique<SvgNode>(Point(0.0, 0.0));
|
||||||
svg_node->setContent(std::move(svg_doc));
|
svg_node->setContent(std::move(svg_doc));
|
||||||
return std::move(svg_node);
|
return svg_node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ Widget::Widget()
|
||||||
: BoxGeometry(),
|
: BoxGeometry(),
|
||||||
mRootNode(std::make_unique<TransformNode>()),
|
mRootNode(std::make_unique<TransformNode>()),
|
||||||
mChildren(),
|
mChildren(),
|
||||||
|
mBorder(Theme::Sys::Color::Outline),
|
||||||
mBorderThickness(0),
|
mBorderThickness(0),
|
||||||
mBackground(Theme::Sys::Color::Primary),
|
mBackground(Theme::Sys::Color::Primary),
|
||||||
mBorder(Theme::Sys::Color::Outline),
|
|
||||||
mVisible(true)
|
mVisible(true)
|
||||||
{
|
{
|
||||||
mName = "Widget";
|
mName = "Widget";
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
DesktopManager::DesktopManager(AbstractDesktopApp* application)
|
DesktopManager::DesktopManager(AbstractDesktopApp* application)
|
||||||
: mScreens(),
|
: mScreens(),
|
||||||
mKeyboard(Keyboard::Create()),
|
mKeyboard(Keyboard::Create()),
|
||||||
mUiApplication(application),
|
|
||||||
mEventManager(EventManager::Create()),
|
|
||||||
mFontsManager(FontsManager::Create()),
|
mFontsManager(FontsManager::Create()),
|
||||||
mThemeManager(std::make_unique<ThemeManager>())
|
mEventManager(EventManager::Create()),
|
||||||
|
mThemeManager(std::make_unique<ThemeManager>()),
|
||||||
|
mUiApplication(application)
|
||||||
{
|
{
|
||||||
mWindowManager = WindowManager::Create(this);
|
mWindowManager = WindowManager::Create(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ std::unique_ptr<MouseEvent> XcbEventInterface::convertButtonPress(xcb_button_pre
|
||||||
|
|
||||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||||
ui_event->setScreenLocation(DiscretePoint(x, y));
|
ui_event->setScreenLocation(DiscretePoint(screen_x, screen_y));
|
||||||
ui_event->setAction(MouseEvent::Action::Pressed);
|
ui_event->setAction(MouseEvent::Action::Pressed);
|
||||||
return ui_event;
|
return ui_event;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ std::unique_ptr<MouseEvent> XcbEventInterface::convertButtonRelease(xcb_button_p
|
||||||
|
|
||||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||||
ui_event->setScreenLocation(DiscretePoint(x, y));
|
ui_event->setScreenLocation(DiscretePoint(screen_x, screen_y));
|
||||||
|
|
||||||
ui_event->setAction(MouseEvent::Action::Released);
|
ui_event->setAction(MouseEvent::Action::Released);
|
||||||
return ui_event;
|
return ui_event;
|
||||||
|
|
|
@ -55,7 +55,7 @@ bool XcbGlWindowInterface::initialize(xcb_window_t window)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto context = glXGetCurrentContext())
|
if (glXGetCurrentContext())
|
||||||
{
|
{
|
||||||
MLOG_INFO("Has valid GL context");
|
MLOG_INFO("Has valid GL context");
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,12 +148,12 @@ void XcbInterface::createGraphicsContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
auto gc = xcb_generate_id(mConnection);
|
auto gc = xcb_generate_id(mConnection);
|
||||||
xcb_drawable_t window = xcb_screen->GetNativeScreen()->root;
|
xcb_drawable_t window = xcb_screen->getNativeScreen()->root;
|
||||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
|
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
|
||||||
auto color = Color(240, 240, 240);
|
auto color = Color(240, 240, 240);
|
||||||
uint32_t values[2] = {color.getAsUInt32(), 0};
|
uint32_t values[2] = {color.getAsUInt32(), 0};
|
||||||
xcb_create_gc(mConnection, gc, window, mask, values);
|
xcb_create_gc(mConnection, gc, window, mask, values);
|
||||||
xcb_screen->SetGraphicsContext(gc);
|
xcb_screen->setGraphicsContext(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XcbInterface::mapWindow(mt::Window* window)
|
void XcbInterface::mapWindow(mt::Window* window)
|
||||||
|
|
|
@ -13,17 +13,17 @@ std::unique_ptr<XcbScreen> XcbScreen::Create(xcb_screen_t* screen)
|
||||||
return std::make_unique<XcbScreen>(screen);
|
return std::make_unique<XcbScreen>(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_screen_t* XcbScreen::GetNativeScreen() const
|
xcb_screen_t* XcbScreen::getNativeScreen() const
|
||||||
{
|
{
|
||||||
return mNativeScreen;
|
return mNativeScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XcbScreen::SetGraphicsContext(unsigned gc)
|
void XcbScreen::setGraphicsContext(unsigned gc)
|
||||||
{
|
{
|
||||||
mGraphicsContext = gc;
|
mGraphicsContext = gc;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned XcbScreen::GetGraphicsContext() const
|
unsigned XcbScreen::getGraphicsContext() const
|
||||||
{
|
{
|
||||||
return mGraphicsContext;
|
return mGraphicsContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma
|
#pragma once
|
||||||
|
|
||||||
#include "IPlatformScreen.h"
|
#include "IPlatformScreen.h"
|
||||||
|
|
||||||
|
@ -7,18 +7,17 @@ struct xcb_screen_t;
|
||||||
class XcbScreen : public IPlatformScreen
|
class XcbScreen : public IPlatformScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XcbScreen(xcb_screen_t* screen);
|
XcbScreen(xcb_screen_t* screen);
|
||||||
|
|
||||||
virtual ~XcbScreen() = default;
|
virtual ~XcbScreen() = default;
|
||||||
|
|
||||||
static std::unique_ptr<XcbScreen> Create(xcb_screen_t* screen);
|
static std::unique_ptr<XcbScreen> Create(xcb_screen_t* screen);
|
||||||
|
|
||||||
xcb_screen_t* GetNativeScreen() const;
|
unsigned getGraphicsContext() const;
|
||||||
|
|
||||||
void SetGraphicsContext(unsigned gc);
|
xcb_screen_t* getNativeScreen() const;
|
||||||
|
|
||||||
unsigned GetGraphicsContext() const;
|
void setGraphicsContext(unsigned gc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned mGraphicsContext {0};
|
unsigned mGraphicsContext {0};
|
||||||
|
|
|
@ -40,9 +40,9 @@ void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen
|
||||||
|
|
||||||
const auto hwnd = xcb_generate_id(connection);
|
const auto hwnd = xcb_generate_id(connection);
|
||||||
const uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
const uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
||||||
const uint32_t values[2] = {xcb_screen->GetNativeScreen()->white_pixel, eventMask};
|
const uint32_t values[2] = {xcb_screen->getNativeScreen()->white_pixel, eventMask};
|
||||||
|
|
||||||
xcb_window_t parent_hwnd = xcb_screen->GetNativeScreen()->root;
|
xcb_window_t parent_hwnd = xcb_screen->getNativeScreen()->root;
|
||||||
if (auto parent = window->getParent())
|
if (auto parent = window->getParent())
|
||||||
{
|
{
|
||||||
parent_hwnd = dynamic_cast<XcbWindow*>(parent->getPlatformWindow())->getHandle();
|
parent_hwnd = dynamic_cast<XcbWindow*>(parent->getPlatformWindow())->getHandle();
|
||||||
|
@ -56,7 +56,7 @@ void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen
|
||||||
window->getWidth(), window->getHeight(), /* width, height */
|
window->getWidth(), window->getHeight(), /* width, height */
|
||||||
10, /* border_width */
|
10, /* border_width */
|
||||||
XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
|
XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
|
||||||
xcb_screen->GetNativeScreen()->root_visual, /* visual */
|
xcb_screen->getNativeScreen()->root_visual, /* visual */
|
||||||
mask, values ); /* masks */
|
mask, values ); /* masks */
|
||||||
|
|
||||||
if (!window->getTitle().empty())
|
if (!window->getTitle().empty())
|
||||||
|
@ -68,7 +68,7 @@ void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen
|
||||||
|
|
||||||
auto xcb_window = std::make_unique<XcbWindow>(window, hwnd, connection, xcbGlInterface);
|
auto xcb_window = std::make_unique<XcbWindow>(window, hwnd, connection, xcbGlInterface);
|
||||||
|
|
||||||
const auto drawing_mode = xcbGlInterface ? DrawingMode::GRAPH : DrawingMode::RASTER;
|
//const auto drawing_mode = xcbGlInterface ? DrawingMode::GRAPH : DrawingMode::RASTER;
|
||||||
window->setPlatformWindow(std::move(xcb_window));
|
window->setPlatformWindow(std::move(xcb_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void XcbWindow::beforePaint(mt::Screen* screen)
|
||||||
auto xcb_screen = dynamic_cast<XcbScreen*>(screen->GetPlatformScreen());
|
auto xcb_screen = dynamic_cast<XcbScreen*>(screen->GetPlatformScreen());
|
||||||
if (!mBackingImage)
|
if (!mBackingImage)
|
||||||
{
|
{
|
||||||
mBackingImage = std::make_unique<XcbImage>(mConnection, mWindow, xcb_screen->GetNativeScreen());
|
mBackingImage = std::make_unique<XcbImage>(mConnection, mWindow, xcb_screen->getNativeScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,9 @@ void XcbWindow::afterPaint(mt::Screen* screen)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto xcb_screen = dynamic_cast<XcbScreen*>(screen->GetPlatformScreen());
|
auto xcb_screen = dynamic_cast<XcbScreen*>(screen->GetPlatformScreen());
|
||||||
mBackingImage->update(mWindow, xcb_screen->GetNativeScreen(), mConnection, xcb_screen->GetGraphicsContext());
|
mBackingImage->update(mWindow, xcb_screen->getNativeScreen(), mConnection, xcb_screen->getGraphicsContext());
|
||||||
|
|
||||||
xcb_copy_area(mConnection, mBackingImage->getPixMap(), mHandle, xcb_screen->GetGraphicsContext(), 0, 0 ,0 , 0, mWindow->getWidth(), mWindow->getHeight());
|
xcb_copy_area(mConnection, mBackingImage->getPixMap(), mHandle, xcb_screen->getGraphicsContext(), 0, 0 ,0 , 0, mWindow->getWidth(), mWindow->getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,6 @@ std::unique_ptr<HtmlDocument> MarkdownConverter::convert(MarkdownDocument* markd
|
||||||
auto body_element = html_doc->getBodyElement();
|
auto body_element = html_doc->getBodyElement();
|
||||||
convert(markdownDoc, body_element);
|
convert(markdownDoc, body_element);
|
||||||
|
|
||||||
return std::move(html_doc);
|
return html_doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,5 +401,5 @@ std::unique_ptr<MarkdownDocument> MarkdownParser::run(const std::string& content
|
||||||
|
|
||||||
run(content, doc.get());
|
run(content, doc.get());
|
||||||
|
|
||||||
return std::move(doc);
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ TEST_CASE(TestHuffmanCodeLengthTable, "compression")
|
||||||
table.buildCompressedLengthSequence();
|
table.buildCompressedLengthSequence();
|
||||||
|
|
||||||
auto compressed_sequence = table.getCompressedLengthSequence();
|
auto compressed_sequence = table.getCompressedLengthSequence();
|
||||||
for (auto entry : compressed_sequence)
|
//for (auto entry : compressed_sequence)
|
||||||
{
|
//{
|
||||||
// std::cout << "Count " << entry.first << " extra bits " << entry.second << std::endl;
|
// std::cout << "Count " << entry.first << " extra bits " << entry.second << std::endl;
|
||||||
}
|
//}
|
||||||
|
|
||||||
auto compressed_lengths = table.getCompressedLengthCounts();
|
auto compressed_lengths = table.getCompressedLengthCounts();
|
||||||
for(unsigned idx = 0; idx<compressed_lengths.size(); idx++)
|
for(unsigned idx = 0; idx<compressed_lengths.size(); idx++)
|
||||||
|
@ -53,10 +53,10 @@ TEST_CASE(TestLiteralsTable, "compression")
|
||||||
table.buildCompressedLengthSequence();
|
table.buildCompressedLengthSequence();
|
||||||
|
|
||||||
auto compressed_sequence = table.getCompressedLengthSequence();
|
auto compressed_sequence = table.getCompressedLengthSequence();
|
||||||
for (auto entry : compressed_sequence)
|
//for (auto entry : compressed_sequence)
|
||||||
{
|
//{
|
||||||
// std::cout << "Code " << entry.first << " extra bits " << entry.second << std::endl;
|
// std::cout << "Code " << entry.first << " extra bits " << entry.second << std::endl;
|
||||||
}
|
//}
|
||||||
|
|
||||||
auto compressed_lengths = table.getCompressedLengthCounts();
|
auto compressed_lengths = table.getCompressedLengthCounts();
|
||||||
for(unsigned idx = 0; idx<compressed_lengths.size(); idx++)
|
for(unsigned idx = 0; idx<compressed_lengths.size(); idx++)
|
||||||
|
|
|
@ -25,11 +25,11 @@ TEST_CASE(TestLz77Encoder, "compression")
|
||||||
encoder.encode();
|
encoder.encode();
|
||||||
|
|
||||||
auto hit_buffer = encoder.getHitBuffer();
|
auto hit_buffer = encoder.getHitBuffer();
|
||||||
for(const auto& hit : hit_buffer)
|
//for(const auto& hit : hit_buffer)
|
||||||
{
|
//{
|
||||||
const auto& [length, distance, next_char] = hit;
|
//const auto& [length, distance, next_char] = hit;
|
||||||
//std::cout << "Got hit " << length << " | " << distance << " | " << static_cast<int>(next_char) << std::endl;
|
//std::cout << "Got hit " << length << " | " << distance << " | " << static_cast<int>(next_char) << std::endl;
|
||||||
}
|
//}
|
||||||
|
|
||||||
HuffmanEncoder huffman_encoder;
|
HuffmanEncoder huffman_encoder;
|
||||||
huffman_encoder.initializeTrees(hit_buffer);
|
huffman_encoder.initializeTrees(hit_buffer);
|
||||||
|
|
|
@ -37,6 +37,7 @@ TEST_CASE(TestReadBitStream, "core")
|
||||||
|
|
||||||
valid = stream.readNextNBits(3, buffer);
|
valid = stream.readNextNBits(3, buffer);
|
||||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||||
|
REQUIRE(valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(TestWritingBitStream, "core")
|
TEST_CASE(TestWritingBitStream, "core")
|
||||||
|
|
|
@ -14,6 +14,7 @@ TEST_CASE(TestReadByteUtils, "core")
|
||||||
|
|
||||||
auto slice = ByteUtils::getMBitsAtN(byte, 3, 3);
|
auto slice = ByteUtils::getMBitsAtN(byte, 3, 3);
|
||||||
//std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
|
//std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
|
||||||
|
(void) slice;
|
||||||
|
|
||||||
uint32_t input {12345678};
|
uint32_t input {12345678};
|
||||||
auto byte0 = ByteUtils::getByteN(input, 0);
|
auto byte0 = ByteUtils::getByteN(input, 0);
|
||||||
|
@ -21,6 +22,11 @@ TEST_CASE(TestReadByteUtils, "core")
|
||||||
auto byte2 = ByteUtils::getByteN(input, 2);
|
auto byte2 = ByteUtils::getByteN(input, 2);
|
||||||
auto byte3 = ByteUtils::getByteN(input, 3);
|
auto byte3 = ByteUtils::getByteN(input, 3);
|
||||||
|
|
||||||
|
(void)byte0;
|
||||||
|
(void)byte1;
|
||||||
|
(void)byte2;
|
||||||
|
(void)byte3;
|
||||||
|
|
||||||
//std::cout << "Byte0 is " << ByteUtils::toString(byte0) << std::endl;
|
//std::cout << "Byte0 is " << ByteUtils::toString(byte0) << std::endl;
|
||||||
//std::cout << "Byte1 is " << ByteUtils::toString(byte1) << std::endl;
|
//std::cout << "Byte1 is " << ByteUtils::toString(byte1) << std::endl;
|
||||||
//std::cout << "Byte2 is " << ByteUtils::toString(byte2) << std::endl;
|
//std::cout << "Byte2 is " << ByteUtils::toString(byte2) << std::endl;
|
||||||
|
@ -28,10 +34,11 @@ TEST_CASE(TestReadByteUtils, "core")
|
||||||
|
|
||||||
//std::cout << "Mirroring" << std::endl;
|
//std::cout << "Mirroring" << std::endl;
|
||||||
|
|
||||||
auto out = ByteUtils::mirror(byte);
|
//auto out = ByteUtils::mirror(byte);
|
||||||
//std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
|
//std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
|
||||||
|
|
||||||
unsigned hold = byte;
|
unsigned hold = byte;
|
||||||
hold = (hold << 5) + 3;
|
hold = (hold << 5) + 3;
|
||||||
|
(void)hold;
|
||||||
//std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
|
//std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,20 @@ TEST_CASE(TestCircleBuffer, "core")
|
||||||
{
|
{
|
||||||
auto item = buffer.getItem(idx);
|
auto item = buffer.getItem(idx);
|
||||||
//std::cout << "Got item: " << idx << " " << item << std::endl;
|
//std::cout << "Got item: " << idx << " " << item << std::endl;
|
||||||
|
(void)item;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto item : {4, 5})
|
for (auto item : {4, 5})
|
||||||
{
|
{
|
||||||
//std::cout << "Add item: " << item << std::endl;
|
//std::cout << "Add item: " << item << std::endl;
|
||||||
//buffer.addItem(item);
|
//buffer.addItem(item);
|
||||||
|
(void)item;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t idx=0; idx<3; idx++)
|
for (std::size_t idx=0; idx<3; idx++)
|
||||||
{
|
{
|
||||||
auto item = buffer.getItem(idx);
|
auto item = buffer.getItem(idx);
|
||||||
//std::cout << "Got item: " << idx << " " << item << std::endl;
|
//std::cout << "Got item: " << idx << " " << item << std::endl;
|
||||||
|
(void)item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ TEST_CASE(TestTomlReader, "core")
|
||||||
|
|
||||||
REQUIRE(themes_table);
|
REQUIRE(themes_table);
|
||||||
|
|
||||||
for (const auto& items : themes_table->getKeyValuePairs())
|
//for (const auto& items : themes_table->getKeyValuePairs())
|
||||||
{
|
//{
|
||||||
//std::cout << "Got entry with key: " << items.first << " and val " << items.second << std::endl;
|
//std::cout << "Got entry with key: " << items.first << " and val " << items.second << std::endl;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[])
|
||||||
auto args = CommandLineArgs::Create();
|
auto args = CommandLineArgs::Create();
|
||||||
args->process(argc, argv);
|
args->process(argc, argv);
|
||||||
|
|
||||||
auto result = TestCaseRunner::getInstance().run(args->getUserArgs());
|
TestCaseRunner::getInstance().run(args->getUserArgs());
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
|
|
|
@ -10,9 +10,9 @@ public:
|
||||||
using TestCaseFunction = std::function<void()>;
|
using TestCaseFunction = std::function<void()>;
|
||||||
|
|
||||||
TestCase(const std::string& name, const std::string& tags, TestCaseFunction func)
|
TestCase(const std::string& name, const std::string& tags, TestCaseFunction func)
|
||||||
: mName(name),
|
: mTestFunction(func),
|
||||||
mTags(tags),
|
mName(name),
|
||||||
mTestFunction(func)
|
mTags(tags)
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TestCaseRunner::getInstance().setTestApplication(gui_app.get());
|
TestCaseRunner::getInstance().setTestApplication(gui_app.get());
|
||||||
auto result = TestCaseRunner::getInstance().run(user_args);
|
TestCaseRunner::getInstance().run(user_args);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
|
|
Loading…
Reference in a new issue