1 // Copyright 2013 The Flutter 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 FLUTTER_FLOW_LAYERS_CONTAINER_LAYER_H_ 6 #define FLUTTER_FLOW_LAYERS_CONTAINER_LAYER_H_ 7 8 #include <unordered_map> 9 #include <vector> 10 #include "flutter/flow/layers/layer.h" 11 12 namespace flutter { 13 14 class ContainerLayer : public Layer { 15 public: 16 ContainerLayer(); 17 ~ContainerLayer() override; 18 19 void Add(std::shared_ptr<Layer> layer); 20 21 void Preroll(PrerollContext* context, const SkMatrix& matrix) override; 22 23 #if defined(OS_FUCHSIA) 24 void UpdateScene(SceneUpdateContext& context) override; 25 #endif // defined(OS_FUCHSIA) 26 layers()27 const std::vector<std::shared_ptr<Layer>>& layers() const { return layers_; } 28 IsContainer()29 bool IsContainer() override { return true; } 30 31 void MarkHole(int hole_id, const SkRect& rect); 32 33 void RemoveHole(int hole_id); 34 35 virtual void MergeParentHole(); 36 MapRect(const SkRect & rect)37 virtual SkRect MapRect(const SkRect& rect) { return rect; } 38 HoleRegions()39 const std::unordered_map<int, SkRect>& HoleRegions() { return hole_regions_; } 40 41 protected: 42 void PrerollChildren(PrerollContext* context, 43 const SkMatrix& child_matrix, 44 SkRect* child_paint_bounds); 45 void PaintChildren(PaintContext& context) const; 46 47 #if defined(OS_FUCHSIA) 48 void UpdateSceneChildren(SceneUpdateContext& context); 49 #endif // defined(OS_FUCHSIA) 50 51 // For OpacityLayer to restructure to have a single child. ClearChildren()52 void ClearChildren() { layers_.clear(); } 53 54 std::unordered_map<int, SkRect> hole_regions_; 55 56 private: 57 std::vector<std::shared_ptr<Layer>> layers_; 58 59 FML_DISALLOW_COPY_AND_ASSIGN(ContainerLayer); 60 }; 61 62 } // namespace flutter 63 64 #endif // FLUTTER_FLOW_LAYERS_CONTAINER_LAYER_H_ 65