summaryrefslogtreecommitdiffstats
path: root/cc/resources/scoped_resource.h
blob: 6a2c8f1e72760f3513d53e856e284ee2bd5365c9 (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
// Copyright 2012 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_SCOPED_RESOURCE_H_
#define CC_RESOURCES_SCOPED_RESOURCE_H_

#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "cc/resources/resource.h"

#ifndef NDEBUG
#include "base/threading/platform_thread.h"
#endif

namespace cc {

class CC_EXPORT ScopedResource : public Resource {
 public:
  static scoped_ptr<ScopedResource> create(
      ResourceProvider* resource_provider) {
    return make_scoped_ptr(new ScopedResource(resource_provider));
  }
  virtual ~ScopedResource();

  bool Allocate(gfx::Size size,
                GLenum format,
                ResourceProvider::TextureUsageHint hint);
  void Free();
  void Leak();

 protected:
  explicit ScopedResource(ResourceProvider* provider);

 private:
  ResourceProvider* resource_provider_;

#ifndef NDEBUG
  base::PlatformThreadId allocate_thread_id_;
#endif

  DISALLOW_COPY_AND_ASSIGN(ScopedResource);
};

}  // namespace cc

#endif  // CC_RESOURCES_SCOPED_RESOURCE_H_