Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/gfx/color_analysis.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/codec/jpeg_codec.cc ('k') | ui/gfx/font_render_params_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/gfx/color_analysis.h" 5 #include "ui/gfx/color_analysis.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <limits> 11 #include <limits>
12 #include <memory>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "third_party/skia/include/core/SkUnPreMultiply.h" 17 #include "third_party/skia/include/core/SkUnPreMultiply.h"
18 #include "ui/gfx/codec/png_codec.h" 18 #include "ui/gfx/codec/png_codec.h"
19 #include "ui/gfx/color_utils.h" 19 #include "ui/gfx/color_utils.h"
20 20
21 namespace color_utils { 21 namespace color_utils {
22 namespace { 22 namespace {
23 23
24 // RGBA KMean Constants 24 // RGBA KMean Constants
25 const uint32_t kNumberOfClusters = 4; 25 const uint32_t kNumberOfClusters = 4;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 390 }
391 391
392 SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap, 392 SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap,
393 const HSL& lower_bound, 393 const HSL& lower_bound,
394 const HSL& upper_bound, 394 const HSL& upper_bound,
395 KMeanImageSampler* sampler) { 395 KMeanImageSampler* sampler) {
396 // SkBitmap uses pre-multiplied alpha but the KMean clustering function 396 // SkBitmap uses pre-multiplied alpha but the KMean clustering function
397 // above uses non-pre-multiplied alpha. Transform the bitmap before we 397 // above uses non-pre-multiplied alpha. Transform the bitmap before we
398 // analyze it because the function reads each pixel multiple times. 398 // analyze it because the function reads each pixel multiple times.
399 int pixel_count = bitmap.width() * bitmap.height(); 399 int pixel_count = bitmap.width() * bitmap.height();
400 scoped_ptr<uint32_t[]> image(new uint32_t[pixel_count]); 400 std::unique_ptr<uint32_t[]> image(new uint32_t[pixel_count]);
401 UnPreMultiply(bitmap, image.get(), pixel_count); 401 UnPreMultiply(bitmap, image.get(), pixel_count);
402 402
403 return CalculateKMeanColorOfBuffer(reinterpret_cast<uint8_t*>(image.get()), 403 return CalculateKMeanColorOfBuffer(reinterpret_cast<uint8_t*>(image.get()),
404 bitmap.width(), 404 bitmap.width(),
405 bitmap.height(), 405 bitmap.height(),
406 lower_bound, 406 lower_bound,
407 upper_bound, 407 upper_bound,
408 sampler); 408 sampler);
409 } 409 }
410 410
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 gfx::Matrix3F covariance = ComputeColorCovariance(source_bitmap); 576 gfx::Matrix3F covariance = ComputeColorCovariance(source_bitmap);
577 gfx::Matrix3F eigenvectors = gfx::Matrix3F::Zeros(); 577 gfx::Matrix3F eigenvectors = gfx::Matrix3F::Zeros();
578 gfx::Vector3dF eigenvals = covariance.SolveEigenproblem(&eigenvectors); 578 gfx::Vector3dF eigenvals = covariance.SolveEigenproblem(&eigenvectors);
579 gfx::Vector3dF principal = eigenvectors.get_column(0); 579 gfx::Vector3dF principal = eigenvectors.get_column(0);
580 if (eigenvals == gfx::Vector3dF() || principal == gfx::Vector3dF()) 580 if (eigenvals == gfx::Vector3dF() || principal == gfx::Vector3dF())
581 return false; // This may happen for some edge cases. 581 return false; // This may happen for some edge cases.
582 return ApplyColorReduction(source_bitmap, principal, true, target_bitmap); 582 return ApplyColorReduction(source_bitmap, principal, true, target_bitmap);
583 } 583 }
584 584
585 } // color_utils 585 } // color_utils
OLDNEW
« no previous file with comments | « ui/gfx/codec/jpeg_codec.cc ('k') | ui/gfx/font_render_params_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698