Mercurial > hg > orthanc-stone
annotate Applications/Platforms/WebAssembly/WebAssemblyViewport.h @ 1769:a217140dd41a
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 May 2021 10:26:13 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1623
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
16 * |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #pragma once |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1578
diff
changeset
|
24 #include "../../../OrthancStone/Sources/OrthancStone.h" |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
25 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
26 #if !defined(ORTHANC_ENABLE_WASM) |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
27 # error Macro ORTHANC_ENABLE_WASM must be defined |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
28 #endif |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
29 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
30 #if ORTHANC_ENABLE_WASM != 1 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
31 # error This file can only be used if targeting WebAssembly |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
32 #endif |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
33 |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1578
diff
changeset
|
34 #include "../../../OrthancStone/Sources/Viewport/IViewport.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1578
diff
changeset
|
35 #include "../../../OrthancStone/Sources/Viewport/IViewportInteractor.h" |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
36 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1351
diff
changeset
|
37 #include <Compatibility.h> |
1333
5b731e176236
Added missing #include directives
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
38 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
39 #include <emscripten.h> |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
40 #include <emscripten/html5.h> |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
1333
5b731e176236
Added missing #include directives
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
42 #include <memory> |
5b731e176236
Added missing #include directives
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
43 #include <string> |
1618
9a52bac0c2a7
Added code to clear pending calls to RequestAnimationFrame
Benjamin Golinvaux <bgo@osimis.io>
parents:
1591
diff
changeset
|
44 #include <vector> |
1558 | 45 #include <boost/enable_shared_from_this.hpp> |
1333
5b731e176236
Added missing #include directives
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
46 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 namespace OrthancStone |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
1328
fd616c4a5904
Added mechanism to prevent callbacks from being sent on dead WebAssemblyViewport objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
49 class WebAssemblyViewport : public IViewport, |
fd616c4a5904
Added mechanism to prevent callbacks from being sent on dead WebAssemblyViewport objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
50 public boost::enable_shared_from_this<WebAssemblyViewport> |
fd616c4a5904
Added mechanism to prevent callbacks from being sent on dead WebAssemblyViewport objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
51 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
53 private: |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
54 class WasmLock; |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
55 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
56 std::string canvasId_; |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
57 std::string canvasCssSelector_; |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
58 std::unique_ptr<ICompositor> compositor_; |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
59 std::unique_ptr<ViewportController> controller_; |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
60 std::unique_ptr<IViewportInteractor> interactor_; |
1346
df8bf351c23f
The flag that allows the WebAssemblyViewport to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1333
diff
changeset
|
61 bool enableEmscriptenMouseEvents_; |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1575
diff
changeset
|
62 unsigned int canvasWidth_; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1575
diff
changeset
|
63 unsigned int canvasHeight_; |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
64 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
65 static EM_BOOL OnRequestAnimationFrame(double time, void *userData); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
66 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
67 static EM_BOOL OnResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData); |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
68 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
69 static EM_BOOL OnMouseDown(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
70 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
71 static EM_BOOL OnMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
72 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
73 static EM_BOOL OnMouseUp(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
74 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
75 protected: |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
76 void Invalidate(); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
77 |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
78 void ClearCompositor() |
907
722ee73e6ba2
cleanup + started to implement WebAssemblyCairoViewport (wip)
Alain Mazy <alain@mazy.be>
parents:
905
diff
changeset
|
79 { |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
80 compositor_.reset(); |
907
722ee73e6ba2
cleanup + started to implement WebAssemblyCairoViewport (wip)
Alain Mazy <alain@mazy.be>
parents:
905
diff
changeset
|
81 } |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
82 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
83 bool HasCompositor() const |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
84 { |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
85 return compositor_.get() != NULL; |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
86 } |
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
87 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
88 void AcquireCompositor(ICompositor* compositor /* takes ownership */); |
1239
ce3052f28f2e
Added a lazy size update system in WebAssemblyOpenGLViewport::Refresh
Benjamin Golinvaux <bgo@osimis.io>
parents:
1072
diff
changeset
|
89 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
90 virtual void Paint(ICompositor& compositor, |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
91 ViewportController& controller) = 0; |
1055
af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
92 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
93 /** |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
94 The second argument is temporary and should be deleted once the migration |
1571 | 95 to interactors is finished. It should be set to "true" for new applications. |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
96 */ |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
97 WebAssemblyViewport(const std::string& canvasId, |
1571 | 98 bool enableEmscriptenMouseEvents); |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
99 |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
100 void PostConstructor(); |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
101 |
1621
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
102 |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
103 /** |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
104 * This method can be called to retrieve a cookie that can be passed to |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
105 * C-style callbacks that expect the object to be passed as a void* |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
106 * |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
107 * This cookie is a resource and must be freed when it is guaranteed |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
108 * not to be used anymore, with ReleaseObjectCookie |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
109 */ |
1623
74be0f498b08
Updated mechanism to avoid using deleted objects in RequestAnimationFrame callbacks.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1621
diff
changeset
|
110 void* CreateObjectCookie(); |
1621
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
111 |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
112 /** |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
113 * This static method can be used to dereference a cookie (i.e. retrieve |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
114 * a pointer to the underlying object) that has been created with |
1623
74be0f498b08
Updated mechanism to avoid using deleted objects in RequestAnimationFrame callbacks.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1621
diff
changeset
|
115 * WebAssemblyViewport::CreateObjectCookie() |
1621
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
116 * |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
117 * If this method returns NULL, it basically means that the |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
118 * WebAssemblyViewport has already been deleted and that you should NOT |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
119 * attempt to use it! |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
120 * |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
121 * This method never releases the cookie (for other in-flight callbacks |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
122 * could possibly require to cookie to be valid) |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
123 * |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
124 * If this method is called AFTER ReleaseObjectCookie has been called on |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
125 * the same cookie, the behavior is undefined and things will CERTAINLY |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
126 * go wrong. |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
127 * |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
128 * NEVER call this method on a void* that has not been generated by the |
1623
74be0f498b08
Updated mechanism to avoid using deleted objects in RequestAnimationFrame callbacks.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1621
diff
changeset
|
129 * CreateObjectCookie method of this class |
1621
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
130 */ |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
131 static WebAssemblyViewport* DereferenceObjectCookie(void* cookie); |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
132 |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
133 /** |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
134 * This method must be used when the object cookie will not be used anymore. |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
135 * |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
136 * You must call it when you are certain that no entity will attempt to |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
137 * dereference the cookie. |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
138 */ |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
139 static void ReleaseObjectCookie(void* cookie); |
575f512cdf48
Used a weak_ptr as a cookie to RequestAnimationFrame to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1618
diff
changeset
|
140 |
1577 | 141 void RefreshCanvasSize(); |
142 | |
143 unsigned int GetCanvasWidth() const | |
144 { | |
145 return canvasWidth_; | |
146 } | |
147 | |
148 unsigned int GetCanvasHeight() | |
149 { | |
150 return canvasHeight_; | |
151 } | |
152 | |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 public: |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
154 virtual ILock* Lock() ORTHANC_OVERRIDE; |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
155 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
156 ~WebAssemblyViewport(); |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1328
diff
changeset
|
157 |
1328
fd616c4a5904
Added mechanism to prevent callbacks from being sent on dead WebAssemblyViewport objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
158 /** |
fd616c4a5904
Added mechanism to prevent callbacks from being sent on dead WebAssemblyViewport objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
159 This method takes ownership |
fd616c4a5904
Added mechanism to prevent callbacks from being sent on dead WebAssemblyViewport objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
160 */ |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
161 void AcquireInteractor(IViewportInteractor* interactor); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
162 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
163 const std::string& GetCanvasId() const |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 { |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
165 return canvasId_; |
1072
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1055
diff
changeset
|
166 } |
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1055
diff
changeset
|
167 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
168 /** |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
169 emscripten functions requires the css selector for the canvas. This is |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
170 different from the canvas id (the syntax is '#mycanvasid') |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
171 */ |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
172 const std::string& GetCanvasCssSelector() const |
907
722ee73e6ba2
cleanup + started to implement WebAssemblyCairoViewport (wip)
Alain Mazy <alain@mazy.be>
parents:
905
diff
changeset
|
173 { |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1346
diff
changeset
|
174 return canvasCssSelector_; |
907
722ee73e6ba2
cleanup + started to implement WebAssemblyCairoViewport (wip)
Alain Mazy <alain@mazy.be>
parents:
905
diff
changeset
|
175 } |
1575 | 176 |
1578 | 177 void FitForPrint(); |
907
722ee73e6ba2
cleanup + started to implement WebAssemblyCairoViewport (wip)
Alain Mazy <alain@mazy.be>
parents:
905
diff
changeset
|
178 }; |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 } |