2012-03-28 16:20:21 +00:00
|
|
|
#include "EdgeDemo.h"
|
2012-03-27 13:23:51 +00:00
|
|
|
#import "SkCanvas.h"
|
|
|
|
#import "SkWindow.h"
|
|
|
|
#include "SkGraphics.h"
|
|
|
|
#include "SkCGUtils.h"
|
|
|
|
|
2012-08-21 13:13:52 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
2012-03-27 13:23:51 +00:00
|
|
|
class SkSampleView : public SkView {
|
|
|
|
public:
|
|
|
|
SkSampleView() {
|
|
|
|
this->setVisibleP(true);
|
|
|
|
this->setClipToBounds(false);
|
2012-10-31 19:00:20 +00:00
|
|
|
useOld = false;
|
2012-03-27 13:23:51 +00:00
|
|
|
};
|
|
|
|
protected:
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
2012-11-09 22:14:19 +00:00
|
|
|
static int step = 0; // 17907 drawLetters first error
|
2012-10-31 19:00:20 +00:00
|
|
|
// drawStars triggers error at 33348
|
2012-10-19 15:54:16 +00:00
|
|
|
// drawStars error not easy to debug last time I checked
|
2012-08-21 13:13:52 +00:00
|
|
|
static double seconds;
|
|
|
|
if (step == -1) {
|
|
|
|
timeval t;
|
|
|
|
gettimeofday(&t, NULL);
|
|
|
|
seconds = t.tv_sec+t.tv_usec/1000000.0;
|
|
|
|
step = 0;
|
|
|
|
}
|
2012-03-28 16:20:21 +00:00
|
|
|
canvas->drawColor(SK_ColorWHITE);
|
2012-08-21 13:13:52 +00:00
|
|
|
if (DrawEdgeDemo(canvas, step, useOld)) {
|
2012-03-28 16:20:21 +00:00
|
|
|
++step;
|
2012-10-31 19:00:20 +00:00
|
|
|
if (step == -1) {
|
2012-08-21 13:13:52 +00:00
|
|
|
timeval t;
|
|
|
|
gettimeofday(&t, NULL);
|
|
|
|
double last = seconds;
|
|
|
|
seconds = t.tv_sec+t.tv_usec/1000000.0;
|
|
|
|
SkDebugf("old=%d seconds=%g\n", useOld, seconds - last);
|
|
|
|
useOld ^= true;
|
|
|
|
step = 0;
|
|
|
|
}
|
2012-03-28 16:20:21 +00:00
|
|
|
inval(NULL);
|
2012-03-27 13:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-27 14:11:33 +00:00
|
|
|
|
|
|
|
virtual Click* onFindClickHandler(SkScalar , SkScalar ) {
|
|
|
|
useOld ^= true;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-27 13:23:51 +00:00
|
|
|
private:
|
2012-08-27 14:11:33 +00:00
|
|
|
bool useOld;
|
2012-03-27 13:23:51 +00:00
|
|
|
typedef SkView INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-08-23 15:24:42 +00:00
|
|
|
void application_init();
|
|
|
|
void application_term();
|
|
|
|
|
2012-03-27 13:23:51 +00:00
|
|
|
void application_init() {
|
|
|
|
SkGraphics::Init();
|
|
|
|
SkEvent::Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void application_term() {
|
|
|
|
SkGraphics::Term();
|
|
|
|
SkEvent::Term();
|
|
|
|
}
|
|
|
|
|
|
|
|
class FillLayout : public SkView::Layout {
|
|
|
|
protected:
|
|
|
|
virtual void onLayoutChildren(SkView* parent) {
|
|
|
|
SkView* view = SkView::F2BIter(parent).next();
|
|
|
|
view->setSize(parent->width(), parent->height());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#import "SimpleApp.h"
|
2012-03-28 16:20:21 +00:00
|
|
|
|
2012-03-27 13:23:51 +00:00
|
|
|
@implementation SimpleNSView
|
|
|
|
|
|
|
|
- (id)initWithDefaults {
|
2012-08-23 15:24:42 +00:00
|
|
|
if ((self = [super initWithDefaults])) {
|
2012-03-27 13:23:51 +00:00
|
|
|
fWind = new SkOSWindow(self);
|
|
|
|
fWind->setLayout(new FillLayout, false);
|
|
|
|
fWind->attachChildToFront(new SkSampleView)->unref();
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)dirtyRect {
|
|
|
|
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
|
|
|
SkCGDrawBitmap(ctx, fWind->getBitmap(), 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|