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 #ifndef UI_GFX_NINE_IMAGE_PAINTER_H_ | 5 #ifndef UI_GFX_NINE_IMAGE_PAINTER_H_ |
6 #define UI_GFX_NINE_IMAGE_PAINTER_H_ | 6 #define UI_GFX_NINE_IMAGE_PAINTER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" |
12 #include "ui/gfx/gfx_export.h" | 15 #include "ui/gfx/gfx_export.h" |
13 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
14 | 17 |
15 namespace gfx { | 18 namespace gfx { |
16 | 19 |
17 class Canvas; | 20 class Canvas; |
18 class Insets; | 21 class Insets; |
19 class Rect; | 22 class Rect; |
20 | 23 |
21 class GFX_EXPORT NineImagePainter { | 24 class GFX_EXPORT NineImagePainter { |
22 public: | 25 public: |
23 explicit NineImagePainter(const std::vector<ImageSkia>& images); | 26 explicit NineImagePainter(const std::vector<ImageSkia>& images); |
24 NineImagePainter(const ImageSkia& image, const Insets& insets); | 27 NineImagePainter(const ImageSkia& image, const Insets& insets); |
25 ~NineImagePainter(); | 28 ~NineImagePainter(); |
26 | 29 |
27 bool IsEmpty() const; | 30 bool IsEmpty() const; |
28 Size GetMinimumSize() const; | 31 Size GetMinimumSize() const; |
29 void Paint(Canvas* canvas, const Rect& bounds); | 32 void Paint(Canvas* canvas, const Rect& bounds); |
30 void Paint(Canvas* canvas, const Rect& bounds, uint8 alpha); | 33 void Paint(Canvas* canvas, const Rect& bounds, uint8_t alpha); |
31 | 34 |
32 private: | 35 private: |
33 friend class NineImagePainterTest; | 36 friend class NineImagePainterTest; |
34 FRIEND_TEST_ALL_PREFIXES(NineImagePainterTest, GetSubsetRegions); | 37 FRIEND_TEST_ALL_PREFIXES(NineImagePainterTest, GetSubsetRegions); |
35 | 38 |
36 // Gets the regions for the subimages into |regions|. | 39 // Gets the regions for the subimages into |regions|. |
37 static void GetSubsetRegions(const ImageSkia& image, | 40 static void GetSubsetRegions(const ImageSkia& image, |
38 const Insets& insets, | 41 const Insets& insets, |
39 std::vector<Rect>* regions); | 42 std::vector<Rect>* regions); |
40 | 43 |
41 // Images are numbered as depicted below. | 44 // Images are numbered as depicted below. |
42 // ____________________ | 45 // ____________________ |
43 // |__i0__|__i1__|__i2__| | 46 // |__i0__|__i1__|__i2__| |
44 // |__i3__|__i4__|__i5__| | 47 // |__i3__|__i4__|__i5__| |
45 // |__i6__|__i7__|__i8__| | 48 // |__i6__|__i7__|__i8__| |
46 ImageSkia images_[9]; | 49 ImageSkia images_[9]; |
47 | 50 |
48 DISALLOW_COPY_AND_ASSIGN(NineImagePainter); | 51 DISALLOW_COPY_AND_ASSIGN(NineImagePainter); |
49 }; | 52 }; |
50 | 53 |
51 } // namespace gfx | 54 } // namespace gfx |
52 | 55 |
53 #endif // UI_GFX_NINE_IMAGE_PAINTER_H_ | 56 #endif // UI_GFX_NINE_IMAGE_PAINTER_H_ |
OLD | NEW |