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 "IntRect.h" |
8 #include "IntSize.h" | 9 #include "IntSize.h" |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/threading/thread_checker.h" |
12 #include "cc/graphics_context.h" | 14 #include "cc/graphics_context.h" |
13 #include "cc/texture_copier.h" | 15 #include "cc/texture_copier.h" |
14 #include "third_party/khronos/GLES2/gl2.h" | 16 #include "third_party/khronos/GLES2/gl2.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "third_party/skia/include/core/SkCanvas.h" | 18 #include "third_party/skia/include/core/SkCanvas.h" |
17 #include <deque> | 19 #include <deque> |
18 #include <vector> | 20 #include <vector> |
19 | 21 |
20 namespace WebKit { | 22 namespace WebKit { |
21 class WebGraphicsContext3D; | 23 class WebGraphicsContext3D; |
22 } | 24 } |
23 | 25 |
24 namespace cc { | 26 namespace cc { |
25 | 27 |
26 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 struct Child { | 234 struct Child { |
234 Child(); | 235 Child(); |
235 ~Child(); | 236 ~Child(); |
236 | 237 |
237 int pool; | 238 int pool; |
238 ResourceIdMap childToParentMap; | 239 ResourceIdMap childToParentMap; |
239 ResourceIdMap parentToChildMap; | 240 ResourceIdMap parentToChildMap; |
240 }; | 241 }; |
241 typedef base::hash_map<int, Child> ChildMap; | 242 typedef base::hash_map<int, Child> ChildMap; |
242 | 243 |
243 explicit ResourceProvider(GraphicsContext*); | 244 ResourceProvider(GraphicsContext*); |
244 bool initialize(); | 245 bool initialize(); |
245 | 246 |
246 const Resource* lockForRead(ResourceId); | 247 const Resource* lockForRead(ResourceId); |
247 void unlockForRead(ResourceId); | 248 void unlockForRead(ResourceId); |
248 const Resource* lockForWrite(ResourceId); | 249 const Resource* lockForWrite(ResourceId); |
249 void unlockForWrite(ResourceId); | 250 void unlockForWrite(ResourceId); |
250 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); | 251 static void populateSkBitmapWithResource(SkBitmap*, const Resource*); |
251 | 252 |
252 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); | 253 bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, Transferabl
eResource*); |
253 void trimMailboxDeque(); | 254 void trimMailboxDeque(); |
254 void deleteResourceInternal(ResourceMap::iterator it); | 255 void deleteResourceInternal(ResourceMap::iterator it); |
255 | 256 |
256 GraphicsContext* m_context; | 257 GraphicsContext* m_context; |
257 ResourceId m_nextId; | 258 ResourceId m_nextId; |
258 ResourceMap m_resources; | 259 ResourceMap m_resources; |
259 int m_nextChild; | 260 int m_nextChild; |
260 ChildMap m_children; | 261 ChildMap m_children; |
261 | 262 |
262 std::deque<Mailbox> m_mailboxes; | 263 std::deque<Mailbox> m_mailboxes; |
263 | 264 |
264 ResourceType m_defaultResourceType; | 265 ResourceType m_defaultResourceType; |
265 bool m_useTextureStorageExt; | 266 bool m_useTextureStorageExt; |
266 bool m_useTextureUsageHint; | 267 bool m_useTextureUsageHint; |
267 bool m_useShallowFlush; | 268 bool m_useShallowFlush; |
268 scoped_ptr<TextureUploader> m_textureUploader; | 269 scoped_ptr<TextureUploader> m_textureUploader; |
269 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 270 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
270 int m_maxTextureSize; | 271 int m_maxTextureSize; |
271 | 272 |
| 273 base::ThreadChecker m_threadChecker; |
| 274 |
272 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 275 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
273 }; | 276 }; |
274 | 277 |
275 } | 278 } |
276 | 279 |
277 #endif | 280 #endif |
OLD | NEW |