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

Side by Side Diff: ui/gfx/image/image_util.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/image/image_unittest_util.cc ('k') | ui/gfx/image/image_util_unittest.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/image/image_util.h" 5 #include "ui/gfx/image/image_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory>
10 11
11 #include "base/memory/scoped_ptr.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/codec/jpeg_codec.h" 14 #include "ui/gfx/codec/jpeg_codec.h"
15 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
17 17
18 namespace { 18 namespace {
19 19
20 // Returns whether column |x| of |bitmap| has any "visible pixels", where 20 // Returns whether column |x| of |bitmap| has any "visible pixels", where
21 // "visible" is defined as having an opactiy greater than an arbitrary small 21 // "visible" is defined as having an opactiy greater than an arbitrary small
22 // value. 22 // value.
23 bool ColumnHasVisiblePixels(const SkBitmap& bitmap, int x) { 23 bool ColumnHasVisiblePixels(const SkBitmap& bitmap, int x) {
24 const SkAlpha kMinimumVisibleOpacity = 12; 24 const SkAlpha kMinimumVisibleOpacity = 12;
25 for (int y = 0; y < bitmap.height(); ++y) { 25 for (int y = 0; y < bitmap.height(); ++y) {
26 if (SkColorGetA(bitmap.getColor(x, y)) > kMinimumVisibleOpacity) 26 if (SkColorGetA(bitmap.getColor(x, y)) > kMinimumVisibleOpacity)
27 return true; 27 return true;
28 } 28 }
29 return false; 29 return false;
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 namespace gfx { 34 namespace gfx {
35 35
36 // The iOS implementations of the JPEG functions are in image_util_ios.mm. 36 // The iOS implementations of the JPEG functions are in image_util_ios.mm.
37 #if !defined(OS_IOS) 37 #if !defined(OS_IOS)
38 Image ImageFrom1xJPEGEncodedData(const unsigned char* input, 38 Image ImageFrom1xJPEGEncodedData(const unsigned char* input,
39 size_t input_size) { 39 size_t input_size) {
40 scoped_ptr<SkBitmap> bitmap(gfx::JPEGCodec::Decode(input, input_size)); 40 std::unique_ptr<SkBitmap> bitmap(gfx::JPEGCodec::Decode(input, input_size));
41 if (bitmap.get()) 41 if (bitmap.get())
42 return Image::CreateFrom1xBitmap(*bitmap); 42 return Image::CreateFrom1xBitmap(*bitmap);
43 43
44 return Image(); 44 return Image();
45 } 45 }
46 46
47 bool JPEG1xEncodedDataFromImage(const Image& image, int quality, 47 bool JPEG1xEncodedDataFromImage(const Image& image, int quality,
48 std::vector<unsigned char>* dst) { 48 std::vector<unsigned char>* dst) {
49 const gfx::ImageSkiaRep& image_skia_rep = 49 const gfx::ImageSkiaRep& image_skia_rep =
50 image.AsImageSkia().GetRepresentation(1.0f); 50 image.AsImageSkia().GetRepresentation(1.0f);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Since we already know column *left is non-transparent, we can avoid 95 // Since we already know column *left is non-transparent, we can avoid
96 // rechecking that column; hence the '>' here. 96 // rechecking that column; hence the '>' here.
97 for (x = bitmap.width() - 1; x > *left; --x) { 97 for (x = bitmap.width() - 1; x > *left; --x) {
98 if (ColumnHasVisiblePixels(bitmap, x)) 98 if (ColumnHasVisiblePixels(bitmap, x))
99 break; 99 break;
100 } 100 }
101 *right = bitmap.width() - 1 - x; 101 *right = bitmap.width() - 1 - x;
102 } 102 }
103 103
104 } // namespace gfx 104 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_unittest_util.cc ('k') | ui/gfx/image/image_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698