c4cae85752
call these new procs in (nearly) all the places we had inlined loops before. In once instance (blitter_argb32::blitAntiH) we get different results by a tiny bit. The new code is more accurate, and exactly inline with all of the other like-minded blits, so I think the change is good going forward. git-svn-id: http://skia.googlecode.com/svn/trunk@366 2bbb7eff-a529-9590-31e7-b0007b416f81
85 lines
1.6 KiB
C++
85 lines
1.6 KiB
C++
#include "SampleCode.h"
|
|
#include "SkView.h"
|
|
#include "SkCanvas.h"
|
|
|
|
#include "gm.h"
|
|
|
|
using namespace skiagm;
|
|
|
|
GM::GM() {}
|
|
GM::~GM() {}
|
|
|
|
void GM::draw(SkCanvas* canvas) {
|
|
this->onDraw(canvas);
|
|
}
|
|
|
|
// need to explicitly declare this, or we get some weird infinite loop llist
|
|
template GMRegistry* GMRegistry::gHead;
|
|
|
|
class Iter {
|
|
public:
|
|
Iter() {
|
|
fReg = GMRegistry::Head();
|
|
}
|
|
|
|
GM* next() {
|
|
if (fReg) {
|
|
GMRegistry::Factory fact = fReg->factory();
|
|
fReg = fReg->next();
|
|
return fact(0);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static int Count() {
|
|
const GMRegistry* reg = GMRegistry::Head();
|
|
int count = 0;
|
|
while (reg) {
|
|
count += 1;
|
|
reg = reg->next();
|
|
}
|
|
return count;
|
|
}
|
|
|
|
private:
|
|
const GMRegistry* fReg;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
class GMView : public SkView {
|
|
Iter fIter;
|
|
GM* fGM;
|
|
public:
|
|
GMView() {
|
|
fGM = fIter.next();
|
|
}
|
|
|
|
protected:
|
|
// overrides from SkEventSink
|
|
virtual bool onQuery(SkEvent* evt) {
|
|
if (SampleCode::TitleQ(*evt)) {
|
|
SampleCode::TitleR(evt, "GM");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
void drawBG(SkCanvas* canvas) {
|
|
canvas->drawColor(0xFFDDDDDD);
|
|
}
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
fGM->draw(canvas);
|
|
}
|
|
|
|
private:
|
|
typedef SkView INHERITED;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static SkView* MyFactory() { return new GMView; }
|
|
static SkViewRegister reg(MyFactory);
|
|
|