Chromium Code Reviews| 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/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 ResourceId id = next_id_++; | 262 ResourceId id = next_id_++; |
| 263 unsigned texture_id = 0; | 263 unsigned texture_id = 0; |
| 264 Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR); | 264 Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR); |
| 265 resource.external = true; | 265 resource.external = true; |
| 266 resource.allocated = true; | 266 resource.allocated = true; |
| 267 resource.mailbox = mailbox; | 267 resource.mailbox = mailbox; |
| 268 resources_[id] = resource; | 268 resources_[id] = resource; |
| 269 return id; | 269 return id; |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ResourceProvider::ResizeResource(ResourceId id, gfx::Size size) { | |
|
reveman
2013/03/22 23:56:50
I don't understand why we need this function.
Leandro GraciĆ” Gil
2013/03/25 15:21:02
Considering all the details that need to be tracke
| |
| 273 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 274 ResourceMap::iterator it = resources_.find(id); | |
| 275 CHECK(it != resources_.end()); | |
| 276 Resource* resource = &it->second; | |
| 277 DCHECK(!resource->lock_for_read_count); | |
| 278 DCHECK(!resource->marked_for_deletion); | |
| 279 DCHECK(resource->pending_set_pixels || !resource->locked_for_write); | |
| 280 DCHECK(!resource->exported); | |
| 281 DCHECK(!resource->external); | |
| 282 DCHECK(!resource->gl_pixel_buffer_id && !resource->pixel_buffer); | |
| 283 | |
| 284 if (resource->size != size) { | |
| 285 switch (resource->type) { | |
| 286 case GLTexture: | |
| 287 DCHECK_LE(size.width(), max_texture_size_); | |
| 288 DCHECK_LE(size.height(), max_texture_size_); | |
| 289 resource->allocated = false; | |
| 290 break; | |
| 291 | |
|
piman
2013/03/22 20:52:34
nit: no need for blank line.
| |
| 292 case Bitmap: | |
| 293 DCHECK(resource->pixels); | |
| 294 delete[] resource->pixels; | |
| 295 resource->pixels = new uint8_t[size.width() * size.height() * 4]; | |
| 296 resource->allocated = true; | |
| 297 break; | |
| 298 | |
| 299 default: | |
| 300 NOTREACHED(); | |
|
piman
2013/03/22 20:52:34
nit: we usually don't add the default clause when
| |
| 301 } | |
| 302 | |
| 303 resource->size = size; | |
| 304 } | |
| 305 } | |
| 306 | |
| 272 void ResourceProvider::DeleteResource(ResourceId id) { | 307 void ResourceProvider::DeleteResource(ResourceId id) { |
| 273 DCHECK(thread_checker_.CalledOnValidThread()); | 308 DCHECK(thread_checker_.CalledOnValidThread()); |
| 274 ResourceMap::iterator it = resources_.find(id); | 309 ResourceMap::iterator it = resources_.find(id); |
| 275 CHECK(it != resources_.end()); | 310 CHECK(it != resources_.end()); |
| 276 Resource* resource = &it->second; | 311 Resource* resource = &it->second; |
| 277 DCHECK(!resource->lock_for_read_count); | 312 DCHECK(!resource->lock_for_read_count); |
| 278 DCHECK(!resource->marked_for_deletion); | 313 DCHECK(!resource->marked_for_deletion); |
| 279 DCHECK(resource->pending_set_pixels || !resource->locked_for_write); | 314 DCHECK(resource->pending_set_pixels || !resource->locked_for_write); |
| 280 | 315 |
| 281 if (resource->exported) { | 316 if (resource->exported) { |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1202 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, | 1237 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, |
| 1203 bool enable) { | 1238 bool enable) { |
| 1204 DCHECK(thread_checker_.CalledOnValidThread()); | 1239 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1205 ResourceMap::iterator it = resources_.find(id); | 1240 ResourceMap::iterator it = resources_.find(id); |
| 1206 CHECK(it != resources_.end()); | 1241 CHECK(it != resources_.end()); |
| 1207 Resource* resource = &it->second; | 1242 Resource* resource = &it->second; |
| 1208 resource->enable_read_lock_fences = enable; | 1243 resource->enable_read_lock_fences = enable; |
| 1209 } | 1244 } |
| 1210 | 1245 |
| 1211 } // namespace cc | 1246 } // namespace cc |
| OLD | NEW |