test_surface_id_allocator.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2021 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 COMPONENTS_VIZ_TEST_TEST_SURFACE_ID_ALLOCATOR_H_
  5. #define COMPONENTS_VIZ_TEST_TEST_SURFACE_ID_ALLOCATOR_H_
  6. #include "components/viz/common/surfaces/frame_sink_id.h"
  7. #include "components/viz/common/surfaces/local_surface_id.h"
  8. #include "components/viz/common/surfaces/surface_id.h"
  9. namespace viz {
  10. // A SurfaceId allocator for ease of allocating and incrementing SurfaceIds in
  11. // tests. Avoids boilerplate associated with ParentLocalSurfaceIdAllocator. The
  12. // LocalSurfaceId is initially valid and can be changed via Increment().
  13. // Will implicitly convert to a SurfaceId so it can be used interchangeably with
  14. // one.
  15. class TestSurfaceIdAllocator {
  16. public:
  17. explicit TestSurfaceIdAllocator(const FrameSinkId& frame_sink_id);
  18. const FrameSinkId& frame_sink_id() const {
  19. return surface_id_.frame_sink_id();
  20. }
  21. const LocalSurfaceId& local_surface_id() const {
  22. return surface_id_.local_surface_id();
  23. }
  24. const SurfaceId& Get() const { return surface_id_; }
  25. operator SurfaceId() const { return surface_id_; }
  26. // Increments the child sequence number.
  27. void Increment();
  28. private:
  29. SurfaceId surface_id_;
  30. };
  31. } // namespace viz
  32. #endif // COMPONENTS_VIZ_TEST_TEST_SURFACE_ID_ALLOCATOR_H_