| OLD | NEW |
| 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 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 return sky::EVENT_TYPE_POINTER_CANCEL; | 31 return sky::EVENT_TYPE_POINTER_CANCEL; |
| 32 } | 32 } |
| 33 | 33 |
| 34 return sky::EVENT_TYPE_UNKNOWN; | 34 return sky::EVENT_TYPE_UNKNOWN; |
| 35 } | 35 } |
| 36 | 36 |
| 37 @implementation SkySurface { | 37 @implementation SkySurface { |
| 38 BOOL _platformViewInitialized; | 38 BOOL _platformViewInitialized; |
| 39 | 39 |
| 40 sky::ViewportObserverPtr _viewport_observer; | 40 sky::ViewportObserverPtr _viewport_observer; |
| 41 scoped_ptr<sky::shell::Instance> _instance; |
| 42 } |
| 43 |
| 44 -(instancetype) initWithSkyInstance:(sky::shell::Instance *) instance { |
| 45 self = [super init]; |
| 46 if (self) |
| 47 _instance.reset(instance); |
| 48 return self; |
| 41 } | 49 } |
| 42 | 50 |
| 43 - (gfx::AcceleratedWidget)acceleratedWidget { | 51 - (gfx::AcceleratedWidget)acceleratedWidget { |
| 44 return (gfx::AcceleratedWidget)self.layer; | 52 return (gfx::AcceleratedWidget)self.layer; |
| 45 } | 53 } |
| 46 | 54 |
| 47 - (void)layoutSubviews { | 55 - (void)layoutSubviews { |
| 48 [super layoutSubviews]; | 56 [super layoutSubviews]; |
| 49 | 57 |
| 50 [self configureLayerDefaults]; | 58 [self configureLayerDefaults]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 73 return; | 81 return; |
| 74 } | 82 } |
| 75 | 83 |
| 76 _platformViewInitialized = YES; | 84 _platformViewInitialized = YES; |
| 77 | 85 |
| 78 [self notifySurfaceCreation]; | 86 [self notifySurfaceCreation]; |
| 79 [self connectToViewportObserverAndLoad]; | 87 [self connectToViewportObserverAndLoad]; |
| 80 } | 88 } |
| 81 | 89 |
| 82 - (sky::shell::PlatformViewIOS*)platformView { | 90 - (sky::shell::PlatformViewIOS*)platformView { |
| 83 auto view = static_cast<sky::shell::PlatformViewIOS*>( | 91 auto view = static_cast<sky::shell::PlatformViewIOS*>(_instance->view()); |
| 84 sky::shell::Shell::Shared().view()); | |
| 85 DCHECK(view); | 92 DCHECK(view); |
| 86 return view; | 93 return view; |
| 87 } | 94 } |
| 88 | 95 |
| 89 - (void)notifySurfaceCreation { | 96 - (void)notifySurfaceCreation { |
| 90 self.platformView->SurfaceCreated(self.acceleratedWidget); | 97 self.platformView->SurfaceCreated(self.acceleratedWidget); |
| 91 } | 98 } |
| 92 | 99 |
| 93 - (NSString*)skyInitialLoadURL { | 100 - (NSString*)skyInitialLoadURL { |
| 94 return [NSBundle mainBundle].infoDictionary[@"com.google.sky.load_url"]; | 101 return [NSBundle mainBundle].infoDictionary[@"com.google.sky.load_url"]; |
| 95 } | 102 } |
| 96 | 103 |
| 97 - (void)connectToViewportObserverAndLoad { | 104 - (void)connectToViewportObserverAndLoad { |
| 98 auto view = sky::shell::Shell::Shared().view(); | 105 auto view = static_cast<sky::shell::PlatformViewIOS*>(_instance->view()); |
| 99 auto interface_request = mojo::GetProxy(&_viewport_observer); | 106 auto interface_request = mojo::GetProxy(&_viewport_observer); |
| 100 view->ConnectToViewportObserver(interface_request.Pass()); | 107 view->ConnectToViewportObserver(interface_request.Pass()); |
| 101 | 108 |
| 102 mojo::String string(self.skyInitialLoadURL.UTF8String); | 109 mojo::String string(self.skyInitialLoadURL.UTF8String); |
| 103 _viewport_observer->LoadURL(string); | 110 _viewport_observer->LoadURL(string); |
| 104 } | 111 } |
| 105 | 112 |
| 106 - (void)notifySurfaceDestruction { | 113 - (void)notifySurfaceDestruction { |
| 107 self.platformView->SurfaceDestroyed(); | 114 self.platformView->SurfaceDestroyed(); |
| 108 } | 115 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 + (Class)layerClass { | 160 + (Class)layerClass { |
| 154 return [CAEAGLLayer class]; | 161 return [CAEAGLLayer class]; |
| 155 } | 162 } |
| 156 | 163 |
| 157 - (void)dealloc { | 164 - (void)dealloc { |
| 158 [self notifySurfaceDestruction]; | 165 [self notifySurfaceDestruction]; |
| 159 [super dealloc]; | 166 [super dealloc]; |
| 160 } | 167 } |
| 161 | 168 |
| 162 @end | 169 @end |
| OLD | NEW |