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/grcontext_provider.h" |
18 #include "cc/output_surface.h" | 19 #include "cc/output_surface.h" |
19 #include "cc/texture_copier.h" | 20 #include "cc/texture_copier.h" |
20 #include "cc/texture_mailbox.h" | 21 #include "cc/texture_mailbox.h" |
21 #include "cc/transferable_resource.h" | 22 #include "cc/transferable_resource.h" |
22 #include "third_party/khronos/GLES2/gl2.h" | 23 #include "third_party/khronos/GLES2/gl2.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "third_party/skia/include/core/SkCanvas.h" | 25 #include "third_party/skia/include/core/SkCanvas.h" |
25 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
26 | 27 |
27 namespace WebKit { | 28 namespace WebKit { |
28 class WebGraphicsContext3D; | 29 class WebGraphicsContext3D; |
29 } | 30 } |
30 | 31 |
31 namespace gfx { | 32 namespace gfx { |
32 class Rect; | 33 class Rect; |
33 class Vector2d; | 34 class Vector2d; |
34 } | 35 } |
35 | 36 |
36 namespace cc { | 37 namespace cc { |
37 | |
38 class TextureUploader; | 38 class TextureUploader; |
39 | 39 |
40 // This class is not thread-safe and can only be called from the thread it was | 40 // This class is not thread-safe and can only be called from the thread it was |
41 // created on (in practice, the impl thread). | 41 // created on (in practice, the impl thread). |
42 class CC_EXPORT ResourceProvider { | 42 class CC_EXPORT ResourceProvider { |
43 public: | 43 public: |
44 typedef unsigned ResourceId; | 44 typedef unsigned ResourceId; |
45 typedef std::vector<ResourceId> ResourceIdArray; | 45 typedef std::vector<ResourceId> ResourceIdArray; |
46 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 46 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
47 enum TextureUsageHint { | 47 enum TextureUsageHint { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // until this fence has passed. | 254 // until this fence has passed. |
255 void setReadLockFence(scoped_refptr<Fence> fence) { m_currentReadLockFence =
fence; } | 255 void setReadLockFence(scoped_refptr<Fence> fence) { m_currentReadLockFence =
fence; } |
256 Fence* getReadLockFence() { return m_currentReadLockFence; } | 256 Fence* getReadLockFence() { return m_currentReadLockFence; } |
257 | 257 |
258 // Enable read lock fences for a specific resource. | 258 // Enable read lock fences for a specific resource. |
259 void enableReadLockFences(ResourceProvider::ResourceId, bool enable); | 259 void enableReadLockFences(ResourceProvider::ResourceId, bool enable); |
260 | 260 |
261 // Indicates if we can currently lock this resource for write. | 261 // Indicates if we can currently lock this resource for write. |
262 bool canLockForWrite(ResourceId); | 262 bool canLockForWrite(ResourceId); |
263 | 263 |
| 264 GrContextProvider* grContextProvider() { return &m_grContextProvider; } |
| 265 void setContext3dForGrContext(WebKit::WebGraphicsContext3D* context3d); |
| 266 |
264 private: | 267 private: |
265 struct Resource { | 268 struct Resource { |
266 Resource(); | 269 Resource(); |
267 ~Resource(); | 270 ~Resource(); |
268 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); | 271 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); |
269 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); | 272 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); |
270 | 273 |
271 unsigned glId; | 274 unsigned glId; |
272 // Pixel buffer used for set pixels without unnecessary copying. | 275 // Pixel buffer used for set pixels without unnecessary copying. |
273 unsigned glPixelBufferId; | 276 unsigned glPixelBufferId; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 328 |
326 ResourceType m_defaultResourceType; | 329 ResourceType m_defaultResourceType; |
327 bool m_useTextureStorageExt; | 330 bool m_useTextureStorageExt; |
328 bool m_useTextureUsageHint; | 331 bool m_useTextureUsageHint; |
329 bool m_useShallowFlush; | 332 bool m_useShallowFlush; |
330 scoped_ptr<TextureUploader> m_textureUploader; | 333 scoped_ptr<TextureUploader> m_textureUploader; |
331 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; | 334 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; |
332 int m_maxTextureSize; | 335 int m_maxTextureSize; |
333 GLenum m_bestTextureFormat; | 336 GLenum m_bestTextureFormat; |
334 | 337 |
| 338 GrContextProvider m_grContextProvider; |
| 339 |
335 base::ThreadChecker m_threadChecker; | 340 base::ThreadChecker m_threadChecker; |
336 | 341 |
337 scoped_refptr<Fence> m_currentReadLockFence; | 342 scoped_refptr<Fence> m_currentReadLockFence; |
338 | 343 |
339 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 344 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
340 }; | 345 }; |
341 | 346 |
342 } | 347 } |
343 | 348 |
344 #endif // CC_RESOURCE_PROVIDER_H_ | 349 #endif // CC_RESOURCE_PROVIDER_H_ |
OLD | NEW |