Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Jan 15, 2025
2 parents 61178b6 + cc92ef1 commit 052a9c8
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 72 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ jobs:
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
if: runner.os == 'Windows' && env.AZURE_TENANT_ID
uses: azure/[email protected].0
uses: azure/[email protected].1
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
Expand Down Expand Up @@ -382,7 +382,7 @@ jobs:
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
if: runner.os == 'Windows' && env.AZURE_TENANT_ID
uses: azure/[email protected].0
uses: azure/[email protected].1
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
Expand Down Expand Up @@ -484,7 +484,7 @@ jobs:
- name: "Upload GitHub Actions artifacts"
if: matrix.artifacts_path != null
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.0
with:
name: ${{ matrix.artifacts_name }}
path: ${{ matrix.artifacts_path }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ jobs:

- name: "Upload patch artifact"
if: failure() && env.UPLOAD_PATCH_FILE != null
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.0
with:
name: ${{ env.UPLOAD_PATCH_FILE }}
path: ${{ env.UPLOAD_PATCH_FILE }}

- name: "Upload pre-commit.log"
if: failure() && env.UPLOAD_PATCH_FILE == null
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.0
with:
name: pre-commit.log
path: /github/home/.cache/pre-commit/pre-commit.log
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ repos:
"\\W(?:m_p*(?=[A-Z])|m_(?=\\w)|pp*(?=[A-Z])|k(?=[A-Z])|s_(?=\\w))",
--write-changes,
]
exclude: ^(packaging/wix/LICENSE.rtf.in|src/dialog/dlgabout\.cpp|.*\.(?:pot?|(?<!\.d\.)ts|wxl|svg))$
exclude: ^(packaging/wix/LICENSE.rtf.in|src/dialog/dlgabout\.cpp|res/linux/org\.mixxx\.Mixxx\.desktop|.*\.(?:pot?|(?<!\.d\.)ts|wxl|svg))$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.14.0
hooks:
Expand Down
8 changes: 4 additions & 4 deletions packaging/CPackDebUploadPPA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ if(DEB_BUILD)
)
endif()

foreach(release ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
if(release STREQUAL "bionic")
set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS_EXTRA "libmp4v2-dev,")
foreach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
if(RELEASE STREQUAL "jammy")
set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS_EXTRA "libqt6shadertools6-dev,")
else()
set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS_EXTRA "libavformat-dev,")
set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS_EXTRA "qt6-shadertools-dev,")
endif()

configure_file(
Expand Down
2 changes: 1 addition & 1 deletion packaging/debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Build-Depends: debhelper (>= 11),
qml6-module-qt-labs-qmlmodels,
libqt6core5compat6-dev,
libqt6opengl6-dev,
libqt6shadertools6-dev,
libqt6sql6-sqlite,
libqt6svg6-dev,
cmake (>= 3.13),
Expand All @@ -34,6 +33,7 @@ Build-Depends: debhelper (>= 11),
libogg-dev,
libsndfile1-dev,
libasound2-dev,
libavformat-dev,
libvorbis-dev,
libfaad-dev,
libportmidi-dev,
Expand Down
41 changes: 24 additions & 17 deletions src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ void allshader::WaveformRenderMark::initializeGL() {
}

void allshader::WaveformRenderMark::drawTexture(
const QMatrix4x4& matrix, float x, float y, QOpenGLTexture* texture) {
const QMatrix4x4& matrix, float x, float y, QOpenGLTexture* pTexture) {
const float devicePixelRatio = m_waveformRenderer->getDevicePixelRatio();
const float texx1 = 0.f;
const float texy1 = 0.f;
const float texx2 = 1.f;
const float texy2 = 1.f;

const float posx1 = x;
const float posx2 = x + static_cast<float>(texture->width() / devicePixelRatio);
const float posx2 = x + static_cast<float>(pTexture->width() / devicePixelRatio);
const float posy1 = y;
const float posy2 = y + static_cast<float>(texture->height() / devicePixelRatio);
const float posy2 = y + static_cast<float>(pTexture->height() / devicePixelRatio);

const float posarray[] = {posx1, posy1, posx2, posy1, posx1, posy2, posx2, posy2};
const float texarray[] = {texx1, texy1, texx2, texy1, texx1, texy2, texx2, texy2};
Expand All @@ -135,11 +135,11 @@ void allshader::WaveformRenderMark::drawTexture(

m_textureShader.setUniformValue(textureLocation, 0);

texture->bind();
pTexture->bind();

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

texture->release();
pTexture->release();

m_textureShader.disableAttributeArray(positionLocation);
m_textureShader.disableAttributeArray(texcoordLocation);
Expand Down Expand Up @@ -242,6 +242,11 @@ void allshader::WaveformRenderMark::paintGL() {
continue;
}

if (!pTexture->isCreated()) {
// This happens if the height is zero
continue;
}

const float currentMarkPos = static_cast<float>(
m_waveformRenderer->transformSamplePositionInRendererWorld(
samplePosition, positionType));
Expand Down Expand Up @@ -376,20 +381,22 @@ void allshader::WaveformRenderMark::drawUntilMark(const QMatrix4x4& matrix, floa
// Note that in the legacy waveform widgets this is drawn directly
// in the WaveformWidgetRenderer itself. Doing it here is cleaner.
void allshader::WaveformRenderMark::updatePlayPosMarkTexture() {
float imgwidth;
float imgheight;
const float imgHeight = m_waveformRenderer->getBreadth();
const float imgWidth = kPlayPosWidth;

const float height = m_waveformRenderer->getBreadth();
const float devicePixelRatio = m_waveformRenderer->getDevicePixelRatio();
if (imgHeight == 0.0f) {
return;
}

const float devicePixelRatio = m_waveformRenderer->getDevicePixelRatio();
const float lineX = 5.5f;

imgwidth = kPlayPosWidth;
imgheight = height;

QImage image(static_cast<int>(imgwidth * devicePixelRatio),
static_cast<int>(imgheight * devicePixelRatio),
QImage image(static_cast<int>(imgWidth * devicePixelRatio),
static_cast<int>(imgHeight * devicePixelRatio),
QImage::Format_ARGB32_Premultiplied);
VERIFY_OR_DEBUG_ASSERT(!image.isNull()) {
return;
}
image.setDevicePixelRatio(devicePixelRatio);
image.fill(QColor(0, 0, 0, 0).rgba());

Expand All @@ -410,8 +417,8 @@ void allshader::WaveformRenderMark::updatePlayPosMarkTexture() {
// lines next to playpos
// Note: don't draw lines where they would overlap the triangles,
// otherwise both translucent strokes add up to a darker tone.
painter.drawLine(QLineF(lineX + 1.f, 4.f, lineX + 1.f, height));
painter.drawLine(QLineF(lineX - 1.f, 4.f, lineX - 1.f, height));
painter.drawLine(QLineF(lineX + 1.f, 4.f, lineX + 1.f, imgHeight));
painter.drawLine(QLineF(lineX - 1.f, 4.f, lineX - 1.f, imgHeight));

// triangle at top edge
// Increase line/waveform contrast
Expand All @@ -426,7 +433,7 @@ void allshader::WaveformRenderMark::updatePlayPosMarkTexture() {
painter.setPen(fgColor);
painter.setOpacity(1.0);
// play position line
painter.drawLine(QLineF(lineX, 0.f, lineX, height));
painter.drawLine(QLineF(lineX, 0.f, lineX, imgHeight));
// triangle at top edge
{
QPointF baseL = QPointF(lineX - 4.f, 0.f);
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendermark.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class allshader::WaveformRenderMark : public ::WaveformRenderMarkBase,
QPointF p3);

void drawMark(const QMatrix4x4& matrix, const QRectF& rect, QColor color);
void drawTexture(const QMatrix4x4& matrix, float x, float y, QOpenGLTexture* texture);
void drawTexture(const QMatrix4x4& matrix, float x, float y, QOpenGLTexture* pTexture);
void updateUntilMark(double playPosition, double markerPosition);
void drawUntilMark(const QMatrix4x4& matrix, float x);
float getMaxHeightForText(float proportion) const;
Expand Down
73 changes: 49 additions & 24 deletions src/waveform/renderers/waveformmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,8 @@ bool WaveformMark::contains(QPoint point, Qt::Orientation orientation) const {

// Helper struct to calculate the geometry and fontsize needed by generateImage
// to draw the label and text
struct MarkerGeometry {
bool m_isSymbol; // is the label normal text or a single symbol (e.g. open circle arrow)
QFont m_font;
QRectF m_contentRect;
QRectF m_labelRect;
QSizeF m_imageSize;

class MarkerGeometry {
public:
MarkerGeometry(const QString& label,
bool useIcon,
Qt::Alignment align,
Expand Down Expand Up @@ -316,10 +311,37 @@ struct MarkerGeometry {
return QSize{static_cast<int>(m_imageSize.width() * devicePixelRatio),
static_cast<int>(m_imageSize.height() * devicePixelRatio)};
}

const QFont font() const {
return m_font;
}

const QRectF& contentRect() const {
return m_contentRect;
}

const QRectF& labelRect() const {
return m_labelRect;
}

const QSizeF& imageSize() const {
return m_imageSize;
}

private:
bool m_isSymbol; // is the label normal text or a single symbol (e.g. open circle arrow)
QFont m_font;
QRectF m_contentRect;
QRectF m_labelRect;
QSizeF m_imageSize;
};

QImage WaveformMark::generateImage(float devicePixelRatio) {
assert(needsImageUpdate());
DEBUG_ASSERT(needsImageUpdate());

if (m_breadth == 0.0f) {
return {};
}

// Load the pixmap from file.
// If that succeeds loading the text and stroke is skipped.
Expand Down Expand Up @@ -357,11 +379,14 @@ QImage WaveformMark::generateImage(float devicePixelRatio) {
// Determine drawing geometries
const MarkerGeometry markerGeometry{label, useIcon, m_align, m_breadth, m_level};

m_label.setAreaRect(markerGeometry.m_labelRect);
m_label.setAreaRect(markerGeometry.labelRect());

// Create the image
QImage image{markerGeometry.getImageSize(devicePixelRatio),
QImage::Format_ARGB32_Premultiplied};
VERIFY_OR_DEBUG_ASSERT(!image.isNull()) {
return image;
}
image.setDevicePixelRatio(devicePixelRatio);

// Fill with transparent pixels
Expand All @@ -376,7 +401,7 @@ QImage WaveformMark::generateImage(float devicePixelRatio) {
painter.setWorldMatrixEnabled(false);

const Qt::Alignment alignH = m_align & Qt::AlignHorizontal_Mask;
const float imgw = static_cast<float>(markerGeometry.m_imageSize.width());
const float imgw = static_cast<float>(markerGeometry.imageSize().width());
switch (alignH) {
case Qt::AlignHCenter:
m_linePosition = imgw / 2.f;
Expand All @@ -400,48 +425,48 @@ QImage WaveformMark::generateImage(float devicePixelRatio) {

// Draw the center line
painter.setPen(fillColor());
painter.drawLine(QLineF(linePos, 0.f, linePos, markerGeometry.m_imageSize.height()));
painter.drawLine(QLineF(linePos, 0.f, linePos, markerGeometry.imageSize().height()));

painter.setPen(borderColor());
painter.drawLine(QLineF(linePos - 1.f,
0.f,
linePos - 1.f,
markerGeometry.m_imageSize.height()));
markerGeometry.imageSize().height()));
painter.drawLine(QLineF(linePos + 1.f,
0.f,
linePos + 1.f,
markerGeometry.m_imageSize.height()));
markerGeometry.imageSize().height()));

if (useIcon || label.length() != 0) {
painter.setPen(borderColor());

// Draw the label rounded rect with border
QPainterPath path;
path.addRoundedRect(markerGeometry.m_labelRect, 2.f, 2.f);
path.addRoundedRect(markerGeometry.labelRect(), 2.f, 2.f);
painter.fillPath(path, fillColor());
painter.drawPath(path);

// Center m_contentRect.width() and m_contentRect.height() inside m_labelRect
// and apply the offset x,y so the text ends up in the centered width,height.
QPointF pos(markerGeometry.m_labelRect.x() +
(markerGeometry.m_labelRect.width() -
markerGeometry.m_contentRect.width()) /
QPointF pos(markerGeometry.labelRect().x() +
(markerGeometry.labelRect().width() -
markerGeometry.contentRect().width()) /
2.f -
markerGeometry.m_contentRect.x(),
markerGeometry.m_labelRect.y() +
(markerGeometry.m_labelRect.height() -
markerGeometry.m_contentRect.height()) /
markerGeometry.contentRect().x(),
markerGeometry.labelRect().y() +
(markerGeometry.labelRect().height() -
markerGeometry.contentRect().height()) /
2.f -
markerGeometry.m_contentRect.y());
markerGeometry.contentRect().y());

if (useIcon) {
QSvgRenderer svgRenderer(m_iconPath);
svgRenderer.render(&painter, QRectF(pos, markerGeometry.m_contentRect.size()));
svgRenderer.render(&painter, QRectF(pos, markerGeometry.contentRect().size()));
} else {
// Draw the text
painter.setBrush(Qt::transparent);
painter.setPen(labelColor());
painter.setFont(markerGeometry.m_font);
painter.setFont(markerGeometry.font());

painter.drawText(pos, label);
}
Expand Down
10 changes: 5 additions & 5 deletions src/widget/wspinnyglsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ void WSpinnyGLSL::initializeGL() {
m_vinylQualityShader.init();
}

void WSpinnyGLSL::drawTexture(QOpenGLTexture* texture) {
void WSpinnyGLSL::drawTexture(QOpenGLTexture* pTexture) {
const float texx1 = 0.f;
const float texy1 = 1.0;
const float texx2 = 1.f;
const float texy2 = 0.f;

const float tw = texture->width();
const float th = texture->height();
const float tw = pTexture->width();
const float th = pTexture->height();

// fill centered
const float posx2 = tw >= th ? 1.f : tw / th;
Expand All @@ -201,11 +201,11 @@ void WSpinnyGLSL::drawTexture(QOpenGLTexture* texture) {
m_textureShader.setAttributeArray(
texcoordLocation, GL_FLOAT, texarray.data(), 2);

texture->bind();
pTexture->bind();

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

texture->release();
pTexture->release();
}

void WSpinnyGLSL::drawVinylQuality() {
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wspinnyglsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WSpinnyGLSL : public WSpinnyBase, private QOpenGLFunctions {
void initializeGL() override;
void paintGL() override;
void resizeGL(int w, int h) override;
void drawTexture(QOpenGLTexture* texture);
void drawTexture(QOpenGLTexture* pTexture);
void cleanupGL();
void updateTextures();

Expand Down
Loading

0 comments on commit 052a9c8

Please sign in to comment.