comparison Framework/Viewport/WebAssemblyCairoViewport.cpp @ 1351:1b8e37770d78 broker

ID vs CSS selector distinction in API and field names.
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 12:57:36 +0200
parents ab81ee8fce1f
children 30deba7bc8e2
comparison
equal deleted inserted replaced
1350:c53a4667f895 1351:1b8e37770d78
29 { 29 {
30 void WebAssemblyCairoViewport::GetCanvasSize(unsigned int& width, 30 void WebAssemblyCairoViewport::GetCanvasSize(unsigned int& width,
31 unsigned int& height) 31 unsigned int& height)
32 { 32 {
33 double w, h; 33 double w, h;
34 emscripten_get_element_css_size(GetFullCanvasId().c_str(), &w, &h); 34 emscripten_get_element_css_size(GetCanvasCssSelector().c_str(), &w, &h);
35 35
36 /** 36 /**
37 * Emscripten has the function emscripten_get_element_css_size() 37 * Emscripten has the function emscripten_get_element_css_size()
38 * to query the width and height of a named HTML element. I'm 38 * to query the width and height of a named HTML element. I'm
39 * calling this first to get the initial size of the canvas DOM 39 * calling this first to get the initial size of the canvas DOM
103 const data = new Uint8ClampedArray(Module.HEAP8.buffer, $1, 4 * $2 * $3); 103 const data = new Uint8ClampedArray(Module.HEAP8.buffer, $1, 4 * $2 * $3);
104 const img = new ImageData(data, $2, $3); 104 const img = new ImageData(data, $2, $3);
105 const ctx = document.getElementById(UTF8ToString($0)).getContext('2d'); 105 const ctx = document.getElementById(UTF8ToString($0)).getContext('2d');
106 ctx.putImageData(img, 0, 0); 106 ctx.putImageData(img, 0, 0);
107 }, 107 },
108 GetShortCanvasId().c_str(), // $0 108 GetCanvasId().c_str(), // $0
109 javascript_->GetBuffer(), // $1 109 javascript_->GetBuffer(), // $1
110 javascript_->GetWidth(), // $2 110 javascript_->GetWidth(), // $2
111 javascript_->GetHeight()); // $3 111 javascript_->GetHeight()); // $3
112 } 112 }
113 113
114 114
115 void WebAssemblyCairoViewport::UpdateSize(ICompositor& compositor) 115 void WebAssemblyCairoViewport::UpdateSize(ICompositor& compositor)
116 { 116 {
117 unsigned int width, height; 117 unsigned int width, height;
118 GetCanvasSize(width, height); 118 GetCanvasSize(width, height);
119 emscripten_set_canvas_element_size(GetFullCanvasId().c_str(), width, height); 119 emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), width, height);
120 120
121 dynamic_cast<CairoCompositor&>(compositor).UpdateSize(width, height); 121 dynamic_cast<CairoCompositor&>(compositor).UpdateSize(width, height);
122 } 122 }
123 123
124 124
126 const std::string& canvasId) : 126 const std::string& canvasId) :
127 WebAssemblyViewport(canvasId) 127 WebAssemblyViewport(canvasId)
128 { 128 {
129 unsigned int width, height; 129 unsigned int width, height;
130 GetCanvasSize(width, height); 130 GetCanvasSize(width, height);
131 emscripten_set_canvas_element_size(GetFullCanvasId().c_str(), 131 emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(),
132 width, 132 width,
133 height); 133 height);
134 134
135 AcquireCompositor(new CairoCompositor(width, height)); 135 AcquireCompositor(new CairoCompositor(width, height));
136 } 136 }