Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/CairoInfoPanelRenderer.cpp @ 597:9e51fb773bbd
CairoCompositor
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2019 17:28:18 +0200 |
parents | |
children | 80829436ce0c 6e888cf6a48b |
comparison
equal
deleted
inserted
replaced
596:b716763571ad | 597:9e51fb773bbd |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "CairoInfoPanelRenderer.h" | |
23 | |
24 #include "../InfoPanelSceneLayer.h" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 namespace Internals | |
29 { | |
30 void CairoInfoPanelRenderer::Update(const ISceneLayer& layer) | |
31 { | |
32 const InfoPanelSceneLayer& l = dynamic_cast<const InfoPanelSceneLayer&>(layer); | |
33 | |
34 texture_.Copy(l.GetTexture(), true); | |
35 anchor_ = l.GetAnchor(); | |
36 isLinearInterpolation_ = l.IsLinearInterpolation(); | |
37 } | |
38 | |
39 | |
40 void CairoInfoPanelRenderer::Render(const AffineTransform2D& transform) | |
41 { | |
42 int dx, dy; | |
43 InfoPanelSceneLayer::ComputeAnchorLocation( | |
44 dx, dy, anchor_, texture_.GetWidth(), texture_.GetHeight(), | |
45 target_.GetCairoWidth(), target_.GetCairoHeight()); | |
46 | |
47 cairo_t* cr = target_.GetCairoContext(); | |
48 | |
49 cairo_save(cr); | |
50 | |
51 cairo_matrix_t t; | |
52 cairo_matrix_init_identity(&t); | |
53 cairo_matrix_translate(&t, dx, dy); | |
54 cairo_transform(cr, &t); | |
55 | |
56 cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | |
57 cairo_set_source_surface(cr, texture_.GetObject(), 0, 0); | |
58 | |
59 if (isLinearInterpolation_) | |
60 { | |
61 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_BILINEAR); | |
62 } | |
63 else | |
64 { | |
65 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST); | |
66 } | |
67 | |
68 cairo_paint(cr); | |
69 | |
70 cairo_restore(cr); | |
71 } | |
72 } | |
73 } |