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

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

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments, added test, dcheck for compressed texture availability Created 7 years, 2 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 | Annotate | Revision Log
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 int highp_threshold_min_; 465 int highp_threshold_min_;
466 ResourceId next_id_; 466 ResourceId next_id_;
467 ResourceMap resources_; 467 ResourceMap resources_;
468 int next_child_; 468 int next_child_;
469 ChildMap children_; 469 ChildMap children_;
470 470
471 ResourceType default_resource_type_; 471 ResourceType default_resource_type_;
472 bool use_texture_storage_ext_; 472 bool use_texture_storage_ext_;
473 bool use_texture_usage_hint_; 473 bool use_texture_usage_hint_;
474 bool use_shallow_flush_; 474 bool use_shallow_flush_;
475 bool use_compressed_texture_etc1_;
475 scoped_ptr<TextureUploader> texture_uploader_; 476 scoped_ptr<TextureUploader> texture_uploader_;
476 int max_texture_size_; 477 int max_texture_size_;
477 ResourceFormat best_texture_format_; 478 ResourceFormat best_texture_format_;
478 479
479 base::ThreadChecker thread_checker_; 480 base::ThreadChecker thread_checker_;
480 481
481 scoped_refptr<Fence> current_read_lock_fence_; 482 scoped_refptr<Fence> current_read_lock_fence_;
482 bool use_rgba_4444_texture_format_; 483 bool use_rgba_4444_texture_format_;
483 484
484 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 485 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
485 }; 486 };
486 487
487 488
488 // TODO(epenner): Move these format conversions to resource_format.h 489 // TODO(epenner): Move these format conversions to resource_format.h
489 // once that builds on mac (npapi.h currently #includes OpenGL.h). 490 // once that builds on mac (npapi.h currently #includes OpenGL.h).
490 inline unsigned BytesPerPixel(ResourceFormat format) { 491 inline unsigned BitsPerPixel(ResourceFormat format) {
491 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 492 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
492 static const unsigned format_bytes_per_pixel[RESOURCE_FORMAT_MAX + 1] = { 493 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = {
493 4, // RGBA_8888 494 32, // RGBA_8888
494 2, // RGBA_4444 495 16, // RGBA_4444
495 4, // BGRA_8888 496 32, // BGRA_8888
496 1, // LUMINANCE_8 497 8, // LUMINANCE_8
497 2 // RGB_565 498 16, // RGB_565,
499 4 // ETC1
498 }; 500 };
499 return format_bytes_per_pixel[format]; 501 return format_bits_per_pixel[format];
500 } 502 }
501 503
502 inline GLenum GLDataType(ResourceFormat format) { 504 inline GLenum GLDataType(ResourceFormat format) {
503 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 505 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
504 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { 506 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = {
505 GL_UNSIGNED_BYTE, // RGBA_8888 507 GL_UNSIGNED_BYTE, // RGBA_8888
506 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 508 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444
507 GL_UNSIGNED_BYTE, // BGRA_8888 509 GL_UNSIGNED_BYTE, // BGRA_8888
508 GL_UNSIGNED_BYTE, // LUMINANCE_8 510 GL_UNSIGNED_BYTE, // LUMINANCE_8
509 GL_UNSIGNED_SHORT_5_6_5 // RGB_565 511 GL_UNSIGNED_SHORT_5_6_5, // RGB_565,
512 GL_UNSIGNED_BYTE // ETC1
510 }; 513 };
511 return format_gl_data_type[format]; 514 return format_gl_data_type[format];
512 } 515 }
513 516
514 inline GLenum GLDataFormat(ResourceFormat format) { 517 inline GLenum GLDataFormat(ResourceFormat format) {
515 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 518 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
516 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { 519 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = {
517 GL_RGBA, // RGBA_8888 520 GL_RGBA, // RGBA_8888
518 GL_RGBA, // RGBA_4444 521 GL_RGBA, // RGBA_4444
519 GL_BGRA_EXT, // BGRA_8888 522 GL_BGRA_EXT, // BGRA_8888
520 GL_LUMINANCE, // LUMINANCE_8 523 GL_LUMINANCE, // LUMINANCE_8
521 GL_RGB // RGB_565 524 GL_RGB, // RGB_565
525 GL_ETC1_RGB8_OES // ETC1
522 }; 526 };
523 return format_gl_data_format[format]; 527 return format_gl_data_format[format];
524 } 528 }
525 529
526 inline GLenum GLInternalFormat(ResourceFormat format) { 530 inline GLenum GLInternalFormat(ResourceFormat format) {
527 return GLDataFormat(format); 531 return GLDataFormat(format);
528 } 532 }
529 533
530 } // namespace cc 534 } // namespace cc
531 535
532 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 536 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698