OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 17 matching lines...) Expand all Loading... |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 // This file contains the implementation of ResourceMapBase. | 33 // This file contains the implementation of ResourceMapBase. |
34 | 34 |
35 #include "gpu/command_buffer/service/precompile.h" | 35 #include "gpu/command_buffer/service/precompile.h" |
36 #include "gpu/command_buffer/service/resource.h" | 36 #include "gpu/command_buffer/service/resource.h" |
37 | 37 |
38 namespace command_buffer { | 38 namespace gpu { |
39 | 39 |
40 // Assigns a resource to a resource ID, by setting it at the right location | 40 // Assigns a resource to a resource ID, by setting it at the right location |
41 // into the list, resizing the list if necessary, and destroying an existing | 41 // into the list, resizing the list if necessary, and destroying an existing |
42 // resource if one existed already. | 42 // resource if one existed already. |
43 void ResourceMapBase::Assign(ResourceId id, Resource *resource) { | 43 void ResourceMapBase::Assign(ResourceId id, Resource *resource) { |
44 if (id >= resources_.size()) { | 44 if (id >= resources_.size()) { |
45 resources_.resize(id + 1, NULL); | 45 resources_.resize(id + 1, NULL); |
46 } else { | 46 } else { |
47 Resource *&entry = resources_[id]; | 47 Resource *&entry = resources_[id]; |
48 if (entry) { | 48 if (entry) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // list. | 91 // list. |
92 void ResourceMapBase::DestroyAllResources() { | 92 void ResourceMapBase::DestroyAllResources() { |
93 for (Container::iterator i = resources_.begin(); i != resources_.end(); ++i) { | 93 for (Container::iterator i = resources_.begin(); i != resources_.end(); ++i) { |
94 if (*i) { | 94 if (*i) { |
95 delete *i; | 95 delete *i; |
96 } | 96 } |
97 } | 97 } |
98 resources_.clear(); | 98 resources_.clear(); |
99 } | 99 } |
100 | 100 |
101 } // namespace command_buffer | 101 } // namespace gpu |
OLD | NEW |