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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include "image_view.hpp"
#include "controller.hpp"
#include "../graphics/screen.hpp"
#include "../graphics/display_list.hpp"
#include "../base/matrix.hpp"
#include "../geometry/transformations.hpp"
namespace gui
{
ImageView::Params::Params()
{}
ImageView::ImageView(Params const & p)
: base_t(p),
m_boundRects(1)
{
m_image = p.m_image;
}
void ImageView::cache()
{
graphics::Screen * cs = m_controller->GetCacheScreen();
m_displayList.reset();
m_displayList.reset(cs->createDisplayList());
cs->beginFrame();
cs->setDisplayList(m_displayList.get());
math::Matrix<double, 3, 3> m =
math::Shift(
math::Identity<double, 3>(),
-(int)m_image.m_size.x / 2, -(int)m_image.m_size.y / 2);
uint32_t imageResID = cs->mapInfo(m_image);
cs->drawImage(m, imageResID, depth());
cs->setDisplayList(0);
cs->endFrame();
}
void ImageView::purge()
{
m_displayList.reset();
}
vector<m2::AnyRectD> const & ImageView::boundRects() const
{
if (isDirtyRect())
{
m2::PointD sz(m_image.m_size);
m2::PointD pt = computeTopLeft(sz,
pivot(),
position());
m_boundRects[0] = m2::AnyRectD(m2::RectD(pt, pt + sz));
setIsDirtyRect(false);
}
return m_boundRects;
}
void ImageView::draw(graphics::OverlayRenderer * r,
math::Matrix<double, 3, 3> const & m) const
{
if (isVisible())
{
checkDirtyLayout();
m2::PointD pt = computeTopLeft(m_image.m_size,
pivot() * m,
position());
math::Matrix<double, 3, 3> drawM = math::Shift(math::Identity<double, 3>(),
pt.x + m_image.m_size.x / 2,
pt.y + m_image.m_size.y / 2);
r->drawDisplayList(m_displayList.get(), drawM * m);
}
}
void ImageView::setImage(graphics::Image::Info const & info)
{
m_image = info;
setIsDirtyLayout(true);
invalidate();
}
}
|