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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 bool* scheduled_completion_callback) { | 83 bool* scheduled_completion_callback) { |
84 *scheduled_completion_callback = false; | 84 *scheduled_completion_callback = false; |
85 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); | 85 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); |
86 | 86 |
87 TransportDIB* dib = process->GetTransportDIB(bitmap); | 87 TransportDIB* dib = process->GetTransportDIB(bitmap); |
88 if (!dib) | 88 if (!dib) |
89 return; | 89 return; |
90 | 90 |
91 gfx::Size pixel_size = gfx::ToFlooredSize( | 91 gfx::Size pixel_size = gfx::ToFlooredSize( |
92 size().Scale(device_scale_factor_)); | 92 size().Scale(device_scale_factor_)); |
93 gfx::RectF scaled_bitmap_rect = bitmap_rect; | 93 gfx::Rect pixel_bitmap_rect = ToFlooredRectDeprecated( |
94 scaled_bitmap_rect.Scale(scale_factor); | 94 gfx::ScaleRect(bitmap_rect, scale_factor)); |
95 gfx::Rect pixel_bitmap_rect = ToFlooredRectDeprecated(scaled_bitmap_rect); | |
96 | 95 |
97 size_t bitmap_byte_count = | 96 size_t bitmap_byte_count = |
98 pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4; | 97 pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4; |
99 DCHECK_GE(dib->size(), bitmap_byte_count); | 98 DCHECK_GE(dib->size(), bitmap_byte_count); |
100 | 99 |
101 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( | 100 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( |
102 CGDataProviderCreateWithData(NULL, dib->memory(), | 101 CGDataProviderCreateWithData(NULL, dib->memory(), |
103 bitmap_byte_count, NULL)); | 102 bitmap_byte_count, NULL)); |
104 | 103 |
105 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image( | 104 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image( |
106 CGImageCreate(pixel_bitmap_rect.width(), pixel_bitmap_rect.height(), | 105 CGImageCreate(pixel_bitmap_rect.width(), pixel_bitmap_rect.height(), |
107 8, 32, 4 * pixel_bitmap_rect.width(), | 106 8, 32, 4 * pixel_bitmap_rect.width(), |
108 base::mac::GetSystemColorSpace(), | 107 base::mac::GetSystemColorSpace(), |
109 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, | 108 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, |
110 data_provider, NULL, false, kCGRenderingIntentDefault)); | 109 data_provider, NULL, false, kCGRenderingIntentDefault)); |
111 | 110 |
112 for (size_t i = 0; i < copy_rects.size(); i++) { | 111 for (size_t i = 0; i < copy_rects.size(); i++) { |
113 const gfx::Rect& copy_rect = copy_rects[i]; | 112 const gfx::Rect& copy_rect = copy_rects[i]; |
114 gfx::RectF scaled_copy_rect = copy_rect; | 113 gfx::Rect pixel_copy_rect = ToFlooredRectDeprecated( |
115 scaled_copy_rect.Scale(scale_factor); | 114 gfx::ScaleRect(copy_rect, scale_factor)); |
116 gfx::Rect pixel_copy_rect = ToFlooredRectDeprecated(scaled_copy_rect); | |
117 | 115 |
118 // Only the subpixels given by copy_rect have pixels to copy. | 116 // Only the subpixels given by copy_rect have pixels to copy. |
119 base::mac::ScopedCFTypeRef<CGImageRef> image( | 117 base::mac::ScopedCFTypeRef<CGImageRef> image( |
120 CGImageCreateWithImageInRect(bitmap_image, CGRectMake( | 118 CGImageCreateWithImageInRect(bitmap_image, CGRectMake( |
121 pixel_copy_rect.x() - pixel_bitmap_rect.x(), | 119 pixel_copy_rect.x() - pixel_bitmap_rect.x(), |
122 pixel_copy_rect.y() - pixel_bitmap_rect.y(), | 120 pixel_copy_rect.y() - pixel_bitmap_rect.y(), |
123 pixel_copy_rect.width(), | 121 pixel_copy_rect.width(), |
124 pixel_copy_rect.height()))); | 122 pixel_copy_rect.height()))); |
125 | 123 |
126 if (!cg_layer()) { | 124 if (!cg_layer()) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 8, pixel_size.width() * 4, | 267 8, pixel_size.width() * 4, |
270 base::mac::GetSystemColorSpace(), | 268 base::mac::GetSystemColorSpace(), |
271 kCGImageAlphaPremultipliedFirst | | 269 kCGImageAlphaPremultipliedFirst | |
272 kCGBitmapByteOrder32Host); | 270 kCGBitmapByteOrder32Host); |
273 DCHECK(context); | 271 DCHECK(context); |
274 | 272 |
275 return context; | 273 return context; |
276 } | 274 } |
277 | 275 |
278 } // namespace content | 276 } // namespace content |
OLD | NEW |