Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1065)

Side by Side Diff: tools/iOSShell.cpp

Issue 373383003: ios fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: only build gyp on ios Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/iOSShell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 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 "iOSShell.h"
9
10 #include "Resources.h"
11 #include "SkCanvas.h"
12 #include "SkCommandLineFlags.h"
13 #include "SkGraphics.h"
14 #include "SkWindow.h"
15 #include "sk_tool_utils.h"
16
17 //////////////////////////////////////////////////////////////////////////////
18
19 static SkView* curr_view(SkWindow* wind) {
20 SkView::F2BIter iter(wind);
21 return iter.next();
22 }
23
24 ShellWindow::ShellWindow(void* hwnd, int argc, char** argv)
25 : INHERITED(hwnd) {
26 SkCommandLineFlags::Parse(argc, argv);
27 }
28
29 ShellWindow::~ShellWindow() {
30 }
31
32 ///////////////////////////////////////////////////////////////////////////////
33
34 bool ShellWindow::onDispatchClick(int x, int y, Click::State state,
35 void* owner, unsigned modi) {
36 int w = SkScalarRoundToInt(this->width());
37 int h = SkScalarRoundToInt(this->height());
38
39 // check for the resize-box
40 if (w - x < 16 && h - y < 16) {
41 return false; // let the OS handle the click
42 } else {
43 return this->INHERITED::onDispatchClick(x, y, state, owner, modi);
44 }
45 }
46
47 void ShellWindow::onSizeChange() {
48 this->INHERITED::onSizeChange();
49
50 SkView::F2BIter iter(this);
51 SkView* view = iter.next();
52 view->setSize(this->width(), this->height());
53 }
54
55 void tool_main(int argc, char *argv[]);
56
57 bool set_cmd_line_args(int argc, char *argv[], const char* resourceDir) {
58 for (int index = 0; index < argc; ++index) {
59 if (!strcmp("--test", argv[index])) {
60 SetResourcePath(resourceDir);
61 tool_main(argc - 1, argv);
62 return true;
63 }
64 }
65 return false;
66 }
67
68 // FIXME: this should be in a header
69 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv);
70 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
71 return new ShellWindow(hwnd, argc, argv);
72 }
73
74 // FIXME: this should be in a header
75 void get_preferred_size(int* x, int* y, int* width, int* height);
76 void get_preferred_size(int* x, int* y, int* width, int* height) {
77 *x = 10;
78 *y = 50;
79 *width = 640;
80 *height = 480;
81 }
82
83 // FIXME: this should be in a header
84 void application_init();
85 void application_init() {
86 SkGraphics::Init();
87 SkEvent::Init();
88 }
89
90 // FIXME: this should be in a header
91 void application_term();
92 void application_term() {
93 SkEvent::Term();
94 SkGraphics::Term();
95 }
OLDNEW
« no previous file with comments | « tools/iOSShell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698