| 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 "TextureCopier.h" |
| 15 #include <wtf/Deque.h> | 15 #include <wtf/Deque.h> |
| 16 #include <wtf/HashMap.h> | 16 #include <wtf/HashMap.h> |
| 17 #include <wtf/OwnPtr.h> | 17 #include <wtf/OwnPtr.h> |
| 18 #include <wtf/PassOwnPtr.h> | 18 #include <wtf/PassOwnPtr.h> |
| 19 #include <wtf/PassRefPtr.h> | 19 #include <wtf/PassRefPtr.h> |
| 20 #include <wtf/RefPtr.h> | 20 #include <wtf/RefPtr.h> |
| 21 #include <wtf/Vector.h> | 21 #include <wtf/Vector.h> |
| 22 | 22 |
| 23 namespace WebKit { | 23 namespace WebKit { |
| 24 class WebGraphicsContext3D; | 24 class WebGraphicsContext3D; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace cc { | 27 namespace cc { |
| 28 | 28 |
| 29 enum TextureUploaderOption { ThrottledUploader, UnthrottledUploader }; | |
| 30 | |
| 31 class IntRect; | 29 class IntRect; |
| 32 class LayerTextureSubImage; | 30 class LayerTextureSubImage; |
| 33 class TextureCopier; | 31 class TextureCopier; |
| 34 class TextureUploader; | 32 class TextureUploader; |
| 35 | 33 |
| 36 // Thread-safety notes: this class is not thread-safe and can only be called | 34 // Thread-safety notes: this class is not thread-safe and can only be called |
| 37 // from the thread it was created on (in practice, the compositor thread). | 35 // from the thread it was created on (in practice, the compositor thread). |
| 38 class CCResourceProvider { | 36 class CCResourceProvider { |
| 39 WTF_MAKE_NONCOPYABLE(CCResourceProvider); | 37 WTF_MAKE_NONCOPYABLE(CCResourceProvider); |
| 40 public: | 38 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 57 }; | 55 }; |
| 58 typedef Vector<TransferableResource> TransferableResourceArray; | 56 typedef Vector<TransferableResource> TransferableResourceArray; |
| 59 struct TransferableResourceList { | 57 struct TransferableResourceList { |
| 60 TransferableResourceList(); | 58 TransferableResourceList(); |
| 61 ~TransferableResourceList(); | 59 ~TransferableResourceList(); |
| 62 | 60 |
| 63 TransferableResourceArray resources; | 61 TransferableResourceArray resources; |
| 64 unsigned syncPoint; | 62 unsigned syncPoint; |
| 65 }; | 63 }; |
| 66 | 64 |
| 67 static PassOwnPtr<CCResourceProvider> create(CCGraphicsContext*, TextureUplo
aderOption); | 65 static PassOwnPtr<CCResourceProvider> create(CCGraphicsContext*); |
| 68 | 66 |
| 69 virtual ~CCResourceProvider(); | 67 virtual ~CCResourceProvider(); |
| 70 | 68 |
| 71 WebKit::WebGraphicsContext3D* graphicsContext3D(); | 69 WebKit::WebGraphicsContext3D* graphicsContext3D(); |
| 72 TextureUploader* textureUploader() const { return m_textureUploader.get(); } | 70 TextureUploader* textureUploader() const { return m_textureUploader.get(); } |
| 73 TextureCopier* textureCopier() const { return m_textureCopier.get(); } | 71 TextureCopier* textureCopier() const { return m_textureCopier.get(); } |
| 74 int maxTextureSize() const { return m_maxTextureSize; } | 72 int maxTextureSize() const { return m_maxTextureSize; } |
| 75 unsigned numResources() const { return m_resources.size(); } | 73 unsigned numResources() const { return m_resources.size(); } |
| 76 | 74 |
| 77 // Checks whether a resource is in use by a consumer. | 75 // Checks whether a resource is in use by a consumer. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 Child(); | 229 Child(); |
| 232 ~Child(); | 230 ~Child(); |
| 233 | 231 |
| 234 int pool; | 232 int pool; |
| 235 ResourceIdMap childToParentMap; | 233 ResourceIdMap childToParentMap; |
| 236 ResourceIdMap parentToChildMap; | 234 ResourceIdMap parentToChildMap; |
| 237 }; | 235 }; |
| 238 typedef HashMap<int, Child> ChildMap; | 236 typedef HashMap<int, Child> ChildMap; |
| 239 | 237 |
| 240 explicit CCResourceProvider(CCGraphicsContext*); | 238 explicit CCResourceProvider(CCGraphicsContext*); |
| 241 bool initialize(TextureUploaderOption); | 239 bool initialize(); |
| 242 | 240 |
| 243 const Resource* lockForRead(ResourceId); | 241 const Resource* lockForRead(ResourceId); |
| 244 void unlockForRead(ResourceId); | 242 void unlockForRead(ResourceId); |
| 245 const Resource* lockForWrite(ResourceId); | 243 const Resource* lockForWrite(ResourceId); |
| 246 void unlockForWrite(ResourceId); | 244 void unlockForWrite(ResourceId); |
| 247 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 245 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
| 248 | 246 |
| 249 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 247 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
| 250 void trimMailboxDeque(); | 248 void trimMailboxDeque(); |
| 251 | 249 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 263 bool m_useShallowFlush; | 261 bool m_useShallowFlush; |
| 264 OwnPtr<LayerTextureSubImage> m_texSubImage; | 262 OwnPtr<LayerTextureSubImage> m_texSubImage; |
| 265 OwnPtr<TextureUploader> m_textureUploader; | 263 OwnPtr<TextureUploader> m_textureUploader; |
| 266 OwnPtr<AcceleratedTextureCopier> m_textureCopier; | 264 OwnPtr<AcceleratedTextureCopier> m_textureCopier; |
| 267 int m_maxTextureSize; | 265 int m_maxTextureSize; |
| 268 }; | 266 }; |
| 269 | 267 |
| 270 } | 268 } |
| 271 | 269 |
| 272 #endif | 270 #endif |
| OLD | NEW |