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 #include "cc/scoped_resource.h" | 5 #include "cc/scoped_resource.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 ScopedResource::ScopedResource(ResourceProvider* resourceProvider) | 9 ScopedResource::ScopedResource(ResourceProvider* resource_provider) |
10 : m_resourceProvider(resourceProvider) | 10 : resource_provider_(resource_provider) { |
11 { | 11 DCHECK(resource_provider_); |
12 DCHECK(m_resourceProvider); | |
13 } | 12 } |
14 | 13 |
15 ScopedResource::~ScopedResource() | 14 ScopedResource::~ScopedResource() { |
16 { | 15 Free(); |
17 free(); | |
18 } | 16 } |
19 | 17 |
20 bool ScopedResource::allocate(int pool, const gfx::Size& size, GLenum format, Re
sourceProvider::TextureUsageHint hint) | 18 bool ScopedResource::Allocate(int pool, const gfx::Size& size, GLenum format, |
21 { | 19 ResourceProvider::TextureUsageHint hint) { |
22 DCHECK(!id()); | 20 DCHECK(!id()); |
23 DCHECK(!size.IsEmpty()); | 21 DCHECK(!size.IsEmpty()); |
24 | 22 |
25 setDimensions(size, format); | 23 set_dimensions(size, format); |
26 setId(m_resourceProvider->createResource(pool, size, format, hint)); | 24 set_id(resource_provider_->createResource(pool, size, format, hint)); |
27 | 25 |
28 #ifndef NDEBUG | 26 #ifndef NDEBUG |
29 m_allocateThreadIdentifier = base::PlatformThread::CurrentId(); | 27 allocate_thread_id_ = base::PlatformThread::CurrentId(); |
30 #endif | 28 #endif |
31 | 29 |
32 return id(); | 30 return id(); |
33 } | 31 } |
34 | 32 |
35 void ScopedResource::free() | 33 void ScopedResource::Free() { |
36 { | 34 if (id()) { |
37 if (id()) { | |
38 #ifndef NDEBUG | 35 #ifndef NDEBUG |
39 DCHECK(m_allocateThreadIdentifier == base::PlatformThread::CurrentId()); | 36 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId()); |
40 #endif | 37 #endif |
41 m_resourceProvider->deleteResource(id()); | 38 resource_provider_->deleteResource(id()); |
42 } | 39 } |
43 setId(0); | 40 set_id(0); |
44 } | 41 } |
45 | 42 |
46 void ScopedResource::leak() | 43 void ScopedResource::Leak() { |
47 { | 44 set_id(0); |
48 setId(0); | |
49 } | 45 } |
50 | 46 |
51 } // namespace cc | 47 } // namespace cc |
OLD | NEW |