Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webkit/tools/test_shell/test_shell.cc

Issue 43058: Reverting 11396. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/tools/test_shell/test_shell.h ('k') | webkit/tools/test_shell/webwidget_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "v8_proxy.h" 5 #include "v8_proxy.h"
6 #undef LOG 6 #undef LOG
7 7
8 #include "webkit/tools/test_shell/test_shell.h" 8 #include "webkit/tools/test_shell/test_shell.h"
9 9
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/message_loop.h" 22 #include "base/message_loop.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "base/stats_table.h" 24 #include "base/stats_table.h"
25 #include "base/string_util.h" 25 #include "base/string_util.h"
26 #include "build/build_config.h" 26 #include "build/build_config.h"
27 #include "googleurl/src/url_util.h" 27 #include "googleurl/src/url_util.h"
28 #include "grit/webkit_strings.h" 28 #include "grit/webkit_strings.h"
29 #include "net/base/mime_util.h" 29 #include "net/base/mime_util.h"
30 #include "net/url_request/url_request_file_job.h" 30 #include "net/url_request/url_request_file_job.h"
31 #include "net/url_request/url_request_filter.h" 31 #include "net/url_request/url_request_filter.h"
32 #include "skia/ext/platform_device.h" 32 #include "skia/ext/bitmap_platform_device.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "webkit/glue/screen_info.h" 34 #include "webkit/glue/screen_info.h"
35 #include "webkit/glue/webdatasource.h" 35 #include "webkit/glue/webdatasource.h"
36 #include "webkit/glue/webframe.h" 36 #include "webkit/glue/webframe.h"
37 #include "webkit/glue/webkit_glue.h" 37 #include "webkit/glue/webkit_glue.h"
38 #include "webkit/glue/webpreferences.h" 38 #include "webkit/glue/webpreferences.h"
39 #include "webkit/glue/weburlrequest.h" 39 #include "webkit/glue/weburlrequest.h"
40 #include "webkit/glue/webview.h" 40 #include "webkit/glue/webview.h"
41 #include "webkit/glue/webwidget.h" 41 #include "webkit/glue/webwidget.h"
42 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 42 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 DumpBackForwardList(&bfDump); 220 DumpBackForwardList(&bfDump);
221 printf("%s", WideToUTF8(bfDump).c_str()); 221 printf("%s", WideToUTF8(bfDump).c_str());
222 } 222 }
223 } 223 }
224 224
225 if (params->dump_pixels && !should_dump_as_text) { 225 if (params->dump_pixels && !should_dump_as_text) {
226 // Image output: we write the image data to the file given on the 226 // Image output: we write the image data to the file given on the
227 // command line (for the dump pixels argument), and the MD5 sum to 227 // command line (for the dump pixels argument), and the MD5 sum to
228 // stdout. 228 // stdout.
229 dumped_anything = true; 229 dumped_anything = true;
230 std::string md5sum = DumpImage(shell->webViewHost(), 230 std::string md5sum = DumpImage(webFrame, params->pixel_file_name);
231 params->pixel_file_name);
232 printf("#MD5:%s\n", md5sum.c_str()); 231 printf("#MD5:%s\n", md5sum.c_str());
233 } 232 }
234 if (dumped_anything) 233 if (dumped_anything)
235 printf("#EOF\n"); 234 printf("#EOF\n");
236 fflush(stdout); 235 fflush(stdout);
237 } 236 }
238 } 237 }
239 238
240 // static 239 // static
241 std::string TestShell::DumpImage(WebViewHost* web_view_host, 240 std::string TestShell::DumpImage(WebFrame* web_frame,
242 const std::wstring& file_name) { 241 const std::wstring& file_name) {
243 web_view_host->Paint(); 242 scoped_ptr<skia::BitmapPlatformDevice> device;
244 skia::PlatformDevice& device = 243 if (!web_frame->CaptureImage(&device, true))
245 web_view_host->canvas()->getTopPlatformDevice(); 244 return std::string();
246 245
247 #if defined(OS_WIN) 246 const SkBitmap& src_bmp = device->accessBitmap(false);
248 // Make a copy, since we will have to fix the opacity.
249 const SkBitmap& orig = device.accessBitmap(false);
250 SkBitmap src_bmp;
251 orig.copyTo(&src_bmp, orig.config());
252 #else
253 const SkBitmap& src_bmp = device.accessBitmap(false);
254 #endif
255 247
256 // Encode image. 248 // Encode image.
257 std::vector<unsigned char> png; 249 std::vector<unsigned char> png;
258 SkAutoLockPixels src_bmp_lock(src_bmp); 250 SkAutoLockPixels src_bmp_lock(src_bmp);
259 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; 251 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA;
260 252
261 // Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want 253 // Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want
262 // to keep it. On Windows, the alpha channel is wrong since text/form control 254 // to keep it. On Windows, the alpha channel is wrong since text/form control
263 // drawing may have erased it in a few places. So on Windows we force it to 255 // drawing may have erased it in a few places. So on Windows we force it to
264 // opaque and also don't write the alpha channel for the reference. Linux 256 // opaque and also don't write the alpha channel for the reference. Linux
265 // doesn't have the wrong alpha like Windows, but we ignore it anyway. 257 // doesn't have the wrong alpha like Windows, but we ignore it anyway.
266 #if defined(OS_WIN) 258 #if defined(OS_WIN)
267 bool discard_transparency = true; 259 bool discard_transparency = true;
268 // TODO(eroman): Clean this up. This used to be device.makeOpaque(), but I 260 device->makeOpaque(0, 0, src_bmp.width(), src_bmp.height());
269 // inlined it when resolving conflicts.
270 uint32_t* data = static_cast<uint32_t*> (src_bmp.getPixels());
271 for (int i = 0; i < src_bmp.width() * src_bmp.height(); ++i) {
272 *(data + i) |= (0xFF << SK_A32_SHIFT);
273 }
274 #elif defined(OS_LINUX) 261 #elif defined(OS_LINUX)
275 bool discard_transparency = true; 262 bool discard_transparency = true;
276 #elif defined(OS_MACOSX) 263 #elif defined(OS_MACOSX)
277 bool discard_transparency = false; 264 bool discard_transparency = false;
278 #endif 265 #endif
279 PNGEncoder::Encode( 266 PNGEncoder::Encode(
280 reinterpret_cast<const unsigned char*>(src_bmp.getPixels()), 267 reinterpret_cast<const unsigned char*>(src_bmp.getPixels()),
281 color_format, src_bmp.width(), src_bmp.height(), 268 color_format, src_bmp.width(), src_bmp.height(),
282 static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png); 269 static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png);
283 270
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 602
616 bool IsDefaultPluginEnabled() { 603 bool IsDefaultPluginEnabled() {
617 return false; 604 return false;
618 } 605 }
619 606
620 std::wstring GetWebKitLocale() { 607 std::wstring GetWebKitLocale() {
621 return L"en-US"; 608 return L"en-US";
622 } 609 }
623 610
624 } // namespace webkit_glue 611 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell.h ('k') | webkit/tools/test_shell/webwidget_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698