Chromium Code Reviews| 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_IMAGE_IMAGE_SKIA_OPERATIONS_H_ | 5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_OPERATIONS_H_ |
| 6 #define UI_GFX_IMAGE_IMAGE_SKIA_OPERATIONS_H_ | 6 #define UI_GFX_IMAGE_IMAGE_SKIA_OPERATIONS_H_ |
| 7 | 7 |
| 8 #include "skia/ext/image_operations.h" | 8 #include "skia/ext/image_operations.h" |
| 9 #include "third_party/skia/include/core/SkDrawLooper.h" | |
| 10 #include "third_party/skia/include/core/SkPaint.h" | |
| 11 #include "third_party/skia/include/core/SkRRect.h" | |
| 9 #include "ui/gfx/color_utils.h" | 12 #include "ui/gfx/color_utils.h" |
| 10 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 11 #include "ui/gfx/shadow_value.h" | 14 #include "ui/gfx/shadow_value.h" |
| 12 #include "ui/gfx/skbitmap_operations.h" | 15 #include "ui/gfx/skbitmap_operations.h" |
| 13 | 16 |
| 14 namespace gfx { | 17 namespace gfx { |
| 15 class ImageSkia; | 18 class ImageSkia; |
| 16 class Rect; | 19 class Rect; |
| 17 class Size; | 20 class Size; |
| 18 | 21 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 | 83 |
| 81 // Creates an image by resizing |source| to given |target_dip_size|. | 84 // Creates an image by resizing |source| to given |target_dip_size|. |
| 82 static ImageSkia CreateResizedImage(const ImageSkia& source, | 85 static ImageSkia CreateResizedImage(const ImageSkia& source, |
| 83 skia::ImageOperations::ResizeMethod methd, | 86 skia::ImageOperations::ResizeMethod methd, |
| 84 const Size& target_dip_size); | 87 const Size& target_dip_size); |
| 85 | 88 |
| 86 // Creates an image with drop shadow defined in |shadows| for |source|. | 89 // Creates an image with drop shadow defined in |shadows| for |source|. |
| 87 static ImageSkia CreateImageWithDropShadow(const ImageSkia& source, | 90 static ImageSkia CreateImageWithDropShadow(const ImageSkia& source, |
| 88 const ShadowValues& shadows); | 91 const ShadowValues& shadows); |
| 89 | 92 |
| 93 // Creates an image with the given shadows painted around a round rect with | |
| 94 // the given corner radius. The image will be just large enough to paint the | |
| 95 // shadows appropriately with no extra space reserved for "content". | |
|
James Cook
2016/12/05 23:38:35
nice comment
Evan Stade
2016/12/06 00:53:21
thanks
| |
| 96 static ImageSkia CreateShadowNinebox(const ShadowValues& shadows, | |
| 97 float corner_radius); | |
| 98 | |
| 90 // Creates an image that is 1dp wide, suitable for tiling horizontally to | 99 // Creates an image that is 1dp wide, suitable for tiling horizontally to |
| 91 // create a drop shadow effect. The purpose of tiling a static image is to | 100 // create a drop shadow effect. The purpose of tiling a static image is to |
| 92 // avoid repeatedly asking Skia to draw a shadow. | 101 // avoid repeatedly asking Skia to draw a shadow. |
| 93 static gfx::ImageSkia CreateHorizontalShadow( | 102 static ImageSkia CreateHorizontalShadow( |
| 94 const std::vector<ShadowValue>& shadows, | 103 const std::vector<ShadowValue>& shadows, |
| 95 bool fades_down); | 104 bool fades_down); |
| 96 | 105 |
| 97 // Creates an image which is a rotation of the |source|. |rotation| is the | 106 // Creates an image which is a rotation of the |source|. |rotation| is the |
| 98 // amount of clockwise rotation in degrees. | 107 // amount of clockwise rotation in degrees. |
| 99 static ImageSkia CreateRotatedImage( | 108 static ImageSkia CreateRotatedImage( |
| 100 const ImageSkia& source, | 109 const ImageSkia& source, |
| 101 SkBitmapOperations::RotationAmount rotation); | 110 SkBitmapOperations::RotationAmount rotation); |
| 102 | 111 |
| 103 // Creates an icon by painting the second icon as a badge to the first one. | 112 // Creates an icon by painting the second icon as a badge to the first one. |
| 104 // The second icon is in the right corner of the first icon. If the icon | 113 // The second icon is in the right corner of the first icon. If the icon |
| 105 // is valid and the badge is not, the icon will be returned. | 114 // is valid and the badge is not, the icon will be returned. |
| 106 static ImageSkia CreateIconWithBadge(const ImageSkia& icon, | 115 static ImageSkia CreateIconWithBadge(const ImageSkia& icon, |
| 107 const ImageSkia& badge); | 116 const ImageSkia& badge); |
| 108 | 117 |
| 109 private: | 118 private: |
| 110 ImageSkiaOperations(); // Class for scoping only. | 119 ImageSkiaOperations(); // Class for scoping only. |
| 111 }; | 120 }; |
| 112 | 121 |
| 113 } // namespace gfx | 122 } // namespace gfx |
| 114 | 123 |
| 115 #endif // UI_GFX_IMAGE_IMAGE_SKIA_OPERATIONS_H_ | 124 #endif // UI_GFX_IMAGE_IMAGE_SKIA_OPERATIONS_H_ |
| OLD | NEW |