summaryrefslogtreecommitdiffstats
path: root/cc/resources/managed_memory_policy.h
blob: dd8ac255ad710b8749cb215c0c038bbd42210253 (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
// Copyright 2011 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_RESOURCES_MANAGED_MEMORY_POLICY_H_
#define CC_RESOURCES_MANAGED_MEMORY_POLICY_H_

#include "base/basictypes.h"
#include "cc/base/cc_export.h"
#include "cc/resources/tile_priority.h"

namespace cc {

struct CC_EXPORT ManagedMemoryPolicy {
  enum PriorityCutoff {
    CUTOFF_ALLOW_NOTHING,
    CUTOFF_ALLOW_REQUIRED_ONLY,
    CUTOFF_ALLOW_NICE_TO_HAVE,
    CUTOFF_ALLOW_EVERYTHING,
  };

  explicit ManagedMemoryPolicy(size_t bytes_limit_when_visible);
  ManagedMemoryPolicy(size_t bytes_limit_when_visible,
                      PriorityCutoff priority_cutoff_when_visible,
                      size_t bytes_limit_when_not_visible,
                      PriorityCutoff priority_cutoff_when_not_visible);
  bool operator==(const ManagedMemoryPolicy&) const;
  bool operator!=(const ManagedMemoryPolicy&) const;

  size_t bytes_limit_when_visible;
  PriorityCutoff priority_cutoff_when_visible;
  size_t bytes_limit_when_not_visible;
  PriorityCutoff priority_cutoff_when_not_visible;

  static int PriorityCutoffToValue(PriorityCutoff priority_cutoff);
  static TileMemoryLimitPolicy PriorityCutoffToTileMemoryLimitPolicy(
      PriorityCutoff priority_cutoff);
};

}  // namespace cc

#endif  // CC_RESOURCES_MANAGED_MEMORY_POLICY_H_