bozmillar
02-17-2011, 12:08 PM
I'm working on a spectrograph. It all works, but drawing out the spectrograph is pretty hard on my CPU. The processing thread is doing very little work (1%).
I'm trying to pin it down, and I'm noticing that my FillIRect() functions are pretty draining, especially if I draw a large rectangle. For example, I have a DrawBG() function that draws a rectangle the size of the canvas and that alone takes 40-45% of my CPU. Is there a more efficient way to make a gray background that doesn't involve making a bitmap? (I'd like the size to be dynamic.)
Edit:
Ok, so for a little more background, here is a class called DrawBG. It basically draws a rectangle:
#include "Sampler.h"
class DrawBG : public IControl
{
public:
DrawBG(IPlugBase *pPlug, int x, int y, int Width, int Height, int paramIdx)
: IControl(pPlug, &IRECT(x,y,x+Width,y+Height )){}
bool Draw(IGraphics* pGraphics);
//bool IsDirty(){return false;}
private:
IPlugBase *m_pPlug;
};
and
#include "DrawBG.h"
bool DrawBG::Draw(IGraphics* pGraphics)
{
IColor color1(255, 100, 100, 100);
pGraphics->FillIRect(&color1, &mRECT, 0);
return true;
}
(yes, it's a dumb as it looks, it just draws a rectangle) But if the rectangle is big, it chews up my CPU. Is Draw() really being called only 24 times a second? Why would this be such a hog?
Update: I have confirmed that Draw() is only gets called 24 times a second. Is FillIRect() just an extremely inefficient way to draw a rectangle?
I'm trying to pin it down, and I'm noticing that my FillIRect() functions are pretty draining, especially if I draw a large rectangle. For example, I have a DrawBG() function that draws a rectangle the size of the canvas and that alone takes 40-45% of my CPU. Is there a more efficient way to make a gray background that doesn't involve making a bitmap? (I'd like the size to be dynamic.)
Edit:
Ok, so for a little more background, here is a class called DrawBG. It basically draws a rectangle:
#include "Sampler.h"
class DrawBG : public IControl
{
public:
DrawBG(IPlugBase *pPlug, int x, int y, int Width, int Height, int paramIdx)
: IControl(pPlug, &IRECT(x,y,x+Width,y+Height )){}
bool Draw(IGraphics* pGraphics);
//bool IsDirty(){return false;}
private:
IPlugBase *m_pPlug;
};
and
#include "DrawBG.h"
bool DrawBG::Draw(IGraphics* pGraphics)
{
IColor color1(255, 100, 100, 100);
pGraphics->FillIRect(&color1, &mRECT, 0);
return true;
}
(yes, it's a dumb as it looks, it just draws a rectangle) But if the rectangle is big, it chews up my CPU. Is Draw() really being called only 24 times a second? Why would this be such a hog?
Update: I have confirmed that Draw() is only gets called 24 times a second. Is FillIRect() just an extremely inefficient way to draw a rectangle?