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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 scoped_ptr<IdAllocator> buffer_id_allocator_; | 600 scoped_ptr<IdAllocator> buffer_id_allocator_; |
601 | 601 |
602 bool use_sync_query_; | 602 bool use_sync_query_; |
603 bool use_persistent_map_for_gpu_memory_buffers_; | 603 bool use_persistent_map_for_gpu_memory_buffers_; |
604 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. | 604 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. |
605 scoped_refptr<SynchronousFence> synchronous_fence_; | 605 scoped_refptr<SynchronousFence> synchronous_fence_; |
606 | 606 |
607 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 607 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
608 }; | 608 }; |
609 | 609 |
610 // TODO(epenner): Move these format conversions to resource_format.h | |
611 // once that builds on mac (npapi.h currently #includes OpenGL.h). | |
612 inline int BitsPerPixel(ResourceFormat format) { | |
613 switch (format) { | |
614 case BGRA_8888: | |
615 case RGBA_8888: | |
616 return 32; | |
617 case RGBA_4444: | |
618 case RGB_565: | |
619 return 16; | |
620 case ALPHA_8: | |
621 case LUMINANCE_8: | |
622 case RED_8: | |
623 return 8; | |
624 case ETC1: | |
625 return 4; | |
626 } | |
627 NOTREACHED(); | |
628 return 0; | |
629 } | |
630 | |
631 inline GLenum GLDataType(ResourceFormat format) { | |
632 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | |
633 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { | |
634 GL_UNSIGNED_BYTE, // RGBA_8888 | |
635 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 | |
636 GL_UNSIGNED_BYTE, // BGRA_8888 | |
637 GL_UNSIGNED_BYTE, // ALPHA_8 | |
638 GL_UNSIGNED_BYTE, // LUMINANCE_8 | |
639 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, | |
640 GL_UNSIGNED_BYTE, // ETC1 | |
641 GL_UNSIGNED_BYTE // RED_8 | |
642 }; | |
643 return format_gl_data_type[format]; | |
644 } | |
645 | |
646 inline GLenum GLDataFormat(ResourceFormat format) { | |
647 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | |
648 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { | |
649 GL_RGBA, // RGBA_8888 | |
650 GL_RGBA, // RGBA_4444 | |
651 GL_BGRA_EXT, // BGRA_8888 | |
652 GL_ALPHA, // ALPHA_8 | |
653 GL_LUMINANCE, // LUMINANCE_8 | |
654 GL_RGB, // RGB_565 | |
655 GL_ETC1_RGB8_OES, // ETC1 | |
656 GL_RED_EXT // RED_8 | |
657 }; | |
658 return format_gl_data_format[format]; | |
659 } | |
660 | |
661 inline GLenum GLInternalFormat(ResourceFormat format) { | |
662 return GLDataFormat(format); | |
663 } | |
664 | |
665 } // namespace cc | 610 } // namespace cc |
666 | 611 |
667 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 612 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |