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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 793693003: Tile Compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // This file is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #include <sstream> 8 #include <sstream>
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 *ret_padded_row_size = row_size; 461 *ret_padded_row_size = row_size;
462 } 462 }
463 } 463 }
464 if (ret_unpadded_row_size) { 464 if (ret_unpadded_row_size) {
465 *ret_unpadded_row_size = row_size; 465 *ret_unpadded_row_size = row_size;
466 } 466 }
467 467
468 return true; 468 return true;
469 } 469 }
470 470
471 namespace {
472
473 const int kS3TCBlockWidth = 4;
474 const int kS3TCBlockHeight = 4;
475 const int kS3TCDXT1BlockSize = 8;
476 const int kS3TCDXT3AndDXT5BlockSize = 16;
477 const int kETC1BlockWidth = 4;
478 const int kETC1BlockHeight = 4;
479 const int kETC1BlockSize = 8;
480
481 bool IsValidDXTSize(GLint level, GLsizei size) {
482 return (size == 1) || (size == 2) || !(size % kS3TCBlockWidth);
483 }
484
485 } // anonymous namespace.
486
487 bool GLES2Util::ComputeCompressedImageSize(int width,
488 int height,
489 int format,
490 int* ret_size) {
491 switch (format) {
492 case GL_ATC_RGB_AMD:
493 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
494 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: {
495 int num_blocks_across = (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth;
496 int num_blocks_down = (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight;
497 int num_blocks = num_blocks_across * num_blocks_down;
498 *ret_size = num_blocks * kS3TCDXT1BlockSize;
499 return true;
500 }
501 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
502 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
503 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: {
504 int num_blocks_across = (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth;
505 int num_blocks_down = (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight;
506 int num_blocks = num_blocks_across * num_blocks_down;
507 *ret_size = num_blocks * kS3TCDXT3AndDXT5BlockSize;
508 return true;
509 }
510 case GL_ETC1_RGB8_OES: {
511 int num_blocks_across = (width + kETC1BlockWidth - 1) / kETC1BlockWidth;
512 int num_blocks_down = (height + kETC1BlockHeight - 1) / kETC1BlockHeight;
513 int num_blocks = num_blocks_across * num_blocks_down;
514 *ret_size = num_blocks * kETC1BlockSize;
515 return true;
516 }
517 }
518
519 return false;
520 }
521
522 bool GLES2Util::IsValidCompressedImageSize(int level,
523 int width,
524 int height,
525 int format) {
526 switch (format) {
527 case GL_ATC_RGB_AMD:
528 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
529 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
530 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
531 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
532 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
533 return IsValidDXTSize(level, width) && IsValidDXTSize(level, height);
534 case GL_ETC1_RGB8_OES:
535 return width > 0 && height > 0;
536 default:
537 return false;
538 }
539 }
540
471 size_t GLES2Util::RenderbufferBytesPerPixel(int format) { 541 size_t GLES2Util::RenderbufferBytesPerPixel(int format) {
472 switch (format) { 542 switch (format) {
473 case GL_STENCIL_INDEX8: 543 case GL_STENCIL_INDEX8:
474 return 1; 544 return 1;
475 case GL_RGBA4: 545 case GL_RGBA4:
476 case GL_RGB565: 546 case GL_RGB565:
477 case GL_RGB5_A1: 547 case GL_RGB5_A1:
478 case GL_DEPTH_COMPONENT16: 548 case GL_DEPTH_COMPONENT16:
479 return 2; 549 return 2;
480 case GL_RGB: 550 case GL_RGB:
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 1023 }
954 1024
955 return true; 1025 return true;
956 } 1026 }
957 1027
958 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" 1028 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h"
959 1029
960 } // namespace gles2 1030 } // namespace gles2
961 } // namespace gpu 1031 } // namespace gpu
962 1032
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | gpu/command_buffer/service/async_pixel_transfer_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698