caryclark@google.com | a576423 | 2012-03-28 16:20:21 +0000 | [diff] [blame^] | 1 | #include "EdgeDemo.h" |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 2 | #import "SkCanvas.h" |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 3 | #import "SkWindow.h" |
| 4 | #include "SkGraphics.h" |
| 5 | #include "SkCGUtils.h" |
| 6 | |
| 7 | class SkSampleView : public SkView { |
| 8 | public: |
| 9 | SkSampleView() { |
| 10 | this->setVisibleP(true); |
| 11 | this->setClipToBounds(false); |
| 12 | }; |
| 13 | protected: |
| 14 | virtual void onDraw(SkCanvas* canvas) { |
caryclark@google.com | a576423 | 2012-03-28 16:20:21 +0000 | [diff] [blame^] | 15 | static int step = 0; |
| 16 | canvas->drawColor(SK_ColorWHITE); |
| 17 | if (DrawEdgeDemo(canvas, step)) { |
| 18 | ++step; |
| 19 | inval(NULL); |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 20 | } |
| 21 | } |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 22 | private: |
| 23 | typedef SkView INHERITED; |
| 24 | }; |
| 25 | |
| 26 | void application_init() { |
| 27 | SkGraphics::Init(); |
| 28 | SkEvent::Init(); |
| 29 | } |
| 30 | |
| 31 | void application_term() { |
| 32 | SkGraphics::Term(); |
| 33 | SkEvent::Term(); |
| 34 | } |
| 35 | |
| 36 | class FillLayout : public SkView::Layout { |
| 37 | protected: |
| 38 | virtual void onLayoutChildren(SkView* parent) { |
| 39 | SkView* view = SkView::F2BIter(parent).next(); |
| 40 | view->setSize(parent->width(), parent->height()); |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | #import "SimpleApp.h" |
caryclark@google.com | a576423 | 2012-03-28 16:20:21 +0000 | [diff] [blame^] | 45 | |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 46 | @implementation SimpleNSView |
| 47 | |
| 48 | - (id)initWithDefaults { |
| 49 | if (self = [super initWithDefaults]) { |
| 50 | fWind = new SkOSWindow(self); |
| 51 | fWind->setLayout(new FillLayout, false); |
| 52 | fWind->attachChildToFront(new SkSampleView)->unref(); |
| 53 | } |
| 54 | return self; |
| 55 | } |
| 56 | |
| 57 | - (void)drawRect:(NSRect)dirtyRect { |
| 58 | CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; |
| 59 | SkCGDrawBitmap(ctx, fWind->getBitmap(), 0, 0); |
| 60 | } |
| 61 | |
| 62 | @end |