Skip to content

Commit

Permalink
Traktor: Some minor cleanup in Spark.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Jun 3, 2024
1 parent a778680 commit bae0bf3
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 104 deletions.
22 changes: 9 additions & 13 deletions code/Spark/Optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Ref< Movie > Optimizer::merge(const Movie* movie) const
{
const Sprite* movieClip = movie->getMovieClip();
if (!movieClip)
return 0;
return nullptr;

Ref< Frame > outputFrame = new Frame();

Expand All @@ -282,9 +282,8 @@ Ref< Movie > Optimizer::merge(const Movie* movie) const
outputMovie->defineCharacter(1, outputSprite);

// Copy bitmaps into output movie; is shared to reduce memory cost.
const SmallMap< uint16_t, Ref< Bitmap > >& bitmaps = movie->getBitmaps();
for (SmallMap< uint16_t, Ref< Bitmap > >::const_iterator i = bitmaps.begin(); i != bitmaps.end(); ++i)
outputMovie->defineBitmap(i->first, i->second);
for (const auto& it : movie->getBitmaps())
outputMovie->defineBitmap(it.first, it.second);

MergeQueue queue(outputMovie, outputFrame);
traverse(queue, movie, movieClip, Matrix33::identity(), c_cxfIdentity, SbmDefault);
Expand All @@ -294,10 +293,9 @@ Ref< Movie > Optimizer::merge(const Movie* movie) const

void Optimizer::triangulate(Movie* movie, bool discardPaths) const
{
const SmallMap< uint16_t, Ref< Character > >& characters = movie->getCharacters();
for (SmallMap< uint16_t, Ref< Character > >::const_iterator i = characters.begin(); i != characters.end(); ++i)
for (const auto& it : movie->getCharacters())
{
Shape* shape = dynamic_type_cast< Shape* >(i->second);
Shape* shape = dynamic_type_cast< Shape* >(it.second);
if (shape)
{
shape->triangulate(false);
Expand All @@ -306,15 +304,13 @@ void Optimizer::triangulate(Movie* movie, bool discardPaths) const
}
}

const SmallMap< uint16_t, Ref< Font > >& fonts = movie->getFonts();
for (SmallMap< uint16_t, Ref< Font > >::const_iterator i = fonts.begin(); i != fonts.end(); ++i)
for (const auto& it : movie->getFonts())
{
const RefArray< Shape >& glyphShapes = i->second->getShapes();
for (RefArray< Shape >::const_iterator j = glyphShapes.begin(); j != glyphShapes.end(); ++j)
for (auto shape : it.second->getShapes())
{
(*j)->triangulate(true);
shape->triangulate(true);
if (discardPaths)
(*j)->discardPaths();
shape->discardPaths();
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions code/Spark/Packer.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,7 +17,7 @@ namespace traktor::spark
class PackerImpl
{
public:
PackerImpl(int32_t width, int32_t height)
explicit PackerImpl(int32_t width, int32_t height)
{
m_packer = new stbrp_context();
m_nodes = new stbrp_node [width];
Expand All @@ -39,10 +39,7 @@ class PackerImpl
stbrp_pack_rects(m_packer, &r, 1);
if (r.was_packed)
{
outRectangle.x = r.x;
outRectangle.y = r.y;
outRectangle.width = r.w;
outRectangle.height = r.h;
outRectangle = { r.x, r.y, r.w, r.h };
return true;
}
else
Expand Down
Loading

0 comments on commit bae0bf3

Please sign in to comment.