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 TextureHintDefault = 0x0, | 70 TEXTURE_HINT_DEFAULT = 0x0, |
71 TextureHintImmutable = 0x1, | 71 TEXTURE_HINT_IMMUTABLE = 0x1, |
72 TextureHintFramebuffer = 0x2, | 72 TEXTURE_HINT_FRAMEBUFFER = 0x2, |
73 TextureHintImmutableFramebuffer = | 73 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = |
74 TextureHintImmutable | TextureHintFramebuffer | 74 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER |
75 }; | 75 }; |
76 enum ResourceType { | 76 enum ResourceType { |
77 InvalidType = 0, | 77 RESOURCE_TYPE_INVALID = 0, |
78 GLTexture = 1, | 78 RESOURCE_TYPE_GL_TEXTURE = 1, |
79 Bitmap, | 79 RESOURCE_TYPE_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. |
153 void SetPixels(ResourceId id, | 154 void SetPixels(ResourceId id, |
154 const uint8_t* image, | 155 const uint8_t* image, |
155 const gfx::Rect& image_rect, | 156 const gfx::Rect& image_rect, |
156 const gfx::Rect& source_rect, | 157 const gfx::Rect& source_rect, |
157 const gfx::Vector2d& dest_offset); | 158 const gfx::Vector2d& dest_offset); |
| 159 void CopyToResource(ResourceId id, |
| 160 const uint8_t* image, |
| 161 const gfx::Size& image_size); |
158 | 162 |
159 // Check upload status. | 163 // Check upload status. |
160 size_t NumBlockingUploads(); | 164 size_t NumBlockingUploads(); |
161 void MarkPendingUploadsAsNonBlocking(); | 165 void MarkPendingUploadsAsNonBlocking(); |
162 size_t EstimatedUploadsPerTick(); | 166 size_t EstimatedUploadsPerTick(); |
163 void FlushUploads(); | 167 void FlushUploads(); |
164 void ReleaseCachedData(); | 168 void ReleaseCachedData(); |
165 base::TimeTicks EstimatedUploadCompletionTime(size_t uploads_per_tick); | 169 base::TimeTicks EstimatedUploadCompletionTime(size_t uploads_per_tick); |
166 | 170 |
167 // Only flush the command buffer if supported. | 171 // Only flush the command buffer if supported. |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 void WaitSyncPointIfNeeded(ResourceId id); | 431 void WaitSyncPointIfNeeded(ResourceId id); |
428 | 432 |
429 void WaitReadLockIfNeeded(ResourceId id); | 433 void WaitReadLockIfNeeded(ResourceId id); |
430 | 434 |
431 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 435 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
432 | 436 |
433 OutputSurface* output_surface() { return output_surface_; } | 437 OutputSurface* output_surface() { return output_surface_; } |
434 | 438 |
435 private: | 439 private: |
436 struct Resource { | 440 struct Resource { |
437 enum Origin { Internal, External, Delegated }; | 441 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; |
438 | 442 |
439 Resource(); | 443 Resource(); |
440 ~Resource(); | 444 ~Resource(); |
441 Resource(unsigned texture_id, | 445 Resource(unsigned texture_id, |
442 const gfx::Size& size, | 446 const gfx::Size& size, |
443 Origin origin, | 447 Origin origin, |
444 GLenum target, | 448 GLenum target, |
445 GLenum filter, | 449 GLenum filter, |
446 GLenum texture_pool, | 450 GLenum texture_pool, |
447 GLint wrap_mode, | 451 GLint wrap_mode, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 Resource* LockForWrite(ResourceId id); | 544 Resource* LockForWrite(ResourceId id); |
541 void UnlockForWrite(Resource* resource); | 545 void UnlockForWrite(Resource* resource); |
542 | 546 |
543 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 547 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
544 const Resource* resource); | 548 const Resource* resource); |
545 | 549 |
546 void TransferResource(gpu::gles2::GLES2Interface* gl, | 550 void TransferResource(gpu::gles2::GLES2Interface* gl, |
547 ResourceId id, | 551 ResourceId id, |
548 TransferableResource* resource); | 552 TransferableResource* resource); |
549 enum DeleteStyle { | 553 enum DeleteStyle { |
550 Normal, | 554 NORMAL, |
551 ForShutdown, | 555 FOR_SHUTDOWN, |
552 }; | 556 }; |
553 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); | 557 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); |
554 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, | 558 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, |
555 DeleteStyle style, | 559 DeleteStyle style, |
556 const ResourceIdArray& unused); | 560 const ResourceIdArray& unused); |
557 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); | 561 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); |
558 void LazyCreate(Resource* resource); | 562 void LazyCreate(Resource* resource); |
559 void LazyAllocate(Resource* resource); | 563 void LazyAllocate(Resource* resource); |
560 | 564 |
561 void BindImageForSampling(Resource* resource); | 565 void BindImageForSampling(Resource* resource); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 return format_gl_data_format[format]; | 660 return format_gl_data_format[format]; |
657 } | 661 } |
658 | 662 |
659 inline GLenum GLInternalFormat(ResourceFormat format) { | 663 inline GLenum GLInternalFormat(ResourceFormat format) { |
660 return GLDataFormat(format); | 664 return GLDataFormat(format); |
661 } | 665 } |
662 | 666 |
663 } // namespace cc | 667 } // namespace cc |
664 | 668 |
665 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 669 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |