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 #define PEPPER_APIS_ENABLED 1 | 5 #define PEPPER_APIS_ENABLED 1 |
6 | 6 |
7 #include "chrome/renderer/webplugin_delegate_pepper.h" | 7 #include "chrome/renderer/webplugin_delegate_pepper.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #if defined(OS_LINUX) | 12 #if defined(OS_LINUX) |
13 #include <unistd.h> | 13 #include <unistd.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
19 #include "base/mac_util.h" | 19 #include "base/mac_util.h" |
20 #endif | 20 #endif |
21 #include "base/md5.h" | 21 #include "base/md5.h" |
22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
24 #include "base/metrics/stats_counters.h" | 24 #include "base/metrics/stats_counters.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/process_util.h" | 26 #include "base/process_util.h" |
27 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
28 #include "base/scoped_cftyperef.h" | 28 #include "base/mac/scoped_cftyperef.h" |
29 #endif | 29 #endif |
30 #include "base/scoped_ptr.h" | 30 #include "base/scoped_ptr.h" |
31 #include "base/string_number_conversions.h" | 31 #include "base/string_number_conversions.h" |
32 #include "base/string_util.h" | 32 #include "base/string_util.h" |
33 #include "base/task.h" | 33 #include "base/task.h" |
34 #include "base/time.h" | 34 #include "base/time.h" |
35 #include "base/utf_string_conversions.h" | 35 #include "base/utf_string_conversions.h" |
36 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
37 #include "chrome/common/render_messages.h" | 37 #include "chrome/common/render_messages.h" |
38 #include "chrome/common/render_messages_params.h" | 38 #include "chrome/common/render_messages_params.h" |
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 } | 1732 } |
1733 #endif // OS_WIN | 1733 #endif // OS_WIN |
1734 | 1734 |
1735 #if defined(OS_MACOSX) | 1735 #if defined(OS_MACOSX) |
1736 void WebPluginDelegatePepper::DrawSkBitmapToCanvas( | 1736 void WebPluginDelegatePepper::DrawSkBitmapToCanvas( |
1737 const SkBitmap& bitmap, WebKit::WebCanvas* canvas, | 1737 const SkBitmap& bitmap, WebKit::WebCanvas* canvas, |
1738 const gfx::Rect& dest_rect, | 1738 const gfx::Rect& dest_rect, |
1739 int canvas_height) { | 1739 int canvas_height) { |
1740 SkAutoLockPixels lock(bitmap); | 1740 SkAutoLockPixels lock(bitmap); |
1741 DCHECK(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); | 1741 DCHECK(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); |
1742 scoped_cftyperef<CGDataProviderRef> data_provider( | 1742 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( |
1743 CGDataProviderCreateWithData( | 1743 CGDataProviderCreateWithData( |
1744 NULL, bitmap.getAddr32(0, 0), | 1744 NULL, bitmap.getAddr32(0, 0), |
1745 bitmap.rowBytes() * bitmap.height(), NULL)); | 1745 bitmap.rowBytes() * bitmap.height(), NULL)); |
1746 scoped_cftyperef<CGImageRef> image( | 1746 base::mac::ScopedCFTypeRef<CGImageRef> image( |
1747 CGImageCreate( | 1747 CGImageCreate( |
1748 bitmap.width(), bitmap.height(), | 1748 bitmap.width(), bitmap.height(), |
1749 8, 32, bitmap.rowBytes(), | 1749 8, 32, bitmap.rowBytes(), |
1750 mac_util::GetSystemColorSpace(), | 1750 mac_util::GetSystemColorSpace(), |
1751 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, | 1751 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, |
1752 data_provider, NULL, false, kCGRenderingIntentDefault)); | 1752 data_provider, NULL, false, kCGRenderingIntentDefault)); |
1753 | 1753 |
1754 // Flip the transform | 1754 // Flip the transform |
1755 CGContextSaveGState(canvas); | 1755 CGContextSaveGState(canvas); |
1756 CGContextTranslateCTM(canvas, 0, canvas_height); | 1756 CGContextTranslateCTM(canvas, 0, canvas_height); |
1757 CGContextScaleCTM(canvas, 1.0, -1.0); | 1757 CGContextScaleCTM(canvas, 1.0, -1.0); |
1758 | 1758 |
1759 CGRect bounds; | 1759 CGRect bounds; |
1760 bounds.origin.x = dest_rect.x(); | 1760 bounds.origin.x = dest_rect.x(); |
1761 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); | 1761 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); |
1762 bounds.size.width = dest_rect.width(); | 1762 bounds.size.width = dest_rect.width(); |
1763 bounds.size.height = dest_rect.height(); | 1763 bounds.size.height = dest_rect.height(); |
1764 | 1764 |
1765 CGContextDrawImage(canvas, bounds, image); | 1765 CGContextDrawImage(canvas, bounds, image); |
1766 CGContextRestoreGState(canvas); | 1766 CGContextRestoreGState(canvas); |
1767 } | 1767 } |
1768 #endif // defined(OS_MACOSX) | 1768 #endif // defined(OS_MACOSX) |
OLD | NEW |