surface_layer_impl.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2014 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_SURFACE_LAYER_IMPL_H_
  5. #define CC_LAYERS_SURFACE_LAYER_IMPL_H_
  6. #include <memory>
  7. #include "base/bind.h"
  8. #include "base/memory/ptr_util.h"
  9. #include "base/synchronization/waitable_event.h"
  10. #include "cc/cc_export.h"
  11. #include "cc/layers/layer_impl.h"
  12. #include "components/viz/common/quads/surface_draw_quad.h"
  13. #include "components/viz/common/surfaces/surface_id.h"
  14. #include "components/viz/common/surfaces/surface_info.h"
  15. #include "components/viz/common/surfaces/surface_range.h"
  16. namespace cc {
  17. // This must match surface_layer.h's UpdateSubmissionStateCB.
  18. using UpdateSubmissionStateCB =
  19. base::RepeatingCallback<void(bool is_visible, base::WaitableEvent*)>;
  20. class CC_EXPORT SurfaceLayerImpl : public LayerImpl {
  21. public:
  22. static std::unique_ptr<SurfaceLayerImpl> Create(
  23. LayerTreeImpl* tree_impl,
  24. int id,
  25. UpdateSubmissionStateCB update_submission_state_callback);
  26. static std::unique_ptr<SurfaceLayerImpl> Create(LayerTreeImpl* tree_impl,
  27. int id);
  28. SurfaceLayerImpl(const SurfaceLayerImpl&) = delete;
  29. ~SurfaceLayerImpl() override;
  30. SurfaceLayerImpl& operator=(const SurfaceLayerImpl&) = delete;
  31. void SetRange(const viz::SurfaceRange& surface_range,
  32. absl::optional<uint32_t> deadline_in_frames);
  33. const viz::SurfaceRange& range() const { return surface_range_; }
  34. absl::optional<uint32_t> deadline_in_frames() const {
  35. return deadline_in_frames_;
  36. }
  37. void SetStretchContentToFillBounds(bool stretch_content);
  38. bool stretch_content_to_fill_bounds() const {
  39. return stretch_content_to_fill_bounds_;
  40. }
  41. void SetSurfaceHitTestable(bool surface_hit_testable);
  42. bool surface_hit_testable() const { return surface_hit_testable_; }
  43. void SetHasPointerEventsNone(bool has_pointer_events_none);
  44. bool has_pointer_events_none() const { return has_pointer_events_none_; }
  45. void SetIsReflection(bool is_reflection);
  46. bool is_reflection() const { return is_reflection_; }
  47. // LayerImpl overrides.
  48. std::unique_ptr<LayerImpl> CreateLayerImpl(
  49. LayerTreeImpl* tree_impl) const override;
  50. void PushPropertiesTo(LayerImpl* layer) override;
  51. bool WillDraw(DrawMode draw_mode,
  52. viz::ClientResourceProvider* resource_provider) override;
  53. void AppendQuads(viz::CompositorRenderPass* render_pass,
  54. AppendQuadsData* append_quads_data) override;
  55. bool is_surface_layer() const override;
  56. gfx::Rect GetEnclosingVisibleRectInTargetSpace() const override;
  57. protected:
  58. SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id, UpdateSubmissionStateCB);
  59. private:
  60. void GetDebugBorderProperties(SkColor4f* color, float* width) const override;
  61. void AppendRainbowDebugBorder(viz::CompositorRenderPass* render_pass);
  62. void AsValueInto(base::trace_event::TracedValue* dict) const override;
  63. const char* LayerTypeAsString() const override;
  64. UpdateSubmissionStateCB update_submission_state_callback_;
  65. viz::SurfaceRange surface_range_;
  66. absl::optional<uint32_t> deadline_in_frames_;
  67. bool stretch_content_to_fill_bounds_ = false;
  68. bool surface_hit_testable_ = false;
  69. bool has_pointer_events_none_ = false;
  70. bool is_reflection_ = false;
  71. bool will_draw_ = false;
  72. };
  73. } // namespace cc
  74. #endif // CC_LAYERS_SURFACE_LAYER_IMPL_H_