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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 bool InUseByConsumer(ResourceId id); | 90 bool InUseByConsumer(ResourceId id); |
91 | 91 |
92 bool IsLost(ResourceId id); | 92 bool IsLost(ResourceId id); |
93 | 93 |
94 // Producer interface. | 94 // Producer interface. |
95 | 95 |
96 ResourceType default_resource_type() const { return default_resource_type_; } | 96 ResourceType default_resource_type() const { return default_resource_type_; } |
97 ResourceType GetResourceType(ResourceId id); | 97 ResourceType GetResourceType(ResourceId id); |
98 | 98 |
99 // Creates a resource of the default resource type. | 99 // Creates a resource of the default resource type. |
100 ResourceId CreateResource(gfx::Size size, | 100 ResourceId CreateResource(const gfx::Size& size, |
101 GLint wrap_mode, | 101 GLint wrap_mode, |
102 TextureUsageHint hint, | 102 TextureUsageHint hint, |
103 ResourceFormat format); | 103 ResourceFormat format); |
104 | 104 |
105 // Creates a resource which is tagged as being managed for GPU memory | 105 // Creates a resource which is tagged as being managed for GPU memory |
106 // accounting purposes. | 106 // accounting purposes. |
107 ResourceId CreateManagedResource(gfx::Size size, | 107 ResourceId CreateManagedResource(const gfx::Size& size, |
108 GLenum target, | 108 GLenum target, |
109 GLint wrap_mode, | 109 GLint wrap_mode, |
110 TextureUsageHint hint, | 110 TextureUsageHint hint, |
111 ResourceFormat format); | 111 ResourceFormat format); |
112 | 112 |
113 // You can also explicitly create a specific resource type. | 113 // You can also explicitly create a specific resource type. |
114 ResourceId CreateGLTexture(gfx::Size size, | 114 ResourceId CreateGLTexture(const gfx::Size& size, |
115 GLenum target, | 115 GLenum target, |
116 GLenum texture_pool, | 116 GLenum texture_pool, |
117 GLint wrap_mode, | 117 GLint wrap_mode, |
118 TextureUsageHint hint, | 118 TextureUsageHint hint, |
119 ResourceFormat format); | 119 ResourceFormat format); |
120 | 120 |
121 ResourceId CreateBitmap(gfx::Size size, GLint wrap_mode); | 121 ResourceId CreateBitmap(const gfx::Size& size, GLint wrap_mode); |
122 // Wraps an external texture into a GL resource. | 122 // Wraps an external texture into a GL resource. |
123 ResourceId CreateResourceFromExternalTexture( | 123 ResourceId CreateResourceFromExternalTexture( |
124 unsigned texture_target, | 124 unsigned texture_target, |
125 unsigned texture_id); | 125 unsigned texture_id); |
126 | 126 |
127 // Wraps an external texture mailbox into a GL resource. | 127 // Wraps an external texture mailbox into a GL resource. |
128 ResourceId CreateResourceFromTextureMailbox( | 128 ResourceId CreateResourceFromTextureMailbox( |
129 const TextureMailbox& mailbox, | 129 const TextureMailbox& mailbox, |
130 scoped_ptr<SingleReleaseCallback> release_callback); | 130 scoped_ptr<SingleReleaseCallback> release_callback); |
131 | 131 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // Indicates if we can currently lock this resource for write. | 359 // Indicates if we can currently lock this resource for write. |
360 bool CanLockForWrite(ResourceId id); | 360 bool CanLockForWrite(ResourceId id); |
361 | 361 |
362 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 362 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
363 | 363 |
364 private: | 364 private: |
365 struct Resource { | 365 struct Resource { |
366 Resource(); | 366 Resource(); |
367 ~Resource(); | 367 ~Resource(); |
368 Resource(unsigned texture_id, | 368 Resource(unsigned texture_id, |
369 gfx::Size size, | 369 const gfx::Size& size, |
370 GLenum target, | 370 GLenum target, |
371 GLenum filter, | 371 GLenum filter, |
372 GLenum texture_pool, | 372 GLenum texture_pool, |
373 GLint wrap_mode, | 373 GLint wrap_mode, |
374 TextureUsageHint hint, | 374 TextureUsageHint hint, |
375 ResourceFormat format); | 375 ResourceFormat format); |
376 Resource(uint8_t* pixels, | 376 Resource(uint8_t* pixels, |
377 SharedBitmap* bitmap, | 377 SharedBitmap* bitmap, |
378 gfx::Size size, | 378 const gfx::Size& size, |
379 GLenum filter, | 379 GLenum filter, |
380 GLint wrap_mode); | 380 GLint wrap_mode); |
381 | 381 |
382 int child_id; | 382 int child_id; |
383 unsigned gl_id; | 383 unsigned gl_id; |
384 // Pixel buffer used for set pixels without unnecessary copying. | 384 // Pixel buffer used for set pixels without unnecessary copying. |
385 unsigned gl_pixel_buffer_id; | 385 unsigned gl_pixel_buffer_id; |
386 // Query used to determine when asynchronous set pixels complete. | 386 // Query used to determine when asynchronous set pixels complete. |
387 unsigned gl_upload_query_id; | 387 unsigned gl_upload_query_id; |
388 TextureMailbox mailbox; | 388 TextureMailbox mailbox; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 return format_gl_data_format[format]; | 557 return format_gl_data_format[format]; |
558 } | 558 } |
559 | 559 |
560 inline GLenum GLInternalFormat(ResourceFormat format) { | 560 inline GLenum GLInternalFormat(ResourceFormat format) { |
561 return GLDataFormat(format); | 561 return GLDataFormat(format); |
562 } | 562 } |
563 | 563 |
564 } // namespace cc | 564 } // namespace cc |
565 | 565 |
566 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 566 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |