tile_size_calculator.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2019 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_TILE_SIZE_CALCULATOR_H_
  5. #define CC_LAYERS_TILE_SIZE_CALCULATOR_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "cc/cc_export.h"
  8. #include "ui/gfx/geometry/size.h"
  9. namespace cc {
  10. class PictureLayerImpl;
  11. // This class calculates the tile size only when the |affecting_params_|
  12. // or |content_bounds_| is changed.
  13. class CC_EXPORT TileSizeCalculator {
  14. public:
  15. explicit TileSizeCalculator(PictureLayerImpl* layer_impl);
  16. gfx::Size CalculateTileSize();
  17. private:
  18. struct AffectingParams {
  19. int max_texture_size = 0;
  20. bool use_gpu_rasterization = false;
  21. float device_scale_factor = 0.0f;
  22. gfx::Size max_tile_size;
  23. int min_height_for_gpu_raster_tile;
  24. gfx::Size gpu_raster_max_texture_size;
  25. gfx::Size max_untiled_layer_size;
  26. gfx::Size default_tile_size;
  27. gfx::Size layer_content_bounds;
  28. bool operator==(const AffectingParams& other) const;
  29. };
  30. PictureLayerImpl* layer_impl() const { return layer_impl_; }
  31. AffectingParams GetAffectingParams();
  32. bool IsAffectingParamsChanged();
  33. raw_ptr<PictureLayerImpl> layer_impl_;
  34. const bool is_using_raw_draw_;
  35. const double raw_draw_tile_size_factor_;
  36. AffectingParams affecting_params_;
  37. gfx::Size tile_size_;
  38. };
  39. } // namespace cc
  40. #endif // CC_LAYERS_TILE_SIZE_CALCULATOR_H_