Don't use std::shared_ptr for state tracker.

This commit is contained in:
Themaister 2014-01-01 16:59:19 +01:00
parent b618306995
commit f64b670d9a
3 changed files with 11 additions and 12 deletions

View File

@ -846,12 +846,7 @@ bool D3DVideo::init_imports(void)
return false;
}
std::shared_ptr<state_tracker_t> tracker(state_tracker, [](state_tracker_t *tracker) {
state_tracker_free(tracker);
});
chain->add_state_tracker(tracker);
chain->add_state_tracker(state_tracker);
return true;
}

View File

@ -57,13 +57,16 @@ RenderChain::~RenderChain()
cgDestroyProgram(fStock);
if (vStock)
cgDestroyProgram(vStock);
if (tracker)
state_tracker_free(tracker);
}
RenderChain::RenderChain(const video_info_t *video_info,
LPDIRECT3DDEVICE dev_,
CGcontext cgCtx_,
const D3DVIEWPORT &final_viewport_)
: dev(dev_), cgCtx(cgCtx_), video_info(*video_info), final_viewport(final_viewport_), frame_count(0)
: dev(dev_), cgCtx(cgCtx_), video_info(*video_info), tracker(NULL),
final_viewport(final_viewport_), frame_count(0)
{}
bool RenderChain::init(const LinkInfo &info, PixelFormat fmt)
@ -225,8 +228,10 @@ bool RenderChain::add_lut(const std::string &id,
return true;
}
void RenderChain::add_state_tracker(std::shared_ptr<state_tracker_t> tracker)
void RenderChain::add_state_tracker(state_tracker_t *tracker)
{
if (this->tracker)
state_tracker_free(this->tracker);
this->tracker = tracker;
}
@ -1137,7 +1142,7 @@ void RenderChain::bind_tracker(Pass &pass, unsigned pass_index)
return;
if (pass_index == 1)
uniform_cnt = state_get_uniform(tracker.get(), uniform_info, MAX_VARIABLES, frame_count);
uniform_cnt = state_get_uniform(tracker, uniform_info, MAX_VARIABLES, frame_count);
for (unsigned i = 0; i < uniform_cnt; i++)
{

View File

@ -21,7 +21,6 @@
#include "../shader_parse.h"
#include <map>
#include <utility>
#include <memory>
struct Vertex
{
@ -56,7 +55,7 @@ class RenderChain
void set_final_viewport(const D3DVIEWPORT9 &final_viewport);
bool add_pass(const LinkInfo &info);
bool add_lut(const std::string &id, const std::string &path, bool smooth);
void add_state_tracker(std::shared_ptr<state_tracker_t> tracker);
void add_state_tracker(state_tracker_t *tracker);
bool render(const void *data,
unsigned width, unsigned height, unsigned pitch, unsigned rotation);
@ -79,7 +78,7 @@ class RenderChain
const video_info_t &video_info;
#define MAX_VARIABLES 64
std::shared_ptr<state_tracker_t> tracker;
state_tracker_t *tracker;
struct state_tracker_uniform uniform_info[MAX_VARIABLES];
unsigned uniform_cnt;