OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/compositor/browser_compositor_view_mac.h" | 5 #include "content/browser/compositor/browser_compositor_view_mac.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
9 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h" | 9 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h" |
10 #include "content/browser/renderer_host/compositing_iosurface_mac.h" | 10 #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
11 #include "content/browser/renderer_host/software_layer_mac.h" | 11 #include "content/browser/renderer_host/software_layer_mac.h" |
| 12 #include "content/public/browser/context_factory.h" |
12 #include "ui/base/cocoa/animation_utils.h" | 13 #include "ui/base/cocoa/animation_utils.h" |
13 #include "ui/gl/scoped_cgl.h" | 14 #include "ui/gl/scoped_cgl.h" |
14 | 15 |
15 // The default implementation of additions to the NSView interface for browser | 16 // The default implementation of additions to the NSView interface for browser |
16 // compositing should never be called. Log an error if they are. | 17 // compositing should never be called. Log an error if they are. |
17 @implementation NSView (BrowserCompositorView) | 18 @implementation NSView (BrowserCompositorView) |
18 | 19 |
19 - (void)gotAcceleratedIOSurfaceFrame:(uint64)surface_handle | 20 - (void)gotAcceleratedIOSurfaceFrame:(uint64)surface_handle |
20 withPixelSize:(gfx::Size)pixel_size | 21 withPixelSize:(gfx::Size)pixel_size |
21 withScaleFactor:(float)scale_factor { | 22 withScaleFactor:(float)scale_factor { |
(...skipping 15 matching lines...) Expand all Loading... |
37 if (self = [super init]) { | 38 if (self = [super init]) { |
38 // Disable the fade-in animation as the layer and view are added. | 39 // Disable the fade-in animation as the layer and view are added. |
39 ScopedCAActionDisabler disabler; | 40 ScopedCAActionDisabler disabler; |
40 | 41 |
41 // Make this view host a transparent layer. | 42 // Make this view host a transparent layer. |
42 background_layer_.reset([[CALayer alloc] init]); | 43 background_layer_.reset([[CALayer alloc] init]); |
43 [background_layer_ setContentsGravity:kCAGravityTopLeft]; | 44 [background_layer_ setContentsGravity:kCAGravityTopLeft]; |
44 [self setLayer:background_layer_]; | 45 [self setLayer:background_layer_]; |
45 [self setWantsLayer:YES]; | 46 [self setWantsLayer:YES]; |
46 | 47 |
47 compositor_.reset(new ui::Compositor(self)); | 48 compositor_.reset(new ui::Compositor(self, content::GetContextFactory())); |
48 [view addSubview:self]; | 49 [view addSubview:self]; |
49 } | 50 } |
50 return self; | 51 return self; |
51 } | 52 } |
52 | 53 |
53 // This function closely mirrors RenderWidgetHostViewMac::LayoutLayers. When | 54 // This function closely mirrors RenderWidgetHostViewMac::LayoutLayers. When |
54 // only delegated rendering is supported, only one copy of this code will | 55 // only delegated rendering is supported, only one copy of this code will |
55 // need to exist. | 56 // need to exist. |
56 - (void)layoutLayers { | 57 - (void)layoutLayers { |
57 // Disable animation of the layers' resizing or repositioning. | 58 // Disable animation of the layers' resizing or repositioning. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // If there was an accelerated layer, remove it. | 166 // If there was an accelerated layer, remove it. |
166 if (accelerated_layer_) { | 167 if (accelerated_layer_) { |
167 // Disable the fade-out animation as the layer is removed. | 168 // Disable the fade-out animation as the layer is removed. |
168 ScopedCAActionDisabler disabler; | 169 ScopedCAActionDisabler disabler; |
169 [accelerated_layer_ removeFromSuperlayer]; | 170 [accelerated_layer_ removeFromSuperlayer]; |
170 accelerated_layer_.reset(); | 171 accelerated_layer_.reset(); |
171 } | 172 } |
172 } | 173 } |
173 | 174 |
174 @end // BrowserCompositorViewMac | 175 @end // BrowserCompositorViewMac |
OLD | NEW |