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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 void setDefaultResourceType(ResourceType type) { m_defaultResourceType = typ e; } | 68 void setDefaultResourceType(ResourceType type) { m_defaultResourceType = typ e; } |
69 ResourceType defaultResourceType() const { return m_defaultResourceType; } | 69 ResourceType defaultResourceType() const { return m_defaultResourceType; } |
70 ResourceType resourceType(ResourceId); | 70 ResourceType resourceType(ResourceId); |
71 | 71 |
72 // Creates a resource of the default resource type. | 72 // Creates a resource of the default resource type. |
73 ResourceId createResource(const gfx::Size&, GLenum format, TextureUsageHint) ; | 73 ResourceId createResource(const gfx::Size&, GLenum format, TextureUsageHint) ; |
74 | 74 |
75 // Creates a resource which is tagged as being managed for GPU memory accoun ting purposes. | 75 // Creates a resource which is tagged as being managed for GPU memory accoun ting purposes. |
76 ResourceId createManagedResource(const gfx::Size&, GLenum format, TextureUsa geHint); | 76 ResourceId createManagedResource(const gfx::Size&, GLenum format, TextureUsa geHint); |
77 | 77 |
78 // For tests only! Otherwise, implicitly allocate via lockForWrite or setPix els variant. | |
79 ResourceId createAllocatedResource(const gfx::Size&, GLenum format, TextureU sageHint); | |
80 ResourceId createAllocatedManagedResource(const gfx::Size&, GLenum format, T extureUsageHint); | |
piman
2012/12/18 22:41:38
How about one explicit allocateResourceForTest(Res
| |
81 | |
78 // You can also explicitly create a specific resource type. | 82 // You can also explicitly create a specific resource type. |
79 ResourceId createGLTexture(const gfx::Size&, GLenum format, GLenum texturePo ol, TextureUsageHint); | 83 ResourceId createGLTexture(const gfx::Size&, GLenum format, GLenum texturePo ol, TextureUsageHint); |
80 | 84 |
81 ResourceId createBitmap(const gfx::Size&); | 85 ResourceId createBitmap(const gfx::Size&); |
82 // Wraps an external texture into a GL resource. | 86 // Wraps an external texture into a GL resource. |
83 ResourceId createResourceFromExternalTexture(unsigned textureId); | 87 ResourceId createResourceFromExternalTexture(unsigned textureId); |
84 | 88 |
85 void deleteResource(ResourceId); | 89 void deleteResource(ResourceId); |
86 | 90 |
87 // Update pixels from image, copying sourceRect (in image) into destRect (in the resource). | 91 // Update pixels from image, copying sourceRect (in image) into destRect (in the resource). |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 unsigned glUploadQueryId; | 247 unsigned glUploadQueryId; |
244 Mailbox mailbox; | 248 Mailbox mailbox; |
245 uint8_t* pixels; | 249 uint8_t* pixels; |
246 uint8_t* pixelBuffer; | 250 uint8_t* pixelBuffer; |
247 int lockForReadCount; | 251 int lockForReadCount; |
248 bool lockedForWrite; | 252 bool lockedForWrite; |
249 bool external; | 253 bool external; |
250 bool exported; | 254 bool exported; |
251 bool markedForDeletion; | 255 bool markedForDeletion; |
252 bool pendingSetPixels; | 256 bool pendingSetPixels; |
257 bool allocated; | |
253 gfx::Size size; | 258 gfx::Size size; |
254 GLenum format; | 259 GLenum format; |
255 // TODO(skyostil): Use a separate sampler object for filter state. | 260 // TODO(skyostil): Use a separate sampler object for filter state. |
256 GLenum filter; | 261 GLenum filter; |
257 ResourceType type; | 262 ResourceType type; |
258 }; | 263 }; |
259 typedef base::hash_map<ResourceId, Resource> ResourceMap; | 264 typedef base::hash_map<ResourceId, Resource> ResourceMap; |
260 struct Child { | 265 struct Child { |
261 Child(); | 266 Child(); |
262 ~Child(); | 267 ~Child(); |
263 | 268 |
264 ResourceIdMap childToParentMap; | 269 ResourceIdMap childToParentMap; |
265 ResourceIdMap parentToChildMap; | 270 ResourceIdMap parentToChildMap; |
266 }; | 271 }; |
267 typedef base::hash_map<int, Child> ChildMap; | 272 typedef base::hash_map<int, Child> ChildMap; |
268 | 273 |
269 explicit ResourceProvider(OutputSurface*); | 274 explicit ResourceProvider(OutputSurface*); |
270 bool initialize(); | 275 bool initialize(); |
271 | 276 |
272 const Resource* lockForRead(ResourceId); | 277 const Resource* lockForRead(ResourceId); |
273 void unlockForRead(ResourceId); | 278 void unlockForRead(ResourceId); |
274 const Resource* lockForWrite(ResourceId); | 279 const Resource* lockForWrite(ResourceId); |
275 void unlockForWrite(ResourceId); | 280 void unlockForWrite(ResourceId); |
276 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 281 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
277 | 282 |
278 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl eResource*); | 283 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl eResource*); |
279 void deleteResourceInternal(ResourceMap::iterator it); | 284 void deleteResourceInternal(ResourceMap::iterator it); |
285 void lazyAllocate(ResourceId); | |
286 void lazyAllocate(Resource*); | |
280 | 287 |
281 OutputSurface* m_outputSurface; | 288 OutputSurface* m_outputSurface; |
282 ResourceId m_nextId; | 289 ResourceId m_nextId; |
283 ResourceMap m_resources; | 290 ResourceMap m_resources; |
284 int m_nextChild; | 291 int m_nextChild; |
285 ChildMap m_children; | 292 ChildMap m_children; |
286 | 293 |
287 ResourceType m_defaultResourceType; | 294 ResourceType m_defaultResourceType; |
288 bool m_useTextureStorageExt; | 295 bool m_useTextureStorageExt; |
289 bool m_useTextureUsageHint; | 296 bool m_useTextureUsageHint; |
290 bool m_useShallowFlush; | 297 bool m_useShallowFlush; |
291 scoped_ptr<TextureUploader> m_textureUploader; | 298 scoped_ptr<TextureUploader> m_textureUploader; |
292 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 299 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
293 int m_maxTextureSize; | 300 int m_maxTextureSize; |
294 GLenum m_bestTextureFormat; | 301 GLenum m_bestTextureFormat; |
295 | 302 |
296 base::ThreadChecker m_threadChecker; | 303 base::ThreadChecker m_threadChecker; |
297 | 304 |
298 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 305 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
299 }; | 306 }; |
300 | 307 |
301 } | 308 } |
302 | 309 |
303 #endif // CC_RESOURCE_PROVIDER_H_ | 310 #endif // CC_RESOURCE_PROVIDER_H_ |
OLD | NEW |