| 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 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Creates a resource which is tagged as being managed for GPU memory | 84 // Creates a resource which is tagged as being managed for GPU memory |
| 85 // accounting purposes. | 85 // accounting purposes. |
| 86 ResourceId CreateManagedResource(gfx::Size size, | 86 ResourceId CreateManagedResource(gfx::Size size, |
| 87 GLenum format, | 87 GLenum format, |
| 88 TextureUsageHint hint); | 88 TextureUsageHint hint); |
| 89 | 89 |
| 90 // You can also explicitly create a specific resource type. | 90 // You can also explicitly create a specific resource type. |
| 91 ResourceId CreateGLTexture(gfx::Size size, | 91 ResourceId CreateGLTexture(gfx::Size size, |
| 92 GLenum format, | 92 GLenum format, |
| 93 GLenum texture_pool, | 93 GLenum texture_pool, |
| 94 GLint wrap_mode, |
| 94 TextureUsageHint hint); | 95 TextureUsageHint hint); |
| 95 | 96 |
| 96 ResourceId CreateBitmap(gfx::Size size); | 97 ResourceId CreateBitmap(gfx::Size size); |
| 97 // Wraps an external texture into a GL resource. | 98 // Wraps an external texture into a GL resource. |
| 98 ResourceId CreateResourceFromExternalTexture( | 99 ResourceId CreateResourceFromExternalTexture( |
| 99 unsigned texture_target, | 100 unsigned texture_target, |
| 100 unsigned texture_id); | 101 unsigned texture_id); |
| 101 | 102 |
| 102 // Wraps an external texture mailbox into a GL resource. | 103 // Wraps an external texture mailbox into a GL resource. |
| 103 ResourceId CreateResourceFromTextureMailbox(const TextureMailbox& mailbox); | 104 ResourceId CreateResourceFromTextureMailbox(const TextureMailbox& mailbox); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // Returns the stride for the image. | 304 // Returns the stride for the image. |
| 304 int GetImageStride(ResourceId id); | 305 int GetImageStride(ResourceId id); |
| 305 | 306 |
| 306 // For tests only! This prevents detecting uninitialized reads. | 307 // For tests only! This prevents detecting uninitialized reads. |
| 307 // Use SetPixels or LockForWrite to allocate implicitly. | 308 // Use SetPixels or LockForWrite to allocate implicitly. |
| 308 void AllocateForTesting(ResourceId id); | 309 void AllocateForTesting(ResourceId id); |
| 309 | 310 |
| 310 // For tests only! | 311 // For tests only! |
| 311 void CreateForTesting(ResourceId id); | 312 void CreateForTesting(ResourceId id); |
| 312 | 313 |
| 314 GLint WrapModeForTesting(ResourceId id); |
| 315 |
| 313 // Sets the current read fence. If a resource is locked for read | 316 // Sets the current read fence. If a resource is locked for read |
| 314 // and has read fences enabled, the resource will not allow writes | 317 // and has read fences enabled, the resource will not allow writes |
| 315 // until this fence has passed. | 318 // until this fence has passed. |
| 316 void SetReadLockFence(scoped_refptr<Fence> fence) { | 319 void SetReadLockFence(scoped_refptr<Fence> fence) { |
| 317 current_read_lock_fence_ = fence; | 320 current_read_lock_fence_ = fence; |
| 318 } | 321 } |
| 319 Fence* GetReadLockFence() { return current_read_lock_fence_.get(); } | 322 Fence* GetReadLockFence() { return current_read_lock_fence_.get(); } |
| 320 | 323 |
| 321 // Enable read lock fences for a specific resource. | 324 // Enable read lock fences for a specific resource. |
| 322 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); | 325 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); |
| 323 | 326 |
| 324 // Indicates if we can currently lock this resource for write. | 327 // Indicates if we can currently lock this resource for write. |
| 325 bool CanLockForWrite(ResourceId id); | 328 bool CanLockForWrite(ResourceId id); |
| 326 | 329 |
| 327 static GLint GetActiveTextureUnit(WebKit::WebGraphicsContext3D* context); | 330 static GLint GetActiveTextureUnit(WebKit::WebGraphicsContext3D* context); |
| 328 | 331 |
| 329 private: | 332 private: |
| 330 struct Resource { | 333 struct Resource { |
| 331 Resource(); | 334 Resource(); |
| 332 ~Resource(); | 335 ~Resource(); |
| 333 Resource(unsigned texture_id, | 336 Resource(unsigned texture_id, |
| 334 gfx::Size size, | 337 gfx::Size size, |
| 335 GLenum format, | 338 GLenum format, |
| 336 GLenum filter, | 339 GLenum filter, |
| 337 GLenum texture_pool, | 340 GLenum texture_pool, |
| 341 GLint wrap_mode, |
| 338 TextureUsageHint hint); | 342 TextureUsageHint hint); |
| 339 Resource(uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter); | 343 Resource(uint8_t* pixels, |
| 344 gfx::Size size, |
| 345 GLenum format, |
| 346 GLenum filter, |
| 347 GLint wrap_mode); |
| 340 | 348 |
| 341 unsigned gl_id; | 349 unsigned gl_id; |
| 342 // Pixel buffer used for set pixels without unnecessary copying. | 350 // Pixel buffer used for set pixels without unnecessary copying. |
| 343 unsigned gl_pixel_buffer_id; | 351 unsigned gl_pixel_buffer_id; |
| 344 // Query used to determine when asynchronous set pixels complete. | 352 // Query used to determine when asynchronous set pixels complete. |
| 345 unsigned gl_upload_query_id; | 353 unsigned gl_upload_query_id; |
| 346 TextureMailbox mailbox; | 354 TextureMailbox mailbox; |
| 347 uint8_t* pixels; | 355 uint8_t* pixels; |
| 348 uint8_t* pixel_buffer; | 356 uint8_t* pixel_buffer; |
| 349 int lock_for_read_count; | 357 int lock_for_read_count; |
| 350 int imported_count; | 358 int imported_count; |
| 351 int exported_count; | 359 int exported_count; |
| 352 bool locked_for_write; | 360 bool locked_for_write; |
| 353 bool external; | 361 bool external; |
| 354 bool marked_for_deletion; | 362 bool marked_for_deletion; |
| 355 bool pending_set_pixels; | 363 bool pending_set_pixels; |
| 356 bool set_pixels_completion_forced; | 364 bool set_pixels_completion_forced; |
| 357 bool allocated; | 365 bool allocated; |
| 358 bool enable_read_lock_fences; | 366 bool enable_read_lock_fences; |
| 359 scoped_refptr<Fence> read_lock_fence; | 367 scoped_refptr<Fence> read_lock_fence; |
| 360 gfx::Size size; | 368 gfx::Size size; |
| 361 GLenum format; | 369 GLenum format; |
| 362 // TODO(skyostil): Use a separate sampler object for filter state. | 370 // TODO(skyostil): Use a separate sampler object for filter state. |
| 363 GLenum filter; | 371 GLenum filter; |
| 364 unsigned image_id; | 372 unsigned image_id; |
| 365 GLenum texture_pool; | 373 GLenum texture_pool; |
| 374 GLint wrap_mode; |
| 366 TextureUsageHint hint; | 375 TextureUsageHint hint; |
| 367 ResourceType type; | 376 ResourceType type; |
| 368 }; | 377 }; |
| 369 typedef base::hash_map<ResourceId, Resource> ResourceMap; | 378 typedef base::hash_map<ResourceId, Resource> ResourceMap; |
| 370 struct Child { | 379 struct Child { |
| 371 Child(); | 380 Child(); |
| 372 ~Child(); | 381 ~Child(); |
| 373 | 382 |
| 374 ResourceIdMap child_to_parent_map; | 383 ResourceIdMap child_to_parent_map; |
| 375 ResourceIdMap parent_to_child_map; | 384 ResourceIdMap parent_to_child_map; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 base::ThreadChecker thread_checker_; | 447 base::ThreadChecker thread_checker_; |
| 439 | 448 |
| 440 scoped_refptr<Fence> current_read_lock_fence_; | 449 scoped_refptr<Fence> current_read_lock_fence_; |
| 441 | 450 |
| 442 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 451 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 443 }; | 452 }; |
| 444 | 453 |
| 445 } // namespace cc | 454 } // namespace cc |
| 446 | 455 |
| 447 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 456 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |