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 skia::ScopedPlatformBitmap scoped_platform_bitmap(output); |
174 CGContextRef temp_context = scoped_platform_paint.GetPlatformSurface(); | 174 CGContextRef temp_context = scoped_platform_bitmap.GetPlatformSurface(); |
175 gfx::ScopedCGContextSaveGState save_gstate(temp_context); | 175 gfx::ScopedCGContextSaveGState save_gstate(temp_context); |
176 CGContextTranslateCTM(temp_context, 0.0, size().height()); | 176 CGContextTranslateCTM(temp_context, 0.0, size().height()); |
177 CGContextScaleCTM(temp_context, 1.0, -1.0); | 177 CGContextScaleCTM(temp_context, 1.0, -1.0); |
178 CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), | 178 CGContextDrawLayerAtPoint(temp_context, CGPointMake(rect.x(), rect.y()), |
179 cg_layer()); | 179 cg_layer()); |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 // Scroll the contents of our CGLayer | 183 // Scroll the contents of our CGLayer |
184 void BackingStoreMac::ScrollBackingStore(int dx, int dy, | 184 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, | 277 8, pixel_size.width() * 4, |
278 base::mac::GetSystemColorSpace(), | 278 base::mac::GetSystemColorSpace(), |
279 kCGImageAlphaPremultipliedFirst | | 279 kCGImageAlphaPremultipliedFirst | |
280 kCGBitmapByteOrder32Host); | 280 kCGBitmapByteOrder32Host); |
281 DCHECK(context); | 281 DCHECK(context); |
282 | 282 |
283 return context; | 283 return context; |
284 } | 284 } |
285 | 285 |
286 } // namespace content | 286 } // namespace content |
OLD | NEW |