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 #include "ui/gfx/blit.h" | 5 #include "ui/gfx/blit.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // If there is a translation on the source context, we need to account for | 64 // If there is a translation on the source context, we need to account for |
65 // it ourselves since CGBitmapContextCreateImage will bypass it. | 65 // it ourselves since CGBitmapContextCreateImage will bypass it. |
66 Rect src_rect(src_origin, dst_rect.size()); | 66 Rect src_rect(src_origin, dst_rect.size()); |
67 CGAffineTransform transform = CGContextGetCTM(src_context); | 67 CGAffineTransform transform = CGContextGetCTM(src_context); |
68 bool flipped = fabs(transform.d + 1) < 0.0001; | 68 bool flipped = fabs(transform.d + 1) < 0.0001; |
69 CGFloat delta_y = flipped ? CGBitmapContextGetHeight(src_context) - | 69 CGFloat delta_y = flipped ? CGBitmapContextGetHeight(src_context) - |
70 transform.ty | 70 transform.ty |
71 : transform.ty; | 71 : transform.ty; |
72 src_rect.Offset(transform.tx, delta_y); | 72 src_rect.Offset(transform.tx, delta_y); |
73 | 73 |
74 base::mac::ScopedCFTypeRef<CGImageRef> | 74 base::ScopedCFTypeRef<CGImageRef> src_image( |
75 src_image(CGBitmapContextCreateImage(src_context)); | 75 CGBitmapContextCreateImage(src_context)); |
76 base::mac::ScopedCFTypeRef<CGImageRef> src_sub_image( | 76 base::ScopedCFTypeRef<CGImageRef> src_sub_image( |
77 CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect())); | 77 CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect())); |
78 CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image); | 78 CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image); |
79 #elif defined(OS_ANDROID) | 79 #elif defined(OS_ANDROID) |
80 NOTIMPLEMENTED(); | 80 NOTIMPLEMENTED(); |
81 #else // Linux, BSD, others | 81 #else // Linux, BSD, others |
82 // Only translations in the source context are supported; more complex | 82 // Only translations in the source context are supported; more complex |
83 // source context transforms will be ignored. | 83 // source context transforms will be ignored. |
84 cairo_save(dst_context); | 84 cairo_save(dst_context); |
85 double surface_x = src_origin.x(); | 85 double surface_x = src_origin.x(); |
86 double surface_y = src_origin.y(); | 86 double surface_y = src_origin.y(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Fortunately, memmove already handles this for us. | 185 // Fortunately, memmove already handles this for us. |
186 for (int y = 0; y < dest_rect.height(); y++) { | 186 for (int y = 0; y < dest_rect.height(); y++) { |
187 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), | 187 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), |
188 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), | 188 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), |
189 row_bytes); | 189 row_bytes); |
190 } | 190 } |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 } // namespace gfx | 194 } // namespace gfx |
OLD | NEW |