| 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 "content/public/test/render_widget_test.h" | 5 #include "content/public/test/render_widget_test.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 for (int y = 0; y < bitmap.height(); ++y) { | 124 for (int y = 0; y < bitmap.height(); ++y) { |
| 125 if (argb_color == *bitmap.getAddr32(x, y)) { | 125 if (argb_color == *bitmap.getAddr32(x, y)) { |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void RenderWidgetTest::OutputBitmapToFile(const SkBitmap& bitmap, | 133 void RenderWidgetTest::OutputBitmapToFile(const SkBitmap& bitmap, |
| 134 const FilePath& file_path) { | 134 const base::FilePath& file_path) { |
| 135 scoped_refptr<base::RefCountedBytes> bitmap_data(new base::RefCountedBytes()); | 135 scoped_refptr<base::RefCountedBytes> bitmap_data(new base::RefCountedBytes()); |
| 136 SkAutoLockPixels lock(bitmap); | 136 SkAutoLockPixels lock(bitmap); |
| 137 ASSERT_TRUE(gfx::JPEGCodec::Encode( | 137 ASSERT_TRUE(gfx::JPEGCodec::Encode( |
| 138 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), | 138 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), |
| 139 gfx::JPEGCodec::FORMAT_BGRA, | 139 gfx::JPEGCodec::FORMAT_BGRA, |
| 140 bitmap.width(), | 140 bitmap.width(), |
| 141 bitmap.height(), | 141 bitmap.height(), |
| 142 static_cast<int>(bitmap.rowBytes()), | 142 static_cast<int>(bitmap.rowBytes()), |
| 143 90 /* quality */, | 143 90 /* quality */, |
| 144 &bitmap_data->data())); | 144 &bitmap_data->data())); |
| 145 ASSERT_LT(0, file_util::WriteFile( | 145 ASSERT_LT(0, file_util::WriteFile( |
| 146 file_path, | 146 file_path, |
| 147 reinterpret_cast<const char*>(bitmap_data->front()), | 147 reinterpret_cast<const char*>(bitmap_data->front()), |
| 148 bitmap_data->size())); | 148 bitmap_data->size())); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace content | 151 } // namespace content |
| OLD | NEW |