Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmoffscreensurface.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
7
8QWasmOffscreenSurface::QWasmOffscreenSurface(QOffscreenSurface *offscreenSurface)
9 : QPlatformOffscreenSurface(offscreenSurface), m_offscreenCanvas(emscripten::val::undefined())
10{
11 const auto offscreenCanvasClass = emscripten::val::global("OffscreenCanvas");
12 // The OffscreenCanvas is not supported on some browsers, most notably on Safari.
13 if (!offscreenCanvasClass)
14 return;
15
16 m_offscreenCanvas = offscreenCanvasClass.new_(offscreenSurface->size().width(),
17 offscreenSurface->size().height());
18
19 m_specialTargetId = std::string("!qtoffscreen_") + std::to_string(uintptr_t(this));
20
21 emscripten::val::module_property("specialHTMLTargets")
22 .set(m_specialTargetId, m_offscreenCanvas);
23}
24
25QWasmOffscreenSurface::~QWasmOffscreenSurface()
26{
27 emscripten::val::module_property("specialHTMLTargets").delete_(m_specialTargetId);
28}
29
30bool QWasmOffscreenSurface::isValid() const
31{
32 return !m_offscreenCanvas.isNull() && !m_offscreenCanvas.isUndefined();
33}
34
35QT_END_NAMESPACE
\inmodule QtGui
bool isValid() const override
Returns true if the platform offscreen surface has been allocated.