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 5 #ifndef CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ 6 #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ 7 8 #include <string> 9 10 #include "base/memory/ptr_util.h" 11 #include "cc/cc_export.h" 12 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/nine_patch_generator.h" 14 #include "cc/layers/ui_resource_layer_impl.h" 15 #include "cc/resources/ui_resource_client.h" 16 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/size.h" 18 19 namespace cc { 20 21 class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl { 22 public: Create(LayerTreeImpl * tree_impl,int id)23 static std::unique_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, 24 int id) { 25 return base::WrapUnique(new NinePatchLayerImpl(tree_impl, id)); 26 } 27 NinePatchLayerImpl(const NinePatchLayerImpl&) = delete; 28 ~NinePatchLayerImpl() override; 29 30 NinePatchLayerImpl& operator=(const NinePatchLayerImpl&) = delete; 31 32 // For parameter meanings, see the declaration of NinePatchGenerator. 33 void SetLayout(const gfx::Rect& image_aperture, 34 const gfx::Rect& border, 35 const gfx::Rect& layer_occlusion, 36 bool fill_center, 37 bool nearest_neighbor); 38 39 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; 40 void PushPropertiesTo(LayerImpl* layer) override; 41 42 void AppendQuads(viz::CompositorRenderPass* render_pass, 43 AppendQuadsData* append_quads_data) override; 44 45 void AsValueInto(base::trace_event::TracedValue* state) const override; 46 47 protected: 48 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); 49 50 private: 51 const char* LayerTypeAsString() const override; 52 53 NinePatchGenerator quad_generator_; 54 }; 55 56 } // namespace cc 57 58 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ 59