| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (!gfx::PNGCodec::Decode( | 176 if (!gfx::PNGCodec::Decode( |
| 177 reinterpret_cast<unsigned char*>(string_as_array(&reference_data)), | 177 reinterpret_cast<unsigned char*>(string_as_array(&reference_data)), |
| 178 reference_data.size(), gfx::PNGCodec::FORMAT_BGRA, &decoded, &w, | 178 reference_data.size(), gfx::PNGCodec::FORMAT_BGRA, &decoded, &w, |
| 179 &h)) { | 179 &h)) { |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (w < kComparisonWidth || h < kComparisonHeight) | 183 if (w < kComparisonWidth || h < kComparisonHeight) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 int32_t* ref_pixels = reinterpret_cast<int32_t*>(vector_as_array(&decoded)); | 186 int32_t* ref_pixels = reinterpret_cast<int32_t*>(decoded.data()); |
| 187 SkAutoLockPixels lock_image(bitmap); | 187 SkAutoLockPixels lock_image(bitmap); |
| 188 int32_t* pixels = static_cast<int32_t*>(bitmap.getPixels()); | 188 int32_t* pixels = static_cast<int32_t*>(bitmap.getPixels()); |
| 189 | 189 |
| 190 int stride = bitmap.rowBytes(); | 190 int stride = bitmap.rowBytes(); |
| 191 for (int y = 0; y < kComparisonHeight; ++y) { | 191 for (int y = 0; y < kComparisonHeight; ++y) { |
| 192 for (int x = 0; x < kComparisonWidth; ++x) { | 192 for (int x = 0; x < kComparisonWidth; ++x) { |
| 193 int32_t pixel = pixels[y * stride / sizeof(int32_t) + x]; | 193 int32_t pixel = pixels[y * stride / sizeof(int32_t) + x]; |
| 194 int pixel_b = pixel & 0xFF; | 194 int pixel_b = pixel & 0xFF; |
| 195 int pixel_g = (pixel >> 8) & 0xFF; | 195 int pixel_g = (pixel >> 8) & 0xFF; |
| 196 int pixel_r = (pixel >> 16) & 0xFF; | 196 int pixel_r = (pixel >> 16) & 0xFF; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (!(*snapshot_matches) && | 233 if (!(*snapshot_matches) && |
| 234 base::CommandLine::ForCurrentProcess()->HasSwitch( | 234 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 235 switches::kRebaselinePixelTests)) { | 235 switches::kRebaselinePixelTests)) { |
| 236 SkBitmap clipped_bitmap; | 236 SkBitmap clipped_bitmap; |
| 237 bitmap.extractSubset(&clipped_bitmap, | 237 bitmap.extractSubset(&clipped_bitmap, |
| 238 SkIRect::MakeWH(kComparisonWidth, kComparisonHeight)); | 238 SkIRect::MakeWH(kComparisonWidth, kComparisonHeight)); |
| 239 std::vector<unsigned char> png_data; | 239 std::vector<unsigned char> png_data; |
| 240 ASSERT_TRUE( | 240 ASSERT_TRUE( |
| 241 gfx::PNGCodec::EncodeBGRASkBitmap(clipped_bitmap, false, &png_data)); | 241 gfx::PNGCodec::EncodeBGRASkBitmap(clipped_bitmap, false, &png_data)); |
| 242 ASSERT_EQ(static_cast<int>(png_data.size()), | 242 ASSERT_EQ(static_cast<int>(png_data.size()), |
| 243 base::WriteFile(reference, reinterpret_cast<const char*>( | 243 base::WriteFile(reference, |
| 244 vector_as_array(&png_data)), | 244 reinterpret_cast<const char*>(png_data.data()), |
| 245 png_data.size())); | 245 png_data.size())); |
| 246 } | 246 } |
| 247 | 247 |
| 248 done_cb.Run(); | 248 done_cb.Run(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace | 251 } // namespace |
| 252 | 252 |
| 253 class PluginPowerSaverBrowserTest : public InProcessBrowserTest { | 253 class PluginPowerSaverBrowserTest : public InProcessBrowserTest { |
| 254 public: | 254 public: |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 624 |
| 625 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { | 625 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { |
| 626 ui_zoom::ZoomController::FromWebContents(GetActiveWebContents()) | 626 ui_zoom::ZoomController::FromWebContents(GetActiveWebContents()) |
| 627 ->SetZoomLevel(4.0); | 627 ->SetZoomLevel(4.0); |
| 628 LoadHTML( | 628 LoadHTML( |
| 629 "<object id='plugin' data='http://otherorigin.com/fake.swf' " | 629 "<object id='plugin' data='http://otherorigin.com/fake.swf' " |
| 630 " type='application/x-ppapi-tests' width='400' height='200'>" | 630 " type='application/x-ppapi-tests' width='400' height='200'>" |
| 631 "</object>"); | 631 "</object>"); |
| 632 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 632 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 633 } | 633 } |
| OLD | NEW |