| 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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 - (void)gotSoftwareFrame:(cc::SoftwareFrameData*)frame_data | 57 - (void)gotSoftwareFrame:(cc::SoftwareFrameData*)frame_data |
| 58 withScaleFactor:(float)scale_factor | 58 withScaleFactor:(float)scale_factor |
| 59 withCanvas:(SkCanvas*)canvas { | 59 withCanvas:(SkCanvas*)canvas { |
| 60 DLOG(ERROR) << "-[NSView gotSoftwareFrame] called on non-overridden class."; | 60 DLOG(ERROR) << "-[NSView gotSoftwareFrame] called on non-overridden class."; |
| 61 } | 61 } |
| 62 | 62 |
| 63 @end // NSView (BrowserCompositorView) | 63 @end // NSView (BrowserCompositorView) |
| 64 | 64 |
| 65 @implementation BrowserCompositorViewMac : NSView | 65 @implementation BrowserCompositorViewMac : NSView |
| 66 | 66 |
| 67 - (id)initWithSuperview:(NSView*)view | 67 - (id)initWithSuperview:(NSView*)view { |
| 68 withClient:(content::BrowserCompositorViewMacClient*)client { | |
| 69 if (self = [super init]) { | 68 if (self = [super init]) { |
| 70 client_ = client; | |
| 71 helper_.reset(new content::BrowserCompositorViewMacHelper(self)); | 69 helper_.reset(new content::BrowserCompositorViewMacHelper(self)); |
| 72 | 70 |
| 73 // Disable the fade-in animation as the layer and view are added. | 71 // Disable the fade-in animation as the layer and view are added. |
| 74 ScopedCAActionDisabler disabler; | 72 ScopedCAActionDisabler disabler; |
| 75 | 73 |
| 76 // Make this view host a transparent layer. | 74 // Make this view host a transparent layer. |
| 77 background_layer_.reset([[CALayer alloc] init]); | 75 background_layer_.reset([[CALayer alloc] init]); |
| 78 [background_layer_ setContentsGravity:kCAGravityTopLeft]; | 76 [background_layer_ setContentsGravity:kCAGravityTopLeft]; |
| 79 [self setLayer:background_layer_]; | 77 [self setLayer:background_layer_]; |
| 80 [self setWantsLayer:YES]; | 78 [self setWantsLayer:YES]; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 132 } |
| 135 | 133 |
| 136 // The content area of the software layer is the size of the image provided. | 134 // The content area of the software layer is the size of the image provided. |
| 137 // Make the bounds of the layer match the superview's bounds, to ensure that | 135 // Make the bounds of the layer match the superview's bounds, to ensure that |
| 138 // the visible contents are drawn. | 136 // the visible contents are drawn. |
| 139 [software_layer_ setBounds:new_background_frame]; | 137 [software_layer_ setBounds:new_background_frame]; |
| 140 } | 138 } |
| 141 | 139 |
| 142 - (void)resetClient { | 140 - (void)resetClient { |
| 143 [accelerated_layer_ resetClient]; | 141 [accelerated_layer_ resetClient]; |
| 144 client_ = NULL; | |
| 145 } | 142 } |
| 146 | 143 |
| 147 - (ui::Compositor*)compositor { | 144 - (ui::Compositor*)compositor { |
| 148 return compositor_.get(); | 145 return compositor_.get(); |
| 149 } | 146 } |
| 150 | 147 |
| 151 - (void)gotAcceleratedIOSurfaceFrame:(uint64)surface_handle | 148 - (void)gotAcceleratedIOSurfaceFrame:(uint64)surface_handle |
| 152 withPixelSize:(gfx::Size)pixel_size | 149 withPixelSize:(gfx::Size)pixel_size |
| 153 withScaleFactor:(float)scale_factor { | 150 withScaleFactor:(float)scale_factor { |
| 154 ScopedCAActionDisabler disabler; | 151 ScopedCAActionDisabler disabler; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 231 |
| 235 // This call can be nested insider ui::Compositor commit calls, and can also | 232 // This call can be nested insider ui::Compositor commit calls, and can also |
| 236 // make additional ui::Compositor commit calls. Avoid the potential recursion | 233 // make additional ui::Compositor commit calls. Avoid the potential recursion |
| 237 // by acknowledging the frame asynchronously. | 234 // by acknowledging the frame asynchronously. |
| 238 [self performSelector:@selector(layerDidDrawFrame) | 235 [self performSelector:@selector(layerDidDrawFrame) |
| 239 withObject:nil | 236 withObject:nil |
| 240 afterDelay:0]; | 237 afterDelay:0]; |
| 241 } | 238 } |
| 242 | 239 |
| 243 - (void)layerDidDrawFrame { | 240 - (void)layerDidDrawFrame { |
| 244 if (client_) | |
| 245 client_->BrowserCompositorDidDrawFrame(); | |
| 246 } | 241 } |
| 247 | 242 |
| 248 @end // BrowserCompositorViewMac | 243 @end // BrowserCompositorViewMac |
| OLD | NEW |