From b8d8e62e9509272d118474ad20582d45102a1689 Mon Sep 17 00:00:00 2001 From: apistol78 Date: Fri, 31 May 2024 16:13:12 +0200 Subject: [PATCH] Traktor: Cleanup in spark module. --- code/Spark/Acc/AccBitmapRect.h | 25 ++++++++----------------- code/Spark/Acc/AccGlyph.h | 20 ++++++++------------ code/Spark/Acc/AccGradientCache.cpp | 25 +++++++++++-------------- code/Spark/Acc/AccGradientCache.h | 14 +++++--------- code/Spark/Acc/AccQuad.cpp | 11 ++++------- code/Spark/Acc/AccQuad.h | 20 ++++++++------------ code/Spark/Acc/AccShape.cpp | 14 +++++++------- code/Spark/Acc/AccShape.h | 14 +++++--------- code/Spark/Acc/AccShapeResources.cpp | 13 +++++-------- code/Spark/Acc/AccShapeResources.h | 14 +++++--------- code/Spark/Acc/AccShapeVertexPool.cpp | 9 +++------ code/Spark/Acc/AccShapeVertexPool.h | 13 +++++-------- code/Spark/Acc/AccTextureCache.cpp | 21 +++++++++------------ code/Spark/Acc/AccTextureCache.h | 20 ++++++++------------ code/Spark/Sound/SoundBuffer.cpp | 16 ++++++---------- code/Spark/Sound/SoundBuffer.h | 10 +++------- code/Spark/Sound/SoundRenderer.cpp | 13 +++++-------- code/Spark/Sound/SoundRenderer.h | 14 +++++--------- code/Spark/Sw/SwDisplayRenderer.cpp | 11 ++++------- code/Spark/Sw/SwDisplayRenderer.h | 14 +++++--------- code/Spark/Swf/SwfMovieFactory.cpp | 7 ++----- code/Spark/Swf/SwfMovieFactory.h | 14 +++++--------- code/Spark/Swf/SwfMovieFactoryTags.cpp | 7 ++----- code/Spark/Swf/SwfMovieFactoryTags.h | 14 +++++--------- code/Spark/Swf/SwfReader.cpp | 11 ++++------- code/Spark/Swf/SwfReader.h | 10 +++++----- code/Spark/Swf/SwfTypes.h | 8 ++------ 27 files changed, 144 insertions(+), 238 deletions(-) diff --git a/code/Spark/Acc/AccBitmapRect.h b/code/Spark/Acc/AccBitmapRect.h index e2fdab10ef..eeec3e4de1 100644 --- a/code/Spark/Acc/AccBitmapRect.h +++ b/code/Spark/Acc/AccBitmapRect.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,17 +10,15 @@ #include "Resource/Proxy.h" -namespace traktor +namespace traktor::render { - namespace render - { class ITexture; - } +} - namespace spark - { +namespace traktor::spark +{ /*! * \ingroup Spark @@ -29,17 +27,11 @@ class AccBitmapRect : public RefCountImpl< IRefCount > { public: resource::Proxy< render::ITexture > texture; - float rect[4]; + float rect[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; - AccBitmapRect() - { - rect[0] = - rect[1] = - rect[2] = - rect[3] = 0.0f; - } + AccBitmapRect() = default; - AccBitmapRect( + explicit AccBitmapRect( const resource::Proxy< render::ITexture >& texture_, float left, float top, @@ -72,5 +64,4 @@ class AccBitmapRect : public RefCountImpl< IRefCount > } }; - } } diff --git a/code/Spark/Acc/AccGlyph.h b/code/Spark/Acc/AccGlyph.h index 40316d1d31..67070b727e 100644 --- a/code/Spark/Acc/AccGlyph.h +++ b/code/Spark/Acc/AccGlyph.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,17 +12,15 @@ #include "Core/Math/Matrix33.h" #include "Resource/Proxy.h" -namespace traktor +namespace traktor::resource { - namespace resource - { class IResourceManager; - } +} - namespace render - { +namespace traktor::render +{ class Buffer; class IRenderSystem; @@ -31,10 +29,10 @@ class IVertexLayout; class RenderPass; class Shader; - } +} - namespace spark - { +namespace traktor::spark +{ class AccGlyph : public Object { @@ -79,6 +77,4 @@ class AccGlyph : public Object uint32_t m_count = 0; }; - } } - diff --git a/code/Spark/Acc/AccGradientCache.cpp b/code/Spark/Acc/AccGradientCache.cpp index df284dd262..d9d938babf 100644 --- a/code/Spark/Acc/AccGradientCache.cpp +++ b/code/Spark/Acc/AccGradientCache.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,12 +15,10 @@ #include "Spark/Acc/AccBitmapRect.h" #include "Spark/Acc/AccGradientCache.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { const uint32_t c_gradientsSize = 32; const uint32_t c_gradientsWidth = 1024; @@ -53,7 +51,7 @@ Color4f interpolateGradient(const AlignedVector< FillStyle::ColorRecord >& color return a.color * Scalar(1.0f - f) + b.color * Scalar(f); } - } + } AccGradientCache::AccGradientCache(render::IRenderSystem* renderSystem) : m_renderSystem(renderSystem) @@ -103,7 +101,7 @@ Ref< AccBitmapRect > AccGradientCache::getGradientTexture(const FillStyle& style cs.feed(colorRecord); cs.end(); - uint64_t hash = cs.get(); + const uint64_t hash = cs.get(); auto it = m_cache.find(hash); if (it != m_cache.end()) return it->second; @@ -127,8 +125,8 @@ Ref< AccBitmapRect > AccGradientCache::getGradientTexture(const FillStyle& style int32_t x2 = int32_t(colorRecords[i].ratio * c_gradientsSize); for (int32_t x = x1; x < x2; ++x) { - float f = float(x - x1) / (x2 - x1); - Color4ub c = (colorRecords[i - 1].color * Scalar(1.0f - f) + colorRecords[i].color * Scalar(f)).toColor4ub(); + const float f = float(x - x1) / (x2 - x1); + const Color4ub c = (colorRecords[i - 1].color * Scalar(1.0f - f) + colorRecords[i].color * Scalar(f)).toColor4ub(); gd[x * 4 + 0] = c.r; gd[x * 4 + 1] = c.g; gd[x * 4 + 2] = c.b; @@ -177,11 +175,11 @@ Ref< AccBitmapRect > AccGradientCache::getGradientTexture(const FillStyle& style { for (int x = 0; x < c_gradientsSize; ++x) { - float fx = x / s - 1.0f; - float fy = y / s - 1.0f; - float f = sqrtf(fx * fx + fy * fy); + const float fx = x / s - 1.0f; + const float fy = y / s - 1.0f; + const float f = sqrtf(fx * fx + fy * fy); - Color4ub c = interpolateGradient(colorRecords, f).toColor4ub(); + const Color4ub c = interpolateGradient(colorRecords, f).toColor4ub(); gd[x * 4 + 0] = c.r; gd[x * 4 + 1] = c.g; gd[x * 4 + 2] = c.b; @@ -226,5 +224,4 @@ void AccGradientCache::synchronize() } } - } } diff --git a/code/Spark/Acc/AccGradientCache.h b/code/Spark/Acc/AccGradientCache.h index 5c1d695929..fbd3098010 100644 --- a/code/Spark/Acc/AccGradientCache.h +++ b/code/Spark/Acc/AccGradientCache.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,18 +12,16 @@ #include "Core/Containers/SmallMap.h" #include "Core/Misc/AutoPtr.h" -namespace traktor +namespace traktor::render { - namespace render - { class IRenderSystem; class ITexture; - } +} - namespace spark - { +namespace traktor::spark +{ class AccBitmapRect; class FillStyle; @@ -56,6 +54,4 @@ class AccGradientCache : public Object bool m_dirty = false; }; - } } - diff --git a/code/Spark/Acc/AccQuad.cpp b/code/Spark/Acc/AccQuad.cpp index 6d5823c449..5bbdfc805b 100644 --- a/code/Spark/Acc/AccQuad.cpp +++ b/code/Spark/Acc/AccQuad.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -18,12 +18,10 @@ #include "Spark/ColorTransform.h" #include "Spark/Acc/AccQuad.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { const resource::Id< render::Shader > c_idShaderSolid(Guid(L"{2EDC5E1B-562D-9F46-9E3C-474729FB078E}")); const resource::Id< render::Shader > c_idShaderTextured(Guid(L"{98A59F6A-1D90-144C-B688-4CEF382453F2}")); @@ -47,7 +45,7 @@ const render::Handle s_handleCxFormAdd(L"Spark_CxFormAdd"); const render::Handle s_handleTexture(L"Spark_Texture"); const render::Handle s_handleTextureOffset(L"Spark_TextureOffset"); - } + } bool AccQuad::create( resource::IResourceManager* resourceManager, @@ -204,5 +202,4 @@ void AccQuad::blit( }); } - } } diff --git a/code/Spark/Acc/AccQuad.h b/code/Spark/Acc/AccQuad.h index c5f80f7bbe..00a6e6c597 100644 --- a/code/Spark/Acc/AccQuad.h +++ b/code/Spark/Acc/AccQuad.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,17 +13,15 @@ #include "Core/Math/Matrix33.h" #include "Resource/Proxy.h" -namespace traktor +namespace traktor::resource { - namespace resource - { class IResourceManager; - } +} - namespace render - { +namespace traktor::render +{ class Buffer; class IRenderSystem; @@ -32,10 +30,10 @@ class IVertexLayout; class RenderPass; class Shader; - } +} - namespace spark - { +namespace traktor::spark +{ class ColorTransform; @@ -81,6 +79,4 @@ class AccQuad : public Object Ref< render::Buffer > m_vertexBuffer; }; - } } - diff --git a/code/Spark/Acc/AccShape.cpp b/code/Spark/Acc/AccShape.cpp index ac37b1543c..83b3be68a0 100644 --- a/code/Spark/Acc/AccShape.cpp +++ b/code/Spark/Acc/AccShape.cpp @@ -193,7 +193,7 @@ bool AccShape::createFromTriangles( for (int32_t it = 0; it < c_maxSubDivide; ++it) { int32_t nsub = 0; - int32_t size = clusters.size(); + int32_t size = (int32_t)clusters.size(); for (int32_t i = 0; i < size; ++i) { if (clusters[i].lines.size() > c_maxLinesPerCluster) @@ -204,14 +204,14 @@ bool AccShape::createFromTriangles( for (int32_t ix = 0; ix < c_subSize; ++ix) { const Vector2 dxy(1.0f / float(c_subSize), 1.0f / float(c_subSize)); - const Vector2 fxy = Vector2(ix, iy) * dxy; + const Vector2 fxy = Vector2(float(ix), float(iy)) * dxy; Aabb2 cell; cell.mn = clusters[i].bounds.mn + (clusters[i].bounds.mx - clusters[i].bounds.mn) * fxy; cell.mx = clusters[i].bounds.mn + (clusters[i].bounds.mx - clusters[i].bounds.mn) * (fxy + dxy); bool foundLine = false; - for (int32_t j = 0; j < clusters[i].lines.size(); ++j) + for (int32_t j = 0; j < (int32_t)clusters[i].lines.size(); ++j) { const Line& line = lines[clusters[i].lines[j]]; @@ -275,7 +275,7 @@ bool AccShape::createFromTriangles( // Generate line batches from clusters. Ref< render::Buffer > vertexRange; - if (!m_lineVertexPool->acquire(clusters.size() * 2 * 3, vertexRange)) + if (!m_lineVertexPool->acquire(int32_t(clusters.size() * 2 * 3), vertexRange)) return false; LineVertex* vertex = static_cast< LineVertex* >(vertexRange->lock()); @@ -285,7 +285,7 @@ bool AccShape::createFromTriangles( // Calculate size of buffer. int32_t lineDataSize = 0; for (auto c : clusters) - lineDataSize += c.lines.size(); + lineDataSize += (int32_t)c.lines.size(); Ref< render::Buffer > lineBuffer = m_renderSystem->createBuffer(render::BufferUsage::BuStructured, lineDataSize * sizeof(LineData), false); if (!lineBuffer) @@ -297,7 +297,7 @@ bool AccShape::createFromTriangles( m_lineRenderBatches.push_back(); m_lineRenderBatches.back().vertexRange = vertexRange; m_lineRenderBatches.back().lineBuffer = lineBuffer; - m_lineRenderBatches.back().primitives.setNonIndexed(render::PrimitiveType::Triangles, 0, clusters.size() * 2); + m_lineRenderBatches.back().primitives.setNonIndexed(render::PrimitiveType::Triangles, 0, uint32_t(clusters.size() * 2)); m_lineRenderBatches.back().color = lineStyle.getLineColor(); m_lineRenderBatches.back().width = width - 0.5f; @@ -352,7 +352,7 @@ bool AccShape::createFromTriangles( Ref< AccBitmapRect > texture; bool textureClamp = false; - if (!m_fillVertexPool->acquire(triangles.size() * 3, m_fillVertexRange)) + if (!m_fillVertexPool->acquire(int32_t(triangles.size() * 3), m_fillVertexRange)) return false; FillVertex* vertex = static_cast< FillVertex* >(m_fillVertexRange->lock()); diff --git a/code/Spark/Acc/AccShape.h b/code/Spark/Acc/AccShape.h index aaa54fca83..f8dbbef699 100644 --- a/code/Spark/Acc/AccShape.h +++ b/code/Spark/Acc/AccShape.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,10 +20,8 @@ #include "Spark/Polygon.h" #include "Spark/Acc/AccShapeVertexPool.h" -namespace traktor +namespace traktor::render { - namespace render - { class Buffer; class IRenderSystem; @@ -31,10 +29,10 @@ class ITexture; class RenderPass; class Shader; - } +} - namespace spark - { +namespace traktor::spark +{ class AccBitmapRect; class AccGradientCache; @@ -158,6 +156,4 @@ class AccShape : public Object uint8_t m_batchFlags = 0; }; - } } - diff --git a/code/Spark/Acc/AccShapeResources.cpp b/code/Spark/Acc/AccShapeResources.cpp index 71815eaee5..0c3de93182 100644 --- a/code/Spark/Acc/AccShapeResources.cpp +++ b/code/Spark/Acc/AccShapeResources.cpp @@ -1,20 +1,18 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#include "Spark/Acc/AccShapeResources.h" #include "Resource/IResourceManager.h" +#include "Spark/Acc/AccShapeResources.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { const resource::Id< render::Shader > c_idShaderSolid(Guid(L"{D46877B9-0F90-3A42-AB2D-7346AA607233}")); const resource::Id< render::Shader > c_idShaderTextured(Guid(L"{5CDDBEC8-1629-0A4E-ACE5-C8186072D694}")); @@ -22,7 +20,7 @@ const resource::Id< render::Shader > c_idShaderLine(Guid(L"{8CAA6CFE-014A-3F4A-8 const resource::Id< render::Shader > c_idShaderIncrementMask(Guid(L"{8DCBCF05-4640-884E-95AC-F090510788F4}")); const resource::Id< render::Shader > c_idShaderDecrementMask(Guid(L"{57F6F4DF-F4EE-6740-907C-027A3A2596D7}")); - } + } T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.AccShapeResources", AccShapeResources, Object) @@ -51,5 +49,4 @@ void AccShapeResources::destroy() m_shaderDecrementMask.clear(); } - } } diff --git a/code/Spark/Acc/AccShapeResources.h b/code/Spark/Acc/AccShapeResources.h index b52063e3bd..c2b2480800 100644 --- a/code/Spark/Acc/AccShapeResources.h +++ b/code/Spark/Acc/AccShapeResources.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,17 +12,15 @@ #include "Render/Shader.h" #include "Resource/Proxy.h" -namespace traktor +namespace traktor::resource { - namespace resource - { class IResourceManager; - } +} - namespace spark - { +namespace traktor::spark +{ class AccShapeResources : public Object { @@ -45,6 +43,4 @@ class AccShapeResources : public Object resource::Proxy< render::Shader > m_shaderDecrementMask; }; - } } - diff --git a/code/Spark/Acc/AccShapeVertexPool.cpp b/code/Spark/Acc/AccShapeVertexPool.cpp index b2ede863e1..bd6f7b8d50 100644 --- a/code/Spark/Acc/AccShapeVertexPool.cpp +++ b/code/Spark/Acc/AccShapeVertexPool.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,14 +9,12 @@ #include "Core/Log/Log.h" #include "Core/Misc/Align.h" #include "Core/Misc/SafeDestroy.h" -#include "Spark/Acc/AccShapeVertexPool.h" #include "Render/Buffer.h" #include "Render/IRenderSystem.h" +#include "Spark/Acc/AccShapeVertexPool.h" -namespace traktor +namespace traktor::spark { - namespace spark - { T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.AccShapeVertexPool", AccShapeVertexPool, Object) @@ -75,5 +73,4 @@ void AccShapeVertexPool::release(render::Buffer* vertexBuffer) m_freeBuffers.push_back(vertexBuffer); } - } } diff --git a/code/Spark/Acc/AccShapeVertexPool.h b/code/Spark/Acc/AccShapeVertexPool.h index 5475505ee8..efbb48706b 100644 --- a/code/Spark/Acc/AccShapeVertexPool.h +++ b/code/Spark/Acc/AccShapeVertexPool.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,19 +13,17 @@ #include "Core/RefArray.h" #include "Render/VertexElement.h" -namespace traktor +namespace traktor::render { - namespace render - { class Buffer; class IRenderSystem; class IVertexLayout; - } +} - namespace spark - { +namespace traktor::spark +{ class AccShapeVertexPool : public Object { @@ -51,5 +49,4 @@ class AccShapeVertexPool : public Object uint32_t m_vertexSize = 0; }; - } } diff --git a/code/Spark/Acc/AccTextureCache.cpp b/code/Spark/Acc/AccTextureCache.cpp index b6b1c9e5b3..7f8348eac6 100644 --- a/code/Spark/Acc/AccTextureCache.cpp +++ b/code/Spark/Acc/AccTextureCache.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,21 +8,19 @@ */ #include #include "Core/Log/Log.h" +#include "Render/IRenderSystem.h" +#include "Resource/IResourceManager.h" +#include "Resource/Proxy.h" #include "Spark/BitmapImage.h" #include "Spark/BitmapResource.h" #include "Spark/BitmapTexture.h" #include "Spark/Acc/AccBitmapRect.h" #include "Spark/Acc/AccTextureCache.h" -#include "Render/IRenderSystem.h" -#include "Resource/IResourceManager.h" -#include "Resource/Proxy.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { class AccCachedTexture : public render::ITexture { @@ -72,7 +70,7 @@ class AccCachedTexture : public render::ITexture Ref< render::ITexture > m_texture; }; - } + } AccTextureCache::AccTextureCache( resource::IResourceManager* resourceManager, @@ -120,8 +118,8 @@ Ref< AccBitmapRect > AccTextureCache::getBitmapTexture(const Bitmap& bitmap) texture ); - float w = float(bitmapResource->getAtlasWidth()); - float h = float(bitmapResource->getAtlasHeight()); + const float w = float(bitmapResource->getAtlasWidth()); + const float h = float(bitmapResource->getAtlasHeight()); Ref< AccBitmapRect > br = new AccBitmapRect( texture, @@ -225,5 +223,4 @@ void AccTextureCache::freeTexture(render::ITexture* texture) texture->destroy(); } - } } diff --git a/code/Spark/Acc/AccTextureCache.h b/code/Spark/Acc/AccTextureCache.h index 73d2465cea..abd2190875 100644 --- a/code/Spark/Acc/AccTextureCache.h +++ b/code/Spark/Acc/AccTextureCache.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,25 +11,23 @@ #include "Core/Object.h" #include "Core/RefArray.h" -namespace traktor +namespace traktor::render { - namespace render - { class IRenderSystem; class ITexture; - } +} - namespace resource - { +namespace traktor::resource +{ class IResourceManager; - } +} - namespace spark - { +namespace traktor::spark +{ class AccBitmapRect; class Bitmap; @@ -63,6 +61,4 @@ class AccTextureCache : public Object bool m_reuseTextures; }; - } } - diff --git a/code/Spark/Sound/SoundBuffer.cpp b/code/Spark/Sound/SoundBuffer.cpp index 86a26cccf9..6d57d943ea 100644 --- a/code/Spark/Sound/SoundBuffer.cpp +++ b/code/Spark/Sound/SoundBuffer.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,20 +10,17 @@ #include "Spark/Sound.h" #include "Spark/Sound/SoundBuffer.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { struct SoundBufferCursor : public RefCountImpl< sound::IAudioBufferCursor > { - int32_t m_position; AutoArrayPtr< float, AllocatorFree > m_samples[2]; + int32_t m_position = 0; SoundBufferCursor() - : m_position(0) { m_samples[0].reset((float*)getAllocator()->alloc(4096 * sizeof(float), 16, T_FILE_LINE)); m_samples[1].reset((float*)getAllocator()->alloc(4096 * sizeof(float), 16, T_FILE_LINE)); @@ -43,7 +40,7 @@ struct SoundBufferCursor : public RefCountImpl< sound::IAudioBufferCursor > } }; - } + } T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.SoundBuffer", SoundBuffer, sound::IAudioBuffer) @@ -63,7 +60,7 @@ bool SoundBuffer::getBlock(sound::IAudioBufferCursor* cursor, const sound::IAudi T_ASSERT(fsbc); // Have we reached the end? - int32_t position = fsbc->m_position; + const int32_t position = fsbc->m_position; if (position >= int32_t(m_sound->getSampleCount())) return false; @@ -99,5 +96,4 @@ bool SoundBuffer::getBlock(sound::IAudioBufferCursor* cursor, const sound::IAudi return true; } - } } diff --git a/code/Spark/Sound/SoundBuffer.h b/code/Spark/Sound/SoundBuffer.h index 956926ab48..4324174b3a 100644 --- a/code/Spark/Sound/SoundBuffer.h +++ b/code/Spark/Sound/SoundBuffer.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,8 @@ #include "Sound/IAudioBuffer.h" -namespace traktor +namespace traktor::spark { - namespace spark - { class Sound; @@ -22,7 +20,7 @@ class SoundBuffer : public sound::IAudioBuffer T_RTTI_CLASS; public: - SoundBuffer(const Sound* sound); + explicit SoundBuffer(const Sound* sound); virtual Ref< sound::IAudioBufferCursor > createCursor() const override final; @@ -32,6 +30,4 @@ class SoundBuffer : public sound::IAudioBuffer Ref< const Sound > m_sound; }; - } } - diff --git a/code/Spark/Sound/SoundRenderer.cpp b/code/Spark/Sound/SoundRenderer.cpp index 044076f31d..4bd46f12c5 100644 --- a/code/Spark/Sound/SoundRenderer.cpp +++ b/code/Spark/Sound/SoundRenderer.cpp @@ -1,20 +1,18 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +#include "Sound/Player/ISoundPlayer.h" +#include "Sound/Sound.h" #include "Spark/Sound/SoundBuffer.h" #include "Spark/Sound/SoundRenderer.h" -#include "Sound/Sound.h" -#include "Sound/Player/ISoundPlayer.h" -namespace traktor +namespace traktor::spark { - namespace spark - { T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.SoundRenderer", SoundRenderer, ISoundRenderer) @@ -28,7 +26,7 @@ bool SoundRenderer::create( void SoundRenderer::destroy() { - m_soundPlayer = 0; + m_soundPlayer = nullptr; } void SoundRenderer::play(const Sound* sound) @@ -40,5 +38,4 @@ void SoundRenderer::play(const Sound* sound) } } - } } diff --git a/code/Spark/Sound/SoundRenderer.h b/code/Spark/Sound/SoundRenderer.h index 2af559fc49..094159c287 100644 --- a/code/Spark/Sound/SoundRenderer.h +++ b/code/Spark/Sound/SoundRenderer.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,17 +19,15 @@ # define T_DLLCLASS T_DLLIMPORT #endif -namespace traktor +namespace traktor::sound { - namespace sound - { class ISoundPlayer; - } +} - namespace spark - { +namespace traktor::spark +{ /*! Default sound renderer using Traktor sound package. * \ingroup Spark @@ -49,6 +47,4 @@ class T_DLLCLASS SoundRenderer : public ISoundRenderer Ref< sound::ISoundPlayer > m_soundPlayer; }; - } } - diff --git a/code/Spark/Sw/SwDisplayRenderer.cpp b/code/Spark/Sw/SwDisplayRenderer.cpp index 80110d21c6..c038c8c3e7 100644 --- a/code/Spark/Sw/SwDisplayRenderer.cpp +++ b/code/Spark/Sw/SwDisplayRenderer.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -17,16 +17,14 @@ #include "Spark/Shape.h" #include "Spark/Sw/SwDisplayRenderer.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { const static Matrix33 c_textureTS = translate(0.5f, 0.5f) * scale(1.0f / 32768.0f, 1.0f / 32768.0f); - } + } T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.SwDisplayRenderer", SwDisplayRenderer, IDisplayRenderer) @@ -518,5 +516,4 @@ void SwDisplayRenderer::end() { } - } } diff --git a/code/Spark/Sw/SwDisplayRenderer.h b/code/Spark/Sw/SwDisplayRenderer.h index edc1e49973..1bce6e0f0d 100644 --- a/code/Spark/Sw/SwDisplayRenderer.h +++ b/code/Spark/Sw/SwDisplayRenderer.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,18 +19,16 @@ # define T_DLLCLASS T_DLLIMPORT #endif -namespace traktor +namespace traktor::drawing { - namespace drawing - { class Image; class Raster; - } +} - namespace spark - { +namespace traktor::spark +{ /*! Software display renderer. * \ingroup Spark @@ -106,6 +104,4 @@ class T_DLLCLASS SwDisplayRenderer : public IDisplayRenderer bool m_writeEnable; }; - } } - diff --git a/code/Spark/Swf/SwfMovieFactory.cpp b/code/Spark/Swf/SwfMovieFactory.cpp index 7d2898ad7f..dca28b2794 100644 --- a/code/Spark/Swf/SwfMovieFactory.cpp +++ b/code/Spark/Swf/SwfMovieFactory.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,10 +20,8 @@ #define T_SHOW_STATISTICS 0 -namespace traktor +namespace traktor::spark { - namespace spark - { T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.SwfMovieFactory", SwfMovieFactory, Object) @@ -195,5 +193,4 @@ Ref< Movie > SwfMovieFactory::createMovieFromImage(const drawing::Image* image) return movie; } - } } diff --git a/code/Spark/Swf/SwfMovieFactory.h b/code/Spark/Swf/SwfMovieFactory.h index 6a9a5e88ac..4a72633260 100644 --- a/code/Spark/Swf/SwfMovieFactory.h +++ b/code/Spark/Swf/SwfMovieFactory.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,17 +19,15 @@ # define T_DLLCLASS T_DLLIMPORT #endif -namespace traktor +namespace traktor::drawing { - namespace drawing - { class Image; - } +} - namespace spark - { +namespace traktor::spark +{ class SwfReader; class Movie; @@ -53,6 +51,4 @@ class T_DLLCLASS SwfMovieFactory : public Object SmallMap< uint16_t, Ref< Tag > > m_tagReaders; }; - } } - diff --git a/code/Spark/Swf/SwfMovieFactoryTags.cpp b/code/Spark/Swf/SwfMovieFactoryTags.cpp index 5cf466c6df..b2700141f2 100644 --- a/code/Spark/Swf/SwfMovieFactoryTags.cpp +++ b/code/Spark/Swf/SwfMovieFactoryTags.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -35,10 +35,8 @@ #include "Spark/Swf/SwfMovieFactoryTags.h" #include "Spark/Swf/SwfReader.h" -namespace traktor +namespace traktor::spark { - namespace spark - { // ============================================================================ // Set background color @@ -1444,5 +1442,4 @@ bool TagUnsupported::read(SwfReader* swf, ReadContext& context) return true; } - } } diff --git a/code/Spark/Swf/SwfMovieFactoryTags.h b/code/Spark/Swf/SwfMovieFactoryTags.h index 3fe776f741..34a0a4899b 100644 --- a/code/Spark/Swf/SwfMovieFactoryTags.h +++ b/code/Spark/Swf/SwfMovieFactoryTags.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,17 +19,15 @@ # define T_DLLCLASS T_DLLIMPORT #endif -namespace traktor +namespace traktor::drawing { - namespace drawing - { class ImageFormatJpeg; - } +} - namespace spark - { +namespace traktor::spark +{ class SwfReader; class Movie; @@ -295,6 +293,4 @@ class TagUnsupported : public Tag //@} - } } - diff --git a/code/Spark/Swf/SwfReader.cpp b/code/Spark/Swf/SwfReader.cpp index 87d06c693a..20cc6cf85b 100644 --- a/code/Spark/Swf/SwfReader.cpp +++ b/code/Spark/Swf/SwfReader.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,16 +15,14 @@ #include "Core/Misc/Endian.h" #include "Spark/Swf/SwfReader.h" -namespace traktor +namespace traktor::spark { - namespace spark + namespace { - namespace - { const uint32_t c_allocSize = 256UL * 1024UL; - } + } T_IMPLEMENT_RTTI_CLASS(L"traktor.spark.SwfReader", SwfReader, Object) @@ -984,5 +982,4 @@ BitReader& SwfReader::getBitReader() return *m_bs; } - } } diff --git a/code/Spark/Swf/SwfReader.h b/code/Spark/Swf/SwfReader.h index c063c71144..2e1cba0c68 100644 --- a/code/Spark/Swf/SwfReader.h +++ b/code/Spark/Swf/SwfReader.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -28,8 +28,10 @@ namespace traktor class IStream; class PoolAllocator; - namespace spark - { +} + +namespace traktor::spark +{ /*! SWF type reader. * \ingroup Spark @@ -180,6 +182,4 @@ class T_DLLCLASS SwfReader : public Object Ref< PoolAllocator > m_pool; }; - } } - diff --git a/code/Spark/Swf/SwfTypes.h b/code/Spark/Swf/SwfTypes.h index 4e332d45e2..f7164f2c05 100644 --- a/code/Spark/Swf/SwfTypes.h +++ b/code/Spark/Swf/SwfTypes.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,10 +13,8 @@ #include "Core/Math/Color4f.h" #include "Core/Containers/AlignedVector.h" -namespace traktor +namespace traktor::spark { - namespace spark - { #if defined (_MSC_VER) # pragma warning( disable:4324 ) @@ -473,6 +471,4 @@ enum SwfBlendMode # pragma warning( default:4324 ) #endif - } } -