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