2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "Resources.h"
11 #include "SkApplication.h"
13 #include "SkCommonFlags.h"
14 #include "SkGraphics.h"
16 #include "sk_tool_utils.h"
18 //////////////////////////////////////////////////////////////////////////////
20 static SkView* curr_view(SkWindow* wind) {
21 SkView::F2BIter iter(wind);
25 ShellWindow::ShellWindow(void* hwnd, int argc, char** argv)
27 SkCommandLineFlags::Parse(argc, argv);
30 ShellWindow::~ShellWindow() {
33 ///////////////////////////////////////////////////////////////////////////////
35 bool ShellWindow::onDispatchClick(int x, int y, Click::State state,
36 void* owner, unsigned modi) {
37 int w = SkScalarRoundToInt(this->width());
38 int h = SkScalarRoundToInt(this->height());
40 // check for the resize-box
41 if (w - x < 16 && h - y < 16) {
42 return false; // let the OS handle the click
44 return this->INHERITED::onDispatchClick(x, y, state, owner, modi);
48 void ShellWindow::onSizeChange() {
49 this->INHERITED::onSizeChange();
51 SkView::F2BIter iter(this);
52 SkView* view = iter.next();
53 view->setSize(this->width(), this->height());
56 DEFINE_bool(dm, false, "run dm");
57 DEFINE_bool(nanobench, false, "run nanobench");
62 IOS_launch_type set_cmd_line_args(int argc, char *argv[], const char* resourceDir) {
63 SkCommandLineFlags::Parse(argc, argv);
64 SetResourcePath(resourceDir);
65 if (FLAGS_nanobench) {
66 return nanobench_main() ? kError_iOSLaunchType : kTool_iOSLaunchType;
69 return dm_main() ? kError_iOSLaunchType : kTool_iOSLaunchType;
71 return kError_iOSLaunchType;
74 // FIXME: this should be in a header
75 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv);
76 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
77 return new ShellWindow(hwnd, argc, argv);
80 // FIXME: this should be in a header
81 void get_preferred_size(int* x, int* y, int* width, int* height);
82 void get_preferred_size(int* x, int* y, int* width, int* height) {
89 // FIXME: this should be in a header
90 void application_init();
91 void application_init() {
96 // FIXME: this should be in a header
97 void application_term();
98 void application_term() {