1 // Copyright 2013 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.
5 #ifndef SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_
6 #define SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_
8 #include "base/memory/discardable_memory.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/skia/src/core/SkDiscardableMemory.h"
12 // This class implements the SkDiscardableMemory interface using
13 // base::DiscardableMemory.
14 class SK_API SkDiscardableMemoryChrome
: public SkDiscardableMemory
{
16 SkDiscardableMemoryChrome();
17 virtual ~SkDiscardableMemoryChrome();
19 // Initialize the SkDiscardableMemoryChrome object and lock the memory.
20 // Returns true on success. No memory is allocated if this call returns
21 // false. This call should only be called once.
22 bool InitializeAndLock(size_t bytes
);
24 // Implementation of SkDiscardableMemory interface.
25 virtual bool lock() OVERRIDE
;
26 virtual void* data() OVERRIDE
;
27 virtual void unlock() OVERRIDE
;
30 scoped_ptr
<base::DiscardableMemory
> discardable_
;
33 #endif // SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_