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_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCE_PROVIDER_H_ |
6 #define CC_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCE_PROVIDER_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" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // NOTE: if the syncPoint filed in TransferableResourceList is set, this | 124 // NOTE: if the syncPoint filed in TransferableResourceList is set, this |
125 // will wait on it. | 125 // will wait on it. |
126 void receiveFromChild(int child, const TransferableResourceList&); | 126 void receiveFromChild(int child, const TransferableResourceList&); |
127 | 127 |
128 // Receives resources from the parent, moving them from mailboxes. Resource
IDs | 128 // Receives resources from the parent, moving them from mailboxes. Resource
IDs |
129 // passed are in the child namespace. | 129 // passed are in the child namespace. |
130 // NOTE: if the syncPoint filed in TransferableResourceList is set, this | 130 // NOTE: if the syncPoint filed in TransferableResourceList is set, this |
131 // will wait on it. | 131 // will wait on it. |
132 void receiveFromParent(const TransferableResourceList&); | 132 void receiveFromParent(const TransferableResourceList&); |
133 | 133 |
134 // Only for testing | |
135 size_t mailboxCount() const { return m_mailboxes.size(); } | |
136 | |
137 // The following lock classes are part of the ResourceProvider API and are | 134 // The following lock classes are part of the ResourceProvider API and are |
138 // needed to read and write the resource contents. The user must ensure | 135 // needed to read and write the resource contents. The user must ensure |
139 // that they only use GL locks on GL resources, etc, and this is enforced | 136 // that they only use GL locks on GL resources, etc, and this is enforced |
140 // by assertions. | 137 // by assertions. |
141 class CC_EXPORT ScopedReadLockGL { | 138 class CC_EXPORT ScopedReadLockGL { |
142 public: | 139 public: |
143 ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId); | 140 ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId); |
144 ~ScopedReadLockGL(); | 141 ~ScopedReadLockGL(); |
145 | 142 |
146 unsigned textureId() const { return m_textureId; } | 143 unsigned textureId() const { return m_textureId; } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 static void debugNotifyEnterZone(unsigned int index); | 201 static void debugNotifyEnterZone(unsigned int index); |
205 static void debugNotifyLeaveZone(); | 202 static void debugNotifyLeaveZone(); |
206 | 203 |
207 private: | 204 private: |
208 struct Resource { | 205 struct Resource { |
209 Resource(); | 206 Resource(); |
210 Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum for
mat); | 207 Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum for
mat); |
211 Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format
); | 208 Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format
); |
212 | 209 |
213 unsigned glId; | 210 unsigned glId; |
| 211 Mailbox mailbox; |
214 uint8_t* pixels; | 212 uint8_t* pixels; |
215 int pool; | 213 int pool; |
216 int lockForReadCount; | 214 int lockForReadCount; |
217 bool lockedForWrite; | 215 bool lockedForWrite; |
218 bool external; | 216 bool external; |
219 bool exported; | 217 bool exported; |
220 bool markedForDeletion; | 218 bool markedForDeletion; |
221 gfx::Size size; | 219 gfx::Size size; |
222 GLenum format; | 220 GLenum format; |
223 ResourceType type; | 221 ResourceType type; |
(...skipping 12 matching lines...) Expand all Loading... |
236 explicit ResourceProvider(GraphicsContext*); | 234 explicit ResourceProvider(GraphicsContext*); |
237 bool initialize(); | 235 bool initialize(); |
238 | 236 |
239 const Resource* lockForRead(ResourceId); | 237 const Resource* lockForRead(ResourceId); |
240 void unlockForRead(ResourceId); | 238 void unlockForRead(ResourceId); |
241 const Resource* lockForWrite(ResourceId); | 239 const Resource* lockForWrite(ResourceId); |
242 void unlockForWrite(ResourceId); | 240 void unlockForWrite(ResourceId); |
243 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 241 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
244 | 242 |
245 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 243 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
246 void trimMailboxDeque(); | |
247 void deleteResourceInternal(ResourceMap::iterator it); | 244 void deleteResourceInternal(ResourceMap::iterator it); |
248 | 245 |
249 GraphicsContext* m_context; | 246 GraphicsContext* m_context; |
250 ResourceId m_nextId; | 247 ResourceId m_nextId; |
251 ResourceMap m_resources; | 248 ResourceMap m_resources; |
252 int m_nextChild; | 249 int m_nextChild; |
253 ChildMap m_children; | 250 ChildMap m_children; |
254 | 251 |
255 std::deque<Mailbox> m_mailboxes; | |
256 | |
257 ResourceType m_defaultResourceType; | 252 ResourceType m_defaultResourceType; |
258 bool m_useTextureStorageExt; | 253 bool m_useTextureStorageExt; |
259 bool m_useTextureUsageHint; | 254 bool m_useTextureUsageHint; |
260 bool m_useShallowFlush; | 255 bool m_useShallowFlush; |
261 scoped_ptr<TextureUploader> m_textureUploader; | 256 scoped_ptr<TextureUploader> m_textureUploader; |
262 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 257 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
263 int m_maxTextureSize; | 258 int m_maxTextureSize; |
264 | 259 |
265 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 260 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
266 }; | 261 }; |
267 | 262 |
268 } | 263 } |
269 | 264 |
270 #endif // CC_RESOURCE_PROVIDER_H_ | 265 #endif // CC_RESOURCE_PROVIDER_H_ |
OLD | NEW |