| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/backing_store_mac.h" | 7 #include "chrome/browser/renderer_host/backing_store_mac.h" |
| 8 | 8 |
| 9 #include "app/surface/transport_dib.h" | 9 #include "app/surface/transport_dib.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "chrome/browser/renderer_host/render_process_host.h" | 14 #include "chrome/browser/renderer_host/render_process_host.h" |
| 15 #include "chrome/browser/renderer_host/render_widget_host.h" | 15 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 16 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 16 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 17 #include "gfx/rect.h" | 17 #include "gfx/rect.h" |
| 18 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 #include "third_party/skia/include/core/SkCanvas.h" | 20 #include "third_party/skia/include/core/SkCanvas.h" |
| 21 | 21 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 TransportDIB* dib = process->GetTransportDIB(bitmap); | 62 TransportDIB* dib = process->GetTransportDIB(bitmap); |
| 63 if (!dib) | 63 if (!dib) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( | 66 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( |
| 67 CGDataProviderCreateWithData(NULL, dib->memory(), | 67 CGDataProviderCreateWithData(NULL, dib->memory(), |
| 68 bitmap_rect.width() * bitmap_rect.height() * 4, NULL)); | 68 bitmap_rect.width() * bitmap_rect.height() * 4, NULL)); |
| 69 | 69 |
| 70 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image( | 70 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image( |
| 71 CGImageCreate(bitmap_rect.width(), bitmap_rect.height(), 8, 32, | 71 CGImageCreate(bitmap_rect.width(), bitmap_rect.height(), 8, 32, |
| 72 4 * bitmap_rect.width(), mac_util::GetSystemColorSpace(), | 72 4 * bitmap_rect.width(), base::mac::GetSystemColorSpace(), |
| 73 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, | 73 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, |
| 74 data_provider, NULL, false, kCGRenderingIntentDefault)); | 74 data_provider, NULL, false, kCGRenderingIntentDefault)); |
| 75 | 75 |
| 76 for (size_t i = 0; i < copy_rects.size(); i++) { | 76 for (size_t i = 0; i < copy_rects.size(); i++) { |
| 77 const gfx::Rect& copy_rect = copy_rects[i]; | 77 const gfx::Rect& copy_rect = copy_rects[i]; |
| 78 | 78 |
| 79 // Only the subpixels given by copy_rect have pixels to copy. | 79 // Only the subpixels given by copy_rect have pixels to copy. |
| 80 base::mac::ScopedCFTypeRef<CGImageRef> image( | 80 base::mac::ScopedCFTypeRef<CGImageRef> image( |
| 81 CGImageCreateWithImageInRect(bitmap_image, CGRectMake( | 81 CGImageCreateWithImageInRect(bitmap_image, CGRectMake( |
| 82 copy_rect.x() - bitmap_rect.x(), | 82 copy_rect.x() - bitmap_rect.x(), |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 return layer; | 227 return layer; |
| 228 } | 228 } |
| 229 | 229 |
| 230 CGContextRef BackingStoreMac::CreateCGBitmapContext() { | 230 CGContextRef BackingStoreMac::CreateCGBitmapContext() { |
| 231 // A CGBitmapContext serves as a stand-in for the layer before the view is | 231 // A CGBitmapContext serves as a stand-in for the layer before the view is |
| 232 // in a containing window. | 232 // in a containing window. |
| 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 mac_util::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 |