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 |
29 class IntRect; | 31 class IntRect; |
30 class LayerTextureSubImage; | 32 class LayerTextureSubImage; |
31 class TextureCopier; | 33 class TextureCopier; |
32 class TextureUploader; | 34 class TextureUploader; |
33 | 35 |
34 // 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 |
35 // 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). |
36 class CCResourceProvider { | 38 class CCResourceProvider { |
37 WTF_MAKE_NONCOPYABLE(CCResourceProvider); | 39 WTF_MAKE_NONCOPYABLE(CCResourceProvider); |
38 public: | 40 public: |
(...skipping 13 matching lines...) Expand all Loading... |
52 GC3Denum format; | 54 GC3Denum format; |
53 IntSize size; | 55 IntSize size; |
54 Mailbox mailbox; | 56 Mailbox mailbox; |
55 }; | 57 }; |
56 typedef Vector<TransferableResource> TransferableResourceArray; | 58 typedef Vector<TransferableResource> TransferableResourceArray; |
57 struct TransferableResourceList { | 59 struct TransferableResourceList { |
58 TransferableResourceArray resources; | 60 TransferableResourceArray resources; |
59 unsigned syncPoint; | 61 unsigned syncPoint; |
60 }; | 62 }; |
61 | 63 |
62 static PassOwnPtr<CCResourceProvider> create(CCGraphicsContext*); | 64 static PassOwnPtr<CCResourceProvider> create(CCGraphicsContext*, TextureUplo
aderOption); |
63 | 65 |
64 virtual ~CCResourceProvider(); | 66 virtual ~CCResourceProvider(); |
65 | 67 |
66 WebKit::WebGraphicsContext3D* graphicsContext3D(); | 68 WebKit::WebGraphicsContext3D* graphicsContext3D(); |
67 TextureUploader* textureUploader() const { return m_textureUploader.get(); } | 69 TextureUploader* textureUploader() const { return m_textureUploader.get(); } |
68 TextureCopier* textureCopier() const { return m_textureCopier.get(); } | 70 TextureCopier* textureCopier() const { return m_textureCopier.get(); } |
69 int maxTextureSize() const { return m_maxTextureSize; } | 71 int maxTextureSize() const { return m_maxTextureSize; } |
70 unsigned numResources() const { return m_resources.size(); } | 72 unsigned numResources() const { return m_resources.size(); } |
71 | 73 |
72 // Checks whether a resource is in use by a consumer. | 74 // Checks whether a resource is in use by a consumer. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 }; | 257 }; |
256 typedef HashMap<ResourceId, Resource> ResourceMap; | 258 typedef HashMap<ResourceId, Resource> ResourceMap; |
257 struct Child { | 259 struct Child { |
258 int pool; | 260 int pool; |
259 ResourceIdMap childToParentMap; | 261 ResourceIdMap childToParentMap; |
260 ResourceIdMap parentToChildMap; | 262 ResourceIdMap parentToChildMap; |
261 }; | 263 }; |
262 typedef HashMap<int, Child> ChildMap; | 264 typedef HashMap<int, Child> ChildMap; |
263 | 265 |
264 explicit CCResourceProvider(CCGraphicsContext*); | 266 explicit CCResourceProvider(CCGraphicsContext*); |
265 bool initialize(); | 267 bool initialize(TextureUploaderOption); |
266 | 268 |
267 const Resource* lockForRead(ResourceId); | 269 const Resource* lockForRead(ResourceId); |
268 void unlockForRead(ResourceId); | 270 void unlockForRead(ResourceId); |
269 const Resource* lockForWrite(ResourceId); | 271 const Resource* lockForWrite(ResourceId); |
270 void unlockForWrite(ResourceId); | 272 void unlockForWrite(ResourceId); |
271 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 273 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
272 | 274 |
273 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 275 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
274 void trimMailboxDeque(); | 276 void trimMailboxDeque(); |
275 | 277 |
(...skipping 11 matching lines...) Expand all Loading... |
287 bool m_useShallowFlush; | 289 bool m_useShallowFlush; |
288 OwnPtr<LayerTextureSubImage> m_texSubImage; | 290 OwnPtr<LayerTextureSubImage> m_texSubImage; |
289 OwnPtr<TextureUploader> m_textureUploader; | 291 OwnPtr<TextureUploader> m_textureUploader; |
290 OwnPtr<AcceleratedTextureCopier> m_textureCopier; | 292 OwnPtr<AcceleratedTextureCopier> m_textureCopier; |
291 int m_maxTextureSize; | 293 int m_maxTextureSize; |
292 }; | 294 }; |
293 | 295 |
294 } | 296 } |
295 | 297 |
296 #endif | 298 #endif |
OLD | NEW |