| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <deque> | 11 #include <deque> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <unordered_map> |
| 15 #include <unordered_set> |
| 14 #include <utility> | 16 #include <utility> |
| 15 #include <vector> | 17 #include <vector> |
| 16 | 18 |
| 17 #include "base/callback.h" | 19 #include "base/callback.h" |
| 18 #include "base/containers/hash_tables.h" | |
| 19 #include "base/macros.h" | 20 #include "base/macros.h" |
| 20 #include "base/memory/linked_ptr.h" | 21 #include "base/memory/linked_ptr.h" |
| 21 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 23 #include "base/trace_event/memory_allocator_dump.h" | 24 #include "base/trace_event/memory_allocator_dump.h" |
| 24 #include "base/trace_event/memory_dump_provider.h" | 25 #include "base/trace_event/memory_dump_provider.h" |
| 25 #include "cc/base/cc_export.h" | 26 #include "cc/base/cc_export.h" |
| 26 #include "cc/base/resource_id.h" | 27 #include "cc/base/resource_id.h" |
| 27 #include "cc/output/context_provider.h" | 28 #include "cc/output/context_provider.h" |
| 28 #include "cc/output/output_surface.h" | 29 #include "cc/output/output_surface.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 class SharedBitmapManager; | 62 class SharedBitmapManager; |
| 62 | 63 |
| 63 // This class is not thread-safe and can only be called from the thread it was | 64 // This class is not thread-safe and can only be called from the thread it was |
| 64 // created on (in practice, the impl thread). | 65 // created on (in practice, the impl thread). |
| 65 class CC_EXPORT ResourceProvider | 66 class CC_EXPORT ResourceProvider |
| 66 : public base::trace_event::MemoryDumpProvider { | 67 : public base::trace_event::MemoryDumpProvider { |
| 67 private: | 68 private: |
| 68 struct Resource; | 69 struct Resource; |
| 69 | 70 |
| 70 public: | 71 public: |
| 71 typedef std::vector<ResourceId> ResourceIdArray; | 72 using ResourceIdArray = std::vector<ResourceId>; |
| 72 typedef base::hash_set<ResourceId> ResourceIdSet; | 73 using ResourceIdSet = std::unordered_set<ResourceId>; |
| 73 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 74 using ResourceIdMap = std::unordered_map<ResourceId, ResourceId>; |
| 74 enum TextureHint { | 75 enum TextureHint { |
| 75 TEXTURE_HINT_DEFAULT = 0x0, | 76 TEXTURE_HINT_DEFAULT = 0x0, |
| 76 TEXTURE_HINT_IMMUTABLE = 0x1, | 77 TEXTURE_HINT_IMMUTABLE = 0x1, |
| 77 TEXTURE_HINT_FRAMEBUFFER = 0x2, | 78 TEXTURE_HINT_FRAMEBUFFER = 0x2, |
| 78 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = | 79 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = |
| 79 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER | 80 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER |
| 80 }; | 81 }; |
| 81 enum ResourceType { | 82 enum ResourceType { |
| 82 RESOURCE_TYPE_GPU_MEMORY_BUFFER, | 83 RESOURCE_TYPE_GPU_MEMORY_BUFFER, |
| 83 RESOURCE_TYPE_GL_TEXTURE, | 84 RESOURCE_TYPE_GL_TEXTURE, |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 GLenum filter; | 495 GLenum filter; |
| 495 unsigned image_id; | 496 unsigned image_id; |
| 496 unsigned bound_image_id; | 497 unsigned bound_image_id; |
| 497 TextureHint hint; | 498 TextureHint hint; |
| 498 ResourceType type; | 499 ResourceType type; |
| 499 ResourceFormat format; | 500 ResourceFormat format; |
| 500 SharedBitmapId shared_bitmap_id; | 501 SharedBitmapId shared_bitmap_id; |
| 501 SharedBitmap* shared_bitmap; | 502 SharedBitmap* shared_bitmap; |
| 502 gfx::GpuMemoryBuffer* gpu_memory_buffer; | 503 gfx::GpuMemoryBuffer* gpu_memory_buffer; |
| 503 }; | 504 }; |
| 504 typedef base::hash_map<ResourceId, Resource> ResourceMap; | 505 using ResourceMap = std::unordered_map<ResourceId, Resource>; |
| 505 | 506 |
| 506 struct Child { | 507 struct Child { |
| 507 Child(); | 508 Child(); |
| 508 ~Child(); | 509 ~Child(); |
| 509 | 510 |
| 510 ResourceIdMap child_to_parent_map; | 511 ResourceIdMap child_to_parent_map; |
| 511 ResourceIdMap parent_to_child_map; | 512 ResourceIdMap parent_to_child_map; |
| 512 ReturnCallback return_callback; | 513 ReturnCallback return_callback; |
| 513 bool marked_for_deletion; | 514 bool marked_for_deletion; |
| 514 bool needs_sync_tokens; | 515 bool needs_sync_tokens; |
| 515 }; | 516 }; |
| 516 typedef base::hash_map<int, Child> ChildMap; | 517 using ChildMap = std::unordered_map<int, Child>; |
| 517 | 518 |
| 518 bool ReadLockFenceHasPassed(const Resource* resource) { | 519 bool ReadLockFenceHasPassed(const Resource* resource) { |
| 519 return !resource->read_lock_fence.get() || | 520 return !resource->read_lock_fence.get() || |
| 520 resource->read_lock_fence->HasPassed(); | 521 resource->read_lock_fence->HasPassed(); |
| 521 } | 522 } |
| 522 | 523 |
| 523 ResourceId CreateGLTexture(const gfx::Size& size, | 524 ResourceId CreateGLTexture(const gfx::Size& size, |
| 524 TextureHint hint, | 525 TextureHint hint, |
| 525 ResourceType type, | 526 ResourceType type, |
| 526 ResourceFormat format); | 527 ResourceFormat format); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 // A process-unique ID used for disambiguating memory dumps from different | 598 // A process-unique ID used for disambiguating memory dumps from different |
| 598 // resource providers. | 599 // resource providers. |
| 599 int tracing_id_; | 600 int tracing_id_; |
| 600 | 601 |
| 601 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 602 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 602 }; | 603 }; |
| 603 | 604 |
| 604 } // namespace cc | 605 } // namespace cc |
| 605 | 606 |
| 606 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 607 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |