| 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_IMPL_H_ | 5 #ifndef CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |
| 6 #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ | 6 #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| 11 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
| 12 #include "cc/layers/ui_resource_layer_impl.h" | 12 #include "cc/layers/ui_resource_layer_impl.h" |
| 13 #include "cc/resources/resource_provider.h" | 13 #include "cc/resources/resource_provider.h" |
| 14 #include "cc/resources/ui_resource_client.h" | 14 #include "cc/resources/ui_resource_client.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class DictionaryValue; | 19 class DictionaryValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl { | 24 class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl { |
| 25 public: | 25 public: |
| 26 static scoped_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, | 26 static scoped_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, |
| 27 int id) { | 27 int id) { |
| 28 return make_scoped_ptr(new NinePatchLayerImpl(tree_impl, id)); | 28 return make_scoped_ptr(new NinePatchLayerImpl(tree_impl, id)); |
| 29 } | 29 } |
| 30 virtual ~NinePatchLayerImpl(); | 30 ~NinePatchLayerImpl() override; |
| 31 | 31 |
| 32 // The bitmap stretches out the bounds of the layer. The following picture | 32 // The bitmap stretches out the bounds of the layer. The following picture |
| 33 // illustrates the parameters associated with the dimensions. | 33 // illustrates the parameters associated with the dimensions. |
| 34 // | 34 // |
| 35 // Layer space layout Bitmap space layout | 35 // Layer space layout Bitmap space layout |
| 36 // | 36 // |
| 37 // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~ | 37 // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~ |
| 38 // | : | : : | | 38 // | : | : : | |
| 39 // | C | : Y | | 39 // | C | : Y | |
| 40 // | : | : : | | 40 // | : | : : | |
| 41 // | ------------ | :~~X~~------------ | | 41 // | ------------ | :~~X~~------------ | |
| 42 // | | | | : | : | | 42 // | | | | : | : | |
| 43 // | | | | : | : | | 43 // | | | | : | : | |
| 44 // |~~A~~| |~~B~~| H | Q | | 44 // |~~A~~| |~~B~~| H | Q | |
| 45 // | | | | : | : | | 45 // | | | | : | : | |
| 46 // | ------------ | : ~~~~~P~~~~~ | | 46 // | ------------ | : ~~~~~P~~~~~ | |
| 47 // | : | : | | 47 // | : | : | |
| 48 // | D | : | | 48 // | D | : | |
| 49 // | : | : | | 49 // | : | : | |
| 50 // ------------------------ ------------------------ | 50 // ------------------------ ------------------------ |
| 51 // | 51 // |
| 52 // |image_bounds| = (W, H) | 52 // |image_bounds| = (W, H) |
| 53 // |image_aperture| = (X, Y, P, Q) | 53 // |image_aperture| = (X, Y, P, Q) |
| 54 // |border| = (A, C, A + B, C + D) | 54 // |border| = (A, C, A + B, C + D) |
| 55 // |fill_center| indicates whether to draw the center quad or not. | 55 // |fill_center| indicates whether to draw the center quad or not. |
| 56 void SetLayout(const gfx::Rect& image_aperture, | 56 void SetLayout(const gfx::Rect& image_aperture, |
| 57 const gfx::Rect& border, | 57 const gfx::Rect& border, |
| 58 bool fill_center); | 58 bool fill_center); |
| 59 | 59 |
| 60 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 60 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 61 override; | 61 void PushPropertiesTo(LayerImpl* layer) override; |
| 62 virtual void PushPropertiesTo(LayerImpl* layer) override; | |
| 63 | 62 |
| 64 virtual void AppendQuads(RenderPass* render_pass, | 63 void AppendQuads(RenderPass* render_pass, |
| 65 const Occlusion& occlusion_in_content_space, | 64 const Occlusion& occlusion_in_content_space, |
| 66 AppendQuadsData* append_quads_data) override; | 65 AppendQuadsData* append_quads_data) override; |
| 67 | 66 |
| 68 virtual base::DictionaryValue* LayerTreeAsJson() const override; | 67 base::DictionaryValue* LayerTreeAsJson() const override; |
| 69 | 68 |
| 70 protected: | 69 protected: |
| 71 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); | 70 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); |
| 72 | 71 |
| 73 private: | 72 private: |
| 74 virtual const char* LayerTypeAsString() const override; | 73 const char* LayerTypeAsString() const override; |
| 75 | 74 |
| 76 void CheckGeometryLimitations(); | 75 void CheckGeometryLimitations(); |
| 77 | 76 |
| 78 // The transparent center region that shows the parent layer's contents in | 77 // The transparent center region that shows the parent layer's contents in |
| 79 // image space. | 78 // image space. |
| 80 gfx::Rect image_aperture_; | 79 gfx::Rect image_aperture_; |
| 81 | 80 |
| 82 // An inset border that the patches will be mapped to. | 81 // An inset border that the patches will be mapped to. |
| 83 gfx::Rect border_; | 82 gfx::Rect border_; |
| 84 | 83 |
| 85 bool fill_center_; | 84 bool fill_center_; |
| 86 | 85 |
| 87 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); | 86 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 } // namespace cc | 89 } // namespace cc |
| 91 | 90 |
| 92 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ | 91 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |
| OLD | NEW |