OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_SCOPED_RESOURCE_H_ | 5 #ifndef CC_SCOPED_RESOURCE_H_ |
6 #define CC_SCOPED_RESOURCE_H_ | 6 #define CC_SCOPED_RESOURCE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "cc/cc_export.h" | 11 #include "cc/cc_export.h" |
12 #include "cc/resource.h" | 12 #include "cc/resource.h" |
13 | 13 |
14 #ifndef NDEBUG | 14 #ifndef NDEBUG |
15 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
16 #endif | 16 #endif |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 class CC_EXPORT ScopedResource : protected Resource { | 20 class CC_EXPORT ScopedResource : public Resource { |
21 public: | 21 public: |
22 static scoped_ptr<ScopedResource> create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedResource(resourceProvider)); } | 22 static scoped_ptr<ScopedResource> create(ResourceProvider* resource_provider) { |
tfarina
2012/11/15 23:46:11
static void Foo(Bar* bar) {
^If it
| |
23 virtual ~ScopedResource(); | 23 return make_scoped_ptr(new ScopedResource(resource_provider)); |
24 } | |
25 virtual ~ScopedResource(); | |
24 | 26 |
25 using Resource::id; | 27 bool Allocate(int pool, const gfx::Size&, GLenum format, ResourceProvider::Tex tureUsageHint); |
tfarina
2012/11/15 23:46:11
do want to fix this while you are here?
Write one
| |
26 using Resource::size; | 28 void Free(); |
27 using Resource::format; | 29 void Leak(); |
28 using Resource::bytes; | |
29 | 30 |
30 bool allocate(int pool, const gfx::Size&, GLenum format, ResourceProvider::T extureUsageHint); | 31 protected: |
31 void free(); | 32 explicit ScopedResource(ResourceProvider*); |
32 void leak(); | |
33 | 33 |
34 protected: | 34 private: |
35 explicit ScopedResource(ResourceProvider*); | 35 ResourceProvider* resource_provider_; |
36 | |
37 private: | |
38 ResourceProvider* m_resourceProvider; | |
39 | 36 |
40 #ifndef NDEBUG | 37 #ifndef NDEBUG |
41 base::PlatformThreadId m_allocateThreadIdentifier; | 38 base::PlatformThreadId allocate_thread_id_; |
42 #endif | 39 #endif |
43 | 40 |
44 DISALLOW_COPY_AND_ASSIGN(ScopedResource); | 41 DISALLOW_COPY_AND_ASSIGN(ScopedResource); |
45 }; | 42 }; |
46 | 43 |
47 } | 44 } |
48 | 45 |
49 #endif // CC_SCOPED_RESOURCE_H_ | 46 #endif // CC_SCOPED_RESOURCE_H_ |
OLD | NEW |