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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 RESOURCE_TYPE_BITMAP, | 80 RESOURCE_TYPE_BITMAP, |
81 }; | 81 }; |
82 | 82 |
83 static scoped_ptr<ResourceProvider> Create( | 83 static scoped_ptr<ResourceProvider> Create( |
84 OutputSurface* output_surface, | 84 OutputSurface* output_surface, |
85 SharedBitmapManager* shared_bitmap_manager, | 85 SharedBitmapManager* shared_bitmap_manager, |
86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
87 BlockingTaskRunner* blocking_main_thread_task_runner, | 87 BlockingTaskRunner* blocking_main_thread_task_runner, |
88 int highp_threshold_min, | 88 int highp_threshold_min, |
89 size_t id_allocation_chunk_size, | 89 size_t id_allocation_chunk_size, |
| 90 bool use_gpu_memory_buffers_by_default, |
90 const std::vector<unsigned>& use_image_texture_targets); | 91 const std::vector<unsigned>& use_image_texture_targets); |
91 ~ResourceProvider() override; | 92 ~ResourceProvider() override; |
92 | 93 |
93 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 94 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
94 | 95 |
95 int max_texture_size() const { return max_texture_size_; } | 96 int max_texture_size() const { return max_texture_size_; } |
96 ResourceFormat best_texture_format() const { return best_texture_format_; } | 97 ResourceFormat best_texture_format() const { return best_texture_format_; } |
97 ResourceFormat best_render_buffer_format() const { | 98 ResourceFormat best_render_buffer_format() const { |
98 return best_render_buffer_format_; | 99 return best_render_buffer_format_; |
99 } | 100 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 public: | 303 public: |
303 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 304 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
304 ResourceId resource_id); | 305 ResourceId resource_id); |
305 ~ScopedWriteLockGpuMemoryBuffer(); | 306 ~ScopedWriteLockGpuMemoryBuffer(); |
306 | 307 |
307 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); | 308 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); |
308 | 309 |
309 private: | 310 private: |
310 ResourceProvider* resource_provider_; | 311 ResourceProvider* resource_provider_; |
311 ResourceProvider::Resource* resource_; | 312 ResourceProvider::Resource* resource_; |
312 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 313 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
313 gfx::GpuMemoryBuffer* gpu_memory_buffer_; | |
314 gfx::Size size_; | |
315 ResourceFormat format_; | |
316 base::ThreadChecker thread_checker_; | 314 base::ThreadChecker thread_checker_; |
317 | 315 |
318 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 316 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
319 }; | 317 }; |
320 | 318 |
321 class CC_EXPORT ScopedWriteLockGr { | 319 class CC_EXPORT ScopedWriteLockGr { |
322 public: | 320 public: |
323 ScopedWriteLockGr(ResourceProvider* resource_provider, | 321 ScopedWriteLockGr(ResourceProvider* resource_provider, |
324 ResourceId resource_id); | 322 ResourceId resource_id); |
325 ~ScopedWriteLockGr(); | 323 ~ScopedWriteLockGr(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 426 |
429 int tracing_id() const { return tracing_id_; } | 427 int tracing_id() const { return tracing_id_; } |
430 | 428 |
431 protected: | 429 protected: |
432 ResourceProvider(OutputSurface* output_surface, | 430 ResourceProvider(OutputSurface* output_surface, |
433 SharedBitmapManager* shared_bitmap_manager, | 431 SharedBitmapManager* shared_bitmap_manager, |
434 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 432 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
435 BlockingTaskRunner* blocking_main_thread_task_runner, | 433 BlockingTaskRunner* blocking_main_thread_task_runner, |
436 int highp_threshold_min, | 434 int highp_threshold_min, |
437 size_t id_allocation_chunk_size, | 435 size_t id_allocation_chunk_size, |
| 436 bool use_gpu_memory_buffers_by_default, |
438 const std::vector<unsigned>& use_image_texture_targets); | 437 const std::vector<unsigned>& use_image_texture_targets); |
439 void Initialize(); | 438 void Initialize(); |
440 | 439 |
441 private: | 440 private: |
442 struct Resource { | 441 struct Resource { |
443 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; | 442 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; |
444 | 443 |
445 ~Resource(); | 444 ~Resource(); |
446 Resource(unsigned texture_id, | 445 Resource(unsigned texture_id, |
447 const gfx::Size& size, | 446 const gfx::Size& size, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 NORMAL, | 538 NORMAL, |
540 FOR_SHUTDOWN, | 539 FOR_SHUTDOWN, |
541 }; | 540 }; |
542 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); | 541 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); |
543 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, | 542 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, |
544 DeleteStyle style, | 543 DeleteStyle style, |
545 const ResourceIdArray& unused); | 544 const ResourceIdArray& unused); |
546 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); | 545 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); |
547 void LazyCreate(Resource* resource); | 546 void LazyCreate(Resource* resource); |
548 void LazyAllocate(Resource* resource); | 547 void LazyAllocate(Resource* resource); |
| 548 void SetGpuMemoryBuffer(Resource* resource, |
| 549 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer); |
549 | 550 |
550 void BindImageForSampling(Resource* resource); | 551 void BindImageForSampling(Resource* resource); |
551 // Binds the given GL resource to a texture target for sampling using the | 552 // Binds the given GL resource to a texture target for sampling using the |
552 // specified filter for both minification and magnification. Returns the | 553 // specified filter for both minification and magnification. Returns the |
553 // texture target used. The resource must be locked for reading. | 554 // texture target used. The resource must be locked for reading. |
554 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); | 555 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); |
555 | 556 |
556 // Returns NULL if the output_surface_ does not have a ContextProvider. | 557 // Returns NULL if the output_surface_ does not have a ContextProvider. |
557 gpu::gles2::GLES2Interface* ContextGL() const; | 558 gpu::gles2::GLES2Interface* ContextGL() const; |
558 class GrContext* GrContext(bool worker_context) const; | 559 class GrContext* GrContext(bool worker_context) const; |
559 | 560 |
560 OutputSurface* output_surface_; | 561 OutputSurface* output_surface_; |
561 SharedBitmapManager* shared_bitmap_manager_; | 562 SharedBitmapManager* shared_bitmap_manager_; |
562 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 563 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
563 BlockingTaskRunner* blocking_main_thread_task_runner_; | 564 BlockingTaskRunner* blocking_main_thread_task_runner_; |
564 bool lost_output_surface_; | 565 bool lost_output_surface_; |
565 int highp_threshold_min_; | 566 int highp_threshold_min_; |
566 ResourceId next_id_; | 567 ResourceId next_id_; |
567 ResourceMap resources_; | 568 ResourceMap resources_; |
568 int next_child_; | 569 int next_child_; |
569 ChildMap children_; | 570 ChildMap children_; |
570 | 571 |
571 ResourceType default_resource_type_; | 572 ResourceType default_resource_type_; |
| 573 bool use_gpu_memory_buffers_by_default_; |
572 bool use_texture_storage_ext_; | 574 bool use_texture_storage_ext_; |
573 bool use_texture_format_bgra_; | 575 bool use_texture_format_bgra_; |
574 bool use_texture_usage_hint_; | 576 bool use_texture_usage_hint_; |
575 bool use_compressed_texture_etc1_; | 577 bool use_compressed_texture_etc1_; |
576 ResourceFormat yuv_resource_format_; | 578 ResourceFormat yuv_resource_format_; |
577 int max_texture_size_; | 579 int max_texture_size_; |
578 ResourceFormat best_texture_format_; | 580 ResourceFormat best_texture_format_; |
579 ResourceFormat best_render_buffer_format_; | 581 ResourceFormat best_render_buffer_format_; |
580 | 582 |
581 base::ThreadChecker thread_checker_; | 583 base::ThreadChecker thread_checker_; |
(...skipping 10 matching lines...) Expand all Loading... |
592 // A process-unique ID used for disambiguating memory dumps from different | 594 // A process-unique ID used for disambiguating memory dumps from different |
593 // resource providers. | 595 // resource providers. |
594 int tracing_id_; | 596 int tracing_id_; |
595 | 597 |
596 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 598 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
597 }; | 599 }; |
598 | 600 |
599 } // namespace cc | 601 } // namespace cc |
600 | 602 |
601 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 603 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |