| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "gfx/blit.h" | 5 #include "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 "gfx/point.h" | 9 #include "gfx/point.h" |
| 10 #include "gfx/rect.h" | 10 #include "gfx/rect.h" |
| 11 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
| 12 #include "skia/ext/platform_device.h" | 12 #include "skia/ext/platform_device.h" |
| 13 | 13 |
| 14 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 14 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 15 #include <cairo/cairo.h> | 15 #include <cairo/cairo.h> |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
| 19 #include "base/mac_util.h" | 19 #include "base/mac_util.h" |
| 20 #include "base/scoped_cftyperef.h" | 20 #include "base/mac/scoped_cftyperef.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace gfx { | 23 namespace gfx { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Returns true if the given canvas has any part of itself clipped out or | 27 // Returns true if the given canvas has any part of itself clipped out or |
| 28 // any non-identity tranform. | 28 // any non-identity tranform. |
| 29 bool HasClipOrTransform(const skia::PlatformCanvas& canvas) { | 29 bool HasClipOrTransform(const skia::PlatformCanvas& canvas) { |
| 30 if (!canvas.getTotalMatrix().isIdentity()) | 30 if (!canvas.getTotalMatrix().isIdentity()) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // If there is a translation on the source context, we need to account for | 63 // If there is a translation on the source context, we need to account for |
| 64 // it ourselves since CGBitmapContextCreateImage will bypass it. | 64 // it ourselves since CGBitmapContextCreateImage will bypass it. |
| 65 Rect src_rect(src_origin, dst_rect.size()); | 65 Rect src_rect(src_origin, dst_rect.size()); |
| 66 CGAffineTransform transform = CGContextGetCTM(src_context); | 66 CGAffineTransform transform = CGContextGetCTM(src_context); |
| 67 bool flipped = fabs(transform.d + 1) < 0.0001; | 67 bool flipped = fabs(transform.d + 1) < 0.0001; |
| 68 CGFloat delta_y = flipped ? CGBitmapContextGetHeight(src_context) - | 68 CGFloat delta_y = flipped ? CGBitmapContextGetHeight(src_context) - |
| 69 transform.ty | 69 transform.ty |
| 70 : transform.ty; | 70 : transform.ty; |
| 71 src_rect.Offset(transform.tx, delta_y); | 71 src_rect.Offset(transform.tx, delta_y); |
| 72 | 72 |
| 73 scoped_cftyperef<CGImageRef> | 73 base::mac::ScopedCFTypeRef<CGImageRef> |
| 74 src_image(CGBitmapContextCreateImage(src_context)); | 74 src_image(CGBitmapContextCreateImage(src_context)); |
| 75 scoped_cftyperef<CGImageRef> src_sub_image( | 75 base::mac::ScopedCFTypeRef<CGImageRef> src_sub_image( |
| 76 CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect())); | 76 CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect())); |
| 77 CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image); | 77 CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image); |
| 78 #else // Linux, BSD, others | 78 #else // Linux, BSD, others |
| 79 // Only translations in the source context are supported; more complex | 79 // Only translations in the source context are supported; more complex |
| 80 // source context transforms will be ignored. | 80 // source context transforms will be ignored. |
| 81 cairo_save(dst_context); | 81 cairo_save(dst_context); |
| 82 double surface_x = src_origin.x(); | 82 double surface_x = src_origin.x(); |
| 83 double surface_y = src_origin.y(); | 83 double surface_y = src_origin.y(); |
| 84 cairo_user_to_device(src_context, &surface_x, &surface_y); | 84 cairo_user_to_device(src_context, &surface_x, &surface_y); |
| 85 cairo_set_source_surface(dst_context, cairo_get_target(src_context), | 85 cairo_set_source_surface(dst_context, cairo_get_target(src_context), |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), | 194 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), |
| 195 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), | 195 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), |
| 196 row_bytes); | 196 row_bytes); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 #endif | 201 #endif |
| 202 | 202 |
| 203 } // namespace gfx | 203 } // namespace gfx |
| OLD | NEW |