| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class TextureUploader; | 53 class TextureUploader; |
| 54 | 54 |
| 55 // This class is not thread-safe and can only be called from the thread it was | 55 // This class is not thread-safe and can only be called from the thread it was |
| 56 // created on (in practice, the impl thread). | 56 // created on (in practice, the impl thread). |
| 57 class CC_EXPORT ResourceProvider { | 57 class CC_EXPORT ResourceProvider { |
| 58 public: | 58 public: |
| 59 typedef unsigned ResourceId; | 59 typedef unsigned ResourceId; |
| 60 typedef std::vector<ResourceId> ResourceIdArray; | 60 typedef std::vector<ResourceId> ResourceIdArray; |
| 61 typedef std::set<ResourceId> ResourceIdSet; | 61 typedef std::set<ResourceId> ResourceIdSet; |
| 62 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 62 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
| 63 enum TextureUsageHint { | 63 enum TextureHint { |
| 64 TextureUsageAny, | 64 TextureHintDefault = 0x0, |
| 65 TextureUsageFramebuffer, | 65 TextureHintImmutable = 0x1, |
| 66 TextureHintFramebuffer = 0x2, |
| 67 TextureHintImmutableFramebuffer = |
| 68 TextureHintImmutable | TextureHintFramebuffer |
| 66 }; | 69 }; |
| 67 enum ResourceType { | 70 enum ResourceType { |
| 68 InvalidType = 0, | 71 InvalidType = 0, |
| 69 GLTexture = 1, | 72 GLTexture = 1, |
| 70 Bitmap, | 73 Bitmap, |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 static scoped_ptr<ResourceProvider> Create( | 76 static scoped_ptr<ResourceProvider> Create( |
| 74 OutputSurface* output_surface, | 77 OutputSurface* output_surface, |
| 75 SharedBitmapManager* shared_bitmap_manager, | 78 SharedBitmapManager* shared_bitmap_manager, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 99 bool AllowOverlay(ResourceId id); | 102 bool AllowOverlay(ResourceId id); |
| 100 | 103 |
| 101 // Producer interface. | 104 // Producer interface. |
| 102 | 105 |
| 103 ResourceType default_resource_type() const { return default_resource_type_; } | 106 ResourceType default_resource_type() const { return default_resource_type_; } |
| 104 ResourceType GetResourceType(ResourceId id); | 107 ResourceType GetResourceType(ResourceId id); |
| 105 | 108 |
| 106 // Creates a resource of the default resource type. | 109 // Creates a resource of the default resource type. |
| 107 ResourceId CreateResource(const gfx::Size& size, | 110 ResourceId CreateResource(const gfx::Size& size, |
| 108 GLint wrap_mode, | 111 GLint wrap_mode, |
| 109 TextureUsageHint hint, | 112 TextureHint hint, |
| 110 ResourceFormat format); | 113 ResourceFormat format); |
| 111 | 114 |
| 112 // Creates a resource which is tagged as being managed for GPU memory | 115 // Creates a resource which is tagged as being managed for GPU memory |
| 113 // accounting purposes. | 116 // accounting purposes. |
| 114 ResourceId CreateManagedResource(const gfx::Size& size, | 117 ResourceId CreateManagedResource(const gfx::Size& size, |
| 115 GLenum target, | 118 GLenum target, |
| 116 GLint wrap_mode, | 119 GLint wrap_mode, |
| 117 TextureUsageHint hint, | 120 TextureHint hint, |
| 118 ResourceFormat format); | 121 ResourceFormat format); |
| 119 | 122 |
| 120 // You can also explicitly create a specific resource type. | 123 // You can also explicitly create a specific resource type. |
| 121 ResourceId CreateGLTexture(const gfx::Size& size, | 124 ResourceId CreateGLTexture(const gfx::Size& size, |
| 122 GLenum target, | 125 GLenum target, |
| 123 GLenum texture_pool, | 126 GLenum texture_pool, |
| 124 GLint wrap_mode, | 127 GLint wrap_mode, |
| 125 TextureUsageHint hint, | 128 TextureHint hint, |
| 126 ResourceFormat format); | 129 ResourceFormat format); |
| 127 | 130 |
| 128 ResourceId CreateBitmap(const gfx::Size& size, GLint wrap_mode); | 131 ResourceId CreateBitmap(const gfx::Size& size, GLint wrap_mode); |
| 129 // Wraps an IOSurface into a GL resource. | 132 // Wraps an IOSurface into a GL resource. |
| 130 ResourceId CreateResourceFromIOSurface(const gfx::Size& size, | 133 ResourceId CreateResourceFromIOSurface(const gfx::Size& size, |
| 131 unsigned io_surface_id); | 134 unsigned io_surface_id); |
| 132 | 135 |
| 133 // Wraps an external texture mailbox into a GL resource. | 136 // Wraps an external texture mailbox into a GL resource. |
| 134 ResourceId CreateResourceFromTextureMailbox( | 137 ResourceId CreateResourceFromTextureMailbox( |
| 135 const TextureMailbox& mailbox, | 138 const TextureMailbox& mailbox, |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 383 |
| 381 Resource(); | 384 Resource(); |
| 382 ~Resource(); | 385 ~Resource(); |
| 383 Resource(unsigned texture_id, | 386 Resource(unsigned texture_id, |
| 384 const gfx::Size& size, | 387 const gfx::Size& size, |
| 385 Origin origin, | 388 Origin origin, |
| 386 GLenum target, | 389 GLenum target, |
| 387 GLenum filter, | 390 GLenum filter, |
| 388 GLenum texture_pool, | 391 GLenum texture_pool, |
| 389 GLint wrap_mode, | 392 GLint wrap_mode, |
| 390 TextureUsageHint hint, | 393 TextureHint hint, |
| 391 ResourceFormat format); | 394 ResourceFormat format); |
| 392 Resource(uint8_t* pixels, | 395 Resource(uint8_t* pixels, |
| 393 SharedBitmap* bitmap, | 396 SharedBitmap* bitmap, |
| 394 const gfx::Size& size, | 397 const gfx::Size& size, |
| 395 Origin origin, | 398 Origin origin, |
| 396 GLenum filter, | 399 GLenum filter, |
| 397 GLint wrap_mode); | 400 GLint wrap_mode); |
| 398 Resource(const SharedBitmapId& bitmap_id, | 401 Resource(const SharedBitmapId& bitmap_id, |
| 399 const gfx::Size& size, | 402 const gfx::Size& size, |
| 400 Origin origin, | 403 Origin origin, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 429 gfx::Size size; | 432 gfx::Size size; |
| 430 Origin origin; | 433 Origin origin; |
| 431 GLenum target; | 434 GLenum target; |
| 432 // TODO(skyostil): Use a separate sampler object for filter state. | 435 // TODO(skyostil): Use a separate sampler object for filter state. |
| 433 GLenum original_filter; | 436 GLenum original_filter; |
| 434 GLenum filter; | 437 GLenum filter; |
| 435 unsigned image_id; | 438 unsigned image_id; |
| 436 unsigned bound_image_id; | 439 unsigned bound_image_id; |
| 437 GLenum texture_pool; | 440 GLenum texture_pool; |
| 438 GLint wrap_mode; | 441 GLint wrap_mode; |
| 439 TextureUsageHint hint; | 442 TextureHint hint; |
| 440 ResourceType type; | 443 ResourceType type; |
| 441 ResourceFormat format; | 444 ResourceFormat format; |
| 442 SharedBitmapId shared_bitmap_id; | 445 SharedBitmapId shared_bitmap_id; |
| 443 SharedBitmap* shared_bitmap; | 446 SharedBitmap* shared_bitmap; |
| 444 linked_ptr<GpuRasterBuffer> gpu_raster_buffer; | 447 linked_ptr<GpuRasterBuffer> gpu_raster_buffer; |
| 445 linked_ptr<ImageRasterBuffer> image_raster_buffer; | 448 linked_ptr<ImageRasterBuffer> image_raster_buffer; |
| 446 linked_ptr<PixelRasterBuffer> pixel_raster_buffer; | 449 linked_ptr<PixelRasterBuffer> pixel_raster_buffer; |
| 447 }; | 450 }; |
| 448 typedef base::hash_map<ResourceId, Resource> ResourceMap; | 451 typedef base::hash_map<ResourceId, Resource> ResourceMap; |
| 449 | 452 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 return format_gl_data_format[format]; | 704 return format_gl_data_format[format]; |
| 702 } | 705 } |
| 703 | 706 |
| 704 inline GLenum GLInternalFormat(ResourceFormat format) { | 707 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 705 return GLDataFormat(format); | 708 return GLDataFormat(format); |
| 706 } | 709 } |
| 707 | 710 |
| 708 } // namespace cc | 711 } // namespace cc |
| 709 | 712 |
| 710 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 713 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |