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_RESOURCES_SCOPED_RESOURCE_H_ | 5 #ifndef CC_RESOURCES_SCOPED_RESOURCE_H_ |
6 #define CC_RESOURCES_SCOPED_RESOURCE_H_ | 6 #define CC_RESOURCES_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/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "cc/resources/resource.h" | 12 #include "cc/resources/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 : public Resource { | 20 class CC_EXPORT ScopedResource : public Resource { |
21 public: | 21 public: |
22 static scoped_ptr<ScopedResource> Create( | 22 static scoped_ptr<ScopedResource> Create( |
23 ResourceProvider* resource_provider) { | 23 ResourceProvider* resource_provider) { |
24 return make_scoped_ptr(new ScopedResource(resource_provider)); | 24 return make_scoped_ptr(new ScopedResource(resource_provider)); |
25 } | 25 } |
26 virtual ~ScopedResource(); | 26 virtual ~ScopedResource(); |
27 | 27 |
28 void Allocate(const gfx::Size& size, | 28 void Allocate(gfx::Size size, |
29 ResourceProvider::TextureUsageHint hint, | 29 ResourceProvider::TextureUsageHint hint, |
30 ResourceFormat format); | 30 ResourceFormat format); |
31 void AllocateManaged(const gfx::Size& size, | 31 void AllocateManaged(gfx::Size size, GLenum target, ResourceFormat format); |
32 GLenum target, | |
33 ResourceFormat format); | |
34 void Free(); | 32 void Free(); |
35 void Leak(); | 33 void Leak(); |
36 | 34 |
37 protected: | 35 protected: |
38 explicit ScopedResource(ResourceProvider* provider); | 36 explicit ScopedResource(ResourceProvider* provider); |
39 | 37 |
40 private: | 38 private: |
41 ResourceProvider* resource_provider_; | 39 ResourceProvider* resource_provider_; |
42 | 40 |
43 #ifndef NDEBUG | 41 #ifndef NDEBUG |
44 base::PlatformThreadId allocate_thread_id_; | 42 base::PlatformThreadId allocate_thread_id_; |
45 #endif | 43 #endif |
46 | 44 |
47 DISALLOW_COPY_AND_ASSIGN(ScopedResource); | 45 DISALLOW_COPY_AND_ASSIGN(ScopedResource); |
48 }; | 46 }; |
49 | 47 |
50 } // namespace cc | 48 } // namespace cc |
51 | 49 |
52 #endif // CC_RESOURCES_SCOPED_RESOURCE_H_ | 50 #endif // CC_RESOURCES_SCOPED_RESOURCE_H_ |
OLD | NEW |