| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/thumbnails/content_analysis.h" | 5 #include "chrome/browser/thumbnails/content_analysis.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 namespace thumbnailing_utils { | 226 namespace thumbnailing_utils { |
| 227 | 227 |
| 228 void ApplyGaussianGradientMagnitudeFilter(SkBitmap* input_bitmap, | 228 void ApplyGaussianGradientMagnitudeFilter(SkBitmap* input_bitmap, |
| 229 float kernel_sigma) { | 229 float kernel_sigma) { |
| 230 // The purpose of this function is to highlight salient | 230 // The purpose of this function is to highlight salient |
| 231 // (attention-attracting?) features of the image for use in image | 231 // (attention-attracting?) features of the image for use in image |
| 232 // retargeting. | 232 // retargeting. |
| 233 SkAutoLockPixels source_lock(*input_bitmap); | 233 SkAutoLockPixels source_lock(*input_bitmap); |
| 234 DCHECK(input_bitmap); | 234 DCHECK(input_bitmap); |
| 235 DCHECK(input_bitmap->getPixels()); | 235 DCHECK(input_bitmap->getPixels()); |
| 236 DCHECK_EQ(SkBitmap::kA8_Config, input_bitmap->config()); | 236 DCHECK_EQ(kAlpha_8_SkColorType, input_bitmap->colorType()); |
| 237 | 237 |
| 238 // To perform computations we will need one intermediate buffer. It can | 238 // To perform computations we will need one intermediate buffer. It can |
| 239 // very well be just another bitmap. | 239 // very well be just another bitmap. |
| 240 const SkISize image_size = SkISize::Make(input_bitmap->width(), | 240 const SkISize image_size = SkISize::Make(input_bitmap->width(), |
| 241 input_bitmap->height()); | 241 input_bitmap->height()); |
| 242 SkBitmap intermediate; | 242 SkBitmap intermediate; |
| 243 intermediate.allocPixels(input_bitmap->info().makeWH(image_size.width(), | 243 intermediate.allocPixels(input_bitmap->info().makeWH(image_size.width(), |
| 244 image_size.height())); | 244 image_size.height())); |
| 245 | 245 |
| 246 SkBitmap intermediate2; | 246 SkBitmap intermediate2; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 void ExtractImageProfileInformation(const SkBitmap& input_bitmap, | 376 void ExtractImageProfileInformation(const SkBitmap& input_bitmap, |
| 377 const gfx::Rect& area, | 377 const gfx::Rect& area, |
| 378 const gfx::Size& target_size, | 378 const gfx::Size& target_size, |
| 379 bool apply_log, | 379 bool apply_log, |
| 380 std::vector<float>* rows, | 380 std::vector<float>* rows, |
| 381 std::vector<float>* columns) { | 381 std::vector<float>* columns) { |
| 382 SkAutoLockPixels source_lock(input_bitmap); | 382 SkAutoLockPixels source_lock(input_bitmap); |
| 383 DCHECK(rows); | 383 DCHECK(rows); |
| 384 DCHECK(columns); | 384 DCHECK(columns); |
| 385 DCHECK(input_bitmap.getPixels()); | 385 DCHECK(input_bitmap.getPixels()); |
| 386 DCHECK_EQ(SkBitmap::kA8_Config, input_bitmap.config()); | 386 DCHECK_EQ(kAlpha_8_SkColorType, input_bitmap.colorType()); |
| 387 DCHECK_GE(area.x(), 0); | 387 DCHECK_GE(area.x(), 0); |
| 388 DCHECK_GE(area.y(), 0); | 388 DCHECK_GE(area.y(), 0); |
| 389 DCHECK_LE(area.right(), input_bitmap.width()); | 389 DCHECK_LE(area.right(), input_bitmap.width()); |
| 390 DCHECK_LE(area.bottom(), input_bitmap.height()); | 390 DCHECK_LE(area.bottom(), input_bitmap.height()); |
| 391 | 391 |
| 392 // Make sure rows and columns are allocated and initialized to 0. | 392 // Make sure rows and columns are allocated and initialized to 0. |
| 393 rows->clear(); | 393 rows->clear(); |
| 394 columns->clear(); | 394 columns->clear(); |
| 395 rows->resize(area.height(), 0); | 395 rows->resize(area.height(), 0); |
| 396 columns->resize(area.width(), 0); | 396 columns->resize(area.width(), 0); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 target_size, | 760 target_size, |
| 761 &included_rows, | 761 &included_rows, |
| 762 &included_columns); | 762 &included_columns); |
| 763 | 763 |
| 764 // Use the original image and computed inclusion vectors to create a resized | 764 // Use the original image and computed inclusion vectors to create a resized |
| 765 // image. | 765 // image. |
| 766 return ComputeDecimatedImage(source_bitmap, included_rows, included_columns); | 766 return ComputeDecimatedImage(source_bitmap, included_rows, included_columns); |
| 767 } | 767 } |
| 768 | 768 |
| 769 } // thumbnailing_utils | 769 } // thumbnailing_utils |
| OLD | NEW |