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 "base/threading/thread_checker.h" | |
12 #include "cc/graphics_context.h" | 13 #include "cc/graphics_context.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 } |
23 | 24 |
24 namespace cc { | 25 namespace cc { |
25 | 26 |
26 class IntRect; | 27 class IntRect; |
27 class LayerTextureSubImage; | 28 class LayerTextureSubImage; |
28 class TextureCopier; | 29 class TextureCopier; |
29 class TextureUploader; | 30 class TextureUploader; |
30 | 31 |
31 // Thread-safety notes: this class is not thread-safe and can only be called | 32 // This class is not thread-safe and can only be called from the thread it was |
32 // from the thread it was created on (in practice, the compositor thread). | 33 // created on (in practice, the impl thread). |
33 class ResourceProvider { | 34 class ResourceProvider { |
34 public: | 35 public: |
35 typedef unsigned ResourceId; | 36 typedef unsigned ResourceId; |
36 typedef std::vector<ResourceId> ResourceIdArray; | 37 typedef std::vector<ResourceId> ResourceIdArray; |
37 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 38 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
38 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; | 39 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; |
39 enum ResourceType { | 40 enum ResourceType { |
40 GLTexture = 1, | 41 GLTexture = 1, |
41 Bitmap, | 42 Bitmap, |
42 }; | 43 }; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 struct Child { | 239 struct Child { |
239 Child(); | 240 Child(); |
240 ~Child(); | 241 ~Child(); |
241 | 242 |
242 int pool; | 243 int pool; |
243 ResourceIdMap childToParentMap; | 244 ResourceIdMap childToParentMap; |
244 ResourceIdMap parentToChildMap; | 245 ResourceIdMap parentToChildMap; |
245 }; | 246 }; |
246 typedef base::hash_map<int, Child> ChildMap; | 247 typedef base::hash_map<int, Child> ChildMap; |
247 | 248 |
248 explicit ResourceProvider(GraphicsContext*); | 249 ResourceProvider(GraphicsContext*); |
jamesr
2012/10/31 04:42:13
think we still want explicit
| |
249 bool initialize(); | 250 bool initialize(); |
250 | 251 |
251 const Resource* lockForRead(ResourceId); | 252 const Resource* lockForRead(ResourceId); |
252 void unlockForRead(ResourceId); | 253 void unlockForRead(ResourceId); |
253 const Resource* lockForWrite(ResourceId); | 254 const Resource* lockForWrite(ResourceId); |
254 void unlockForWrite(ResourceId); | 255 void unlockForWrite(ResourceId); |
255 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 256 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
256 | 257 |
257 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl eResource*); | 258 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl eResource*); |
258 void trimMailboxDeque(); | 259 void trimMailboxDeque(); |
259 void deleteResourceInternal(ResourceMap::iterator it); | 260 void deleteResourceInternal(ResourceMap::iterator it); |
260 | 261 |
261 GraphicsContext* m_context; | 262 GraphicsContext* m_context; |
262 ResourceId m_nextId; | 263 ResourceId m_nextId; |
263 ResourceMap m_resources; | 264 ResourceMap m_resources; |
264 int m_nextChild; | 265 int m_nextChild; |
265 ChildMap m_children; | 266 ChildMap m_children; |
266 | 267 |
267 std::deque<Mailbox> m_mailboxes; | 268 std::deque<Mailbox> m_mailboxes; |
268 | 269 |
269 ResourceType m_defaultResourceType; | 270 ResourceType m_defaultResourceType; |
270 bool m_useTextureStorageExt; | 271 bool m_useTextureStorageExt; |
271 bool m_useTextureUsageHint; | 272 bool m_useTextureUsageHint; |
272 bool m_useShallowFlush; | 273 bool m_useShallowFlush; |
273 scoped_ptr<TextureUploader> m_textureUploader; | 274 scoped_ptr<TextureUploader> m_textureUploader; |
274 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 275 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
275 int m_maxTextureSize; | 276 int m_maxTextureSize; |
276 | 277 |
278 base::ThreadChecker m_threadChecker; | |
279 | |
277 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 280 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
278 }; | 281 }; |
279 | 282 |
280 } | 283 } |
281 | 284 |
282 #endif | 285 #endif |
OLD | NEW |