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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 }; | 197 }; |
201 | 198 |
202 // Temporary functions for debugging crashes in issue 151428 in canary. | 199 // Temporary functions for debugging crashes in issue 151428 in canary. |
203 // Do not use these! | 200 // Do not use these! |
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, const Mailbox& mailbox, int pool, |
| 208 const gfx::Size& size, GLenum format); |
211 Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format
); | 209 Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format
); |
212 | 210 |
213 unsigned glId; | 211 unsigned glId; |
| 212 Mailbox mailbox; |
214 uint8_t* pixels; | 213 uint8_t* pixels; |
215 int pool; | 214 int pool; |
216 int lockForReadCount; | 215 int lockForReadCount; |
217 bool lockedForWrite; | 216 bool lockedForWrite; |
218 bool external; | 217 bool external; |
219 bool exported; | 218 bool exported; |
220 bool markedForDeletion; | 219 bool markedForDeletion; |
221 gfx::Size size; | 220 gfx::Size size; |
222 GLenum format; | 221 GLenum format; |
223 ResourceType type; | 222 ResourceType type; |
(...skipping 12 matching lines...) Expand all Loading... |
236 explicit ResourceProvider(GraphicsContext*); | 235 explicit ResourceProvider(GraphicsContext*); |
237 bool initialize(); | 236 bool initialize(); |
238 | 237 |
239 const Resource* lockForRead(ResourceId); | 238 const Resource* lockForRead(ResourceId); |
240 void unlockForRead(ResourceId); | 239 void unlockForRead(ResourceId); |
241 const Resource* lockForWrite(ResourceId); | 240 const Resource* lockForWrite(ResourceId); |
242 void unlockForWrite(ResourceId); | 241 void unlockForWrite(ResourceId); |
243 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 242 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
244 | 243 |
245 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 244 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
246 void trimMailboxDeque(); | |
247 void deleteResourceInternal(ResourceMap::iterator it); | 245 void deleteResourceInternal(ResourceMap::iterator it); |
248 | 246 |
249 GraphicsContext* m_context; | 247 GraphicsContext* m_context; |
250 ResourceId m_nextId; | 248 ResourceId m_nextId; |
251 ResourceMap m_resources; | 249 ResourceMap m_resources; |
252 int m_nextChild; | 250 int m_nextChild; |
253 ChildMap m_children; | 251 ChildMap m_children; |
254 | 252 |
255 std::deque<Mailbox> m_mailboxes; | |
256 | |
257 ResourceType m_defaultResourceType; | 253 ResourceType m_defaultResourceType; |
258 bool m_useTextureStorageExt; | 254 bool m_useTextureStorageExt; |
259 bool m_useTextureUsageHint; | 255 bool m_useTextureUsageHint; |
260 bool m_useShallowFlush; | 256 bool m_useShallowFlush; |
261 scoped_ptr<TextureUploader> m_textureUploader; | 257 scoped_ptr<TextureUploader> m_textureUploader; |
262 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 258 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
263 int m_maxTextureSize; | 259 int m_maxTextureSize; |
264 | 260 |
265 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 261 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
266 }; | 262 }; |
267 | 263 |
268 } | 264 } |
269 | 265 |
270 #endif // CC_RESOURCE_PROVIDER_H_ | 266 #endif // CC_RESOURCE_PROVIDER_H_ |
OLD | NEW |