8#include <QtGui/qpainter.h>
9#include <QtGui/qbackingstore.h>
11#include <emscripten.h>
12#include <emscripten/wire.h>
53 if (m_webImageDataArray.isUndefined()) {
54 m_webImageDataArray =
window->context2d().call<emscripten::val>(
55 "createImageData", emscripten::val(m_image.
width()),
56 emscripten::val(m_image.
height()));
70 if (
r.width() >= imageRect.
width() / 2) {
72 r.setWidth(imageRect.
width());
75 clippedDpiScaledRegion |=
r;
78 for (
const QRect &dirtyRect : clippedDpiScaledRegion) {
79 constexpr int BytesPerColor = 4;
80 if (dirtyRect.width() == imageRect.
width()) {
87 auto imageMemory = emscripten::typed_memory_view(dirtyRect.width() * dirtyRect.height()
90 m_webImageDataArray[
"data"].call<
void>(
"set", imageMemory,
91 dirtyRect.y() * m_image.
width() * BytesPerColor);
100 for (
int r = 0;
r < dirtyRect.height(); ++
r) {
101 auto scanlineMemory = emscripten::typed_memory_view(
102 dirtyRect.width() * BytesPerColor,
103 m_image.
constScanLine(
r + dirtyRect.y()) + BytesPerColor * dirtyRect.x());
104 m_webImageDataArray[
"data"].call<
void>(
"set", scanlineMemory,
105 (dirtyRect.y() +
r) * m_image.
width()
107 + dirtyRect.x() * BytesPerColor);
140 m_webImageDataArray = emscripten::val::undefined();
157 return m_webImageDataArray;
The QColor class provides colors based on RGB, HSV or CMYK values.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
const uchar * constScanLine(int) const
Returns a pointer to the pixel data at the scanline with index i.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
qreal devicePixelRatio() const
Returns the device pixel ratio for the image.
The QPainter class performs low-level painting on widgets and other paint devices.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr void setX(int x) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override
Flushes the given region from the specified window.
QWasmBackingStore(QWasmCompositor *compositor, QWindow *window)
emscripten::val getUpdatedWebImage(QWasmWindow *window)
void beginPaint(const QRegion &) override
This function is called before painting onto the surface begins, with the region in which the paintin...
void resize(const QSize &size, const QRegion &staticContents) override
void updateTexture(QWasmWindow *window)
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
const QImage & getImageRef() const
QImage toImage() const override
Implemented in subclasses to return the content of the backingstore as a QImage.
void handleBackingStoreFlush(QWindow *window)
static QWasmIntegration * get()
void removeBackingStore(QWindow *window)
void setBackingStore(QWasmBackingStore *store)
Combined button and popup list for selecting options.
static QOpenGLCompositor * compositor
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)