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_IMPL_H_
6 #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
10 #include "cc/base/cc_export.h"
11 #include "cc/layers/layer_impl.h"
12 #include "cc/layers/ui_resource_layer_impl.h"
13 #include "cc/resources/resource_provider.h"
14 #include "cc/resources/ui_resource_client.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/size.h"
19 class DictionaryValue
;
24 class CC_EXPORT NinePatchLayerImpl
: public UIResourceLayerImpl
{
26 static scoped_ptr
<NinePatchLayerImpl
> Create(LayerTreeImpl
* tree_impl
,
28 return make_scoped_ptr(new NinePatchLayerImpl(tree_impl
, id
));
30 virtual ~NinePatchLayerImpl();
32 // The bitmap stretches out the bounds of the layer. The following picture
33 // illustrates the parameters associated with the dimensions.
35 // Layer space layout Bitmap space layout
37 // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~
41 // | ------------ | :~~X~~------------ |
44 // |~~A~~| |~~B~~| H | Q |
46 // | ------------ | : ~~~~~P~~~~~ |
50 // ------------------------ ------------------------
52 // |image_bounds| = (W, H)
53 // |image_aperture| = (X, Y, P, Q)
54 // |border| = (A, C, A + B, C + D)
55 // |fill_center| indicates whether to draw the center quad or not.
56 void SetLayout(const gfx::Rect
& image_aperture
,
57 const gfx::Rect
& border
,
60 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
)
62 virtual void PushPropertiesTo(LayerImpl
* layer
) OVERRIDE
;
64 virtual void AppendQuads(QuadSink
* quad_sink
,
65 AppendQuadsData
* append_quads_data
) OVERRIDE
;
67 virtual base::DictionaryValue
* LayerTreeAsJson() const OVERRIDE
;
70 NinePatchLayerImpl(LayerTreeImpl
* tree_impl
, int id
);
73 virtual const char* LayerTypeAsString() const OVERRIDE
;
75 void CheckGeometryLimitations();
77 // The transparent center region that shows the parent layer's contents in
79 gfx::Rect image_aperture_
;
81 // An inset border that the patches will be mapped to.
86 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl
);
91 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_