| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 static scoped_ptr<ResourceProvider> Create(OutputSurface* output_surface, | 56 static scoped_ptr<ResourceProvider> Create(OutputSurface* output_surface, |
| 57 int highp_threshold_min); | 57 int highp_threshold_min); |
| 58 | 58 |
| 59 virtual ~ResourceProvider(); | 59 virtual ~ResourceProvider(); |
| 60 | 60 |
| 61 void InitializeSoftware(); | 61 void InitializeSoftware(); |
| 62 bool InitializeGL(); | 62 bool InitializeGL(); |
| 63 | 63 |
| 64 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 64 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| 65 | 65 |
| 66 WebKit::WebGraphicsContext3D* GraphicsContext3D(); | |
| 67 int max_texture_size() const { return max_texture_size_; } | 66 int max_texture_size() const { return max_texture_size_; } |
| 68 GLenum best_texture_format() const { return best_texture_format_; } | 67 GLenum best_texture_format() const { return best_texture_format_; } |
| 69 size_t num_resources() const { return resources_.size(); } | 68 size_t num_resources() const { return resources_.size(); } |
| 70 | 69 |
| 71 // Checks whether a resource is in use by a consumer. | 70 // Checks whether a resource is in use by a consumer. |
| 72 bool InUseByConsumer(ResourceId id); | 71 bool InUseByConsumer(ResourceId id); |
| 73 | 72 |
| 74 | 73 |
| 75 // Producer interface. | 74 // Producer interface. |
| 76 | 75 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 current_read_lock_fence_ = fence; | 316 current_read_lock_fence_ = fence; |
| 318 } | 317 } |
| 319 Fence* GetReadLockFence() { return current_read_lock_fence_.get(); } | 318 Fence* GetReadLockFence() { return current_read_lock_fence_.get(); } |
| 320 | 319 |
| 321 // Enable read lock fences for a specific resource. | 320 // Enable read lock fences for a specific resource. |
| 322 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); | 321 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); |
| 323 | 322 |
| 324 // Indicates if we can currently lock this resource for write. | 323 // Indicates if we can currently lock this resource for write. |
| 325 bool CanLockForWrite(ResourceId id); | 324 bool CanLockForWrite(ResourceId id); |
| 326 | 325 |
| 327 cc::ContextProvider* offscreen_context_provider() { | 326 ContextProvider* offscreen_context_provider() { |
| 328 return offscreen_context_provider_.get(); | 327 return offscreen_context_provider_.get(); |
| 329 } | 328 } |
| 330 void set_offscreen_context_provider( | 329 void set_offscreen_context_provider( |
| 331 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { | 330 scoped_refptr<ContextProvider> offscreen_context_provider) { |
| 332 offscreen_context_provider_ = offscreen_context_provider; | 331 offscreen_context_provider_ = offscreen_context_provider; |
| 333 } | 332 } |
| 334 static GLint GetActiveTextureUnit(WebKit::WebGraphicsContext3D* context); | 333 static GLint GetActiveTextureUnit(WebKit::WebGraphicsContext3D* context); |
| 335 | 334 |
| 336 private: | 335 private: |
| 337 struct Resource { | 336 struct Resource { |
| 338 Resource(); | 337 Resource(); |
| 339 ~Resource(); | 338 ~Resource(); |
| 340 Resource(unsigned texture_id, | 339 Resource(unsigned texture_id, |
| 341 gfx::Size size, | 340 gfx::Size size, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // specified filter for both minification and magnification. The resource | 413 // specified filter for both minification and magnification. The resource |
| 415 // must be locked for reading. | 414 // must be locked for reading. |
| 416 void BindForSampling(ResourceProvider::ResourceId resource_id, | 415 void BindForSampling(ResourceProvider::ResourceId resource_id, |
| 417 GLenum target, | 416 GLenum target, |
| 418 GLenum unit, | 417 GLenum unit, |
| 419 GLenum filter); | 418 GLenum filter); |
| 420 void UnbindForSampling(ResourceProvider::ResourceId resource_id, | 419 void UnbindForSampling(ResourceProvider::ResourceId resource_id, |
| 421 GLenum target, | 420 GLenum target, |
| 422 GLenum unit); | 421 GLenum unit); |
| 423 | 422 |
| 423 // Returns NULL if the output_surface_ does not have a ContextProvider. |
| 424 WebKit::WebGraphicsContext3D* Context3d() const; |
| 425 |
| 424 OutputSurface* output_surface_; | 426 OutputSurface* output_surface_; |
| 425 bool lost_output_surface_; | 427 bool lost_output_surface_; |
| 426 int highp_threshold_min_; | 428 int highp_threshold_min_; |
| 427 ResourceId next_id_; | 429 ResourceId next_id_; |
| 428 ResourceMap resources_; | 430 ResourceMap resources_; |
| 429 int next_child_; | 431 int next_child_; |
| 430 ChildMap children_; | 432 ChildMap children_; |
| 431 | 433 |
| 432 ResourceType default_resource_type_; | 434 ResourceType default_resource_type_; |
| 433 bool use_texture_storage_ext_; | 435 bool use_texture_storage_ext_; |
| 434 bool use_texture_usage_hint_; | 436 bool use_texture_usage_hint_; |
| 435 bool use_shallow_flush_; | 437 bool use_shallow_flush_; |
| 436 scoped_ptr<TextureUploader> texture_uploader_; | 438 scoped_ptr<TextureUploader> texture_uploader_; |
| 437 int max_texture_size_; | 439 int max_texture_size_; |
| 438 GLenum best_texture_format_; | 440 GLenum best_texture_format_; |
| 439 | 441 |
| 440 scoped_refptr<cc::ContextProvider> offscreen_context_provider_; | 442 scoped_refptr<cc::ContextProvider> offscreen_context_provider_; |
| 441 | 443 |
| 442 base::ThreadChecker thread_checker_; | 444 base::ThreadChecker thread_checker_; |
| 443 | 445 |
| 444 scoped_refptr<Fence> current_read_lock_fence_; | 446 scoped_refptr<Fence> current_read_lock_fence_; |
| 445 | 447 |
| 446 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 448 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 447 }; | 449 }; |
| 448 | 450 |
| 449 } // namespace cc | 451 } // namespace cc |
| 450 | 452 |
| 451 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 453 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |