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 CCResourceProvider_h | 5 #ifndef CCResourceProvider_h |
6 #define CCResourceProvider_h | 6 #define CCResourceProvider_h |
7 | 7 |
8 #include "IntSize.h" | 8 #include "IntSize.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "cc/graphics_context.h" | 12 #include "cc/graphics_context.h" |
| 13 #include "cc/proxy.h" |
13 #include "cc/texture_copier.h" | 14 #include "cc/texture_copier.h" |
14 #include "third_party/khronos/GLES2/gl2.h" | 15 #include "third_party/khronos/GLES2/gl2.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/core/SkCanvas.h" |
17 #include <deque> | 18 #include <deque> |
18 #include <vector> | 19 #include <vector> |
19 | 20 |
20 namespace WebKit { | 21 namespace WebKit { |
21 class WebGraphicsContext3D; | 22 class WebGraphicsContext3D; |
22 } | 23 } |
(...skipping 28 matching lines...) Expand all Loading... |
51 }; | 52 }; |
52 typedef std::vector<TransferableResource> TransferableResourceArray; | 53 typedef std::vector<TransferableResource> TransferableResourceArray; |
53 struct TransferableResourceList { | 54 struct TransferableResourceList { |
54 TransferableResourceList(); | 55 TransferableResourceList(); |
55 ~TransferableResourceList(); | 56 ~TransferableResourceList(); |
56 | 57 |
57 TransferableResourceArray resources; | 58 TransferableResourceArray resources; |
58 unsigned syncPoint; | 59 unsigned syncPoint; |
59 }; | 60 }; |
60 | 61 |
61 static scoped_ptr<CCResourceProvider> create(CCGraphicsContext*); | 62 static scoped_ptr<CCResourceProvider> create(CCGraphicsContext*, CCProxy*); |
62 | 63 |
63 virtual ~CCResourceProvider(); | 64 virtual ~CCResourceProvider(); |
64 | 65 |
65 WebKit::WebGraphicsContext3D* graphicsContext3D(); | 66 WebKit::WebGraphicsContext3D* graphicsContext3D(); |
| 67 CCProxy* proxy() { return m_proxy; } |
66 TextureCopier* textureCopier() const { return m_textureCopier.get(); } | 68 TextureCopier* textureCopier() const { return m_textureCopier.get(); } |
67 int maxTextureSize() const { return m_maxTextureSize; } | 69 int maxTextureSize() const { return m_maxTextureSize; } |
68 unsigned numResources() const { return m_resources.size(); } | 70 unsigned numResources() const { return m_resources.size(); } |
69 | 71 |
70 // Checks whether a resource is in use by a consumer. | 72 // Checks whether a resource is in use by a consumer. |
71 bool inUseByConsumer(ResourceId); | 73 bool inUseByConsumer(ResourceId); |
72 | 74 |
73 | 75 |
74 // Producer interface. | 76 // Producer interface. |
75 | 77 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 struct Child { | 235 struct Child { |
234 Child(); | 236 Child(); |
235 ~Child(); | 237 ~Child(); |
236 | 238 |
237 int pool; | 239 int pool; |
238 ResourceIdMap childToParentMap; | 240 ResourceIdMap childToParentMap; |
239 ResourceIdMap parentToChildMap; | 241 ResourceIdMap parentToChildMap; |
240 }; | 242 }; |
241 typedef base::hash_map<int, Child> ChildMap; | 243 typedef base::hash_map<int, Child> ChildMap; |
242 | 244 |
243 explicit CCResourceProvider(CCGraphicsContext*); | 245 CCResourceProvider(CCGraphicsContext*, CCProxy*); |
244 bool initialize(); | 246 bool initialize(); |
245 | 247 |
246 const Resource* lockForRead(ResourceId); | 248 const Resource* lockForRead(ResourceId); |
247 void unlockForRead(ResourceId); | 249 void unlockForRead(ResourceId); |
248 const Resource* lockForWrite(ResourceId); | 250 const Resource* lockForWrite(ResourceId); |
249 void unlockForWrite(ResourceId); | 251 void unlockForWrite(ResourceId); |
250 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 252 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
251 | 253 |
252 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 254 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
253 void trimMailboxDeque(); | 255 void trimMailboxDeque(); |
254 void deleteResourceInternal(ResourceMap::iterator it); | 256 void deleteResourceInternal(ResourceMap::iterator it); |
255 | 257 |
256 CCGraphicsContext* m_context; | 258 CCGraphicsContext* m_context; |
| 259 CCProxy* m_proxy; |
257 ResourceId m_nextId; | 260 ResourceId m_nextId; |
258 ResourceMap m_resources; | 261 ResourceMap m_resources; |
259 int m_nextChild; | 262 int m_nextChild; |
260 ChildMap m_children; | 263 ChildMap m_children; |
261 | 264 |
262 std::deque<Mailbox> m_mailboxes; | 265 std::deque<Mailbox> m_mailboxes; |
263 | 266 |
264 ResourceType m_defaultResourceType; | 267 ResourceType m_defaultResourceType; |
265 bool m_useTextureStorageExt; | 268 bool m_useTextureStorageExt; |
266 bool m_useTextureUsageHint; | 269 bool m_useTextureUsageHint; |
267 bool m_useShallowFlush; | 270 bool m_useShallowFlush; |
268 scoped_ptr<TextureUploader> m_textureUploader; | 271 scoped_ptr<TextureUploader> m_textureUploader; |
269 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 272 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
270 int m_maxTextureSize; | 273 int m_maxTextureSize; |
271 | 274 |
272 DISALLOW_COPY_AND_ASSIGN(CCResourceProvider); | 275 DISALLOW_COPY_AND_ASSIGN(CCResourceProvider); |
273 }; | 276 }; |
274 | 277 |
275 } | 278 } |
276 | 279 |
277 #endif | 280 #endif |
OLD | NEW |