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 CC_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCE_PROVIDER_H_ |
6 #define CC_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCE_PROVIDER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "cc/cc_export.h" | 17 #include "cc/cc_export.h" |
18 #include "cc/output_surface.h" | 18 #include "cc/output_surface.h" |
19 #include "cc/texture_copier.h" | 19 #include "cc/texture_copier.h" |
20 #include "cc/texture_mailbox.h" | 20 #include "cc/texture_mailbox.h" |
21 #include "cc/transferable_resource.h" | 21 #include "cc/transferable_resource.h" |
22 #include "third_party/khronos/GLES2/gl2.h" | 22 #include "third_party/khronos/GLES2/gl2.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "third_party/skia/include/core/SkCanvas.h" | 24 #include "third_party/skia/include/core/SkCanvas.h" |
25 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
26 | 26 |
| 27 class GrContext; |
| 28 |
27 namespace WebKit { | 29 namespace WebKit { |
28 class WebGraphicsContext3D; | 30 class WebGraphicsContext3D; |
29 } | 31 } |
30 | 32 |
31 namespace gfx { | 33 namespace gfx { |
32 class Rect; | 34 class Rect; |
33 class Vector2d; | 35 class Vector2d; |
34 } | 36 } |
35 | 37 |
36 namespace cc { | 38 namespace cc { |
37 | 39 |
| 40 class GaneshResourceProvider; |
38 class TextureUploader; | 41 class TextureUploader; |
39 | 42 |
40 // This class is not thread-safe and can only be called from the thread it was | 43 // This class is not thread-safe and can only be called from the thread it was |
41 // created on (in practice, the impl thread). | 44 // created on (in practice, the impl thread). |
42 class CC_EXPORT ResourceProvider { | 45 class CC_EXPORT ResourceProvider { |
43 public: | 46 public: |
44 typedef unsigned ResourceId; | 47 typedef unsigned ResourceId; |
45 typedef std::vector<ResourceId> ResourceIdArray; | 48 typedef std::vector<ResourceId> ResourceIdArray; |
46 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 49 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
47 enum TextureUsageHint { | 50 enum TextureUsageHint { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void setPixelsFromBuffer(ResourceId id); | 237 void setPixelsFromBuffer(ResourceId id); |
235 | 238 |
236 // Asynchronously update pixels from acquired pixel buffer. | 239 // Asynchronously update pixels from acquired pixel buffer. |
237 void beginSetPixels(ResourceId id); | 240 void beginSetPixels(ResourceId id); |
238 bool didSetPixelsComplete(ResourceId id); | 241 bool didSetPixelsComplete(ResourceId id); |
239 | 242 |
240 // For tests only! This prevents detecting uninitialized reads. | 243 // For tests only! This prevents detecting uninitialized reads. |
241 // Use setPixels or lockForWrite to allocate implicitly. | 244 // Use setPixels or lockForWrite to allocate implicitly. |
242 void allocateForTesting(ResourceId id); | 245 void allocateForTesting(ResourceId id); |
243 | 246 |
| 247 GaneshResourceProvider* ganeshResourceProvider() { return m_ganeshResourcePr
ovider.get(); } |
| 248 void setGaneshContexts(WebKit::WebGraphicsContext3D* context3d, GrContext* g
rContext); |
| 249 |
244 private: | 250 private: |
245 struct Resource { | 251 struct Resource { |
246 Resource(); | 252 Resource(); |
247 ~Resource(); | 253 ~Resource(); |
248 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); | 254 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); |
249 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); | 255 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); |
250 | 256 |
251 unsigned glId; | 257 unsigned glId; |
252 // Pixel buffer used for set pixels without unnecessary copying. | 258 // Pixel buffer used for set pixels without unnecessary copying. |
253 unsigned glPixelBufferId; | 259 unsigned glPixelBufferId; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 306 |
301 ResourceType m_defaultResourceType; | 307 ResourceType m_defaultResourceType; |
302 bool m_useTextureStorageExt; | 308 bool m_useTextureStorageExt; |
303 bool m_useTextureUsageHint; | 309 bool m_useTextureUsageHint; |
304 bool m_useShallowFlush; | 310 bool m_useShallowFlush; |
305 scoped_ptr<TextureUploader> m_textureUploader; | 311 scoped_ptr<TextureUploader> m_textureUploader; |
306 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 312 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
307 int m_maxTextureSize; | 313 int m_maxTextureSize; |
308 GLenum m_bestTextureFormat; | 314 GLenum m_bestTextureFormat; |
309 | 315 |
| 316 scoped_ptr<GaneshResourceProvider> m_ganeshResourceProvider; |
| 317 |
310 base::ThreadChecker m_threadChecker; | 318 base::ThreadChecker m_threadChecker; |
311 | 319 |
312 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 320 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
313 }; | 321 }; |
314 | 322 |
315 } | 323 } |
316 | 324 |
317 #endif // CC_RESOURCE_PROVIDER_H_ | 325 #endif // CC_RESOURCE_PROVIDER_H_ |
OLD | NEW |