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

Side by Side Diff: sky/shell/ios/sky_surface.mm

Issue 1187503003: Refactor SkyShell to allow multiple SkyViews (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: s/instance/sky_shell/ Created 5 years, 6 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 | « sky/shell/ios/sky_surface.h ('k') | sky/shell/ios/sky_view_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "sky_surface.h" 5 #import "sky_surface.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 #import <OpenGLES/EAGL.h> 8 #import <OpenGLES/EAGL.h>
9 #import <OpenGLES/EAGLDrawable.h> 9 #import <OpenGLES/EAGLDrawable.h>
10 10
11 #include "sky/shell/ios/platform_view_ios.h"
12 #include "sky/shell/shell.h"
13 #include "sky/shell/shell_view.h"
11 #include "sky/shell/ui_delegate.h" 14 #include "sky/shell/ui_delegate.h"
12 #include "sky/shell/shell.h"
13 #include "sky/shell/ios/platform_view_ios.h"
14 15
15 #include "mojo/public/cpp/bindings/interface_request.h" 16 #include "mojo/public/cpp/bindings/interface_request.h"
16 #include "sky/services/viewport/input_event.mojom.h" 17 #include "sky/services/viewport/input_event.mojom.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 19
19 static inline sky::EventType EventTypeFromUITouchPhase(UITouchPhase phase) { 20 static inline sky::EventType EventTypeFromUITouchPhase(UITouchPhase phase) {
20 switch (phase) { 21 switch (phase) {
21 case UITouchPhaseBegan: 22 case UITouchPhaseBegan:
22 return sky::EVENT_TYPE_POINTER_DOWN; 23 return sky::EVENT_TYPE_POINTER_DOWN;
23 case UITouchPhaseMoved: 24 case UITouchPhaseMoved:
24 case UITouchPhaseStationary: 25 case UITouchPhaseStationary:
25 // There is no EVENT_TYPE_POINTER_STATIONARY. So we just pass a move type 26 // There is no EVENT_TYPE_POINTER_STATIONARY. So we just pass a move type
26 // with the same coordinates 27 // with the same coordinates
27 return sky::EVENT_TYPE_POINTER_MOVE; 28 return sky::EVENT_TYPE_POINTER_MOVE;
28 case UITouchPhaseEnded: 29 case UITouchPhaseEnded:
29 return sky::EVENT_TYPE_POINTER_UP; 30 return sky::EVENT_TYPE_POINTER_UP;
30 case UITouchPhaseCancelled: 31 case UITouchPhaseCancelled:
31 return sky::EVENT_TYPE_POINTER_CANCEL; 32 return sky::EVENT_TYPE_POINTER_CANCEL;
32 } 33 }
33 34
34 return sky::EVENT_TYPE_UNKNOWN; 35 return sky::EVENT_TYPE_UNKNOWN;
35 } 36 }
36 37
37 @implementation SkySurface { 38 @implementation SkySurface {
38 BOOL _platformViewInitialized; 39 BOOL _platformViewInitialized;
39 40
40 sky::ViewportObserverPtr _viewport_observer; 41 sky::ViewportObserverPtr _viewport_observer;
42 scoped_ptr<sky::shell::ShellView> _shell_view;
43 }
44
45 -(instancetype) initWithShellView:(sky::shell::ShellView *) shellView {
46 self = [super init];
47 if (self)
48 _shell_view.reset(shellView);
49 return self;
41 } 50 }
42 51
43 - (gfx::AcceleratedWidget)acceleratedWidget { 52 - (gfx::AcceleratedWidget)acceleratedWidget {
44 return (gfx::AcceleratedWidget)self.layer; 53 return (gfx::AcceleratedWidget)self.layer;
45 } 54 }
46 55
47 - (void)layoutSubviews { 56 - (void)layoutSubviews {
48 [super layoutSubviews]; 57 [super layoutSubviews];
49 58
50 [self configureLayerDefaults]; 59 [self configureLayerDefaults];
(...skipping 22 matching lines...) Expand all
73 return; 82 return;
74 } 83 }
75 84
76 _platformViewInitialized = YES; 85 _platformViewInitialized = YES;
77 86
78 [self notifySurfaceCreation]; 87 [self notifySurfaceCreation];
79 [self connectToViewportObserverAndLoad]; 88 [self connectToViewportObserverAndLoad];
80 } 89 }
81 90
82 - (sky::shell::PlatformViewIOS*)platformView { 91 - (sky::shell::PlatformViewIOS*)platformView {
83 auto view = static_cast<sky::shell::PlatformViewIOS*>( 92 auto view = static_cast<sky::shell::PlatformViewIOS*>(_shell_view->view());
84 sky::shell::Shell::Shared().view());
85 DCHECK(view); 93 DCHECK(view);
86 return view; 94 return view;
87 } 95 }
88 96
89 - (void)notifySurfaceCreation { 97 - (void)notifySurfaceCreation {
90 self.platformView->SurfaceCreated(self.acceleratedWidget); 98 self.platformView->SurfaceCreated(self.acceleratedWidget);
91 } 99 }
92 100
93 - (NSString*)skyInitialLoadURL { 101 - (NSString*)skyInitialLoadURL {
94 return [NSBundle mainBundle].infoDictionary[@"com.google.sky.load_url"]; 102 return [NSBundle mainBundle].infoDictionary[@"com.google.sky.load_url"];
95 } 103 }
96 104
97 - (void)connectToViewportObserverAndLoad { 105 - (void)connectToViewportObserverAndLoad {
98 auto view = sky::shell::Shell::Shared().view(); 106 auto view = static_cast<sky::shell::PlatformViewIOS*>(_shell_view->view());
99 auto interface_request = mojo::GetProxy(&_viewport_observer); 107 auto interface_request = mojo::GetProxy(&_viewport_observer);
100 view->ConnectToViewportObserver(interface_request.Pass()); 108 view->ConnectToViewportObserver(interface_request.Pass());
101 109
102 mojo::String string(self.skyInitialLoadURL.UTF8String); 110 mojo::String string(self.skyInitialLoadURL.UTF8String);
103 _viewport_observer->LoadURL(string); 111 _viewport_observer->LoadURL(string);
104 } 112 }
105 113
106 - (void)notifySurfaceDestruction { 114 - (void)notifySurfaceDestruction {
107 self.platformView->SurfaceDestroyed(); 115 self.platformView->SurfaceDestroyed();
108 } 116 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 + (Class)layerClass { 161 + (Class)layerClass {
154 return [CAEAGLLayer class]; 162 return [CAEAGLLayer class];
155 } 163 }
156 164
157 - (void)dealloc { 165 - (void)dealloc {
158 [self notifySurfaceDestruction]; 166 [self notifySurfaceDestruction];
159 [super dealloc]; 167 [super dealloc];
160 } 168 }
161 169
162 @end 170 @end
OLDNEW
« no previous file with comments | « sky/shell/ios/sky_surface.h ('k') | sky/shell/ios/sky_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698