Skip to content

Commit

Permalink
Cleanup: Employ macro DENG2_PIMPL in material/texture subsystem compo…
Browse files Browse the repository at this point in the history
…nents
  • Loading branch information
danij-deng committed Feb 12, 2013
1 parent dc34a8c commit 688d62c
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 56 deletions.
14 changes: 9 additions & 5 deletions doomsday/client/src/resource/material.cpp
Expand Up @@ -235,7 +235,7 @@ Material::Decoration::Stages const &Material::Decoration::stages() const
return stages_;
}

struct Material::Instance
DENG2_PIMPL(Material)
{
/// Manifest derived to yield the material.
MaterialManifest &manifest;
Expand Down Expand Up @@ -263,9 +263,13 @@ struct Material::Instance
/// @c false= the material is no longer valid.
bool valid;

Instance(MaterialManifest &_manifest)
: manifest(_manifest), envClass(AEC_UNKNOWN), flags(0),
detailLayer(0), shineLayer(0), valid(true)
Instance(Public &a, MaterialManifest &_manifest) : Base(a),
manifest(_manifest),
envClass(AEC_UNKNOWN),
flags(0),
detailLayer(0),
shineLayer(0),
valid(true)
{}

~Instance()
Expand Down Expand Up @@ -301,7 +305,7 @@ struct Material::Instance
};

Material::Material(MaterialManifest &_manifest, ded_material_t const *def)
: de::MapElement(DMU_MATERIAL), d(new Instance(_manifest))
: de::MapElement(DMU_MATERIAL), d(new Instance(*this, _manifest))
{
DENG_ASSERT(def);
if(def->flags & MATF_NO_DRAW) d->flags |= NoDraw;
Expand Down
11 changes: 6 additions & 5 deletions doomsday/client/src/resource/materialarchive.cpp
Expand Up @@ -113,7 +113,7 @@ static Material *findRecordMaterial(Records &records, SerialId id)
return (Material *) records.userPointer(id);
}

struct MaterialArchive::Instance
DENG2_PIMPL(MaterialArchive)
{
/// Logical version number of the archive.
int version;
Expand All @@ -127,9 +127,10 @@ struct MaterialArchive::Instance
/// Used with older versions.
int numFlats;

Instance(bool _useSegments)
: version(MATERIALARCHIVE_VERSION),
useSegments(_useSegments), numFlats(0)
Instance(Public &a, bool _useSegments) : Base(a),
version(MATERIALARCHIVE_VERSION),
useSegments(_useSegments),
numFlats(0)
{}

inline SerialId insertRecord(Uri const &uri)
Expand Down Expand Up @@ -200,8 +201,8 @@ struct MaterialArchive::Instance
};

MaterialArchive::MaterialArchive(int useSegments, bool recordSymbolicMaterials)
: d(new Instance(*this, useSegments))
{
d = new Instance(useSegments);
if(recordSymbolicMaterials)
{
// The first material is the special "unknown material".
Expand Down
8 changes: 5 additions & 3 deletions doomsday/client/src/resource/materialmanifest.cpp
Expand Up @@ -24,7 +24,7 @@

namespace de {

struct MaterialManifest::Instance
DENG2_PIMPL(MaterialManifest)
{
/// Material associated with this.
Material *material;
Expand All @@ -35,12 +35,14 @@ struct MaterialManifest::Instance
/// Classification flags.
MaterialManifest::Flags flags;

Instance() : material(0), id(0)
Instance(Public &a) : Base(a),
material(0),
id(0)
{}
};

MaterialManifest::MaterialManifest(PathTree::NodeArgs const &args)
: Node(args), d(new Instance())
: Node(args), d(new Instance(*this))
{}

MaterialManifest::~MaterialManifest()
Expand Down
10 changes: 6 additions & 4 deletions doomsday/client/src/resource/materials.cpp
Expand Up @@ -132,7 +132,7 @@ struct VariantCacheTask
/// the material is destroyed in the mean time.
typedef QList<VariantCacheTask *> VariantCacheQueue;

struct Materials::Instance
DENG2_PIMPL(Materials)
{
/// System subspace schemes containing the manifests.
Materials::Schemes schemes;
Expand All @@ -158,8 +158,10 @@ struct Materials::Instance
uint manifestIdMapSize;
Materials::Manifest **manifestIdMap;

Instance()
: manifestCount(0), manifestIdMapSize(0), manifestIdMap(0)
Instance(Public &a) : Base(a),
manifestCount(0),
manifestIdMapSize(0),
manifestIdMap(0)
{}

~Instance()
Expand Down Expand Up @@ -263,7 +265,7 @@ void Materials::consoleRegister()
#endif
}

Materials::Materials() : d(new Instance())
Materials::Materials() : d(new Instance(*this))
{}

Materials::~Materials()
Expand Down
9 changes: 6 additions & 3 deletions doomsday/client/src/resource/materialscheme.cpp
Expand Up @@ -22,20 +22,23 @@

namespace de {

struct MaterialScheme::Instance
DENG2_PIMPL(MaterialScheme)
{
/// Symbolic name of the scheme.
String name;

/// Mappings from paths to manifests.
MaterialScheme::Index index;

Instance(String symbolicName) : name(symbolicName) {}
Instance(Public &a, String symbolicName) : Base(a),
name(symbolicName)
{}

~Instance() { DENG_ASSERT(index.isEmpty()); }
};

MaterialScheme::MaterialScheme(String symbolicName) : d(new Instance(symbolicName))
MaterialScheme::MaterialScheme(String symbolicName)
: d(new Instance(*this, symbolicName))
{}

MaterialScheme::~MaterialScheme()
Expand Down
9 changes: 5 additions & 4 deletions doomsday/client/src/resource/materialsnapshot.cpp
Expand Up @@ -99,22 +99,23 @@ struct Store {
#endif // __CLIENT__
};

struct MaterialSnapshot::Instance
DENG2_PIMPL(MaterialSnapshot)
{
/// Variant material used to derive this snapshot.
Material::Variant *variant;

Store stored;

Instance(Material::Variant &_variant)
: variant(&_variant), stored()
Instance(Public &a, Material::Variant &_variant) : Base(a),
variant(&_variant),
stored()
{}

void takeSnapshot();
};

MaterialSnapshot::MaterialSnapshot(Material::Variant &materialVariant)
: d(new Instance(materialVariant))
: d(new Instance(*this, materialVariant))
{}

MaterialSnapshot::~MaterialSnapshot()
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/resource/materialvariant.cpp
Expand Up @@ -43,7 +43,7 @@ bool MaterialVariantSpec::compare(MaterialVariantSpec const &other) const

using namespace de;

struct Material::Variant::Instance
DENG2_PIMPL(Material::Variant)
{
/// Superior material of which this is a derivative.
Material *material;
Expand All @@ -65,8 +65,8 @@ struct Material::Variant::Instance
/// Decoration animation states.
Material::Variant::DecorationState decorations[Material::max_decorations];

Instance(Material &generalCase, Material::VariantSpec const &_spec)
: material(&generalCase),
Instance(Public &a, Material &generalCase, Material::VariantSpec const &_spec)
: Base(a), material(&generalCase),
spec(_spec), snapshot(0), snapshotPrepareFrame(-1)
{}

Expand Down Expand Up @@ -179,7 +179,7 @@ struct Material::Variant::Instance
};

Material::Variant::Variant(Material &generalCase, Material::VariantSpec const &spec)
: d(new Instance(generalCase, spec))
: d(new Instance(*this, generalCase, spec))
{
// Initialize animation states.
resetAnim();
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/resource/texture.cpp
Expand Up @@ -31,7 +31,7 @@

namespace de {

struct Texture::Instance
DENG2_PIMPL(Texture)
{
/// Manifest derived to yield the texture.
TextureManifest &manifest;
Expand All @@ -54,8 +54,8 @@ struct Texture::Instance
/// on the variant specification.
void *analyses[TEXTURE_ANALYSIS_COUNT];

Instance(TextureManifest &_manifest)
: manifest(_manifest), userData(0)
Instance(Public &a, TextureManifest &_manifest)
: Base(a), manifest(_manifest), userData(0)
{
std::memset(analyses, 0, sizeof(analyses));
}
Expand Down Expand Up @@ -85,7 +85,7 @@ struct Texture::Instance
}
};

Texture::Texture(TextureManifest &manifest) : d(new Instance(manifest))
Texture::Texture(TextureManifest &manifest) : d(new Instance(*this, manifest))
{}

Texture::~Texture()
Expand Down
7 changes: 4 additions & 3 deletions doomsday/client/src/resource/texturemanifest.cpp
Expand Up @@ -24,7 +24,7 @@

namespace de {

struct TextureManifest::Instance
DENG2_PIMPL(TextureManifest)
{
/// Scheme-unique identifier determined by the owner of the subspace.
int uniqueId;
Expand All @@ -44,7 +44,8 @@ struct TextureManifest::Instance
/// The associated logical Texture instance (if any).
Texture *texture;

Instance() : uniqueId(0), resourceUri(), texture(0)
Instance(Public &a) : Base(a),
uniqueId(0), resourceUri(), texture(0)
{}

~Instance()
Expand All @@ -54,7 +55,7 @@ struct TextureManifest::Instance
};

TextureManifest::TextureManifest(PathTree::NodeArgs const &args)
: Node(args), d(new Instance())
: Node(args), d(new Instance(*this))
{}

TextureManifest::~TextureManifest()
Expand Down
19 changes: 9 additions & 10 deletions doomsday/client/src/resource/textures.cpp
Expand Up @@ -17,22 +17,21 @@
* 02110-1301 USA</small>
*/

#include <cstdlib>
//#include <cstdlib>

#include "de_base.h"
#include "de_console.h"
#include "gl/gl_texmanager.h"

#include <QtAlgorithms>
#include <QList>
#include "resource/compositetexture.h"
#include "TextureManifest"
#include <de/Error>
#include <de/Log>
#include <de/PathTree>
#include <de/mathutil.h> // for M_NumDigits
#include <QList>
#include <QtAlgorithms>

#include "resource/compositetexture.h"
#include "TextureManifest"
#include "Textures"
#include "resource/textures.h"

char const *TexSource_Name(TexSource source)
{
Expand Down Expand Up @@ -62,13 +61,13 @@ Texture *Textures::ResourceClass::interpret(TextureManifest &manifest, void *use
return tex;
}

struct Textures::Instance
DENG2_PIMPL(Textures)
{
/// System subspace schemes containing the textures.
Textures::Schemes schemes;
QList<Textures::Scheme *> schemeCreationOrder;

Instance() {}
Instance(Public &a) : Base(a) {}
~Instance() { clearManifests(); }

void clearManifests()
Expand All @@ -91,7 +90,7 @@ void Textures::consoleRegister()
#endif
}

Textures::Textures() : d(new Instance())
Textures::Textures() : d(new Instance(*this))
{}

Textures::~Textures()
Expand Down
12 changes: 7 additions & 5 deletions doomsday/client/src/resource/texturescheme.cpp
Expand Up @@ -22,7 +22,7 @@

namespace de {

struct TextureScheme::Instance
DENG2_PIMPL(TextureScheme)
{
/// Symbolic name of the scheme.
String name;
Expand All @@ -36,9 +36,11 @@ struct TextureScheme::Instance
bool uniqueIdLutDirty;
int uniqueIdBase;

Instance(String symbolicName)
: name(symbolicName),
uniqueIdLut(), uniqueIdLutDirty(false), uniqueIdBase(0)
Instance(Public &a, String symbolicName) : Base(a),
name(symbolicName),
uniqueIdLut(),
uniqueIdLutDirty(false),
uniqueIdBase(0)
{}

~Instance() { DENG_ASSERT(index.isEmpty()); }
Expand Down Expand Up @@ -146,7 +148,7 @@ struct TextureScheme::Instance
}
};

TextureScheme::TextureScheme(String symbolicName) : d(new Instance(symbolicName))
TextureScheme::TextureScheme(String symbolicName) : d(new Instance(*this, symbolicName))
{}

TextureScheme::~TextureScheme()
Expand Down
17 changes: 11 additions & 6 deletions doomsday/client/src/resource/texturevariant.cpp
Expand Up @@ -72,7 +72,7 @@ int TextureVariantSpec_Compare(texturevariantspecification_t const *a,

namespace de {

struct Texture::Variant::Instance
DENG2_PIMPL(Texture::Variant)
{
/// Superior Texture of which this is a derivative.
Texture &texture;
Expand All @@ -92,15 +92,20 @@ struct Texture::Variant::Instance
/// Prepared coordinates for the bottom right of the texture minus border.
float s, t;

Instance(Texture &generalCase, texturevariantspecification_t const &spec)
: texture(generalCase), spec(spec),
flags(0), texSource(TEXS_NONE),
glTexName(0), s(0), t(0)
Instance(Public &a, Texture &generalCase,
texturevariantspecification_t const &spec) : Base(a),
texture(generalCase),
spec(spec),
flags(0),
texSource(TEXS_NONE),
glTexName(0),
s(0),
t(0)
{}
};

Texture::Variant::Variant(Texture &generalCase, texturevariantspecification_t const &spec)
: d(new Instance(generalCase, spec))
: d(new Instance(*this, generalCase, spec))
{}

Texture::Variant::~Variant()
Expand Down

0 comments on commit 688d62c

Please sign in to comment.