Chromium Code Reviews| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 int highp_threshold_min_; | 475 int highp_threshold_min_; |
| 476 ResourceId next_id_; | 476 ResourceId next_id_; |
| 477 ResourceMap resources_; | 477 ResourceMap resources_; |
| 478 int next_child_; | 478 int next_child_; |
| 479 ChildMap children_; | 479 ChildMap children_; |
| 480 | 480 |
| 481 ResourceType default_resource_type_; | 481 ResourceType default_resource_type_; |
| 482 bool use_texture_storage_ext_; | 482 bool use_texture_storage_ext_; |
| 483 bool use_texture_usage_hint_; | 483 bool use_texture_usage_hint_; |
| 484 bool use_shallow_flush_; | 484 bool use_shallow_flush_; |
| 485 bool use_compressed_texture_etc1_; | |
| 485 scoped_ptr<TextureUploader> texture_uploader_; | 486 scoped_ptr<TextureUploader> texture_uploader_; |
| 486 int max_texture_size_; | 487 int max_texture_size_; |
| 487 ResourceFormat best_texture_format_; | 488 ResourceFormat best_texture_format_; |
| 488 | 489 |
| 489 base::ThreadChecker thread_checker_; | 490 base::ThreadChecker thread_checker_; |
| 490 | 491 |
| 491 scoped_refptr<Fence> current_read_lock_fence_; | 492 scoped_refptr<Fence> current_read_lock_fence_; |
| 492 bool use_rgba_4444_texture_format_; | 493 bool use_rgba_4444_texture_format_; |
| 493 | 494 |
| 494 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 495 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 495 }; | 496 }; |
| 496 | 497 |
| 497 | 498 |
| 498 // TODO(epenner): Move these format conversions to resource_format.h | 499 // TODO(epenner): Move these format conversions to resource_format.h |
| 499 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 500 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
| 501 inline unsigned BitsPerPixel(ResourceFormat format) { | |
| 502 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | |
| 503 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | |
| 504 32, // RGBA_8888 | |
| 505 16, // RGBA_4444 | |
| 506 32, // BGRA_8888 | |
| 507 8, // LUMINANCE_8 | |
| 508 16, // RGB_565, | |
| 509 4 // ETC1 | |
| 510 }; | |
| 511 return format_bits_per_pixel[format]; | |
| 512 } | |
| 513 | |
| 500 inline unsigned BytesPerPixel(ResourceFormat format) { | 514 inline unsigned BytesPerPixel(ResourceFormat format) { |
| 501 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 515 DCHECK_EQ(0u, BitsPerPixel(format) % 8); |
|
kaanb
2013/10/23 22:25:25
wouldn't this be false for ETC1?
aelias_OOO_until_Jul13
2013/10/23 22:29:13
Yes, I suggest deleting this method instead of ass
kaanb
2013/10/23 22:34:51
sgtm
powei
2013/10/23 23:25:58
Done.
| |
| 502 static const unsigned format_bytes_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 516 return BitsPerPixel(format) / 8; |
| 503 4, // RGBA_8888 | |
| 504 2, // RGBA_4444 | |
| 505 4, // BGRA_8888 | |
| 506 1, // LUMINANCE_8 | |
| 507 2 // RGB_565 | |
| 508 }; | |
| 509 return format_bytes_per_pixel[format]; | |
| 510 } | 517 } |
| 511 | 518 |
| 512 inline GLenum GLDataType(ResourceFormat format) { | 519 inline GLenum GLDataType(ResourceFormat format) { |
| 513 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 520 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 514 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { | 521 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { |
| 515 GL_UNSIGNED_BYTE, // RGBA_8888 | 522 GL_UNSIGNED_BYTE, // RGBA_8888 |
| 516 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 | 523 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 |
| 517 GL_UNSIGNED_BYTE, // BGRA_8888 | 524 GL_UNSIGNED_BYTE, // BGRA_8888 |
| 518 GL_UNSIGNED_BYTE, // LUMINANCE_8 | 525 GL_UNSIGNED_BYTE, // LUMINANCE_8 |
| 519 GL_UNSIGNED_SHORT_5_6_5 // RGB_565 | 526 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, |
| 527 GL_UNSIGNED_BYTE // ETC1 | |
| 520 }; | 528 }; |
| 521 return format_gl_data_type[format]; | 529 return format_gl_data_type[format]; |
| 522 } | 530 } |
| 523 | 531 |
| 524 inline GLenum GLDataFormat(ResourceFormat format) { | 532 inline GLenum GLDataFormat(ResourceFormat format) { |
| 525 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 533 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 526 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { | 534 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { |
| 527 GL_RGBA, // RGBA_8888 | 535 GL_RGBA, // RGBA_8888 |
| 528 GL_RGBA, // RGBA_4444 | 536 GL_RGBA, // RGBA_4444 |
| 529 GL_BGRA_EXT, // BGRA_8888 | 537 GL_BGRA_EXT, // BGRA_8888 |
| 530 GL_LUMINANCE, // LUMINANCE_8 | 538 GL_LUMINANCE, // LUMINANCE_8 |
| 531 GL_RGB // RGB_565 | 539 GL_RGB, // RGB_565 |
| 540 GL_ETC1_RGB8_OES // ETC1 | |
| 532 }; | 541 }; |
| 533 return format_gl_data_format[format]; | 542 return format_gl_data_format[format]; |
| 534 } | 543 } |
| 535 | 544 |
| 536 inline GLenum GLInternalFormat(ResourceFormat format) { | 545 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 537 return GLDataFormat(format); | 546 return GLDataFormat(format); |
| 538 } | 547 } |
| 539 | 548 |
| 540 } // namespace cc | 549 } // namespace cc |
| 541 | 550 |
| 542 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 551 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |