Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: cc/resources/resource_provider.h

Issue 1202843008: cc: Fix BytesPerPixel issue and refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Android build break. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_pool_unittest.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 scoped_ptr<IdAllocator> buffer_id_allocator_; 601 scoped_ptr<IdAllocator> buffer_id_allocator_;
602 602
603 bool use_sync_query_; 603 bool use_sync_query_;
604 bool use_persistent_map_for_gpu_memory_buffers_; 604 bool use_persistent_map_for_gpu_memory_buffers_;
605 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. 605 // Fence used for CopyResource if CHROMIUM_sync_query is not supported.
606 scoped_refptr<SynchronousFence> synchronous_fence_; 606 scoped_refptr<SynchronousFence> synchronous_fence_;
607 607
608 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 608 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
609 }; 609 };
610 610
611 // TODO(epenner): Move these format conversions to resource_format.h
612 // once that builds on mac (npapi.h currently #includes OpenGL.h).
613 inline int BitsPerPixel(ResourceFormat format) {
614 switch (format) {
615 case BGRA_8888:
616 case RGBA_8888:
617 return 32;
618 case RGBA_4444:
619 case RGB_565:
620 return 16;
621 case ALPHA_8:
622 case LUMINANCE_8:
623 case RED_8:
624 return 8;
625 case ETC1:
626 return 4;
627 }
628 NOTREACHED();
629 return 0;
630 }
631
632 inline GLenum GLDataType(ResourceFormat format) {
633 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
634 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = {
635 GL_UNSIGNED_BYTE, // RGBA_8888
636 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444
637 GL_UNSIGNED_BYTE, // BGRA_8888
638 GL_UNSIGNED_BYTE, // ALPHA_8
639 GL_UNSIGNED_BYTE, // LUMINANCE_8
640 GL_UNSIGNED_SHORT_5_6_5, // RGB_565,
641 GL_UNSIGNED_BYTE, // ETC1
642 GL_UNSIGNED_BYTE // RED_8
643 };
644 return format_gl_data_type[format];
645 }
646
647 inline GLenum GLDataFormat(ResourceFormat format) {
648 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
649 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = {
650 GL_RGBA, // RGBA_8888
651 GL_RGBA, // RGBA_4444
652 GL_BGRA_EXT, // BGRA_8888
653 GL_ALPHA, // ALPHA_8
654 GL_LUMINANCE, // LUMINANCE_8
655 GL_RGB, // RGB_565
656 GL_ETC1_RGB8_OES, // ETC1
657 GL_RED_EXT // RED_8
658 };
659 return format_gl_data_format[format];
660 }
661
662 inline GLenum GLInternalFormat(ResourceFormat format) {
663 return GLDataFormat(format);
664 }
665
666 } // namespace cc 611 } // namespace cc
667 612
668 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 613 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/resources/resource_pool_unittest.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698