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 <cmath> | 9 #include <cmath> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } else { | 158 } else { |
159 // The layer hasn't been created yet, so draw into the cache bitmap. | 159 // The layer hasn't been created yet, so draw into the cache bitmap. |
160 gfx::Rect paint_rect = copy_rect; | 160 gfx::Rect paint_rect = copy_rect; |
161 paint_rect.set_y(size().height() - copy_rect.bottom()); | 161 paint_rect.set_y(size().height() - copy_rect.bottom()); |
162 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image); | 162 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image); |
163 } | 163 } |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect, | 167 bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect, |
168 skia::PlatformCanvas* output) { | 168 skia::PlatformBitmap* output) { |
169 // TODO(thakis): Make sure this works with HiDPI backing stores. | 169 // TODO(thakis): Make sure this works with HiDPI backing stores. |
170 if (!output->initialize(rect.width(), rect.height(), true)) | 170 if (!output->Allocate(rect.width(), rect.height(), true)) |
171 return false; | 171 return false; |
172 | 172 |
173 skia::ScopedPlatformPaint scoped_platform_paint(output); | 173 CGContextRef temp_context = output->GetSurface(); |
174 CGContextRef temp_context = scoped_platform_paint.GetPlatformSurface(); | |
175 gfx::ScopedCGContextSaveGState save_gstate(temp_context); | 174 gfx::ScopedCGContextSaveGState save_gstate(temp_context); |
176 CGContextTranslateCTM(temp_context, 0.0, size().height()); | 175 CGContextTranslateCTM(temp_context, 0.0, size().height()); |
177 CGContextScaleCTM(temp_context, 1.0, -1.0); | 176 CGContextScaleCTM(temp_context, 1.0, -1.0); |
178 CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), | 177 CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), |
179 cg_layer()); | 178 cg_layer()); |
180 return true; | 179 return true; |
181 } | 180 } |
182 | 181 |
183 // Scroll the contents of our CGLayer | 182 // Scroll the contents of our CGLayer |
184 void BackingStoreMac::ScrollBackingStore(int dx, int dy, | 183 void BackingStoreMac::ScrollBackingStore(int dx, int dy, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 8, pixel_size.width() * 4, | 276 8, pixel_size.width() * 4, |
278 base::mac::GetSystemColorSpace(), | 277 base::mac::GetSystemColorSpace(), |
279 kCGImageAlphaPremultipliedFirst | | 278 kCGImageAlphaPremultipliedFirst | |
280 kCGBitmapByteOrder32Host); | 279 kCGBitmapByteOrder32Host); |
281 DCHECK(context); | 280 DCHECK(context); |
282 | 281 |
283 return context; | 282 return context; |
284 } | 283 } |
285 | 284 |
286 } // namespace content | 285 } // namespace content |
OLD | NEW |