Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Function-scope statics aren't as efficient as file-scope ones
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Apr 15, 2016
1 parent 65cdadf commit e40a836
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
5 changes: 3 additions & 2 deletions lib/Space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ static logvisor::Module Log("specter::Space");

#define CORNER_DRAG_THRESHOLD 20

static const zeus::CColor TriColor = {0.75, 0.75, 0.75, 1.0};

Space::Space(ViewResources& res, View& parentView, ISpaceController& controller,
Toolbar::Position tbPos, unsigned tbUnits)
: View(res, parentView), m_controller(controller), m_tbPos(tbPos)
Expand All @@ -26,9 +28,8 @@ Space::Space(ViewResources& res, View& parentView, ISpaceController& controller,
return true;
});
setBackground(res.themeData().spaceBackground());
static const zeus::CColor triColor = {0.75, 0.75, 0.75, 1.0};
if (controller.spaceSplitAllowed())
m_cornerView.m_view.reset(new CornerView(res, *this, triColor));
m_cornerView.m_view.reset(new CornerView(res, *this, TriColor));
if (tbPos != Toolbar::Position::None)
m_toolbar.m_view.reset(new Toolbar(res, *this, tbPos, tbUnits));
}
Expand Down
15 changes: 8 additions & 7 deletions lib/SplitView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ namespace specter
{
static logvisor::Module Log("specter::SplitView");

static const zeus::RGBA32 Tex[3] =
{
{0,0,0,64},
{0,0,0,255},
{255,255,255,64}
};

void SplitView::Resources::init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme)
{
static const zeus::RGBA32 tex[3] =
{
{0,0,0,64},
{0,0,0,255},
{255,255,255,64}
};
m_shadingTex = ctx.newStaticTexture(3, 1, 1, boo::TextureFormat::RGBA8, tex, 12);
m_shadingTex = ctx.newStaticTexture(3, 1, 1, boo::TextureFormat::RGBA8, Tex, 12);
}

SplitView::SplitView(ViewResources& res, View& parentView, ISplitSpaceController* controller,
Expand Down
4 changes: 2 additions & 2 deletions lib/TextView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ BOO_GLSL_BINDING_HEAD
" blendOut = colorOut.a * texture(fontTex, vtf.uv);\n"
"}\n";

static const char* BlockNames[] = {"SpecterViewBlock"};

void TextView::Resources::init(boo::GLDataFactory::Context& ctx, FontCache* fcache)
{
m_fcache = fcache;

static const char* BlockNames[] = {"SpecterViewBlock"};

m_regular =
ctx.newShaderPipeline(GLSLVS, GLSLFSReg, 1, "fontTex", 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
Expand Down
17 changes: 9 additions & 8 deletions lib/Toolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ namespace specter
{
static logvisor::Module Log("specter::Space");

static const zeus::RGBA32 Tex[] =
{
{{255,255,255,64}},
{{255,255,255,64}},
{{0,0,0,64}},
{{0,0,0,64}}
};

void Toolbar::Resources::init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme)
{
static const zeus::RGBA32 tex[] =
{
{{255,255,255,64}},
{{255,255,255,64}},
{{0,0,0,64}},
{{0,0,0,64}}
};
m_shadingTex = ctx.newStaticTexture(4, 1, 1, boo::TextureFormat::RGBA8, tex, 16);
m_shadingTex = ctx.newStaticTexture(4, 1, 1, boo::TextureFormat::RGBA8, Tex, 16);
}

Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos, unsigned units)
Expand Down
4 changes: 2 additions & 2 deletions lib/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ BOO_GLSL_BINDING_HEAD
" colorOut = texture(tex, vtf.uv) * vtf.color;\n"
"}\n";

static const char* BlockNames[] = {"SpecterViewBlock"};

void View::Resources::init(boo::GLDataFactory::Context& ctx, const IThemeData& theme)
{
static const char* BlockNames[] = {"SpecterViewBlock"};

m_solidShader = ctx.newShaderPipeline(GLSLSolidVS, GLSLSolidFS, 0, nullptr, 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
Expand Down

0 comments on commit e40a836

Please sign in to comment.