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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 | 481 |
| 482 scoped_refptr<Fence> current_read_lock_fence_; | 482 scoped_refptr<Fence> current_read_lock_fence_; |
| 483 bool use_rgba_4444_texture_format_; | 483 bool use_rgba_4444_texture_format_; |
| 484 | 484 |
| 485 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 485 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 486 }; | 486 }; |
| 487 | 487 |
| 488 | 488 |
| 489 // TODO(epenner): Move these format conversions to resource_format.h | 489 // TODO(epenner): Move these format conversions to resource_format.h |
| 490 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 490 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
| 491 inline unsigned BytesPerPixel(ResourceFormat format) { | 491 inline unsigned BytesPerPixel(ResourceFormat format) { |
|
aelias_OOO_until_Jul13
2013/10/18 01:59:24
Please rename this method to BitsPerPixel and mult
powei
2013/10/23 05:36:15
Done.
| |
| 492 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 492 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 493 static const unsigned format_bytes_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 493 static const unsigned format_bytes_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
| 494 0, // ETC1 | |
| 494 4, // RGBA_8888 | 495 4, // RGBA_8888 |
| 495 2, // RGBA_4444 | 496 2, // RGBA_4444 |
| 496 4, // BGRA_8888 | 497 4, // BGRA_8888 |
| 497 1, // LUMINANCE_8 | 498 1, // LUMINANCE_8 |
| 498 2 // RGB_565 | 499 2 // RGB_565 |
| 499 }; | 500 }; |
| 500 return format_bytes_per_pixel[format]; | 501 return format_bytes_per_pixel[format]; |
| 501 } | 502 } |
| 502 | 503 |
| 503 inline GLenum GLDataType(ResourceFormat format) { | 504 inline GLenum GLDataType(ResourceFormat format) { |
| 504 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 505 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 505 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { | 506 static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { |
| 507 GL_UNSIGNED_BYTE, // ETC1 | |
| 506 GL_UNSIGNED_BYTE, // RGBA_8888 | 508 GL_UNSIGNED_BYTE, // RGBA_8888 |
| 507 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 | 509 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 |
| 508 GL_UNSIGNED_BYTE, // BGRA_8888 | 510 GL_UNSIGNED_BYTE, // BGRA_8888 |
| 509 GL_UNSIGNED_BYTE, // LUMINANCE_8 | 511 GL_UNSIGNED_BYTE, // LUMINANCE_8 |
| 510 GL_UNSIGNED_SHORT_5_6_5 // RGB_565 | 512 GL_UNSIGNED_SHORT_5_6_5 // RGB_565 |
| 511 }; | 513 }; |
| 512 return format_gl_data_type[format]; | 514 return format_gl_data_type[format]; |
| 513 } | 515 } |
| 514 | 516 |
| 515 inline GLenum GLDataFormat(ResourceFormat format) { | 517 inline GLenum GLDataFormat(ResourceFormat format) { |
| 516 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 518 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 517 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { | 519 static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { |
| 518 GL_RGBA, // RGBA_8888 | 520 GL_ETC1_RGB8_OES, // ETC1 |
|
kaanb
2013/10/18 16:54:49
Is this a GL data format or a GL internal format?
powei
2013/10/23 05:36:15
If I'm reading the spec correctly. We're suppose
| |
| 519 GL_RGBA, // RGBA_4444 | 521 GL_RGBA, // RGBA_8888 |
| 520 GL_BGRA_EXT, // BGRA_8888 | 522 GL_RGBA, // RGBA_4444 |
| 521 GL_LUMINANCE, // LUMINANCE_8 | 523 GL_BGRA_EXT, // BGRA_8888 |
| 522 GL_RGB // RGB_565 | 524 GL_LUMINANCE, // LUMINANCE_8 |
| 525 GL_RGB // RGB_565 | |
| 523 }; | 526 }; |
| 524 return format_gl_data_format[format]; | 527 return format_gl_data_format[format]; |
| 525 } | 528 } |
| 526 | 529 |
| 527 inline GLenum GLInternalFormat(ResourceFormat format) { | 530 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 528 return GLDataFormat(format); | 531 return GLDataFormat(format); |
| 529 } | 532 } |
| 530 | 533 |
| 531 } // namespace cc | 534 } // namespace cc |
| 532 | 535 |
| 533 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 536 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |