diff options
author | zmo <zmo@chromium.org> | 2015-12-09 15:13:15 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 23:14:02 +0000 |
commit | fc27654db19f5495a9ad541ee27cf68a804fc632 (patch) | |
tree | a61b4804222bb92dcd2efad2def9a7edbff1f9a0 /gpu/command_buffer/common/gles2_cmd_utils.h | |
parent | ac8224c8a42e794b9c496f7e718a4fc4764e3c9e (diff) | |
download | chromium_src-fc27654db19f5495a9ad541ee27cf68a804fc632.zip chromium_src-fc27654db19f5495a9ad541ee27cf68a804fc632.tar.gz chromium_src-fc27654db19f5495a9ad541ee27cf68a804fc632.tar.bz2 |
Reland: Implement helper functionalities for computing image size with ES3 settings.
This will be used in ReadPixels, Tex{Sub}Image* in followup CLs.
Original reviewed CL is https://codereview.chromium.org/1508953002/
BUG=429053,563714
TEST=gpu_unittests
TBR=piman@chromium.org
Review URL: https://codereview.chromium.org/1513013002
Cr-Commit-Position: refs/heads/master@{#364200}
Diffstat (limited to 'gpu/command_buffer/common/gles2_cmd_utils.h')
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils.h | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index 3aa0299..e3b82b8 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -52,6 +52,24 @@ inline bool SafeAddInt32(int32_t a, int32_t b, int32_t* dst) { return checked.IsValid(); } +struct GLES2_UTILS_EXPORT PixelStoreParams { + PixelStoreParams() + : alignment(4), + row_length(0), + image_height(0), + skip_pixels(0), + skip_rows(0), + skip_images(0) { + } + + int32_t alignment; + int32_t row_length; + int32_t image_height; + int32_t skip_pixels; + int32_t skip_rows; + int32_t skip_images; +}; + // Utilties for GLES2 support. class GLES2_UTILS_EXPORT GLES2Util { public: @@ -105,17 +123,26 @@ class GLES2_UTILS_EXPORT GLES2Util { // Computes the size of an image row including alignment padding static bool ComputeImagePaddedRowSize( - int width, int format, int type, int unpack_alignment, + int width, int format, int type, int alignment, uint32_t* padded_row_size); // Computes the size of image data for TexImage2D and TexSubImage2D. - // Optionally the unpadded and padded row sizes can be returned. If height < 2 - // then the padded_row_size will be the same as the unpadded_row_size since - // padding is not necessary. + // Optionally the unpadded and padded row sizes can be returned. static bool ComputeImageDataSizes( int width, int height, int depth, int format, int type, - int unpack_alignment, uint32_t* size, uint32_t* unpadded_row_size, - uint32_t* padded_row_size); + int alignment, uint32_t* size, uint32_t* opt_unpadded_row_size, + uint32_t* opt_padded_row_size); + + // Similar to the above function, but taking into consideration all ES3 + // pixel pack/unpack parameters. + // Optionally the skipped bytes in the beginning can be returned. + // Note the returned |size| does NOT include |skip_size|. + // TODO(zmo): merging ComputeImageDataSize and ComputeImageDataSizeES3. + static bool ComputeImageDataSizesES3( + int width, int height, int depth, int format, int type, + const PixelStoreParams& params, + uint32_t* size, uint32_t* opt_unpadded_row_size, + uint32_t* opt_padded_row_size, uint32_t* opt_skip_size); static size_t RenderbufferBytesPerPixel(int format); @@ -192,6 +219,10 @@ class GLES2_UTILS_EXPORT GLES2Util { static std::string GetQualifiedEnumString( const EnumToString* table, size_t count, uint32_t value); + static bool ComputeImageRowSizeHelper( + int width, uint32 bytes_per_group, int alignment, + uint32* rt_unpadded_row_size, uint32* rt_padded_row_size); + static const EnumToString* const enum_to_string_table_; static const size_t enum_to_string_table_len_; |