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/resources/scoped_resource.h" | 5 #include "cc/resources/scoped_resource.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 ScopedResource::ScopedResource(ResourceProvider* resource_provider) | 9 ScopedResource::ScopedResource(ResourceProvider* resource_provider) |
10 : resource_provider_(resource_provider) { | 10 : resource_provider_(resource_provider) { |
(...skipping 11 matching lines...) Expand all Loading... |
22 DCHECK(!size.IsEmpty()); | 22 DCHECK(!size.IsEmpty()); |
23 | 23 |
24 set_dimensions(size, format); | 24 set_dimensions(size, format); |
25 set_id(resource_provider_->CreateResource(size, hint, format)); | 25 set_id(resource_provider_->CreateResource(size, hint, format)); |
26 | 26 |
27 #if DCHECK_IS_ON() | 27 #if DCHECK_IS_ON() |
28 allocate_thread_id_ = base::PlatformThread::CurrentId(); | 28 allocate_thread_id_ = base::PlatformThread::CurrentId(); |
29 #endif | 29 #endif |
30 } | 30 } |
31 | 31 |
32 void ScopedResource::AllocateWithTextureTarget(const gfx::Size& size, | 32 void ScopedResource::AllocateWithImageTextureTarget(const gfx::Size& size, |
33 GLenum target, | 33 ResourceFormat format) { |
34 ResourceFormat format) { | |
35 DCHECK(!id()); | 34 DCHECK(!id()); |
36 DCHECK(!size.IsEmpty()); | 35 DCHECK(!size.IsEmpty()); |
37 | 36 |
38 set_dimensions(size, format); | 37 set_dimensions(size, format); |
39 set_id(resource_provider_->CreateResourceWithTextureTarget( | 38 set_id(resource_provider_->CreateResourceWithImageTextureTarget( |
40 size, target, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format)); | 39 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format)); |
41 | 40 |
42 #if DCHECK_IS_ON() | 41 #if DCHECK_IS_ON() |
43 allocate_thread_id_ = base::PlatformThread::CurrentId(); | 42 allocate_thread_id_ = base::PlatformThread::CurrentId(); |
44 #endif | 43 #endif |
45 } | 44 } |
46 | 45 |
47 void ScopedResource::Free() { | 46 void ScopedResource::Free() { |
48 if (id()) { | 47 if (id()) { |
49 #if DCHECK_IS_ON() | 48 #if DCHECK_IS_ON() |
50 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId()); | 49 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId()); |
51 #endif | 50 #endif |
52 resource_provider_->DeleteResource(id()); | 51 resource_provider_->DeleteResource(id()); |
53 } | 52 } |
54 set_id(0); | 53 set_id(0); |
55 } | 54 } |
56 | 55 |
57 } // namespace cc | 56 } // namespace cc |
OLD | NEW |