nine_patch_layer_impl.h 1.9 KB

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