| OLD | NEW |
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 scoped_ptr<skia::BitmapPlatformDevice> device; | 241 scoped_ptr<skia::BitmapPlatformDevice> device; |
| 242 if (!web_frame->CaptureImage(&device, true)) | 242 if (!web_frame->CaptureImage(&device, true)) |
| 243 return std::string(); | 243 return std::string(); |
| 244 | 244 |
| 245 const SkBitmap& src_bmp = device->accessBitmap(false); | 245 const SkBitmap& src_bmp = device->accessBitmap(false); |
| 246 | 246 |
| 247 // Encode image. | 247 // Encode image. |
| 248 std::vector<unsigned char> png; | 248 std::vector<unsigned char> png; |
| 249 SkAutoLockPixels src_bmp_lock(src_bmp); | 249 SkAutoLockPixels src_bmp_lock(src_bmp); |
| 250 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; | 250 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; |
| 251 #if defined(OS_WIN) || defined(OS_LINUX) | 251 |
| 252 // Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want |
| 253 // to keep it. On Windows, the alpha channel is wrong since text/form control |
| 254 // drawing may have erased it in a few places. So on Windows we force it to |
| 255 // opaque and also don't write the alpha channel for the reference. Linux |
| 256 // doesn't have the wrong alpha like Windows, but we ignore it anyway. |
| 257 #if defined(OS_WIN) |
| 258 bool discard_transparency = true; |
| 259 device->makeOpaque(0, 0, src_bmp.width(), src_bmp.height()); |
| 260 #elif defined(OS_LINUX) |
| 252 bool discard_transparency = true; | 261 bool discard_transparency = true; |
| 253 #elif defined(OS_MACOSX) | 262 #elif defined(OS_MACOSX) |
| 254 // the expected PNGs in webkit have an alpha channel. We shouldn't discard | |
| 255 // the transparency for reference purposes, though the hashes will still | |
| 256 // match. | |
| 257 bool discard_transparency = false; | 263 bool discard_transparency = false; |
| 258 #endif | 264 #endif |
| 259 PNGEncoder::Encode( | 265 PNGEncoder::Encode( |
| 260 reinterpret_cast<const unsigned char*>(src_bmp.getPixels()), | 266 reinterpret_cast<const unsigned char*>(src_bmp.getPixels()), |
| 261 color_format, src_bmp.width(), src_bmp.height(), | 267 color_format, src_bmp.width(), src_bmp.height(), |
| 262 static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png); | 268 static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png); |
| 263 | 269 |
| 264 // Write to disk. | 270 // Write to disk. |
| 265 file_util::WriteFile(file_name, reinterpret_cast<const char *>(&png[0]), | 271 file_util::WriteFile(file_name, reinterpret_cast<const char *>(&png[0]), |
| 266 png.size()); | 272 png.size()); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 635 |
| 630 uint64 VisitedLinkHash(const char* canonical_url, size_t length) { | 636 uint64 VisitedLinkHash(const char* canonical_url, size_t length) { |
| 631 return 0; | 637 return 0; |
| 632 } | 638 } |
| 633 | 639 |
| 634 bool IsLinkVisited(uint64 link_hash) { | 640 bool IsLinkVisited(uint64 link_hash) { |
| 635 return false; | 641 return false; |
| 636 } | 642 } |
| 637 | 643 |
| 638 } // namespace webkit_glue | 644 } // namespace webkit_glue |
| OLD | NEW |