[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 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. |
| 4 | |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 5 | #ifndef CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |
| 6 | #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 7 | |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 8 | #include <string> |
| 9 | |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 10 | #include "cc/base/cc_export.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 11 | #include "cc/layers/layer_impl.h" |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 12 | #include "cc/layers/ui_resource_layer_impl.h" |
[email protected] | e12dd0e | 2013-03-18 08:24:40 | [diff] [blame] | 13 | #include "cc/resources/resource_provider.h" |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 14 | #include "cc/resources/ui_resource_client.h" |
heejin.r.chung | d28506ba | 2014-10-23 16:36:20 | [diff] [blame^] | 15 | #include "ui/gfx/geometry/rect.h" |
| 16 | #include "ui/gfx/geometry/size.h" |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 17 | |
[email protected] | 4a23c374c | 2012-12-08 08:38:55 | [diff] [blame] | 18 | namespace base { |
| 19 | class DictionaryValue; |
| 20 | } |
| 21 | |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 22 | namespace cc { |
| 23 | |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 24 | class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl { |
[email protected] | 37adf94 | 2013-03-08 04:43:17 | [diff] [blame] | 25 | public: |
| 26 | static scoped_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, |
| 27 | int id) { |
| 28 | return make_scoped_ptr(new NinePatchLayerImpl(tree_impl, id)); |
| 29 | } |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 30 | ~NinePatchLayerImpl() override; |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 31 | |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 32 | // The bitmap stretches out the bounds of the layer. The following picture |
| 33 | // illustrates the parameters associated with the dimensions. |
| 34 | // |
| 35 | // Layer space layout Bitmap space layout |
| 36 | // |
| 37 | // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~ |
| 38 | // | : | : : | |
| 39 | // | C | : Y | |
| 40 | // | : | : : | |
| 41 | // | ------------ | :~~X~~------------ | |
| 42 | // | | | | : | : | |
| 43 | // | | | | : | : | |
| 44 | // |~~A~~| |~~B~~| H | Q | |
| 45 | // | | | | : | : | |
| 46 | // | ------------ | : ~~~~~P~~~~~ | |
| 47 | // | : | : | |
| 48 | // | D | : | |
| 49 | // | : | : | |
| 50 | // ------------------------ ------------------------ |
| 51 | // |
| 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. |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 56 | void SetLayout(const gfx::Rect& image_aperture, |
| 57 | const gfx::Rect& border, |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 58 | bool fill_center); |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 59 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 60 | scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 61 | void PushPropertiesTo(LayerImpl* layer) override; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 62 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 63 | void AppendQuads(RenderPass* render_pass, |
| 64 | const Occlusion& occlusion_in_content_space, |
| 65 | AppendQuadsData* append_quads_data) override; |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 66 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 67 | base::DictionaryValue* LayerTreeAsJson() const override; |
[email protected] | 4a23c374c | 2012-12-08 08:38:55 | [diff] [blame] | 68 | |
[email protected] | 37adf94 | 2013-03-08 04:43:17 | [diff] [blame] | 69 | protected: |
| 70 | NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 71 | |
[email protected] | 37adf94 | 2013-03-08 04:43:17 | [diff] [blame] | 72 | private: |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 73 | const char* LayerTypeAsString() const override; |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 74 | |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 75 | void CheckGeometryLimitations(); |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 76 | |
[email protected] | 37adf94 | 2013-03-08 04:43:17 | [diff] [blame] | 77 | // The transparent center region that shows the parent layer's contents in |
| 78 | // image space. |
| 79 | gfx::Rect image_aperture_; |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 80 | |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 81 | // An inset border that the patches will be mapped to. |
| 82 | gfx::Rect border_; |
| 83 | |
| 84 | bool fill_center_; |
| 85 | |
[email protected] | fa2d9a5 | 2013-03-27 18:47:08 | [diff] [blame] | 86 | DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 87 | }; |
| 88 | |
[email protected] | ffaa2a63 | 2012-11-11 14:47:50 | [diff] [blame] | 89 | } // namespace cc |
[email protected] | 35680c0 | 2012-11-06 05:53:00 | [diff] [blame] | 90 | |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 91 | #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |