summaryrefslogtreecommitdiff
path: root/chromium/skia/ext/SkDiscardableMemory_chrome.h
blob: a16f249fa2679b5006c45a62a22669b7294de38a (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
// Copyright 2013 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 SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_
#define SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_

#include <memory>

#include "third_party/skia/src/core/SkDiscardableMemory.h"

namespace base {
class DiscardableMemory;

namespace trace_event {
class MemoryAllocatorDump;
class ProcessMemoryDump;
}

}  // namespace base

// This class implements the SkDiscardableMemory interface using
// base::DiscardableMemory.
class SK_API SkDiscardableMemoryChrome : public SkDiscardableMemory {
public:
 ~SkDiscardableMemoryChrome() override;

  // SkDiscardableMemory:
 bool lock() override;
 void* data() override;
 void unlock() override;

 base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump(
     const char* name,
     base::trace_event::ProcessMemoryDump* pmd) const;

private:
  friend class SkDiscardableMemory;

  SkDiscardableMemoryChrome(std::unique_ptr<base::DiscardableMemory> memory);

  std::unique_ptr<base::DiscardableMemory> discardable_;
};

#endif  // SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_