-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPush2DisplayRenderer.cpp
More file actions
66 lines (58 loc) · 2.03 KB
/
Push2DisplayRenderer.cpp
File metadata and controls
66 lines (58 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "Push2DisplayRenderer.h"
#include "Push2Topology.h"
#include <cstdlib> //exit
#include <iostream>
using namespace push2device;
DisplayRenderer::DisplayRenderer() :
m_frameBuf({1024, 160})
{
if(!m_usbDisplay.init())
{
std::cerr << "m_usbDisplay.init() failed, exiting ..." << std::endl;
exit(-1);
}
}
DisplayRenderer::~DisplayRenderer()
{
}
void DisplayRenderer::drawPixel(const gfx::Coord& coord, const ColorRGB& color)
{
m_frameBuf.at(coord.x, coord.y) = color.toUint16_BRG565_dither(coord.x, coord.y);
}
void DisplayRenderer::streamToSubWindow(const gfx::Rectangle& subWindow,
const ColorRGB* pPixelStream)
{
for(gfx::Pixel subY = 0; subY < subWindow.height(); ++subY)
{
for(gfx::Pixel subX = 0; subX < subWindow.width(); ++subX)
{
const gfx::Pixel x = subWindow.upperLeft.x + subX;
const gfx::Pixel y = subWindow.upperLeft.y + subY;
const auto streamIndex = subX + (subY * subWindow.width());
m_frameBuf.at(x, y) = pPixelStream[streamIndex].toUint16_BRG565_dither(x, y);
}
}
}
void DisplayRenderer::streamFromFramebuf(const gfx::Rectangle& subWindow,
const gfx::Resolution& resolution,
const ColorRGB* pFrameBuf)
{
for(gfx::Pixel subY = 0; subY < subWindow.height(); ++subY)
{
for(gfx::Pixel subX = 0; subX < subWindow.width(); ++subX)
{
const gfx::Pixel x = subWindow.upperLeft.x + subX;
const gfx::Pixel y = subWindow.upperLeft.y + subY;
const auto streamIndex = x + (y * resolution.x);
m_frameBuf.at(x, y) = pFrameBuf[streamIndex].toUint16_BRG565_dither(x, y);
}
}
}
fp::gfx::Resolution DisplayRenderer::getResolution() const
{
return fp::Push2Topology::Display::getResolution(fp::Push2Topology::Display::Id::eDisplay);
}
void DisplayRenderer::flushFrameBuffer()
{
m_usbDisplay.sendFrameToDisplay(m_frameBuf);
}