| 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 "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 static std::unique_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, | 28 static std::unique_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, |
| 29 int id) { | 29 int id) { |
| 30 return base::WrapUnique(new NinePatchLayerImpl(tree_impl, id)); | 30 return base::WrapUnique(new NinePatchLayerImpl(tree_impl, id)); |
| 31 } | 31 } |
| 32 ~NinePatchLayerImpl() override; | 32 ~NinePatchLayerImpl() override; |
| 33 | 33 |
| 34 // The bitmap stretches out the bounds of the layer. The following picture | 34 // The bitmap stretches out the bounds of the layer. The following picture |
| 35 // illustrates the parameters associated with the dimensions. | 35 // illustrates the parameters associated with the dimensions. |
| 36 // | 36 // |
| 37 // Layer space layout | 37 // Layer space layout Bitmap space layout |
| 38 // | 38 // |
| 39 // -------------------------------- | 39 // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~ |
| 40 // | : : | | 40 // | : | : : | |
| 41 // | J C | | 41 // | C | : Y | |
| 42 // | : : | | 42 // | : | : : | |
| 43 // | ------------------ | | 43 // | ------------ | :~~X~~------------ | |
| 44 // | | : | | | 44 // | | | | : | : | |
| 45 // |~~~I~~| ------------ | | | 45 // | | | | : | : | |
| 46 // | | | | | | | 46 // |~~A~~| |~~B~~| H | Q | |
| 47 // | | | | | | | 47 // | | | | : | : | |
| 48 // |~~~A~~|~~| |~~|~B~~~~| | 48 // | ------------ | : ~~~~~P~~~~~ | |
| 49 // | | | | | | | 49 // | : | : | |
| 50 // | L ------------ | | | 50 // | D | : | |
| 51 // | | : | | | 51 // | : | : | |
| 52 // | ---K-------------- | | 52 // ------------------------ ------------------------ |
| 53 // | D | | |
| 54 // | : | | |
| 55 // | : | | |
| 56 // -------------------------------- | |
| 57 // | |
| 58 // Bitmap space layout | |
| 59 // | |
| 60 // ~~~~~~~~~~ W ~~~~~~~~~~ | |
| 61 // : : | | |
| 62 // : Y | | |
| 63 // : : | | |
| 64 // :~~X~~------------ | | |
| 65 // : | : | | |
| 66 // : | : | | |
| 67 // H | Q | | |
| 68 // : | : | | |
| 69 // : ~~~~~P~~~~~ | | |
| 70 // : | | |
| 71 // : | | |
| 72 // : | | |
| 73 // ------------------------ | |
| 74 // | 53 // |
| 75 // |image_bounds| = (W, H) | 54 // |image_bounds| = (W, H) |
| 76 // |image_aperture| = (X, Y, P, Q) | 55 // |image_aperture| = (X, Y, P, Q) |
| 77 // |border| = (A, C, A + B, C + D) | 56 // |border| = (A, C, A + B, C + D) |
| 78 // |occlusion_rectangle| = (I, J, K, L) | |
| 79 // |fill_center| indicates whether to draw the center quad or not. | 57 // |fill_center| indicates whether to draw the center quad or not. |
| 80 void SetLayout(const gfx::Rect& image_aperture, | 58 void SetLayout(const gfx::Rect& image_aperture, |
| 81 const gfx::Rect& border, | 59 const gfx::Rect& border, |
| 82 const gfx::Rect& layer_occlusion, | |
| 83 bool fill_center, | 60 bool fill_center, |
| 84 bool nearest_neighbor); | 61 bool nearest_neighbor); |
| 85 | 62 |
| 86 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 63 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 87 void PushPropertiesTo(LayerImpl* layer) override; | 64 void PushPropertiesTo(LayerImpl* layer) override; |
| 88 | 65 |
| 89 void AppendQuads(RenderPass* render_pass, | 66 void AppendQuads(RenderPass* render_pass, |
| 90 AppendQuadsData* append_quads_data) override; | 67 AppendQuadsData* append_quads_data) override; |
| 91 | 68 |
| 92 base::DictionaryValue* LayerTreeAsJson() const override; | 69 base::DictionaryValue* LayerTreeAsJson() const override; |
| 93 | 70 |
| 94 protected: | 71 protected: |
| 95 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); | 72 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); |
| 96 | 73 |
| 97 private: | 74 private: |
| 98 class Patch { | |
| 99 public: | |
| 100 Patch(const gfx::Rect& image_rect, const gfx::Rect& layer_rect); | |
| 101 | |
| 102 gfx::Rect image_rect; | |
| 103 gfx::Rect layer_rect; | |
| 104 }; | |
| 105 | |
| 106 const char* LayerTypeAsString() const override; | 75 const char* LayerTypeAsString() const override; |
| 107 | 76 |
| 108 void CheckGeometryLimitations(); | 77 void CheckGeometryLimitations(); |
| 109 | 78 |
| 110 std::vector<Patch> ComputeQuadsWithOcclusion() const; | |
| 111 std::vector<Patch> ComputeQuadsWithoutOcclusion() const; | |
| 112 | |
| 113 // The transparent center region that shows the parent layer's contents in | 79 // The transparent center region that shows the parent layer's contents in |
| 114 // image space. | 80 // image space. |
| 115 gfx::Rect image_aperture_; | 81 gfx::Rect image_aperture_; |
| 116 | 82 |
| 117 // An inset border that the patches will be mapped to. | 83 // An inset border that the patches will be mapped to. |
| 118 gfx::Rect border_; | 84 gfx::Rect border_; |
| 119 | 85 |
| 120 bool fill_center_; | 86 bool fill_center_; |
| 121 | 87 |
| 122 bool nearest_neighbor_; | 88 bool nearest_neighbor_; |
| 123 | 89 |
| 124 gfx::Rect layer_occlusion_; | |
| 125 | |
| 126 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); | 90 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); |
| 127 }; | 91 }; |
| 128 | 92 |
| 129 } // namespace cc | 93 } // namespace cc |
| 130 | 94 |
| 131 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ | 95 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ |
| OLD | NEW |