annotate OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp @ 1558:314b6dc507d9

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Aug 2020 11:38:56 +0200
parents c54bc5bffd01
children 92fca2b3ba3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1271
0ca50d275b9a upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
22 #if defined(ORTHANC_BUILDING_STONE_LIBRARY) && ORTHANC_BUILDING_STONE_LIBRARY == 1
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
23 # include "WebAssemblyCairoViewport.h"
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
24 # include "../Scene2D/CairoCompositor.h"
1558
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
25 # include "../Scene2DViewport/ViewportController.h"
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
26 #else
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
27 // This is the case when using the WebAssembly side module, and this
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
28 // source file must be compiled within the WebAssembly main module
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
29 # include <Viewport/WebAssemblyCairoViewport.h>
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
30 # include <Scene2D/CairoCompositor.h>
1558
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
31 # include <Scene2DViewport/ViewportController.h>
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
32 #endif
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1558
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
34
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1351
diff changeset
35 #include <Images/Image.h>
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
1480
4de884c95cd8 fix includes in WebAssemblyCairoViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
37 #include <boost/math/special_functions/round.hpp>
4de884c95cd8 fix includes in WebAssemblyCairoViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
38
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 namespace OrthancStone
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 void WebAssemblyCairoViewport::GetCanvasSize(unsigned int& width,
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 unsigned int& height)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 double w, h;
1351
1b8e37770d78 ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1331
diff changeset
45 emscripten_get_element_css_size(GetCanvasCssSelector().c_str(), &w, &h);
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 /**
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 * Emscripten has the function emscripten_get_element_css_size()
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 * to query the width and height of a named HTML element. I'm
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 * calling this first to get the initial size of the canvas DOM
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 * element, and then call emscripten_set_canvas_size() to
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 * initialize the framebuffer size of the canvas to the same
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 * size as its DOM element.
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 * https://floooh.github.io/2017/02/22/emsc-html.html
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 **/
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 if (w > 0 &&
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 h > 0)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 width = static_cast<unsigned int>(boost::math::iround(w));
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 height = static_cast<unsigned int>(boost::math::iround(h));
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 else
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 width = 0;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 height = 0;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 void WebAssemblyCairoViewport::Paint(ICompositor& compositor,
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ViewportController& controller)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 compositor.Refresh(controller.GetScene());
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 // Create a temporary memory buffer for the canvas in JavaScript
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 Orthanc::ImageAccessor cairo;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 dynamic_cast<CairoCompositor&>(compositor).GetCanvas().GetReadOnlyAccessor(cairo);
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 const unsigned int width = cairo.GetWidth();
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 const unsigned int height = cairo.GetHeight();
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 if (javascript_.get() == NULL ||
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 javascript_->GetWidth() != width ||
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 javascript_->GetHeight() != height)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 javascript_.reset(new Orthanc::Image(Orthanc::PixelFormat_RGBA32, width, height,
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 true /* force minimal pitch */));
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 // Convert from BGRA32 memory layout (only color mode supported
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 // by Cairo, which corresponds to CAIRO_FORMAT_ARGB32) to RGBA32
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 // (as expected by HTML5 canvas). This simply amounts to
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 // swapping the B and R channels. Alpha channel is also set to
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 // full opacity (255).
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 uint8_t* q = reinterpret_cast<uint8_t*>(javascript_->GetBuffer());
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 for (unsigned int y = 0; y < height; y++)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 const uint8_t* p = reinterpret_cast<const uint8_t*>(cairo.GetConstRow(y));
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 for (unsigned int x = 0; x < width; x++)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 q[0] = p[2]; // R
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 q[1] = p[1]; // G
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 q[2] = p[0]; // B
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 q[3] = 255; // A
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 p += 4;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 q += 4;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 // Execute JavaScript commands to blit the image buffer onto the
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 // 2D drawing context of the HTML5 canvas
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 EM_ASM({
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 const data = new Uint8ClampedArray(Module.HEAP8.buffer, $1, 4 * $2 * $3);
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 const img = new ImageData(data, $2, $3);
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 const ctx = document.getElementById(UTF8ToString($0)).getContext('2d');
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 ctx.putImageData(img, 0, 0);
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 },
1351
1b8e37770d78 ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1331
diff changeset
119 GetCanvasId().c_str(), // $0
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 javascript_->GetBuffer(), // $1
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 javascript_->GetWidth(), // $2
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 javascript_->GetHeight()); // $3
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 void WebAssemblyCairoViewport::UpdateSize(ICompositor& compositor)
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 unsigned int width, height;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 GetCanvasSize(width, height);
1351
1b8e37770d78 ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1331
diff changeset
130 emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), width, height);
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 dynamic_cast<CairoCompositor&>(compositor).UpdateSize(width, height);
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
136 WebAssemblyCairoViewport::WebAssemblyCairoViewport(const std::string& canvasId,
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
137 bool enableEmscriptenMouseEvents) :
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
138 WebAssemblyViewport(canvasId,enableEmscriptenMouseEvents)
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 unsigned int width, height;
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 GetCanvasSize(width, height);
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
142 emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), width, height);
1331
ab81ee8fce1f - Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents: 1318
diff changeset
143
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 AcquireCompositor(new CairoCompositor(width, height));
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
146
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
147
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
148 boost::shared_ptr<WebAssemblyCairoViewport> WebAssemblyCairoViewport::Create(
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
149 const std::string& canvasId, bool enableEmscriptenMouseEvents)
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
150 {
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
151 boost::shared_ptr<WebAssemblyCairoViewport> that = boost::shared_ptr<WebAssemblyCairoViewport>(
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
152 new WebAssemblyCairoViewport(canvasId, enableEmscriptenMouseEvents));
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
153
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
154 that->WebAssemblyViewport::PostConstructor();
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
155 return that;
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
156 }
1232
a28861abf888 viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }