| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 uint8_t* mapPixelBuffer(ResourceId id); | 223 uint8_t* mapPixelBuffer(ResourceId id); |
| 224 void unmapPixelBuffer(ResourceId id); | 224 void unmapPixelBuffer(ResourceId id); |
| 225 | 225 |
| 226 // Update pixels from acquired pixel buffer. | 226 // Update pixels from acquired pixel buffer. |
| 227 void setPixelsFromBuffer(ResourceId id); | 227 void setPixelsFromBuffer(ResourceId id); |
| 228 | 228 |
| 229 // Asynchronously update pixels from acquired pixel buffer. | 229 // Asynchronously update pixels from acquired pixel buffer. |
| 230 void beginSetPixels(ResourceId id); | 230 void beginSetPixels(ResourceId id); |
| 231 bool didSetPixelsComplete(ResourceId id); | 231 bool didSetPixelsComplete(ResourceId id); |
| 232 | 232 |
| 233 // For tests only! This prevents detecting uninitialized reads. |
| 234 // Use setPixels or lockForWrite to allocate implicitly. |
| 235 void allocateForTesting(ResourceId id); |
| 236 |
| 233 private: | 237 private: |
| 234 struct Resource { | 238 struct Resource { |
| 235 Resource(); | 239 Resource(); |
| 236 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); | 240 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); |
| 237 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); | 241 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); |
| 238 | 242 |
| 239 unsigned glId; | 243 unsigned glId; |
| 240 // Pixel buffer used for set pixels without unnecessary copying. | 244 // Pixel buffer used for set pixels without unnecessary copying. |
| 241 unsigned glPixelBufferId; | 245 unsigned glPixelBufferId; |
| 242 // Query used to determine when asynchronous set pixels complete. | 246 // Query used to determine when asynchronous set pixels complete. |
| 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(Resource*); |
| 280 | 286 |
| 281 OutputSurface* m_outputSurface; | 287 OutputSurface* m_outputSurface; |
| 282 ResourceId m_nextId; | 288 ResourceId m_nextId; |
| 283 ResourceMap m_resources; | 289 ResourceMap m_resources; |
| 284 int m_nextChild; | 290 int m_nextChild; |
| 285 ChildMap m_children; | 291 ChildMap m_children; |
| 286 | 292 |
| 287 ResourceType m_defaultResourceType; | 293 ResourceType m_defaultResourceType; |
| 288 bool m_useTextureStorageExt; | 294 bool m_useTextureStorageExt; |
| 289 bool m_useTextureUsageHint; | 295 bool m_useTextureUsageHint; |
| 290 bool m_useShallowFlush; | 296 bool m_useShallowFlush; |
| 291 scoped_ptr<TextureUploader> m_textureUploader; | 297 scoped_ptr<TextureUploader> m_textureUploader; |
| 292 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 298 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
| 293 int m_maxTextureSize; | 299 int m_maxTextureSize; |
| 294 GLenum m_bestTextureFormat; | 300 GLenum m_bestTextureFormat; |
| 295 | 301 |
| 296 base::ThreadChecker m_threadChecker; | 302 base::ThreadChecker m_threadChecker; |
| 297 | 303 |
| 298 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 304 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 299 }; | 305 }; |
| 300 | 306 |
| 301 } | 307 } |
| 302 | 308 |
| 303 #endif // CC_RESOURCE_PROVIDER_H_ | 309 #endif // CC_RESOURCE_PROVIDER_H_ |
| OLD | NEW |