| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer_host/compositing_iosurface_layer_mac.h" | 5 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
| 9 | 9 |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 context_ = content::CompositingIOSurfaceContext::Get( | 34 context_ = content::CompositingIOSurfaceContext::Get( |
| 35 content::CompositingIOSurfaceContext::kOffscreenContextWindowNumber); | 35 content::CompositingIOSurfaceContext::kOffscreenContextWindowNumber); |
| 36 DCHECK(context_); | 36 DCHECK(context_); |
| 37 needsDisplay_ = NO; | 37 needsDisplay_ = NO; |
| 38 | 38 |
| 39 ScopedCAActionDisabler disabler; | 39 ScopedCAActionDisabler disabler; |
| 40 [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; | 40 [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
| 41 [self setContentsGravity:kCAGravityTopLeft]; | 41 [self setContentsGravity:kCAGravityTopLeft]; |
| 42 [self setFrame:NSRectToCGRect( | 42 [self setFrame:NSRectToCGRect( |
| 43 [renderWidgetHostView_->cocoa_view() bounds])]; | 43 [renderWidgetHostView_->cocoa_view() bounds])]; |
| 44 if ([self respondsToSelector:(@selector(setContentsScale:))]) { |
| 45 [self setContentsScale: |
| 46 renderWidgetHostView_->backing_store_scale_factor_]; |
| 47 } |
| 44 [self setNeedsDisplay]; | 48 [self setNeedsDisplay]; |
| 45 [self updateScaleFactor]; | |
| 46 } | 49 } |
| 47 return self; | 50 return self; |
| 48 } | 51 } |
| 49 | 52 |
| 50 - (void)updateScaleFactor { | |
| 51 if (!renderWidgetHostView_ || | |
| 52 ![self respondsToSelector:(@selector(contentsScale))] || | |
| 53 ![self respondsToSelector:(@selector(setContentsScale:))]) | |
| 54 return; | |
| 55 | |
| 56 float current_scale_factor = [self contentsScale]; | |
| 57 float new_scale_factor = current_scale_factor; | |
| 58 if (renderWidgetHostView_->compositing_iosurface_) { | |
| 59 new_scale_factor = | |
| 60 renderWidgetHostView_->compositing_iosurface_->scale_factor(); | |
| 61 } | |
| 62 | |
| 63 if (new_scale_factor == current_scale_factor) | |
| 64 return; | |
| 65 | |
| 66 ScopedCAActionDisabler disabler; | |
| 67 [self setContentsScale:new_scale_factor]; | |
| 68 } | |
| 69 | |
| 70 - (void)disableCompositing{ | 53 - (void)disableCompositing{ |
| 71 ScopedCAActionDisabler disabler; | 54 ScopedCAActionDisabler disabler; |
| 72 [self removeFromSuperlayer]; | 55 [self removeFromSuperlayer]; |
| 73 renderWidgetHostView_ = nil; | 56 renderWidgetHostView_ = nil; |
| 74 } | 57 } |
| 75 | 58 |
| 76 - (void)gotNewFrame { | 59 - (void)gotNewFrame { |
| 77 if (![self isAsynchronous]) { | 60 if (![self isAsynchronous]) { |
| 78 [self setNeedsDisplay]; | 61 [self setNeedsDisplay]; |
| 79 [self setAsynchronous:YES]; | 62 [self setAsynchronous:YES]; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 false)) { | 174 false)) { |
| 192 renderWidgetHostView_->GotAcceleratedCompositingError(); | 175 renderWidgetHostView_->GotAcceleratedCompositingError(); |
| 193 return; | 176 return; |
| 194 } | 177 } |
| 195 | 178 |
| 196 needsDisplay_ = NO; | 179 needsDisplay_ = NO; |
| 197 renderWidgetHostView_->SendPendingLatencyInfoToHost(); | 180 renderWidgetHostView_->SendPendingLatencyInfoToHost(); |
| 198 } | 181 } |
| 199 | 182 |
| 200 @end | 183 @end |
| OLD | NEW |