| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/chrome_render_frame_observer.h" | 5 #include "chrome/renderer/chrome_render_frame_observer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 thumbnail_max_size_pixels); | 202 thumbnail_max_size_pixels); |
| 203 } | 203 } |
| 204 | 204 |
| 205 SkBitmap bitmap; | 205 SkBitmap bitmap; |
| 206 if (thumbnail.colorType() == kN32_SkColorType) | 206 if (thumbnail.colorType() == kN32_SkColorType) |
| 207 bitmap = thumbnail; | 207 bitmap = thumbnail; |
| 208 else | 208 else |
| 209 thumbnail.copyTo(&bitmap, kN32_SkColorType); | 209 thumbnail.copyTo(&bitmap, kN32_SkColorType); |
| 210 | 210 |
| 211 std::vector<uint8_t> thumbnail_data; | 211 std::vector<uint8_t> thumbnail_data; |
| 212 SkAutoLockPixels lock(bitmap); | |
| 213 if (bitmap.getPixels()) { | 212 if (bitmap.getPixels()) { |
| 214 const int kDefaultQuality = 90; | 213 const int kDefaultQuality = 90; |
| 215 std::vector<unsigned char> data; | 214 std::vector<unsigned char> data; |
| 216 if (gfx::JPEGCodec::Encode( | 215 if (gfx::JPEGCodec::Encode( |
| 217 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), | 216 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), |
| 218 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), | 217 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), |
| 219 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) { | 218 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) { |
| 220 thumbnail_data.swap(data); | 219 thumbnail_data.swap(data); |
| 221 } | 220 } |
| 222 } | 221 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 359 |
| 361 void ChromeRenderFrameObserver::OnImageContextMenuRendererRequest( | 360 void ChromeRenderFrameObserver::OnImageContextMenuRendererRequest( |
| 362 chrome::mojom::ImageContextMenuRendererRequest request) { | 361 chrome::mojom::ImageContextMenuRendererRequest request) { |
| 363 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); | 362 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); |
| 364 } | 363 } |
| 365 | 364 |
| 366 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( | 365 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( |
| 367 chrome::mojom::ThumbnailCapturerRequest request) { | 366 chrome::mojom::ThumbnailCapturerRequest request) { |
| 368 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); | 367 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); |
| 369 } | 368 } |
| OLD | NEW |