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 "webkit/tools/test_shell/mock_webclipboard_impl.h" | 5 #include "webkit/tools/test_shell/mock_webclipboard_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 WebKit::WebData MockWebClipboardImpl::readImage( | 100 WebKit::WebData MockWebClipboardImpl::readImage( |
101 WebKit::WebClipboard::Buffer buffer) { | 101 WebKit::WebClipboard::Buffer buffer) { |
102 std::string data; | 102 std::string data; |
103 std::vector<unsigned char> encoded_image; | 103 std::vector<unsigned char> encoded_image; |
104 // TODO(dcheng): Verify that we can assume the image is ARGB8888. Note that | 104 // TODO(dcheng): Verify that we can assume the image is ARGB8888. Note that |
105 // for endianess reasons, it will be BGRA8888 on Windows. | 105 // for endianess reasons, it will be BGRA8888 on Windows. |
106 const SkBitmap& bitmap = m_image.getSkBitmap(); | 106 const SkBitmap& bitmap = m_image.getSkBitmap(); |
107 SkAutoLockPixels lock(bitmap); | 107 SkAutoLockPixels lock(bitmap); |
| 108 #if defined(OS_ANDROID) |
| 109 webkit_support::EncodeRGBAPNG(static_cast<unsigned char*>(bitmap.getPixels()), |
| 110 bitmap.width(), |
| 111 bitmap.height(), |
| 112 bitmap.rowBytes(), |
| 113 &encoded_image); |
| 114 #else |
108 webkit_support::EncodeBGRAPNG(static_cast<unsigned char*>(bitmap.getPixels()), | 115 webkit_support::EncodeBGRAPNG(static_cast<unsigned char*>(bitmap.getPixels()), |
109 bitmap.width(), | 116 bitmap.width(), |
110 bitmap.height(), | 117 bitmap.height(), |
111 bitmap.rowBytes(), | 118 bitmap.rowBytes(), |
112 false, | 119 false, |
113 &encoded_image); | 120 &encoded_image); |
| 121 #endif |
114 data.assign(reinterpret_cast<char*>(vector_as_array(&encoded_image)), | 122 data.assign(reinterpret_cast<char*>(vector_as_array(&encoded_image)), |
115 encoded_image.size()); | 123 encoded_image.size()); |
116 return data; | 124 return data; |
117 } | 125 } |
118 | 126 |
119 WebKit::WebString MockWebClipboardImpl::readCustomData( | 127 WebKit::WebString MockWebClipboardImpl::readCustomData( |
120 WebKit::WebClipboard::Buffer buffer, | 128 WebKit::WebClipboard::Buffer buffer, |
121 const WebKit::WebString& type) { | 129 const WebKit::WebString& type) { |
122 std::map<string16, string16>::const_iterator it = m_customData.find(type); | 130 std::map<string16, string16>::const_iterator it = m_customData.find(type); |
123 if (it != m_customData.end()) | 131 if (it != m_customData.end()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 196 } |
189 } | 197 } |
190 | 198 |
191 void MockWebClipboardImpl::clear() { | 199 void MockWebClipboardImpl::clear() { |
192 m_plainText = WebString(); | 200 m_plainText = WebString(); |
193 m_htmlText = WebString(); | 201 m_htmlText = WebString(); |
194 m_image.reset(); | 202 m_image.reset(); |
195 m_customData.clear(); | 203 m_customData.clear(); |
196 m_writeSmartPaste = false; | 204 m_writeSmartPaste = false; |
197 } | 205 } |
OLD | NEW |