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
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_NINE_PATCH_LAYER_H_
6 #define CC_LAYERS_NINE_PATCH_LAYER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/layers/layer.h"
11 #include "cc/layers/ui_resource_layer.h"
12 #include "cc/resources/ui_resource_client.h"
13 #include "ui/gfx/geometry/rect.h"
18 class ScopedUIResource
;
20 class CC_EXPORT NinePatchLayer
: public UIResourceLayer
{
22 static scoped_refptr
<NinePatchLayer
> Create(const LayerSettings
& settings
);
24 void PushPropertiesTo(LayerImpl
* layer
) override
;
26 // |border| is the space around the center rectangular region in layer space
27 // (known as aperture in image space). |border.x()| and |border.y()| are the
28 // size of the left and top boundary, respectively.
29 // |border.width()-border.x()| and |border.height()-border.y()| are the size
30 // of the right and bottom boundary, respectively.
31 void SetBorder(const gfx::Rect
& border
);
33 // aperture is in the pixel space of the bitmap resource and refers to
34 // the center patch of the ninepatch (which is unused in this
35 // implementation). We split off eight rects surrounding it and stick them
36 // on the edges of the layer. The corners are unscaled, the top and bottom
37 // rects are x-stretched to fit, and the left and right rects are
38 // y-stretched to fit.
39 void SetAperture(const gfx::Rect
& aperture
);
40 void SetFillCenter(bool fill_center
);
43 explicit NinePatchLayer(const LayerSettings
& settings
);
44 ~NinePatchLayer() override
;
45 scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
) override
;
50 // The transparent center region that shows the parent layer's contents in
52 gfx::Rect image_aperture_
;
54 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer
);
59 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_