| 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). |
| 500 inline unsigned BytesPerPixel(ResourceFormat format) { | 501 inline unsigned BitsPerPixel(ResourceFormat format) { |
| 501 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 502 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 502 static const unsigned format_bytes_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 503 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
| 503 4, // RGBA_8888 | 504 32, // RGBA_8888 |
| 504 2, // RGBA_4444 | 505 16, // RGBA_4444 |
| 505 4, // BGRA_8888 | 506 32, // BGRA_8888 |
| 506 1, // LUMINANCE_8 | 507 8, // LUMINANCE_8 |
| 507 2 // RGB_565 | 508 16, // RGB_565, |
| 509 4 // ETC1 |
| 508 }; | 510 }; |
| 509 return format_bytes_per_pixel[format]; | 511 return format_bits_per_pixel[format]; |
| 510 } | 512 } |
| 511 | 513 |
| 512 inline GLenum GLDataType(ResourceFormat format) { | 514 inline GLenum GLDataType(ResourceFormat format) { |
| 513 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 515 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 514 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { | 516 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { |
| 515 GL_UNSIGNED_BYTE, // RGBA_8888 | 517 GL_UNSIGNED_BYTE, // RGBA_8888 |
| 516 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 | 518 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 |
| 517 GL_UNSIGNED_BYTE, // BGRA_8888 | 519 GL_UNSIGNED_BYTE, // BGRA_8888 |
| 518 GL_UNSIGNED_BYTE, // LUMINANCE_8 | 520 GL_UNSIGNED_BYTE, // LUMINANCE_8 |
| 519 GL_UNSIGNED_SHORT_5_6_5 // RGB_565 | 521 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, |
| 522 GL_UNSIGNED_BYTE // ETC1 |
| 520 }; | 523 }; |
| 521 return format_gl_data_type[format]; | 524 return format_gl_data_type[format]; |
| 522 } | 525 } |
| 523 | 526 |
| 524 inline GLenum GLDataFormat(ResourceFormat format) { | 527 inline GLenum GLDataFormat(ResourceFormat format) { |
| 525 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 528 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 526 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { | 529 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { |
| 527 GL_RGBA, // RGBA_8888 | 530 GL_RGBA, // RGBA_8888 |
| 528 GL_RGBA, // RGBA_4444 | 531 GL_RGBA, // RGBA_4444 |
| 529 GL_BGRA_EXT, // BGRA_8888 | 532 GL_BGRA_EXT, // BGRA_8888 |
| 530 GL_LUMINANCE, // LUMINANCE_8 | 533 GL_LUMINANCE, // LUMINANCE_8 |
| 531 GL_RGB // RGB_565 | 534 GL_RGB, // RGB_565 |
| 535 GL_ETC1_RGB8_OES // ETC1 |
| 532 }; | 536 }; |
| 533 return format_gl_data_format[format]; | 537 return format_gl_data_format[format]; |
| 534 } | 538 } |
| 535 | 539 |
| 536 inline GLenum GLInternalFormat(ResourceFormat format) { | 540 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 537 return GLDataFormat(format); | 541 return GLDataFormat(format); |
| 538 } | 542 } |
| 539 | 543 |
| 540 } // namespace cc | 544 } // namespace cc |
| 541 | 545 |
| 542 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 546 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |