OLD | NEW |
---|---|
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 #ifndef UI_GFX_IMAGESKIA_OPERATIONS_H_ | 5 #ifndef UI_GFX_IMAGESKIA_OPERATIONS_H_ |
6 #define UI_GFX_IMAGESKIA_OPERATIONS_H_ | 6 #define UI_GFX_IMAGESKIA_OPERATIONS_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "ui/base/ui_export.h" | 9 #include "ui/base/ui_export.h" |
10 #include "ui/gfx/size.h" | 10 #include "ui/gfx/color_utils.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 class ImageSkia; | 13 class ImageSkia; |
14 class Rect; | |
15 class Size; | |
14 | 16 |
15 class UI_EXPORT ImageSkiaOperations { | 17 class UI_EXPORT ImageSkiaOperations { |
16 public: | 18 public: |
17 // Create an image that is a blend of two others. The alpha argument | 19 // Create an image that is a blend of two others. The alpha argument |
18 // specifies the opacity of the second imag. The provided image must | 20 // specifies the opacity of the second imag. The provided image must |
19 // use the kARGB_8888_Config config and be of equal dimensions. | 21 // use the kARGB_8888_Config config and be of equal dimensions. |
20 static ImageSkia CreateBlendedImage(const ImageSkia& first, | 22 static ImageSkia CreateBlendedImage(const ImageSkia& first, |
21 const ImageSkia& second, | 23 const ImageSkia& second, |
22 double alpha); | 24 double alpha); |
23 | 25 |
24 // Create an image that is the original image masked out by the mask defined | 26 // Create an image that is the original image masked out by the mask defined |
25 // in the alpha image. The images must use the kARGB_8888_Config config and | 27 // in the alpha image. The images must use the kARGB_8888_Config config and |
26 // be of equal dimensions. | 28 // be of equal dimensions. |
27 static ImageSkia CreateMaskedImage(const ImageSkia& first, | 29 static ImageSkia CreateMaskedImage(const ImageSkia& first, |
28 const ImageSkia& alpha); | 30 const ImageSkia& alpha); |
29 | 31 |
30 // Create an image that is cropped from another image. This is special | 32 // Create an image that is cropped from another image. This is special |
31 // because it tiles the original image, so your coordinates can extend | 33 // because it tiles the original image, so your coordinates can extend |
32 // outside the bounds of the original image. | 34 // outside the bounds of the original image. |
33 static ImageSkia CreateTiledImage(const ImageSkia& image, | 35 static ImageSkia CreateTiledImage(const ImageSkia& image, |
34 int src_x, int src_y, | 36 int src_x, int src_y, |
35 int dst_w, int dst_h); | 37 int dst_w, int dst_h); |
36 | 38 |
39 // We create a button background image by compositing the color and image | |
sky
2012/07/16 21:23:40
We create -> Creates
| |
40 // together, then applying the mask. This is a highly specialized composite | |
41 // operation that is the equivalent of drawing a background in |color|, | |
42 // tiling |image| over the top, and then masking the result out with |mask|. | |
43 // The images must use kARGB_8888_Config config. | |
44 static ImageSkia CreateButtonBackground(SkColor color, | |
45 const gfx::ImageSkia& image, | |
46 const gfx::ImageSkia& mask); | |
47 | |
48 // Returns an image which is a subset of |image| with bounds |subset_bounds|. | |
49 // |image| cannot have image reps of |kA1_Config| config. | |
sky
2012/07/16 21:23:40
What does this second line mean?
kAll_Config?
pkotwicz
2012/07/17 01:15:41
The config of the bitmaps contained by the ImageSk
sky
2012/07/20 23:21:25
Make the comment clearer than. Right now it is con
| |
50 static ImageSkia ExtractSubset(const gfx::ImageSkia& image, | |
51 const gfx::Rect& subset_bounds); | |
52 | |
37 // Creates an image that resizes |source| to given |target_size_in_dip|. | 53 // Creates an image that resizes |source| to given |target_size_in_dip|. |
38 // The resize operation occurs synchronously at the time that the desired | 54 // The resize operation occurs synchronously at the time that the desired |
39 // scale factor is known (either GetRepresentation is called or the image | 55 // scale factor is known (either GetRepresentation is called or the image |
40 // is painted). | 56 // is painted). |
41 // As |source| is cached for the lifetime of this object and the resize | 57 // As |source| is cached for the lifetime of this object and the resize |
42 // operation will most likely be performed on the UI thread, the maximum | 58 // operation will most likely be performed on the UI thread, the maximum |
43 // supported DIP size of |source| and |target_size_in_dip| is 64x64 DIP. | 59 // supported DIP size of |source| and |target_size_in_dip| is 64x64 DIP. |
44 // Resizing larger bitmaps should be done more explicitly using | 60 // Resizing larger bitmaps should be done more explicitly using |
45 // ImageOperations::Resize. | 61 // ImageOperations::Resize. |
46 static ImageSkia CreateResizedImage(const ImageSkia& source, | 62 static ImageSkia CreateResizedImage(const ImageSkia& source, |
47 const Size& target_size_in_dip); | 63 const Size& target_size_in_dip); |
48 | 64 |
49 private: | 65 private: |
50 ImageSkiaOperations(); // Class for scoping only. | 66 ImageSkiaOperations(); // Class for scoping only. |
51 }; | 67 }; |
52 | 68 |
53 } // namespace gfx | 69 } // namespace gfx |
54 | 70 |
55 #endif // UI_GFX_IMAGESKIA_OPERATIONS_H_ | 71 #endif // UI_GFX_IMAGESKIA_OPERATIONS_H_ |
OLD | NEW |