| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 class CC_EXPORT ResourceProvider { | 60 class CC_EXPORT ResourceProvider { |
| 61 private: | 61 private: |
| 62 struct Resource; | 62 struct Resource; |
| 63 | 63 |
| 64 public: | 64 public: |
| 65 typedef unsigned ResourceId; | 65 typedef unsigned ResourceId; |
| 66 typedef std::vector<ResourceId> ResourceIdArray; | 66 typedef std::vector<ResourceId> ResourceIdArray; |
| 67 typedef std::set<ResourceId> ResourceIdSet; | 67 typedef std::set<ResourceId> ResourceIdSet; |
| 68 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 68 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
| 69 enum TextureHint { | 69 enum TextureHint { |
| 70 TEXTURE_HINT_DEFAULT = 0x0, | 70 TextureHintDefault = 0x0, |
| 71 TEXTURE_HINT_IMMUTABLE = 0x1, | 71 TextureHintImmutable = 0x1, |
| 72 TEXTURE_HINT_FRAMEBUFFER = 0x2, | 72 TextureHintFramebuffer = 0x2, |
| 73 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = | 73 TextureHintImmutableFramebuffer = |
| 74 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER | 74 TextureHintImmutable | TextureHintFramebuffer |
| 75 }; | 75 }; |
| 76 enum ResourceType { | 76 enum ResourceType { |
| 77 RESOURCE_TYPE_INVALID = 0, | 77 InvalidType = 0, |
| 78 RESOURCE_TYPE_GL_TEXTURE = 1, | 78 GLTexture = 1, |
| 79 RESOURCE_TYPE_BITMAP, | 79 Bitmap, |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 static scoped_ptr<ResourceProvider> Create( | 82 static scoped_ptr<ResourceProvider> Create( |
| 83 OutputSurface* output_surface, | 83 OutputSurface* output_surface, |
| 84 SharedBitmapManager* shared_bitmap_manager, | 84 SharedBitmapManager* shared_bitmap_manager, |
| 85 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 85 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 86 BlockingTaskRunner* blocking_main_thread_task_runner, | 86 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 87 int highp_threshold_min, | 87 int highp_threshold_min, |
| 88 bool use_rgba_4444_texture_format, | 88 bool use_rgba_4444_texture_format, |
| 89 size_t id_allocation_chunk_size); | 89 size_t id_allocation_chunk_size); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 // Wraps an external texture mailbox into a GL resource. | 144 // Wraps an external texture mailbox into a GL resource. |
| 145 ResourceId CreateResourceFromTextureMailbox( | 145 ResourceId CreateResourceFromTextureMailbox( |
| 146 const TextureMailbox& mailbox, | 146 const TextureMailbox& mailbox, |
| 147 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl); | 147 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl); |
| 148 | 148 |
| 149 void DeleteResource(ResourceId id); | 149 void DeleteResource(ResourceId id); |
| 150 | 150 |
| 151 // Update pixels from image, copying source_rect (in image) to dest_offset (in | 151 // Update pixels from image, copying source_rect (in image) to dest_offset (in |
| 152 // the resource). | 152 // the resource). |
| 153 // NOTE: DEPRECATED. Use CopyToResource() instead. | |
| 154 void SetPixels(ResourceId id, | 153 void SetPixels(ResourceId id, |
| 155 const uint8_t* image, | 154 const uint8_t* image, |
| 156 const gfx::Rect& image_rect, | 155 const gfx::Rect& image_rect, |
| 157 const gfx::Rect& source_rect, | 156 const gfx::Rect& source_rect, |
| 158 const gfx::Vector2d& dest_offset); | 157 const gfx::Vector2d& dest_offset); |
| 159 void CopyToResource(ResourceId id, | |
| 160 const uint8_t* image, | |
| 161 const gfx::Size& image_size); | |
| 162 | 158 |
| 163 // Check upload status. | 159 // Check upload status. |
| 164 size_t NumBlockingUploads(); | 160 size_t NumBlockingUploads(); |
| 165 void MarkPendingUploadsAsNonBlocking(); | 161 void MarkPendingUploadsAsNonBlocking(); |
| 166 size_t EstimatedUploadsPerTick(); | 162 size_t EstimatedUploadsPerTick(); |
| 167 void FlushUploads(); | 163 void FlushUploads(); |
| 168 void ReleaseCachedData(); | 164 void ReleaseCachedData(); |
| 169 base::TimeTicks EstimatedUploadCompletionTime(size_t uploads_per_tick); | 165 base::TimeTicks EstimatedUploadCompletionTime(size_t uploads_per_tick); |
| 170 | 166 |
| 171 // Only flush the command buffer if supported. | 167 // Only flush the command buffer if supported. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 void WaitSyncPointIfNeeded(ResourceId id); | 427 void WaitSyncPointIfNeeded(ResourceId id); |
| 432 | 428 |
| 433 void WaitReadLockIfNeeded(ResourceId id); | 429 void WaitReadLockIfNeeded(ResourceId id); |
| 434 | 430 |
| 435 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 431 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
| 436 | 432 |
| 437 OutputSurface* output_surface() { return output_surface_; } | 433 OutputSurface* output_surface() { return output_surface_; } |
| 438 | 434 |
| 439 private: | 435 private: |
| 440 struct Resource { | 436 struct Resource { |
| 441 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; | 437 enum Origin { Internal, External, Delegated }; |
| 442 | 438 |
| 443 Resource(); | 439 Resource(); |
| 444 ~Resource(); | 440 ~Resource(); |
| 445 Resource(unsigned texture_id, | 441 Resource(unsigned texture_id, |
| 446 const gfx::Size& size, | 442 const gfx::Size& size, |
| 447 Origin origin, | 443 Origin origin, |
| 448 GLenum target, | 444 GLenum target, |
| 449 GLenum filter, | 445 GLenum filter, |
| 450 GLenum texture_pool, | 446 GLenum texture_pool, |
| 451 GLint wrap_mode, | 447 GLint wrap_mode, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 Resource* LockForWrite(ResourceId id); | 540 Resource* LockForWrite(ResourceId id); |
| 545 void UnlockForWrite(Resource* resource); | 541 void UnlockForWrite(Resource* resource); |
| 546 | 542 |
| 547 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 543 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 548 const Resource* resource); | 544 const Resource* resource); |
| 549 | 545 |
| 550 void TransferResource(gpu::gles2::GLES2Interface* gl, | 546 void TransferResource(gpu::gles2::GLES2Interface* gl, |
| 551 ResourceId id, | 547 ResourceId id, |
| 552 TransferableResource* resource); | 548 TransferableResource* resource); |
| 553 enum DeleteStyle { | 549 enum DeleteStyle { |
| 554 NORMAL, | 550 Normal, |
| 555 FOR_SHUTDOWN, | 551 ForShutdown, |
| 556 }; | 552 }; |
| 557 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); | 553 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); |
| 558 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, | 554 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, |
| 559 DeleteStyle style, | 555 DeleteStyle style, |
| 560 const ResourceIdArray& unused); | 556 const ResourceIdArray& unused); |
| 561 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); | 557 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); |
| 562 void LazyCreate(Resource* resource); | 558 void LazyCreate(Resource* resource); |
| 563 void LazyAllocate(Resource* resource); | 559 void LazyAllocate(Resource* resource); |
| 564 | 560 |
| 565 void BindImageForSampling(Resource* resource); | 561 void BindImageForSampling(Resource* resource); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 return format_gl_data_format[format]; | 656 return format_gl_data_format[format]; |
| 661 } | 657 } |
| 662 | 658 |
| 663 inline GLenum GLInternalFormat(ResourceFormat format) { | 659 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 664 return GLDataFormat(format); | 660 return GLDataFormat(format); |
| 665 } | 661 } |
| 666 | 662 |
| 667 } // namespace cc | 663 } // namespace cc |
| 668 | 664 |
| 669 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 665 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |