Skip to content

Commit

Permalink
Cleanup|Client|Renderer: Redundant static/inline symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 25, 2016
1 parent 096a021 commit 51b28e8
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 153 deletions.
17 changes: 6 additions & 11 deletions doomsday/apps/client/src/render/api_render.cpp
Expand Up @@ -44,11 +44,6 @@

using namespace de;

static inline ClientResources &resSys()
{
return App_ResourceSystem();
}

// m_misc.c
DENG_EXTERN_C dint M_ScreenShot(char const *name, dint bits);

Expand All @@ -58,7 +53,7 @@ DENG_EXTERN_C void Models_CacheForState(dint stateIndex)
#ifdef __CLIENT__
if(FrameModelDef *modelDef = App_ResourceSystem().modelDefForState(stateIndex))
{
resSys().cache(modelDef);
App_ResourceSystem().cache(modelDef);
}
#endif
}
Expand Down Expand Up @@ -89,7 +84,7 @@ DENG_EXTERN_C void Rend_CacheForMobjType(dint num)
{
if(state_t *state = Def_GetState(i))
{
resSys().cache(state->sprite, spec);
App_ResourceSystem().cache(state->sprite, spec);
}
}
/// @todo What about sounds?
Expand All @@ -114,7 +109,7 @@ DENG_EXTERN_C void R_SetViewPortPlayer(dint consoleNum, dint viewPlayer);
DENG_EXTERN_C void R_SkyParams(dint layer, dint param, void *data);

#ifdef __CLIENT__
static inline MaterialVariantSpec const &pspriteMaterialSpec()
static inline MaterialVariantSpec const &pspriteMaterialSpec_GetSpriteInfo()
{
return App_ResourceSystem().materialSpec(PSpriteContext, 0, 1, 0, 0, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
0, 1, -1, false, true, true, false);
Expand All @@ -130,14 +125,14 @@ DENG_EXTERN_C dd_bool R_GetSpriteInfo(dint id, dint frame, spriteinfo_t *info)

de::zapPtr(info);

if(!resSys().hasSprite(id, frame))
if(!App_ResourceSystem().hasSprite(id, frame))
{
LOG_RES_WARNING("Invalid sprite id:%i and/or frame:%i")
<< id << frame;
return false;
}

defn::Sprite sprite(resSys().sprite(id, frame));
defn::Sprite sprite(App_ResourceSystem().sprite(id, frame));
if(!sprite.hasView(0))
{
LOG_RES_WARNING("Sprite id:%i frame:%i has no front view")
Expand All @@ -154,7 +149,7 @@ DENG_EXTERN_C dd_bool R_GetSpriteInfo(dint id, dint frame, spriteinfo_t *info)
#ifdef __CLIENT__
/// @todo fixme: We should not be using the PSprite spec here. -ds
MaterialAnimator &matAnimator = reinterpret_cast<world::Material *>(info->material)->as<ClientMaterial>()
.getAnimator(pspriteMaterialSpec());
.getAnimator(pspriteMaterialSpec_GetSpriteInfo());
matAnimator.prepare(); // Ensure we have up-to-date info.

Vector2ui const &matDimensions = matAnimator.dimensions();
Expand Down
9 changes: 2 additions & 7 deletions doomsday/apps/client/src/render/billboard.cpp
Expand Up @@ -50,11 +50,6 @@ dint noSpriteZWrite;

dbyte devNoSprites;

static inline RenderSystem &rendSys()
{
return ClientApp::renderSystem();
}

static inline void drawQuad(dgl_vertex_t *v, dgl_color_t *c, dgl_texcoord_t *tc)
{
glBegin(GL_QUADS);
Expand Down Expand Up @@ -260,7 +255,7 @@ static void Spr_VertexColors(dint count, dgl_color_t *out, dgl_vertex_t *normals
Vector3f const normal(normals[i].xyz);
Vector3f accum[2]; // Begin with total darkness [color, extra].
dint numProcessed = 0;
rendSys().forAllVectorLights(lightListIdx, [&maxLights, &normal
ClientApp::renderSystem().forAllVectorLights(lightListIdx, [&maxLights, &normal
, &accum, &numProcessed](VectorLightData const &vlight)
{
numProcessed += 1;
Expand Down Expand Up @@ -622,7 +617,7 @@ void Rend_DrawSprite(vissprite_t const &spr)
glTranslatef(spr.pose.origin[0], spr.pose.origin[2], spr.pose.origin[1]);

coord_t const distFromViewer = de::abs(spr.pose.distance);
rendSys().forAllVectorLights(spr.light.vLightListIdx, [&distFromViewer] (VectorLightData const &vlight)
ClientApp::renderSystem().forAllVectorLights(spr.light.vLightListIdx, [&distFromViewer] (VectorLightData const &vlight)
{
if(distFromViewer < 1600 - 8)
{
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/render/model.cpp
Expand Up @@ -20,10 +20,10 @@

using namespace de;

static String const DEF_TIMELINE("timeline");

namespace render {

static String const DEF_TIMELINE("timeline");

Model::AnimSequence::AnimSequence(String const &name, Record const &def)
: name(name)
, def(&def)
Expand Down
25 changes: 10 additions & 15 deletions doomsday/apps/client/src/render/r_draw.cpp
Expand Up @@ -50,24 +50,19 @@ enum {
BG_BOTTOMLEFT
};

static bool inited = false;
static bool initedDraw = false;
static int borderSize;
static de::Uri *borderGraphicsNames[9];

/// @todo Declare the patches with URNs to avoid unnecessary duplication here -ds
static patchid_t borderPatches[9];

static inline ClientResources &resSys()
{
return ClientApp::resources();
}

static void loadViewBorderPatches()
{
borderPatches[0] = 0;
for(uint i = 1; i < 9; ++i)
{
borderPatches[i] = resSys().declarePatch(borderGraphicsNames[i]->path());
borderPatches[i] = ClientApp::resources().declarePatch(borderGraphicsNames[i]->path());
}

// Detemine the view border size.
Expand All @@ -90,7 +85,7 @@ static ClientTexture &borderTexture(int borderComp)
#undef R_SetBorderGfx
DENG_EXTERN_C void R_SetBorderGfx(struct uri_s const *const *paths)
{
DENG2_ASSERT(inited);
DENG2_ASSERT(initedDraw);
if(!paths) return;

for(uint i = 0; i < 9; ++i)
Expand Down Expand Up @@ -125,7 +120,7 @@ void R_InitViewWindow()
R_SetupDefaultViewWindow(i);
}

if(inited)
if(initedDraw)
{
for(int i = 0; i < 9; ++i)
{
Expand All @@ -138,12 +133,12 @@ void R_InitViewWindow()
de::zap(borderGraphicsNames);
de::zap(borderPatches);
borderSize = 0;
inited = true;
initedDraw = true;
}

void R_ShutdownViewWindow()
{
if(!inited) return;
if(!initedDraw) return;

for(int i = 0; i < 9; ++i)
{
Expand All @@ -154,13 +149,13 @@ void R_ShutdownViewWindow()
}

de::zap(borderGraphicsNames);
inited = false;
initedDraw = false;
}

TextureVariantSpec const &Rend_PatchTextureSpec(int flags, gl::Wrapping wrapS,
gl::Wrapping wrapT)
{
return resSys().textureSpec(TC_UI, flags, 0, 0, 0,
return ClientApp::resources().textureSpec(TC_UI, flags, 0, 0, 0,
GL_Wrap(wrapS), GL_Wrap(wrapT), 0, -3, 0, false, false, false, false);
}

Expand Down Expand Up @@ -206,15 +201,15 @@ void R_DrawPatchTiled(ClientTexture &texture, int x, int y, int w, int h,

static MaterialVariantSpec const &bgMaterialSpec()
{
return resSys().materialSpec(UiContext, 0, 0, 0, 0,
return ClientApp::resources().materialSpec(UiContext, 0, 0, 0, 0,
GL_REPEAT, GL_REPEAT, 0, -3,
0, false, false, false, false);
}

/// @todo Optimize: Do not search for resources (materials, textures) each frame.
void R_DrawViewBorder()
{
DENG2_ASSERT(inited);
DENG2_ASSERT(initedDraw);

viewport_t const *port = R_CurrentViewPort();
viewdata_t const *vd = &DD_Player(displayPlayer)->viewport();
Expand Down
9 changes: 2 additions & 7 deletions doomsday/apps/client/src/render/r_main.cpp
Expand Up @@ -56,14 +56,9 @@ dfloat weaponFOVShift = 45;
dfloat weaponOffsetScale = 0.3183f; // 1/Pi
dbyte weaponScaleMode = SCALEMODE_SMART_STRETCH;

static inline ClientResources &resSys()
{
return ClientApp::resources();
}

static MaterialVariantSpec const &pspriteMaterialSpec()
{
return resSys().materialSpec(PSpriteContext, 0, 1, 0, 0, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
return ClientApp::resources().materialSpec(PSpriteContext, 0, 1, 0, 0, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
0, -2, 0, false, true, true, false);
}

Expand All @@ -78,7 +73,7 @@ static void setupPSpriteParams(rendpspriteparams_t &parm, vispsprite_t const &vs
DENG2_ASSERT(psp.statePtr);
state_t const &state = *psp.statePtr;

Record const &spriteView = defn::Sprite(resSys().sprite(state.sprite, state.frame)).view(0);
Record const &spriteView = defn::Sprite(ClientApp::resources().sprite(state.sprite, state.frame)).view(0);

// Lookup the Material for this Sprite and prepare the animator.
MaterialAnimator &matAnimator = ClientMaterial::find(de::Uri(spriteView.gets("material"), RC_NULL))
Expand Down
7 changes: 1 addition & 6 deletions doomsday/apps/client/src/render/r_things.cpp
Expand Up @@ -57,11 +57,6 @@
using namespace de;
using namespace world;

static inline RenderSystem &rendSys()
{
return ClientApp::renderSystem();
}

static void evaluateLighting(Vector3d const &origin, ConvexSubspace &subspaceAtOrigin,
coord_t distToEye, bool fullbright, Vector4f &ambientColor, duint *vLightListIdx)
{
Expand Down Expand Up @@ -261,7 +256,7 @@ void R_ProjectSprite(mobj_t &mob)
v1, v2);

// Not visible?
if(!rendSys().angleClipper().checkRangeFromViewRelPoints(v1, v2))
if(!ClientApp::renderSystem().angleClipper().checkRangeFromViewRelPoints(v1, v2))
{
coord_t const MAX_OBJECT_RADIUS = 128;

Expand Down
15 changes: 5 additions & 10 deletions doomsday/apps/client/src/render/rend_fakeradio.cpp
Expand Up @@ -66,11 +66,6 @@ dint rendFakeRadio = true; ///< cvar
static dfloat fakeRadioDarkness = 1.2f; ///< cvar
byte devFakeRadioUpdate = true; ///< cvar

static inline RenderSystem &rendSys()
{
return ClientApp::renderSystem();
}

/**
* Returns the "shadow darkness" (factor) for the given @a ambientLight (level), derived
* from values in Config.
Expand Down Expand Up @@ -755,12 +750,12 @@ static void drawWallShadow(Vector3f const *posCoords, WallEdge const &leftEdge,
DrawListSpec listSpec;
listSpec.group = ShadowGeom;
listSpec.texunits[TU_PRIMARY] = GLTextureUnit(GL_PrepareLSTexture(tp.texture), gl::ClampToEdge, gl::ClampToEdge);
DrawList &shadowList = rendSys().drawLists().find(listSpec);
DrawList &shadowList = ClientApp::renderSystem().drawLists().find(listSpec);

// Walls with edge divisions mean two trifans.
if(leftEdge.divisionCount() || rightEdge.divisionCount())
{
Store &buffer = rendSys().buffer();
Store &buffer = ClientApp::renderSystem().buffer();
// Right fan.
{
duint const numVerts = 3 + rightEdge.divisionCount();
Expand Down Expand Up @@ -846,7 +841,7 @@ static void drawWallShadow(Vector3f const *posCoords, WallEdge const &leftEdge,
}
else
{
Store &buffer = rendSys().buffer();
Store &buffer = ClientApp::renderSystem().buffer();
duint base = buffer.allocateVertices(4);
DrawList::Indices indices;
indices.resize(4);
Expand Down Expand Up @@ -1028,7 +1023,7 @@ void Rend_DrawFlatRadio(ConvexSubspace const &subspace)
auto const eyeToSubspace = Vector2f(Rend_EyeOrigin().xz() - subspace.poly().center());

// All shadow geometry uses the same texture (i.e., none) - use the same list.
DrawList &shadowList = rendSys().drawLists().find(DrawListSpec(::renderWireframe? UnlitGeom : ShadowGeom));
DrawList &shadowList = ClientApp::renderSystem().drawLists().find(DrawListSpec(::renderWireframe? UnlitGeom : ShadowGeom));

// Process all LineSides linked to this subspace as potential shadow casters.
subspace.forAllShadowLines([&subsec, &shadowDark, &eyeToSubspace, &shadowList] (LineSide &side)
Expand Down Expand Up @@ -1058,7 +1053,7 @@ void Rend_DrawFlatRadio(ConvexSubspace const &subspace)
bool const haveFloor = plane.surface().normal()[2] > 0;

// Build geometry.
Store &buffer = rendSys().buffer();
Store &buffer = ClientApp::renderSystem().buffer();
gl::Primitive primitive;
DrawList::Indices indices = makeFlatShadowGeometry(buffer, primitive, shadowEdges, shadowDark, haveFloor);

Expand Down
16 changes: 8 additions & 8 deletions doomsday/apps/client/src/render/rend_font.cpp
Expand Up @@ -100,7 +100,7 @@ typedef struct {
static void drawChar(uchar ch, float posX, float posY, AbstractFont *font, int alignFlags, short textFlags);
static void drawFlash(Point2Raw const *origin, Size2Raw const *size, bool bright);

static int inited = false;
static int initedFont = false;

static char smallTextBuffer[FR_SMALL_TEXT_BUFFER_SIZE+1];
static char *largeTextBuffer = NULL;
Expand All @@ -110,7 +110,7 @@ static int typeInTime;

static void errorIfNotInited(const char* callerName)
{
if(inited) return;
if(initedFont) return;
App_Error("%s: font renderer module is not presently initialized.", callerName);
// Unreachable. Prevents static analysers from getting rather confused, poor things.
exit(1);
Expand All @@ -131,18 +131,18 @@ static inline fr_state_attributes_t *currentAttribs(void)

void FR_Shutdown(void)
{
if(!inited) return;
inited = false;
if(!initedFont) return;
initedFont = false;
}

dd_bool FR_Available(void)
{
return inited;
return initedFont;
}

void FR_Ticker(timespan_t /*ticLength*/)
{
if(!inited)
if(!initedFont)
return;

// Restricted to fixed 35 Hz ticks.
Expand Down Expand Up @@ -1539,10 +1539,10 @@ void FR_DrawCharXY(unsigned char ch, int x, int y)
void FR_Init(void)
{
// No reinitializations...
if(inited) return;
if(initedFont) return;
if(isDedicated) return;

inited = true;
initedFont = true;
fr.fontNum = 0;
FR_LoadDefaultAttrib();
typeInTime = 0;
Expand Down

0 comments on commit 51b28e8

Please sign in to comment.