Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
| 13 #include "cc/layers/ui_resource_layer.h" | 13 #include "cc/layers/ui_resource_layer.h" |
| 14 #include "cc/resources/ui_resource_client.h" | 14 #include "cc/resources/ui_resource_client.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 class CC_EXPORT NinePatchLayer : public UIResourceLayer { | 19 class CC_EXPORT NinePatchLayer : public UIResourceLayer { |
| 20 public: | 20 public: |
| 21 static scoped_refptr<NinePatchLayer> Create(); | 21 static scoped_refptr<NinePatchLayer> Create(); |
| 22 | 22 |
| 23 void PushPropertiesTo(LayerImpl* layer) override; | 23 void PushPropertiesTo(LayerImpl* layer) override; |
| 24 | 24 |
| 25 // |border| is the space around the center rectangular region in layer space | 25 // |border| is the space around the center rectangular region in layer space |
| 26 // (known as aperture in image space). |border.x()| and |border.y()| are the | 26 // (known as aperture in image space). |border.x()| and |border.y()| are the |
| 27 // size of the left and top boundary, respectively. | 27 // size of the left and top boundary, respectively. |
| 28 // |border.width()-border.x()| and |border.height()-border.y()| are the size | 28 // |border.width()-border.x()| and |border.height()-border.y()| are the size |
| 29 // of the right and bottom boundary, respectively. | 29 // of the right and bottom boundary, respectively. |
| 30 // TODO(estade): this really ought to be a gfx::Insets and not a gfx::Rect. To | |
|
Evan Stade
2016/12/01 02:39:02
does this make sense? This API was a bit of a head
| |
| 31 // convert from rect to insets, think of x() as left(), y() as top(), width() | |
| 32 // - x() as right(), and height() - y() as bottom(). | |
| 30 void SetBorder(const gfx::Rect& border); | 33 void SetBorder(const gfx::Rect& border); |
| 31 | 34 |
| 32 // aperture is in the pixel space of the bitmap resource and refers to | 35 // aperture is in the pixel space of the bitmap resource and refers to |
| 33 // the center patch of the ninepatch (which is unused in this | 36 // the center patch of the ninepatch (which is unused in this |
| 34 // implementation). We split off eight rects surrounding it and stick them | 37 // implementation). We split off eight rects surrounding it and stick them |
| 35 // on the edges of the layer. The corners are unscaled, the top and bottom | 38 // on the edges of the layer. The corners are unscaled, the top and bottom |
| 36 // rects are x-stretched to fit, and the left and right rects are | 39 // rects are x-stretched to fit, and the left and right rects are |
| 37 // y-stretched to fit. | 40 // y-stretched to fit. |
| 38 void SetAperture(const gfx::Rect& aperture); | 41 void SetAperture(const gfx::Rect& aperture); |
| 39 void SetFillCenter(bool fill_center); | 42 void SetFillCenter(bool fill_center); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 60 // The occluded region in layer space set by SetLayerOcclusion. It is | 63 // The occluded region in layer space set by SetLayerOcclusion. It is |
| 61 // usually larger than |image_aperture_|. | 64 // usually larger than |image_aperture_|. |
| 62 gfx::Rect layer_occlusion_; | 65 gfx::Rect layer_occlusion_; |
| 63 | 66 |
| 64 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); | 67 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 } // namespace cc | 70 } // namespace cc |
| 68 | 71 |
| 69 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ | 72 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ |
| OLD | NEW |