blob: 123449f4e6eb84d0c401cf146daf9b9ec4d81349 [file] [log] [blame]
mtkleinfe81e2d2015-09-09 07:35:42 -07001/*
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
caryclark17f0b6d2014-07-22 10:15:34 -07008#include "SkApplication.h"
yangsu@google.com688823f2011-08-30 19:14:13 +00009#import "SkCanvas.h"
10#import "SkPaint.h"
11#import "SkWindow.h"
12#include "SkGraphics.h"
13#include "SkCGUtils.h"
caryclark@google.com5987f582012-10-02 18:33:14 +000014
caryclark17f0b6d2014-07-22 10:15:34 -070015void dummy_main(int , char *[]) {
16}
caryclark@google.com5987f582012-10-02 18:33:14 +000017
yangsu@google.com688823f2011-08-30 19:14:13 +000018class 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);
caryclark@google.com5987f582012-10-02 18:33:14 +000030 canvas->drawText("finished", 13, 50, 30, p);
yangsu@google.com688823f2011-08-30 19:14:13 +000031 SkRect r = {50, 50, 80, 80};
32 p.setColor(0xAA11EEAA);
33 canvas->drawRect(r, p);
34 }
35private:
mtkleinfe81e2d2015-09-09 07:35:42 -070036 typedef SkView INHERITED;
yangsu@google.com688823f2011-08-30 19:14:13 +000037};
38
39void application_init() {
40 SkGraphics::Init();
41 SkEvent::Init();
42}
43
44void application_term() {
yangsu@google.com688823f2011-08-30 19:14:13 +000045 SkEvent::Term();
46}
47
caryclark@google.com5987f582012-10-02 18:33:14 +000048int saved_argc;
49char** saved_argv;
50
caryclark17f0b6d2014-07-22 10:15:34 -070051IOS_launch_type set_cmd_line_args(int argc, char *argv[], const char* ) {
caryclark@google.com5987f582012-10-02 18:33:14 +000052 saved_argc = argc;
53 saved_argv = argv;
caryclark17f0b6d2014-07-22 10:15:34 -070054 return kTool_iOSLaunchType;
caryclark@google.com5987f582012-10-02 18:33:14 +000055}
56
yangsu@google.com688823f2011-08-30 19:14:13 +000057class 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 {
caryclark17f0b6d2014-07-22 10:15:34 -070069 dummy_main(saved_argc, saved_argv);
yangsu@google.com688823f2011-08-30 19:14:13 +000070 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