comparison OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp @ 1551:c54bc5bffd01

software rendering
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Aug 2020 22:05:13 +0200
parents 244ad1e4e76a
children 314b6dc507d9
comparison
equal deleted inserted replaced
1550:012ab2c1f23b 1551:c54bc5bffd01
17 * You should have received a copy of the GNU Affero General Public License 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/>. 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/ 19 **/
20 20
21 21
22 #include "WebAssemblyCairoViewport.h" 22 #if defined(ORTHANC_BUILDING_STONE_LIBRARY) && ORTHANC_BUILDING_STONE_LIBRARY == 1
23 23 # include "WebAssemblyCairoViewport.h"
24 #include "../Scene2D/CairoCompositor.h" 24 # include "../Scene2D/CairoCompositor.h"
25 #else
26 // This is the case when using the WebAssembly side module, and this
27 // source file must be compiled within the WebAssembly main module
28 # include <Viewport/WebAssemblyCairoViewport.h>
29 # include <Scene2D/CairoCompositor.h>
30 #endif
25 31
26 #include <Images/Image.h> 32 #include <Images/Image.h>
27 33
28 #include <boost/math/special_functions/round.hpp> 34 #include <boost/math/special_functions/round.hpp>
29 35
122 128
123 dynamic_cast<CairoCompositor&>(compositor).UpdateSize(width, height); 129 dynamic_cast<CairoCompositor&>(compositor).UpdateSize(width, height);
124 } 130 }
125 131
126 132
127 WebAssemblyCairoViewport::WebAssemblyCairoViewport( 133 WebAssemblyCairoViewport::WebAssemblyCairoViewport(const std::string& canvasId,
128 const std::string& canvasId) : 134 bool enableEmscriptenMouseEvents) :
129 WebAssemblyViewport(canvasId) 135 WebAssemblyViewport(canvasId,enableEmscriptenMouseEvents)
130 { 136 {
131 unsigned int width, height; 137 unsigned int width, height;
132 GetCanvasSize(width, height); 138 GetCanvasSize(width, height);
133 emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), 139 emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), width, height);
134 width,
135 height);
136 140
137 AcquireCompositor(new CairoCompositor(width, height)); 141 AcquireCompositor(new CairoCompositor(width, height));
138 } 142 }
143
144
145 boost::shared_ptr<WebAssemblyCairoViewport> WebAssemblyCairoViewport::Create(
146 const std::string& canvasId, bool enableEmscriptenMouseEvents)
147 {
148 boost::shared_ptr<WebAssemblyCairoViewport> that = boost::shared_ptr<WebAssemblyCairoViewport>(
149 new WebAssemblyCairoViewport(canvasId, enableEmscriptenMouseEvents));
150
151 that->WebAssemblyViewport::PostConstructor();
152 return that;
153 }
139 } 154 }