OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "content/browser/renderer_host/backing_store_mac.h" | 7 #include "content/browser/renderer_host/backing_store_mac.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 base::mac::ScopedCFTypeRef<CGImageRef> image( | 202 base::mac::ScopedCFTypeRef<CGImageRef> image( |
203 CGBitmapContextCreateImage(cg_bitmap_)); | 203 CGBitmapContextCreateImage(cg_bitmap_)); |
204 CGContextDrawImage(context, dest_rect, image); | 204 CGContextDrawImage(context, dest_rect, image); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 CGLayerRef BackingStoreMac::CreateCGLayer() { | 208 CGLayerRef BackingStoreMac::CreateCGLayer() { |
209 // The CGLayer should be optimized for drawing into the containing window, | 209 // The CGLayer should be optimized for drawing into the containing window, |
210 // so extract a CGContext corresponding to the window to be passed to | 210 // so extract a CGContext corresponding to the window to be passed to |
211 // CGLayerCreateWithContext. | 211 // CGLayerCreateWithContext. |
212 NSWindow* window = [render_widget_host()->view()->GetNativeView() window]; | 212 NSWindow* window = [render_widget_host()->GetView()->GetNativeView() window]; |
213 if ([window windowNumber] <= 0) { | 213 if ([window windowNumber] <= 0) { |
214 // This catches a nil |window|, as well as windows that exist but that | 214 // This catches a nil |window|, as well as windows that exist but that |
215 // aren't yet connected to WindowServer. | 215 // aren't yet connected to WindowServer. |
216 return NULL; | 216 return NULL; |
217 } | 217 } |
218 | 218 |
219 NSGraphicsContext* ns_context = [window graphicsContext]; | 219 NSGraphicsContext* ns_context = [window graphicsContext]; |
220 DCHECK(ns_context); | 220 DCHECK(ns_context); |
221 | 221 |
222 CGContextRef cg_context = static_cast<CGContextRef>( | 222 CGContextRef cg_context = static_cast<CGContextRef>( |
(...skipping 14 matching lines...) Expand all Loading... |
237 CGContextRef context = CGBitmapContextCreate(NULL, | 237 CGContextRef context = CGBitmapContextCreate(NULL, |
238 size().width(), size().height(), | 238 size().width(), size().height(), |
239 8, size().width() * 4, | 239 8, size().width() * 4, |
240 base::mac::GetSystemColorSpace(), | 240 base::mac::GetSystemColorSpace(), |
241 kCGImageAlphaPremultipliedFirst | | 241 kCGImageAlphaPremultipliedFirst | |
242 kCGBitmapByteOrder32Host); | 242 kCGBitmapByteOrder32Host); |
243 DCHECK(context); | 243 DCHECK(context); |
244 | 244 |
245 return context; | 245 return context; |
246 } | 246 } |
OLD | NEW |