| 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 | 5 |
| 6 #ifndef CCResourceProvider_h | 6 #ifndef CCResourceProvider_h |
| 7 #define CCResourceProvider_h | 7 #define CCResourceProvider_h |
| 8 | 8 |
| 9 #include "CCGraphicsContext.h" | 9 #include "CCGraphicsContext.h" |
| 10 #include "GraphicsContext3D.h" | 10 #include "GraphicsContext3D.h" |
| 11 #include "IntSize.h" | 11 #include "IntSize.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "TextureCopier.h" |
| 14 #include <wtf/Deque.h> | 15 #include <wtf/Deque.h> |
| 15 #include <wtf/HashMap.h> | 16 #include <wtf/HashMap.h> |
| 16 #include <wtf/OwnPtr.h> | 17 #include <wtf/OwnPtr.h> |
| 17 #include <wtf/PassOwnPtr.h> | 18 #include <wtf/PassOwnPtr.h> |
| 18 #include <wtf/PassRefPtr.h> | 19 #include <wtf/PassRefPtr.h> |
| 19 #include <wtf/RefPtr.h> | 20 #include <wtf/RefPtr.h> |
| 20 #include <wtf/Vector.h> | 21 #include <wtf/Vector.h> |
| 21 | 22 |
| 22 namespace WebKit { | 23 namespace WebKit { |
| 23 class WebGraphicsContext3D; | 24 class WebGraphicsContext3D; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 | 28 |
| 29 enum TextureUploaderOption { ThrottledUploader, UnthrottledUploader }; |
| 30 |
| 28 class IntRect; | 31 class IntRect; |
| 29 class LayerTextureSubImage; | 32 class LayerTextureSubImage; |
| 33 class TextureCopier; |
| 34 class TextureUploader; |
| 30 | 35 |
| 31 // Thread-safety notes: this class is not thread-safe and can only be called | 36 // Thread-safety notes: this class is not thread-safe and can only be called |
| 32 // from the thread it was created on (in practice, the compositor thread). | 37 // from the thread it was created on (in practice, the compositor thread). |
| 33 class CCResourceProvider { | 38 class CCResourceProvider { |
| 34 WTF_MAKE_NONCOPYABLE(CCResourceProvider); | 39 WTF_MAKE_NONCOPYABLE(CCResourceProvider); |
| 35 public: | 40 public: |
| 36 typedef unsigned ResourceId; | 41 typedef unsigned ResourceId; |
| 37 typedef Vector<ResourceId> ResourceIdArray; | 42 typedef Vector<ResourceId> ResourceIdArray; |
| 38 typedef HashMap<ResourceId, ResourceId> ResourceIdMap; | 43 typedef HashMap<ResourceId, ResourceId> ResourceIdMap; |
| 39 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; | 44 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; |
| 40 enum ResourceType { | 45 enum ResourceType { |
| 41 GLTexture = 1, | 46 GLTexture = 1, |
| 42 Bitmap, | 47 Bitmap, |
| 43 }; | 48 }; |
| 44 struct Mailbox { | 49 struct Mailbox { |
| 45 GC3Dbyte name[64]; | 50 GC3Dbyte name[64]; |
| 46 }; | 51 }; |
| 47 struct TransferableResource { | 52 struct TransferableResource { |
| 48 unsigned id; | 53 unsigned id; |
| 49 GC3Denum format; | 54 GC3Denum format; |
| 50 IntSize size; | 55 IntSize size; |
| 51 Mailbox mailbox; | 56 Mailbox mailbox; |
| 52 }; | 57 }; |
| 53 typedef Vector<TransferableResource> TransferableResourceArray; | 58 typedef Vector<TransferableResource> TransferableResourceArray; |
| 54 struct TransferableResourceList { | 59 struct TransferableResourceList { |
| 55 TransferableResourceArray resources; | 60 TransferableResourceArray resources; |
| 56 unsigned syncPoint; | 61 unsigned syncPoint; |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 static PassOwnPtr<CCResourceProvider> create(CCGraphicsContext*); | 64 static PassOwnPtr<CCResourceProvider> create(CCGraphicsContext*, TextureUplo
aderOption); |
| 60 | 65 |
| 61 virtual ~CCResourceProvider(); | 66 virtual ~CCResourceProvider(); |
| 62 | 67 |
| 63 WebKit::WebGraphicsContext3D* graphicsContext3D(); | 68 WebKit::WebGraphicsContext3D* graphicsContext3D(); |
| 69 TextureUploader* textureUploader() const { return m_textureUploader.get(); } |
| 70 TextureCopier* textureCopier() const { return m_textureCopier.get(); } |
| 64 int maxTextureSize() const { return m_maxTextureSize; } | 71 int maxTextureSize() const { return m_maxTextureSize; } |
| 65 unsigned numResources() const { return m_resources.size(); } | 72 unsigned numResources() const { return m_resources.size(); } |
| 66 | 73 |
| 67 // Checks whether a resource is in use by a consumer. | 74 // Checks whether a resource is in use by a consumer. |
| 68 bool inUseByConsumer(ResourceId); | 75 bool inUseByConsumer(ResourceId); |
| 69 | 76 |
| 70 | 77 |
| 71 // Producer interface. | 78 // Producer interface. |
| 72 | 79 |
| 73 void setDefaultResourceType(ResourceType type) { m_defaultResourceType = typ
e; } | 80 void setDefaultResourceType(ResourceType type) { m_defaultResourceType = typ
e; } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 }; | 257 }; |
| 251 typedef HashMap<ResourceId, Resource> ResourceMap; | 258 typedef HashMap<ResourceId, Resource> ResourceMap; |
| 252 struct Child { | 259 struct Child { |
| 253 int pool; | 260 int pool; |
| 254 ResourceIdMap childToParentMap; | 261 ResourceIdMap childToParentMap; |
| 255 ResourceIdMap parentToChildMap; | 262 ResourceIdMap parentToChildMap; |
| 256 }; | 263 }; |
| 257 typedef HashMap<int, Child> ChildMap; | 264 typedef HashMap<int, Child> ChildMap; |
| 258 | 265 |
| 259 explicit CCResourceProvider(CCGraphicsContext*); | 266 explicit CCResourceProvider(CCGraphicsContext*); |
| 260 bool initialize(); | 267 bool initialize(TextureUploaderOption); |
| 261 | 268 |
| 262 const Resource* lockForRead(ResourceId); | 269 const Resource* lockForRead(ResourceId); |
| 263 void unlockForRead(ResourceId); | 270 void unlockForRead(ResourceId); |
| 264 const Resource* lockForWrite(ResourceId); | 271 const Resource* lockForWrite(ResourceId); |
| 265 void unlockForWrite(ResourceId); | 272 void unlockForWrite(ResourceId); |
| 266 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 273 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
| 267 | 274 |
| 268 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 275 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
| 269 void trimMailboxDeque(); | 276 void trimMailboxDeque(); |
| 270 | 277 |
| 271 CCGraphicsContext* m_context; | 278 CCGraphicsContext* m_context; |
| 272 ResourceId m_nextId; | 279 ResourceId m_nextId; |
| 273 ResourceMap m_resources; | 280 ResourceMap m_resources; |
| 274 int m_nextChild; | 281 int m_nextChild; |
| 275 ChildMap m_children; | 282 ChildMap m_children; |
| 276 | 283 |
| 277 Deque<Mailbox> m_mailboxes; | 284 Deque<Mailbox> m_mailboxes; |
| 278 | 285 |
| 279 ResourceType m_defaultResourceType; | 286 ResourceType m_defaultResourceType; |
| 280 bool m_useTextureStorageExt; | 287 bool m_useTextureStorageExt; |
| 281 bool m_useTextureUsageHint; | 288 bool m_useTextureUsageHint; |
| 282 bool m_useShallowFlush; | 289 bool m_useShallowFlush; |
| 283 OwnPtr<LayerTextureSubImage> m_texSubImage; | 290 OwnPtr<LayerTextureSubImage> m_texSubImage; |
| 291 OwnPtr<TextureUploader> m_textureUploader; |
| 292 OwnPtr<AcceleratedTextureCopier> m_textureCopier; |
| 284 int m_maxTextureSize; | 293 int m_maxTextureSize; |
| 285 }; | 294 }; |
| 286 | 295 |
| 287 } | 296 } |
| 288 | 297 |
| 289 #endif | 298 #endif |
| OLD | NEW |