| 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 "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
| 11 #include "ui/gfx/color_utils.h" | 11 #include "ui/gfx/color_utils.h" |
| 12 #include "ui/gfx/shadow_value.h" |
| 12 | 13 |
| 13 namespace gfx { | 14 namespace gfx { |
| 14 class Point; | 15 class Point; |
| 15 class Size; | 16 class Size; |
| 16 } | 17 } |
| 17 | 18 |
| 18 class SkBitmap; | 19 class SkBitmap; |
| 19 | 20 |
| 20 class UI_EXPORT SkBitmapOperations { | 21 class UI_EXPORT SkBitmapOperations { |
| 21 public: | 22 public: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 // Unpremultiplies all pixels in |bitmap|. You almost never want to call | 93 // Unpremultiplies all pixels in |bitmap|. You almost never want to call |
| 93 // this, as |SkBitmap|s are always premultiplied by conversion. Call this | 94 // 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 | 95 // only if you will pass the bitmap's data into a system function that |
| 95 // doesn't expect premultiplied colors. | 96 // doesn't expect premultiplied colors. |
| 96 static SkBitmap UnPreMultiply(const SkBitmap& bitmap); | 97 static SkBitmap UnPreMultiply(const SkBitmap& bitmap); |
| 97 | 98 |
| 98 // Transpose the pixels in |bitmap| by swapping x and y. | 99 // Transpose the pixels in |bitmap| by swapping x and y. |
| 99 static SkBitmap CreateTransposedBtmap(const SkBitmap& bitmap); | 100 static SkBitmap CreateTransposedBtmap(const SkBitmap& bitmap); |
| 100 | 101 |
| 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|. | 102 // Create a bitmap by combining alpha channel of |bitmap| and color |c|. |
| 107 // The image must use the kARGB_8888_Config config. | 103 // The image must use the kARGB_8888_Config config. |
| 108 static SkBitmap CreateColorMask(const SkBitmap& bitmap, SkColor c); | 104 static SkBitmap CreateColorMask(const SkBitmap& bitmap, SkColor c); |
| 109 | 105 |
| 110 // Create a bitmap with drop shadow added to |bitmap|. |shadow_count| is the | 106 // Create a bitmap with drop shadow added to |bitmap|. |shadows| defines |
| 111 // number of shadows to add. |shadow_offset| and |shadow_radius| are arrays | 107 // the shadows to add. The created bitmap would be padded to have enough space |
| 112 // with |shadow_count| elements to provide definition for each shadow. The | 108 // for shadows and have original bitmap in the center. The image must use the |
| 113 // created bitmap would be padded to have enough space for shadows and have | 109 // kARGB_8888_Config config. |
| 114 // original bitmap in the center. The image must use the kARGB_8888_Config | |
| 115 // config. | |
| 116 static SkBitmap CreateDropShadow(const SkBitmap& bitmap, | 110 static SkBitmap CreateDropShadow(const SkBitmap& bitmap, |
| 117 int shadow_count, | 111 const gfx::ShadowValues& shadows); |
| 118 const SkColor* shadow_color, | 112 |
| 119 const gfx::Point* shadow_offset, | |
| 120 const SkScalar* shadow_radius); | |
| 121 private: | 113 private: |
| 122 SkBitmapOperations(); // Class for scoping only. | 114 SkBitmapOperations(); // Class for scoping only. |
| 123 | 115 |
| 124 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwo); | 116 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwo); |
| 125 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwoSmall); | 117 FRIEND_TEST_ALL_PREFIXES(SkBitmapOperationsTest, DownsampleByTwoSmall); |
| 126 }; | 118 }; |
| 127 | 119 |
| 128 #endif // UI_GFX_SKBITMAP_OPERATIONS_H_ | 120 #endif // UI_GFX_SKBITMAP_OPERATIONS_H_ |
| OLD | NEW |