Chromium Code Reviews| 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 CCResourceProvider_h | 5 #ifndef CCResourceProvider_h |
| 6 #define CCResourceProvider_h | 6 #define CCResourceProvider_h |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/cc_export.h" | 11 #include "cc/cc_export.h" |
| 12 #include "cc/graphics_context.h" | 12 #include "cc/graphics_context.h" |
| 13 #include "cc/texture_copier.h" | 13 #include "cc/texture_copier.h" |
| 14 #include "cc/transferable_resource.h" | |
| 14 #include "third_party/khronos/GLES2/gl2.h" | 15 #include "third_party/khronos/GLES2/gl2.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 18 #include <deque> | 19 #include <deque> |
| 19 #include <vector> | 20 #include <vector> |
| 20 | 21 |
| 21 namespace WebKit { | 22 namespace WebKit { |
| 22 class WebGraphicsContext3D; | 23 class WebGraphicsContext3D; |
| 23 } | 24 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 36 class CC_EXPORT ResourceProvider { | 37 class CC_EXPORT ResourceProvider { |
| 37 public: | 38 public: |
| 38 typedef unsigned ResourceId; | 39 typedef unsigned ResourceId; |
| 39 typedef std::vector<ResourceId> ResourceIdArray; | 40 typedef std::vector<ResourceId> ResourceIdArray; |
| 40 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 41 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
| 41 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; | 42 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; |
| 42 enum ResourceType { | 43 enum ResourceType { |
| 43 GLTexture = 1, | 44 GLTexture = 1, |
| 44 Bitmap, | 45 Bitmap, |
| 45 }; | 46 }; |
| 46 struct Mailbox { | |
| 47 GLbyte name[64]; | |
| 48 }; | |
| 49 struct TransferableResource { | |
| 50 unsigned id; | |
| 51 GLenum format; | |
| 52 gfx::Size size; | |
| 53 Mailbox mailbox; | |
| 54 }; | |
| 55 typedef std::vector<TransferableResource> TransferableResourceArray; | |
| 56 struct CC_EXPORT TransferableResourceList { | |
| 57 TransferableResourceList(); | |
| 58 ~TransferableResourceList(); | |
| 59 | |
| 60 TransferableResourceArray resources; | |
| 61 unsigned syncPoint; | |
| 62 }; | |
| 63 | 47 |
| 64 static scoped_ptr<ResourceProvider> create(GraphicsContext*); | 48 static scoped_ptr<ResourceProvider> create(GraphicsContext*); |
| 65 | 49 |
| 66 virtual ~ResourceProvider(); | 50 virtual ~ResourceProvider(); |
| 67 | 51 |
| 52 GraphicsContext* context() const { return m_context; } | |
|
danakj
2012/11/03 01:00:51
Why'd you add this one? I don't see any users.
piman
2012/11/03 01:05:47
Done.
| |
| 68 WebKit::WebGraphicsContext3D* graphicsContext3D(); | 53 WebKit::WebGraphicsContext3D* graphicsContext3D(); |
| 69 TextureCopier* textureCopier() const { return m_textureCopier.get(); } | 54 TextureCopier* textureCopier() const { return m_textureCopier.get(); } |
| 70 int maxTextureSize() const { return m_maxTextureSize; } | 55 int maxTextureSize() const { return m_maxTextureSize; } |
| 71 unsigned numResources() const { return m_resources.size(); } | 56 unsigned numResources() const { return m_resources.size(); } |
| 72 | 57 |
| 73 // Checks whether a resource is in use by a consumer. | 58 // Checks whether a resource is in use by a consumer. |
| 74 bool inUseByConsumer(ResourceId); | 59 bool inUseByConsumer(ResourceId); |
| 75 | 60 |
| 76 | 61 |
| 77 // Producer interface. | 62 // Producer interface. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 int createChild(int pool); | 100 int createChild(int pool); |
| 116 | 101 |
| 117 // Destroys accounting for the child, deleting all resources from that pool. | 102 // Destroys accounting for the child, deleting all resources from that pool. |
| 118 void destroyChild(int child); | 103 void destroyChild(int child); |
| 119 | 104 |
| 120 // Gets the child->parent resource ID map. | 105 // Gets the child->parent resource ID map. |
| 121 const ResourceIdMap& getChildToParentMap(int child) const; | 106 const ResourceIdMap& getChildToParentMap(int child) const; |
| 122 | 107 |
| 123 // Prepares resources to be transfered to the parent, moving them to | 108 // Prepares resources to be transfered to the parent, moving them to |
| 124 // mailboxes and serializing meta-data into TransferableResources. | 109 // mailboxes and serializing meta-data into TransferableResources. |
| 125 // Resources are not removed from the ResourceProvider, but are markes as | 110 // Resources are not removed from the ResourceProvider, but are marked as |
| 126 // "in use". | 111 // "in use". |
| 127 TransferableResourceList prepareSendToParent(const ResourceIdArray&); | 112 void prepareSendToParent(const ResourceIdArray&, TransferableResourceList*); |
| 128 | 113 |
| 129 // Prepares resources to be transfered back to the child, moving them to | 114 // Prepares resources to be transfered back to the child, moving them to |
| 130 // mailboxes and serializing meta-data into TransferableResources. | 115 // mailboxes and serializing meta-data into TransferableResources. |
| 131 // Resources are removed from the ResourceProvider. Note: the resource IDs | 116 // Resources are removed from the ResourceProvider. Note: the resource IDs |
| 132 // passed are in the parent namespace and will be translated to the child | 117 // passed are in the parent namespace and will be translated to the child |
| 133 // namespace when returned. | 118 // namespace when returned. |
| 134 TransferableResourceList prepareSendToChild(int child, const ResourceIdArray &); | 119 void prepareSendToChild(int child, const ResourceIdArray&, TransferableResou rceList*); |
| 135 | 120 |
| 136 // Receives resources from a child, moving them from mailboxes. Resource IDs | 121 // Receives resources from a child, moving them from mailboxes. Resource IDs |
| 137 // passed are in the child namespace, and will be translated to the parent | 122 // passed are in the child namespace, and will be translated to the parent |
| 138 // namespace, added to the child->parent map. | 123 // namespace, added to the child->parent map. |
| 139 // NOTE: if the syncPoint filed in TransferableResourceList is set, this | 124 // NOTE: if the syncPoint filed in TransferableResourceList is set, this |
| 140 // will wait on it. | 125 // will wait on it. |
| 141 void receiveFromChild(int child, const TransferableResourceList&); | 126 void receiveFromChild(int child, const TransferableResourceList&); |
| 142 | 127 |
| 143 // Receives resources from the parent, moving them from mailboxes. Resource IDs | 128 // Receives resources from the parent, moving them from mailboxes. Resource IDs |
| 144 // passed are in the child namespace. | 129 // passed are in the child namespace. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 scoped_ptr<TextureUploader> m_textureUploader; | 261 scoped_ptr<TextureUploader> m_textureUploader; |
| 277 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 262 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
| 278 int m_maxTextureSize; | 263 int m_maxTextureSize; |
| 279 | 264 |
| 280 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 265 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 281 }; | 266 }; |
| 282 | 267 |
| 283 } | 268 } |
| 284 | 269 |
| 285 #endif | 270 #endif |
| OLD | NEW |