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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void InitializeSoftware(); | 92 void InitializeSoftware(); |
93 void InitializeGL(); | 93 void InitializeGL(); |
94 | 94 |
95 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 95 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
96 | 96 |
97 int max_texture_size() const { return max_texture_size_; } | 97 int max_texture_size() const { return max_texture_size_; } |
98 ResourceFormat memory_efficient_texture_format() const { | 98 ResourceFormat memory_efficient_texture_format() const { |
99 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 99 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
100 } | 100 } |
101 ResourceFormat best_texture_format() const { return best_texture_format_; } | 101 ResourceFormat best_texture_format() const { return best_texture_format_; } |
| 102 ResourceFormat yuv_resource_format() const { return yuv_resource_format_; } |
102 bool use_sync_query() const { return use_sync_query_; } | 103 bool use_sync_query() const { return use_sync_query_; } |
103 size_t num_resources() const { return resources_.size(); } | 104 size_t num_resources() const { return resources_.size(); } |
104 | 105 |
105 // Checks whether a resource is in use by a consumer. | 106 // Checks whether a resource is in use by a consumer. |
106 bool InUseByConsumer(ResourceId id); | 107 bool InUseByConsumer(ResourceId id); |
107 | 108 |
108 bool IsLost(ResourceId id); | 109 bool IsLost(ResourceId id); |
109 bool AllowOverlay(ResourceId id); | 110 bool AllowOverlay(ResourceId id); |
110 | 111 |
111 // Producer interface. | 112 // Producer interface. |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 ResourceId next_id_; | 572 ResourceId next_id_; |
572 ResourceMap resources_; | 573 ResourceMap resources_; |
573 int next_child_; | 574 int next_child_; |
574 ChildMap children_; | 575 ChildMap children_; |
575 | 576 |
576 ResourceType default_resource_type_; | 577 ResourceType default_resource_type_; |
577 bool use_texture_storage_ext_; | 578 bool use_texture_storage_ext_; |
578 bool use_texture_format_bgra_; | 579 bool use_texture_format_bgra_; |
579 bool use_texture_usage_hint_; | 580 bool use_texture_usage_hint_; |
580 bool use_compressed_texture_etc1_; | 581 bool use_compressed_texture_etc1_; |
| 582 ResourceFormat yuv_resource_format_; |
581 scoped_ptr<TextureUploader> texture_uploader_; | 583 scoped_ptr<TextureUploader> texture_uploader_; |
582 int max_texture_size_; | 584 int max_texture_size_; |
583 ResourceFormat best_texture_format_; | 585 ResourceFormat best_texture_format_; |
584 | 586 |
585 base::ThreadChecker thread_checker_; | 587 base::ThreadChecker thread_checker_; |
586 | 588 |
587 scoped_refptr<Fence> current_read_lock_fence_; | 589 scoped_refptr<Fence> current_read_lock_fence_; |
588 bool use_rgba_4444_texture_format_; | 590 bool use_rgba_4444_texture_format_; |
589 | 591 |
590 const size_t id_allocation_chunk_size_; | 592 const size_t id_allocation_chunk_size_; |
(...skipping 12 matching lines...) Expand all Loading... |
603 inline unsigned BitsPerPixel(ResourceFormat format) { | 605 inline unsigned BitsPerPixel(ResourceFormat format) { |
604 switch (format) { | 606 switch (format) { |
605 case BGRA_8888: | 607 case BGRA_8888: |
606 case RGBA_8888: | 608 case RGBA_8888: |
607 return 32; | 609 return 32; |
608 case RGBA_4444: | 610 case RGBA_4444: |
609 case RGB_565: | 611 case RGB_565: |
610 return 16; | 612 return 16; |
611 case ALPHA_8: | 613 case ALPHA_8: |
612 case LUMINANCE_8: | 614 case LUMINANCE_8: |
| 615 case RED_8: |
613 return 8; | 616 return 8; |
614 case ETC1: | 617 case ETC1: |
615 return 4; | 618 return 4; |
616 } | 619 } |
617 NOTREACHED(); | 620 NOTREACHED(); |
618 return 0; | 621 return 0; |
619 } | 622 } |
620 | 623 |
621 inline GLenum GLDataType(ResourceFormat format) { | 624 inline GLenum GLDataType(ResourceFormat format) { |
622 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 625 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
623 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { | 626 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { |
624 GL_UNSIGNED_BYTE, // RGBA_8888 | 627 GL_UNSIGNED_BYTE, // RGBA_8888 |
625 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 | 628 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 |
626 GL_UNSIGNED_BYTE, // BGRA_8888 | 629 GL_UNSIGNED_BYTE, // BGRA_8888 |
627 GL_UNSIGNED_BYTE, // ALPHA_8 | 630 GL_UNSIGNED_BYTE, // ALPHA_8 |
628 GL_UNSIGNED_BYTE, // LUMINANCE_8 | 631 GL_UNSIGNED_BYTE, // LUMINANCE_8 |
629 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, | 632 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, |
630 GL_UNSIGNED_BYTE // ETC1 | 633 GL_UNSIGNED_BYTE, // ETC1 |
| 634 GL_UNSIGNED_BYTE // RED_8 |
631 }; | 635 }; |
632 return format_gl_data_type[format]; | 636 return format_gl_data_type[format]; |
633 } | 637 } |
634 | 638 |
635 inline GLenum GLDataFormat(ResourceFormat format) { | 639 inline GLenum GLDataFormat(ResourceFormat format) { |
636 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 640 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
637 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { | 641 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { |
638 GL_RGBA, // RGBA_8888 | 642 GL_RGBA, // RGBA_8888 |
639 GL_RGBA, // RGBA_4444 | 643 GL_RGBA, // RGBA_4444 |
640 GL_BGRA_EXT, // BGRA_8888 | 644 GL_BGRA_EXT, // BGRA_8888 |
641 GL_ALPHA, // ALPHA_8 | 645 GL_ALPHA, // ALPHA_8 |
642 GL_LUMINANCE, // LUMINANCE_8 | 646 GL_LUMINANCE, // LUMINANCE_8 |
643 GL_RGB, // RGB_565 | 647 GL_RGB, // RGB_565 |
644 GL_ETC1_RGB8_OES // ETC1 | 648 GL_ETC1_RGB8_OES, // ETC1 |
| 649 GL_RED_EXT // RED_8 |
645 }; | 650 }; |
646 return format_gl_data_format[format]; | 651 return format_gl_data_format[format]; |
647 } | 652 } |
648 | 653 |
649 inline GLenum GLInternalFormat(ResourceFormat format) { | 654 inline GLenum GLInternalFormat(ResourceFormat format) { |
650 return GLDataFormat(format); | 655 return GLDataFormat(format); |
651 } | 656 } |
652 | 657 |
653 } // namespace cc | 658 } // namespace cc |
654 | 659 |
655 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 660 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |