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_SKBITMAP_OPERATIONS_H_ | 5 #ifndef UI_GFX_SKBITMAP_OPERATIONS_H_ |
| 6 #define UI_GFX_SKBITMAP_OPERATIONS_H_ | 6 #define UI_GFX_SKBITMAP_OPERATIONS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | |
| 10 | |
| 9 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 10 #include "ui/base/ui_export.h" | 12 #include "ui/base/ui_export.h" |
| 11 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
| 12 | 14 |
| 13 namespace gfx { | 15 namespace gfx { |
| 14 class Point; | 16 class Point; |
| 17 class ShadowValue; | |
| 15 class Size; | 18 class Size; |
| 16 } | 19 } |
| 17 | 20 |
| 18 class SkBitmap; | 21 class SkBitmap; |
| 19 | 22 |
| 20 class UI_EXPORT SkBitmapOperations { | 23 class UI_EXPORT SkBitmapOperations { |
| 21 public: | 24 public: |
| 22 // Create a bitmap that is an inverted image of the passed in image. | 25 // Create a bitmap that is an inverted image of the passed in image. |
| 23 // Each color becomes its inverse in the color wheel. So (255, 15, 0) becomes | 26 // Each color becomes its inverse in the color wheel. So (255, 15, 0) becomes |
| 24 // (0, 240, 255). The alpha value is not inverted. | 27 // (0, 240, 255). The alpha value is not inverted. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 | 94 |
| 92 // Unpremultiplies all pixels in |bitmap|. You almost never want to call | 95 // Unpremultiplies all pixels in |bitmap|. You almost never want to call |
| 93 // this, as |SkBitmap|s are always premultiplied by conversion. Call this | 96 // this, as |SkBitmap|s are always premultiplied by conversion. Call this |
| 94 // only if you will pass the bitmap's data into a system function that | 97 // only if you will pass the bitmap's data into a system function that |
| 95 // doesn't expect premultiplied colors. | 98 // doesn't expect premultiplied colors. |
| 96 static SkBitmap UnPreMultiply(const SkBitmap& bitmap); | 99 static SkBitmap UnPreMultiply(const SkBitmap& bitmap); |
| 97 | 100 |
| 98 // Transpose the pixels in |bitmap| by swapping x and y. | 101 // Transpose the pixels in |bitmap| by swapping x and y. |
| 99 static SkBitmap CreateTransposedBtmap(const SkBitmap& bitmap); | 102 static SkBitmap CreateTransposedBtmap(const SkBitmap& bitmap); |
| 100 | 103 |
| 101 // Create a copy of |bitmap| with specified |size|. The image must use the | |
| 102 // kARGB_8888_Config config. | |
| 103 static SkBitmap CreateResizedBitmap(const SkBitmap& bitmap, | |
| 104 const gfx::Size& size); | |
| 105 | |
| 106 // Create a bitmap by combining alpha channel of |bitmap| and color |c|. | 104 // Create a bitmap by combining alpha channel of |bitmap| and color |c|. |
| 107 // The image must use the kARGB_8888_Config config. | 105 // The image must use the kARGB_8888_Config config. |
| 108 static SkBitmap CreateColorMask(const SkBitmap& bitmap, SkColor c); | 106 static SkBitmap CreateColorMask(const SkBitmap& bitmap, SkColor c); |
| 109 | 107 |
| 110 // Create a bitmap with drop shadow added to |bitmap|. |shadow_count| is the | 108 // Create a bitmap with drop shadow added to |bitmap|. |shadow_count| is the |
| 111 // number of shadows to add. |shadow_offset| and |shadow_radius| are arrays | 109 // number of shadows to add. |shadow_offset| and |shadow_radius| are arrays |
| 112 // with |shadow_count| elements to provide definition for each shadow. The | 110 // with |shadow_count| elements to provide definition for each shadow. The |
| 113 // created bitmap would be padded to have enough space for shadows and have | 111 // created bitmap would be padded to have enough space for shadows and have |
| 114 // original bitmap in the center. The image must use the kARGB_8888_Config | 112 // original bitmap in the center. The image must use the kARGB_8888_Config |
| 115 // config. | 113 // config. |
|
Alexei Svitkine (slow)
2012/05/25 18:16:06
Please update the comment (it references things li
xiyuan
2012/05/25 19:34:01
Done. Totally blind. Thanks for pointing out. :p
| |
| 116 static SkBitmap CreateDropShadow(const SkBitmap& bitmap, | 114 static SkBitmap CreateDropShadow( |
| 117 int shadow_count, | 115 const SkBitmap& bitmap, |
| 118 const SkColor* shadow_color, | 116 const std::vector<gfx::ShadowValue>& shadows); |
| 119 const gfx::Point* shadow_offset, | 117 |
| 120 const SkScalar* shadow_radius); | |
| 121 private: | 118 private: |
| 122 SkBitmapOperations(); // Class for scoping only. | 119 SkBitmapOperations(); // Class for scoping only. |
| 123 | 120 |
| 124 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwo); | 121 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwo); |
| 125 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwoSmall); | 122 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwoSmall); |
| 126 }; | 123 }; |
| 127 | 124 |
| 128 #endif // UI_GFX_SKBITMAP_OPERATIONS_H_ | 125 #endif // UI_GFX_SKBITMAP_OPERATIONS_H_ |
| OLD | NEW |