OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image); | 116 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image); |
117 } | 117 } |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect, | 121 bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect, |
122 skia::PlatformCanvas* output) { | 122 skia::PlatformCanvas* output) { |
123 if (!output->initialize(rect.width(), rect.height(), true)) | 123 if (!output->initialize(rect.width(), rect.height(), true)) |
124 return false; | 124 return false; |
125 | 125 |
126 CGContextRef temp_context = output->beginPlatformPaint(); | 126 skia::ScopedPlatformPaint scoped_platform_paint(output); |
| 127 CGContextRef temp_context = scoped_platform_paint.GetPlatformSurface(); |
127 CGContextSaveGState(temp_context); | 128 CGContextSaveGState(temp_context); |
128 CGContextTranslateCTM(temp_context, 0.0, size().height()); | 129 CGContextTranslateCTM(temp_context, 0.0, size().height()); |
129 CGContextScaleCTM(temp_context, 1.0, -1.0); | 130 CGContextScaleCTM(temp_context, 1.0, -1.0); |
130 CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), | 131 CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), |
131 cg_layer()); | 132 cg_layer()); |
132 CGContextRestoreGState(temp_context); | 133 CGContextRestoreGState(temp_context); |
133 output->endPlatformPaint(); | |
134 return true; | 134 return true; |
135 } | 135 } |
136 | 136 |
137 // Scroll the contents of our CGLayer | 137 // Scroll the contents of our CGLayer |
138 void BackingStoreMac::ScrollBackingStore(int dx, int dy, | 138 void BackingStoreMac::ScrollBackingStore(int dx, int dy, |
139 const gfx::Rect& clip_rect, | 139 const gfx::Rect& clip_rect, |
140 const gfx::Size& view_size) { | 140 const gfx::Size& view_size) { |
141 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); | 141 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); |
142 | 142 |
143 // "Scroll" the contents of the layer by creating a new CGLayer, | 143 // "Scroll" the contents of the layer by creating a new CGLayer, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 CGContextRef context = CGBitmapContextCreate(NULL, | 233 CGContextRef context = CGBitmapContextCreate(NULL, |
234 size().width(), size().height(), | 234 size().width(), size().height(), |
235 8, size().width() * 4, | 235 8, size().width() * 4, |
236 base::mac::GetSystemColorSpace(), | 236 base::mac::GetSystemColorSpace(), |
237 kCGImageAlphaPremultipliedFirst | | 237 kCGImageAlphaPremultipliedFirst | |
238 kCGBitmapByteOrder32Host); | 238 kCGBitmapByteOrder32Host); |
239 DCHECK(context); | 239 DCHECK(context); |
240 | 240 |
241 return context; | 241 return context; |
242 } | 242 } |
OLD | NEW |