1/* 2 * Copyright 2015 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#include "SkApplication.h" 9#import "SkCanvas.h" 10#import "SkPaint.h" 11#import "SkWindow.h" 12#include "SkGraphics.h" 13#include "SkCGUtils.h" 14 15void dummy_main(int , char *[]) { 16} 17 18class SkSampleView : public SkView { 19public: 20 SkSampleView() { 21 this->setVisibleP(true); 22 this->setClipToBounds(false); 23 }; 24protected: 25 virtual void onDraw(SkCanvas* canvas) { 26 canvas->drawColor(0xFFFFFFFF); 27 SkPaint p; 28 p.setTextSize(20); 29 p.setAntiAlias(true); 30 canvas->drawText("finished", 13, 50, 30, p); 31 SkRect r = {50, 50, 80, 80}; 32 p.setColor(0xAA11EEAA); 33 canvas->drawRect(r, p); 34 } 35private: 36 typedef SkView INHERITED; 37}; 38 39void application_init() { 40 SkGraphics::Init(); 41 SkEvent::Init(); 42} 43 44void application_term() { 45 SkEvent::Term(); 46} 47 48int saved_argc; 49char** saved_argv; 50 51IOS_launch_type set_cmd_line_args(int argc, char *argv[], const char* ) { 52 saved_argc = argc; 53 saved_argv = argv; 54 return kTool_iOSLaunchType; 55} 56 57class FillLayout : public SkView::Layout { 58protected: 59 virtual void onLayoutChildren(SkView* parent) { 60 SkView* view = SkView::F2BIter(parent).next(); 61 view->setSize(parent->width(), parent->height()); 62 } 63}; 64 65#import "SimpleApp.h" 66@implementation SimpleApp 67 68- (id)initWithDefaults { 69 dummy_main(saved_argc, saved_argv); 70 if (self = [super initWithDefaults]) { 71 fWind = new SkOSWindow(self); 72 fWind->setLayout(new FillLayout, false); 73 fWind->attachChildToFront(new SkSampleView)->unref(); 74 } 75 return self; 76} 77 78@end 79