OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/enhanced_bookmarks/image_store_util.h" | 5 #include "components/enhanced_bookmarks/image_store_util.h" |
6 | 6 |
| 7 #include <stddef.h> |
7 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
8 | 9 |
9 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/macros.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "ui/gfx/color_analysis.h" | 14 #include "ui/gfx/color_analysis.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 // An implementation of RefCountedMemory, where the bytes are stored in a | 17 // An implementation of RefCountedMemory, where the bytes are stored in a |
16 // NSData. This class assumes the NSData is non mutable to avoid a copy. | 18 // NSData. This class assumes the NSData is non mutable to avoid a copy. |
17 class RefCountedNSDataMemory : public base::RefCountedMemory { | 19 class RefCountedNSDataMemory : public base::RefCountedMemory { |
18 public: | 20 public: |
19 explicit RefCountedNSDataMemory(NSData* memory) : data_([memory retain]) {} | 21 explicit RefCountedNSDataMemory(NSData* memory) : data_([memory retain]) {} |
20 | 22 |
(...skipping 24 matching lines...) Expand all Loading... |
45 gfx::Image ImageForBytes(const scoped_refptr<base::RefCountedMemory>& data) { | 47 gfx::Image ImageForBytes(const scoped_refptr<base::RefCountedMemory>& data) { |
46 return gfx::Image([[NSKeyedUnarchiver unarchiveObjectWithData: | 48 return gfx::Image([[NSKeyedUnarchiver unarchiveObjectWithData: |
47 [NSData dataWithBytes:data->front() length:data->size()]] retain]); | 49 [NSData dataWithBytes:data->front() length:data->size()]] retain]); |
48 } | 50 } |
49 | 51 |
50 SkColor DominantColorForImage(const gfx::Image& image) { | 52 SkColor DominantColorForImage(const gfx::Image& image) { |
51 return color_utils::CalculateKMeanColorOfBitmap(*image.ToSkBitmap()); | 53 return color_utils::CalculateKMeanColorOfBitmap(*image.ToSkBitmap()); |
52 } | 54 } |
53 | 55 |
54 } // namespace enhanced_bookmarks | 56 } // namespace enhanced_bookmarks |
OLD | NEW |