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