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

Side by Side Diff: src/views/mac/skia_mac.mm

Issue 2229853002: Sample app uses Ganesh before calling SkGraphics::Init(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | src/views/unix/skia_unix.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include <crt_externs.h> 9 #include <crt_externs.h>
10 #import <Cocoa/Cocoa.h> 10 #import <Cocoa/Cocoa.h>
11 #include "SkApplication.h" 11 #include "SkApplication.h"
12 #include "SkGraphics.h"
12 #include "SkNSView.h" 13 #include "SkNSView.h"
13 14
14 @interface MainView : SkNSView { 15 @interface MainView : SkNSView {
15 } 16 }
16 - (id)initWithFrame: (NSRect)frame ; 17 - (id)initWithFrame: (NSRect)frame ;
17 - (void)dealloc; 18 - (void)dealloc;
18 - (void)begin; 19 - (void)begin;
19 @end 20 @end
20 21
21 @implementation MainView : SkNSView 22 @implementation MainView : SkNSView
(...skipping 26 matching lines...) Expand all
48 self = [super init]; 49 self = [super init];
49 return self; 50 return self;
50 } 51 }
51 52
52 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl ication { 53 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl ication {
53 return TRUE; 54 return TRUE;
54 } 55 }
55 @end 56 @end
56 57
57 int main(int argc, char *argv[]) { 58 int main(int argc, char *argv[]) {
59 SkGraphics::Init();
58 signal(SIGPIPE, SIG_IGN); 60 signal(SIGPIPE, SIG_IGN);
59 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 61 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
60 62
61 NSApplication* app = [NSApplication sharedApplication]; 63 NSApplication* app = [NSApplication sharedApplication];
62 64
63 NSUInteger windowStyle = (NSTitledWindowMask | NSClosableWindowMask | NSResi zableWindowMask | NSMiniaturizableWindowMask); 65 NSUInteger windowStyle = (NSTitledWindowMask | NSClosableWindowMask | NSResi zableWindowMask | NSMiniaturizableWindowMask);
64 66
65 NSRect windowRect = NSMakeRect(100, 100, 1000, 1000); 67 NSRect windowRect = NSMakeRect(100, 100, 1000, 1000);
66 NSWindow* window = [[NSWindow alloc] initWithContentRect:windowRect styleMas k:windowStyle backing:NSBackingStoreBuffered defer:NO]; 68 NSWindow* window = [[NSWindow alloc] initWithContentRect:windowRect styleMas k:windowStyle backing:NSBackingStoreBuffered defer:NO];
67 69
68 NSRect rect = [NSWindow contentRectForFrameRect:windowRect styleMask:windowS tyle]; 70 NSRect rect = [NSWindow contentRectForFrameRect:windowRect styleMask:windowS tyle];
69 MainView* customView = [[MainView alloc] initWithFrame:rect]; 71 MainView* customView = [[MainView alloc] initWithFrame:rect];
70 [customView setTranslatesAutoresizingMaskIntoConstraints:NO]; 72 [customView setTranslatesAutoresizingMaskIntoConstraints:NO];
71 NSView* contentView = window.contentView; 73 NSView* contentView = window.contentView;
72 [contentView addSubview:customView]; 74 [contentView addSubview:customView];
73 NSDictionary *views = NSDictionaryOfVariableBindings(customView); 75 NSDictionary *views = NSDictionaryOfVariableBindings(customView);
74 76
75 [contentView addConstraints: 77 [contentView addConstraints:
76 [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|" 78 [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|"
77 options:0 79 options:0
78 metrics:nil 80 metrics:nil
79 views:views]]; 81 views:views]];
80 82
81 [contentView addConstraints: 83 [contentView addConstraints:
82 [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[customView]|" 84 [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[customView]|"
83 options:0 85 options:0
84 metrics:nil 86 metrics:nil
85 views:views]]; 87 views:views]];
86 88
87 [customView begin]; 89 [customView begin];
88 [customView release]; 90 [customView release];
89 91
90 [window makeKeyAndOrderFront:NSApp]; 92 [window makeKeyAndOrderFront:NSApp];
91 93
92 AppDelegate * appDelegate = [[[AppDelegate alloc] init] autorelease]; 94 AppDelegate * appDelegate = [[[AppDelegate alloc] init] autorelease];
93 95
94 app.delegate = appDelegate; 96 app.delegate = appDelegate;
95 97
96 NSMenu* menu=[[NSMenu alloc] initWithTitle:@"AMainMenu"]; 98 NSMenu* menu=[[NSMenu alloc] initWithTitle:@"AMainMenu"];
97 NSMenuItem* item; 99 NSMenuItem* item;
98 NSMenu* subMenu; 100 NSMenu* subMenu;
99 101
100 //Create the application menu. 102 //Create the application menu.
101 item=[[NSMenuItem alloc] initWithTitle:@"Apple" action:NULL keyEquivalent:@" "]; 103 item=[[NSMenuItem alloc] initWithTitle:@"Apple" action:NULL keyEquivalent:@" "];
102 [menu addItem:item]; 104 [menu addItem:item];
103 subMenu=[[NSMenu alloc] initWithTitle:@"Apple"]; 105 subMenu=[[NSMenu alloc] initWithTitle:@"Apple"];
104 [menu setSubmenu:subMenu forItem:item]; 106 [menu setSubmenu:subMenu forItem:item];
105 [item release]; 107 [item release];
106 item=[[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; 108 item=[[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
107 [subMenu addItem:item]; 109 [subMenu addItem:item];
108 [item release]; 110 [item release];
109 [subMenu release]; 111 [subMenu release];
110 112
111 //Add the menu to the app. 113 //Add the menu to the app.
112 [app setMenu:menu]; 114 [app setMenu:menu];
113 115
114 [app setActivationPolicy:NSApplicationActivationPolicyRegular]; 116 [app setActivationPolicy:NSApplicationActivationPolicyRegular];
115 117
116 [app run]; 118 [app run];
117 119
118 [menu release]; 120 [menu release];
119 [appDelegate release]; 121 [appDelegate release];
120 [window release]; 122 [window release];
121 [pool release]; 123 [pool release];
122 124
123 return EXIT_SUCCESS; 125 return EXIT_SUCCESS;
124 } 126 }
OLDNEW
« no previous file with comments | « no previous file | src/views/unix/skia_unix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698