mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
Merge pull request #10611 from davidkelly/dk/4873
protect _text member of Text3DOverlay with mutex
This commit is contained in:
commit
06527ac0a2
2 changed files with 20 additions and 9 deletions
|
@ -51,6 +51,16 @@ Text3DOverlay::~Text3DOverlay() {
|
|||
}
|
||||
}
|
||||
|
||||
const QString Text3DOverlay::getText() const {
|
||||
QMutexLocker lock(&_mutex);
|
||||
return _text;
|
||||
}
|
||||
|
||||
void Text3DOverlay::setText(const QString& text) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_text = text;
|
||||
}
|
||||
|
||||
xColor Text3DOverlay::getBackgroundColor() {
|
||||
if (_colorPulse == 0.0f) {
|
||||
return _backgroundColor;
|
||||
|
@ -125,7 +135,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
// FIXME: Factor out textRenderer so that Text3DOverlay overlay parts can be grouped by pipeline
|
||||
// for a gpu performance increase. Currently,
|
||||
// Text renderer sets its own pipeline,
|
||||
_textRenderer->draw(batch, 0, 0, _text, textColor, glm::vec2(-1.0f), getDrawInFront());
|
||||
_textRenderer->draw(batch, 0, 0, getText(), textColor, glm::vec2(-1.0f), getDrawInFront());
|
||||
// so before we continue, we must reset the pipeline
|
||||
batch.setPipeline(args->_pipeline->pipeline);
|
||||
args->_pipeline->prepare(batch);
|
||||
|
@ -188,7 +198,7 @@ void Text3DOverlay::setProperties(const QVariantMap& properties) {
|
|||
|
||||
QVariant Text3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "text") {
|
||||
return _text;
|
||||
return getText();
|
||||
}
|
||||
if (property == "textAlpha") {
|
||||
return _textAlpha;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define hifi_Text3DOverlay_h
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
#include "Billboard3DOverlay.h"
|
||||
|
||||
class TextRenderer3D;
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
virtual const render::ShapeKey getShapeKey() override;
|
||||
|
||||
// getters
|
||||
const QString& getText() const { return _text; }
|
||||
const QString getText() const;
|
||||
float getLineHeight() const { return _lineHeight; }
|
||||
float getLeftMargin() const { return _leftMargin; }
|
||||
float getTopMargin() const { return _topMargin; }
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
float getBackgroundAlpha() { return getAlpha(); }
|
||||
|
||||
// setters
|
||||
void setText(const QString& text) { _text = text; }
|
||||
void setText(const QString& text);
|
||||
void setTextAlpha(float alpha) { _textAlpha = alpha; }
|
||||
void setLineHeight(float value) { _lineHeight = value; }
|
||||
void setLeftMargin(float margin) { _leftMargin = margin; }
|
||||
|
@ -67,6 +67,7 @@ private:
|
|||
TextRenderer3D* _textRenderer = nullptr;
|
||||
|
||||
QString _text;
|
||||
mutable QMutex _mutex; // used to make get/setText threadsafe, mutable so can be used in const functions
|
||||
xColor _backgroundColor = xColor { 0, 0, 0 };
|
||||
float _textAlpha { 1.0f };
|
||||
float _lineHeight { 1.0f };
|
||||
|
|
Loading…
Reference in a new issue