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) { |
11 DCHECK(resource_provider_); | 11 DCHECK(resource_provider_); |
12 } | 12 } |
13 | 13 |
14 ScopedResource::~ScopedResource() { | 14 ScopedResource::~ScopedResource() { |
15 Free(); | 15 Free(); |
16 } | 16 } |
17 | 17 |
18 void ScopedResource::Allocate(const gfx::Size& size, | 18 void ScopedResource::Allocate(const gfx::Size& size, |
19 ResourceProvider::TextureHint hint, | 19 ResourceProvider::TextureHint hint, |
20 ResourceFormat format) { | 20 ResourceFormat format, |
| 21 const gfx::ColorSpace& color_space) { |
21 DCHECK(!id()); | 22 DCHECK(!id()); |
22 DCHECK(!size.IsEmpty()); | 23 DCHECK(!size.IsEmpty()); |
23 | 24 |
24 set_dimensions(size, format); | 25 set_dimensions(size, format); |
25 set_id(resource_provider_->CreateResource(size, hint, format)); | 26 set_id(resource_provider_->CreateResource(size, hint, format, color_space)); |
26 | 27 |
27 #if DCHECK_IS_ON() | 28 #if DCHECK_IS_ON() |
28 allocate_thread_id_ = base::PlatformThread::CurrentId(); | 29 allocate_thread_id_ = base::PlatformThread::CurrentId(); |
29 #endif | 30 #endif |
30 } | 31 } |
31 | 32 |
32 void ScopedResource::AllocateWithGpuMemoryBuffer(const gfx::Size& size, | 33 void ScopedResource::AllocateWithGpuMemoryBuffer( |
33 ResourceFormat format, | 34 const gfx::Size& size, |
34 gfx::BufferUsage usage) { | 35 ResourceFormat format, |
| 36 gfx::BufferUsage usage, |
| 37 const gfx::ColorSpace& color_space) { |
35 DCHECK(!id()); | 38 DCHECK(!id()); |
36 DCHECK(!size.IsEmpty()); | 39 DCHECK(!size.IsEmpty()); |
37 | 40 |
38 set_dimensions(size, format); | 41 set_dimensions(size, format); |
39 set_id(resource_provider_->CreateGpuMemoryBufferResource( | 42 set_id(resource_provider_->CreateGpuMemoryBufferResource( |
40 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, usage)); | 43 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, usage, |
| 44 color_space)); |
41 | 45 |
42 #if DCHECK_IS_ON() | 46 #if DCHECK_IS_ON() |
43 allocate_thread_id_ = base::PlatformThread::CurrentId(); | 47 allocate_thread_id_ = base::PlatformThread::CurrentId(); |
44 #endif | 48 #endif |
45 } | 49 } |
46 | 50 |
47 void ScopedResource::Free() { | 51 void ScopedResource::Free() { |
48 if (id()) { | 52 if (id()) { |
49 #if DCHECK_IS_ON() | 53 #if DCHECK_IS_ON() |
50 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId()); | 54 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId()); |
51 #endif | 55 #endif |
52 resource_provider_->DeleteResource(id()); | 56 resource_provider_->DeleteResource(id()); |
53 } | 57 } |
54 set_id(0); | 58 set_id(0); |
55 } | 59 } |
56 | 60 |
57 } // namespace cc | 61 } // namespace cc |
OLD | NEW |