summaryrefslogtreecommitdiffstats
path: root/chromium/cc/layers/tile_size_calculator.h
blob: cd455b922d2b2e273b944905d75a6cce4d81b3fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_LAYERS_TILE_SIZE_CALCULATOR_H_
#define CC_LAYERS_TILE_SIZE_CALCULATOR_H_

#include "cc/cc_export.h"
#include "ui/gfx/geometry/size.h"

namespace cc {

class PictureLayerImpl;

// This class calculates the tile size only when the |affecting_params_|
// or |content_bounds_| is changed.
class CC_EXPORT TileSizeCalculator {
 public:
  explicit TileSizeCalculator(PictureLayerImpl* layer_impl);

  gfx::Size CalculateTileSize();

 private:
  struct AffectingParams {
    int max_texture_size = 0;
    bool use_gpu_rasterization = false;
    float device_scale_factor = 0.0f;
    gfx::Size max_tile_size;
    gfx::Size gpu_raster_max_texture_size;
    gfx::Size max_untiled_layer_size;
    gfx::Size default_tile_size;
    gfx::Size layer_content_bounds;

    bool operator==(const AffectingParams& other);
  };

  PictureLayerImpl* layer_impl() const { return layer_impl_; }
  AffectingParams GetAffectingParams();
  bool IsAffectingParamsChanged();

  PictureLayerImpl* layer_impl_;

  AffectingParams affecting_params_;

  gfx::Size tile_size_;
};

}  // namespace cc

#endif  // CC_LAYERS_TILE_SIZE_CALCULATOR_H_