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_RESOURCES_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ |
6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 // Creates a resource of the default resource type. | 95 // Creates a resource of the default resource type. |
96 ResourceId CreateResource(gfx::Size size, | 96 ResourceId CreateResource(gfx::Size size, |
97 GLint wrap_mode, | 97 GLint wrap_mode, |
98 TextureUsageHint hint, | 98 TextureUsageHint hint, |
99 ResourceFormat format); | 99 ResourceFormat format); |
100 | 100 |
101 // Creates a resource which is tagged as being managed for GPU memory | 101 // Creates a resource which is tagged as being managed for GPU memory |
102 // accounting purposes. | 102 // accounting purposes. |
103 ResourceId CreateManagedResource(gfx::Size size, | 103 ResourceId CreateManagedResource(gfx::Size size, |
| 104 GLenum target, |
104 GLint wrap_mode, | 105 GLint wrap_mode, |
105 TextureUsageHint hint, | 106 TextureUsageHint hint, |
106 ResourceFormat format); | 107 ResourceFormat format); |
107 | 108 |
108 // You can also explicitly create a specific resource type. | 109 // You can also explicitly create a specific resource type. |
109 ResourceId CreateGLTexture(gfx::Size size, | 110 ResourceId CreateGLTexture(gfx::Size size, |
| 111 GLenum target, |
110 GLenum texture_pool, | 112 GLenum texture_pool, |
111 GLint wrap_mode, | 113 GLint wrap_mode, |
112 TextureUsageHint hint, | 114 TextureUsageHint hint, |
113 ResourceFormat format); | 115 ResourceFormat format); |
114 | 116 |
115 ResourceId CreateBitmap(gfx::Size size, GLint wrap_mode); | 117 ResourceId CreateBitmap(gfx::Size size, GLint wrap_mode); |
116 // Wraps an external texture into a GL resource. | 118 // Wraps an external texture into a GL resource. |
117 ResourceId CreateResourceFromExternalTexture( | 119 ResourceId CreateResourceFromExternalTexture( |
118 unsigned texture_target, | 120 unsigned texture_target, |
119 unsigned texture_id); | 121 unsigned texture_id); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 private: | 216 private: |
215 unsigned texture_id_; | 217 unsigned texture_id_; |
216 | 218 |
217 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL); | 219 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL); |
218 }; | 220 }; |
219 | 221 |
220 class CC_EXPORT ScopedSamplerGL : public ScopedReadLockGL { | 222 class CC_EXPORT ScopedSamplerGL : public ScopedReadLockGL { |
221 public: | 223 public: |
222 ScopedSamplerGL(ResourceProvider* resource_provider, | 224 ScopedSamplerGL(ResourceProvider* resource_provider, |
223 ResourceProvider::ResourceId resource_id, | 225 ResourceProvider::ResourceId resource_id, |
224 GLenum target, | |
225 GLenum filter); | 226 GLenum filter); |
226 ScopedSamplerGL(ResourceProvider* resource_provider, | 227 ScopedSamplerGL(ResourceProvider* resource_provider, |
227 ResourceProvider::ResourceId resource_id, | 228 ResourceProvider::ResourceId resource_id, |
228 GLenum target, | |
229 GLenum unit, | 229 GLenum unit, |
230 GLenum filter); | 230 GLenum filter); |
231 virtual ~ScopedSamplerGL(); | 231 virtual ~ScopedSamplerGL(); |
232 | 232 |
| 233 GLenum target() const { return target_; } |
| 234 |
233 private: | 235 private: |
| 236 GLenum unit_; |
234 GLenum target_; | 237 GLenum target_; |
235 GLenum unit_; | |
236 | 238 |
237 DISALLOW_COPY_AND_ASSIGN(ScopedSamplerGL); | 239 DISALLOW_COPY_AND_ASSIGN(ScopedSamplerGL); |
238 }; | 240 }; |
239 | 241 |
240 class CC_EXPORT ScopedWriteLockGL { | 242 class CC_EXPORT ScopedWriteLockGL { |
241 public: | 243 public: |
242 ScopedWriteLockGL(ResourceProvider* resource_provider, | 244 ScopedWriteLockGL(ResourceProvider* resource_provider, |
243 ResourceProvider::ResourceId resource_id); | 245 ResourceProvider::ResourceId resource_id); |
244 ~ScopedWriteLockGL(); | 246 ~ScopedWriteLockGL(); |
245 | 247 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 }; | 460 }; |
459 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); | 461 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); |
460 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, | 462 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, |
461 DeleteStyle style, | 463 DeleteStyle style, |
462 const ResourceIdArray& unused); | 464 const ResourceIdArray& unused); |
463 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); | 465 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); |
464 void LazyCreate(Resource* resource); | 466 void LazyCreate(Resource* resource); |
465 void LazyAllocate(Resource* resource); | 467 void LazyAllocate(Resource* resource); |
466 | 468 |
467 // Binds the given GL resource to a texture target for sampling using the | 469 // Binds the given GL resource to a texture target for sampling using the |
468 // specified filter for both minification and magnification. The resource | 470 // specified filter for both minification and magnification. Returns the |
469 // must be locked for reading. | 471 // texture target used. The resource must be locked for reading. |
470 void BindForSampling(ResourceProvider::ResourceId resource_id, | 472 GLenum BindForSampling(ResourceProvider::ResourceId resource_id, |
471 GLenum target, | 473 GLenum unit, |
472 GLenum unit, | 474 GLenum filter); |
473 GLenum filter); | |
474 | 475 |
475 // Returns NULL if the output_surface_ does not have a ContextProvider. | 476 // Returns NULL if the output_surface_ does not have a ContextProvider. |
476 blink::WebGraphicsContext3D* Context3d() const; | 477 blink::WebGraphicsContext3D* Context3d() const; |
477 | 478 |
478 OutputSurface* output_surface_; | 479 OutputSurface* output_surface_; |
479 SharedBitmapManager* shared_bitmap_manager_; | 480 SharedBitmapManager* shared_bitmap_manager_; |
480 bool lost_output_surface_; | 481 bool lost_output_surface_; |
481 int highp_threshold_min_; | 482 int highp_threshold_min_; |
482 ResourceId next_id_; | 483 ResourceId next_id_; |
483 ResourceMap resources_; | 484 ResourceMap resources_; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 return format_gl_data_format[format]; | 548 return format_gl_data_format[format]; |
548 } | 549 } |
549 | 550 |
550 inline GLenum GLInternalFormat(ResourceFormat format) { | 551 inline GLenum GLInternalFormat(ResourceFormat format) { |
551 return GLDataFormat(format); | 552 return GLDataFormat(format); |
552 } | 553 } |
553 | 554 |
554 } // namespace cc | 555 } // namespace cc |
555 | 556 |
556 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 557 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |