OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_LAYERS_NINE_PATCH_LAYER_H_ | 5 #ifndef CC_LAYERS_NINE_PATCH_LAYER_H_ |
6 #define CC_LAYERS_NINE_PATCH_LAYER_H_ | 6 #define CC_LAYERS_NINE_PATCH_LAYER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
12 #include "cc/layers/ui_resource_layer.h" | 12 #include "cc/layers/ui_resource_layer.h" |
13 #include "cc/resources/ui_resource_client.h" | 13 #include "cc/resources/ui_resource_client.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 class LayerTreeHost; | 18 class LayerTreeHost; |
19 class ScopedUIResource; | 19 class ScopedUIResource; |
20 | 20 |
21 class CC_EXPORT NinePatchLayer : public UIResourceLayer { | 21 class CC_EXPORT NinePatchLayer : public UIResourceLayer { |
22 public: | 22 public: |
23 static scoped_refptr<NinePatchLayer> Create(const LayerSettings& settings); | 23 static scoped_refptr<NinePatchLayer> Create(); |
24 | 24 |
25 void PushPropertiesTo(LayerImpl* layer) override; | 25 void PushPropertiesTo(LayerImpl* layer) override; |
26 | 26 |
27 // |border| is the space around the center rectangular region in layer space | 27 // |border| is the space around the center rectangular region in layer space |
28 // (known as aperture in image space). |border.x()| and |border.y()| are the | 28 // (known as aperture in image space). |border.x()| and |border.y()| are the |
29 // size of the left and top boundary, respectively. | 29 // size of the left and top boundary, respectively. |
30 // |border.width()-border.x()| and |border.height()-border.y()| are the size | 30 // |border.width()-border.x()| and |border.height()-border.y()| are the size |
31 // of the right and bottom boundary, respectively. | 31 // of the right and bottom boundary, respectively. |
32 void SetBorder(const gfx::Rect& border); | 32 void SetBorder(const gfx::Rect& border); |
33 | 33 |
34 // aperture is in the pixel space of the bitmap resource and refers to | 34 // aperture is in the pixel space of the bitmap resource and refers to |
35 // the center patch of the ninepatch (which is unused in this | 35 // the center patch of the ninepatch (which is unused in this |
36 // implementation). We split off eight rects surrounding it and stick them | 36 // implementation). We split off eight rects surrounding it and stick them |
37 // on the edges of the layer. The corners are unscaled, the top and bottom | 37 // on the edges of the layer. The corners are unscaled, the top and bottom |
38 // rects are x-stretched to fit, and the left and right rects are | 38 // rects are x-stretched to fit, and the left and right rects are |
39 // y-stretched to fit. | 39 // y-stretched to fit. |
40 void SetAperture(const gfx::Rect& aperture); | 40 void SetAperture(const gfx::Rect& aperture); |
41 void SetFillCenter(bool fill_center); | 41 void SetFillCenter(bool fill_center); |
42 void SetNearestNeighbor(bool nearest_neighbor); | 42 void SetNearestNeighbor(bool nearest_neighbor); |
43 | 43 |
44 private: | 44 private: |
45 explicit NinePatchLayer(const LayerSettings& settings); | 45 NinePatchLayer(); |
46 ~NinePatchLayer() override; | 46 ~NinePatchLayer() override; |
47 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 47 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
48 | 48 |
49 gfx::Rect border_; | 49 gfx::Rect border_; |
50 bool fill_center_; | 50 bool fill_center_; |
51 bool nearest_neighbor_; | 51 bool nearest_neighbor_; |
52 | 52 |
53 // The transparent center region that shows the parent layer's contents in | 53 // The transparent center region that shows the parent layer's contents in |
54 // image space. | 54 // image space. |
55 gfx::Rect image_aperture_; | 55 gfx::Rect image_aperture_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); | 57 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace cc | 60 } // namespace cc |
61 | 61 |
62 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ | 62 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ |
OLD | NEW |