| OLD | NEW |
| 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 7974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7985 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != | 7985 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != |
| 7986 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || | 7986 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || |
| 7987 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != | 7987 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != |
| 7988 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { | 7988 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { |
| 7989 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7989 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7990 "src and dst formats differ for depth/stencil"); | 7990 "src and dst formats differ for depth/stencil"); |
| 7991 return; | 7991 return; |
| 7992 } | 7992 } |
| 7993 } | 7993 } |
| 7994 | 7994 |
| 7995 if (workarounds().adjust_src_dst_region_for_blitframebuffer) { |
| 7996 gfx::Size read_size = GetBoundReadFramebufferSize(); |
| 7997 gfx::Rect src_bounds(0, 0, read_size.width(), read_size.height()); |
| 7998 GLint src_x = srcX1 > srcX0 ? srcX0 : srcX1; |
| 7999 GLint src_y = srcY1 > srcY0 ? srcY0 : srcY1; |
| 8000 base::CheckedNumeric<GLint> src_width_temp = srcX1; |
| 8001 src_width_temp -= srcX0; |
| 8002 base::CheckedNumeric<GLint> src_height_temp = srcY1; |
| 8003 src_height_temp -= srcY0; |
| 8004 GLuint src_width = 0, src_height = 0; |
| 8005 if (!src_width_temp.IsValid() || !src_height_temp.IsValid()) { |
| 8006 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 8007 "the width or height of src region overflow"); |
| 8008 return; |
| 8009 } |
| 8010 src_width = std::abs(src_width_temp.ValueOrDefault(0)); |
| 8011 src_height = std::abs(src_height_temp.ValueOrDefault(0)); |
| 8012 |
| 8013 gfx::Rect src_region(src_x, src_y, src_width, src_height); |
| 8014 if (!src_bounds.Contains(src_region) && |
| 8015 (src_width != 0) && (src_height != 0)) { |
| 8016 // If pixels lying outside the read framebuffer, adjust src region |
| 8017 // and dst region to appropriate in-bounds regions respectively. |
| 8018 src_bounds.Intersect(src_region); |
| 8019 GLuint src_real_width = src_bounds.width(); |
| 8020 GLuint src_real_height = src_bounds.height(); |
| 8021 GLuint xoffset = src_bounds.x() - src_x; |
| 8022 GLuint yoffset = src_bounds.y() - src_y; |
| 8023 // if X/Y is reversed, use the top/right out-of-bounds region for mapping |
| 8024 // to dst region, instead of left/bottom out-of-bounds region for mapping. |
| 8025 if (((srcX1 > srcX0) && (dstX1 < dstX0)) || |
| 8026 ((srcX1 < srcX0) && (dstX1 > dstX0))) { |
| 8027 xoffset = src_x + src_width - src_bounds.x() - src_bounds.width(); |
| 8028 } |
| 8029 if (((srcY1 > srcY0) && (dstY1 < dstY0)) || |
| 8030 ((srcY1 < srcY0) && (dstY1 > dstY0))) { |
| 8031 yoffset = src_y + src_height - src_bounds.y() - src_bounds.height(); |
| 8032 } |
| 8033 |
| 8034 GLint dst_x = dstX1 > dstX0 ? dstX0 : dstX1; |
| 8035 GLint dst_y = dstY1 > dstY0 ? dstY0 : dstY1; |
| 8036 base::CheckedNumeric<GLint> dst_width_temp = dstX1; |
| 8037 dst_width_temp -= dstX0; |
| 8038 base::CheckedNumeric<GLint> dst_height_temp = dstY1; |
| 8039 dst_height_temp -= dstY0; |
| 8040 GLuint dst_width = 0, dst_height = 0; |
| 8041 if (!dst_width_temp.IsValid() || !dst_height_temp.IsValid()) { |
| 8042 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 8043 "the width or height of dst region overflow"); |
| 8044 return; |
| 8045 } |
| 8046 dst_width = std::abs(dst_width_temp.ValueOrDefault(0)); |
| 8047 dst_height = std::abs(dst_height_temp.ValueOrDefault(0)); |
| 8048 |
| 8049 GLfloat dst_mapping_width = |
| 8050 static_cast<GLfloat>(src_real_width) * dst_width / src_width; |
| 8051 GLfloat dst_mapping_height = |
| 8052 static_cast<GLfloat>(src_real_height) * dst_height / src_height; |
| 8053 GLfloat dst_mapping_xoffset = |
| 8054 static_cast<GLfloat>(xoffset) * dst_width / src_width; |
| 8055 GLfloat dst_mapping_yoffset = |
| 8056 static_cast<GLfloat>(yoffset) * dst_height / src_height; |
| 8057 |
| 8058 GLuint dst_mapping_x0 = |
| 8059 std::round(dst_x + dst_mapping_xoffset); |
| 8060 GLuint dst_mapping_y0 = |
| 8061 std::round(dst_y + dst_mapping_yoffset); |
| 8062 |
| 8063 GLuint dst_mapping_x1 = |
| 8064 std::round(dst_x + dst_mapping_xoffset + dst_mapping_width); |
| 8065 GLuint dst_mapping_y1 = |
| 8066 std::round(dst_y + dst_mapping_yoffset + dst_mapping_height); |
| 8067 |
| 8068 // adjust the src region and dst region to fit the read framebuffer |
| 8069 srcX0 = srcX0 < srcX1 ? |
| 8070 src_bounds.x() : src_bounds.x() + src_bounds.width(); |
| 8071 srcY0 = srcY0 < srcY1 ? |
| 8072 src_bounds.y() : src_bounds.y() + src_bounds.height(); |
| 8073 srcX1 = srcX0 < srcX1 ? |
| 8074 src_bounds.x() + src_bounds.width() : src_bounds.x(); |
| 8075 srcY1 = srcY0 < srcY1 ? |
| 8076 src_bounds.y() + src_bounds.height() : src_bounds.y(); |
| 8077 |
| 8078 dstX0 = dstX0 < dstX1 ? dst_mapping_x0 : dst_mapping_x1; |
| 8079 dstY0 = dstY0 < dstY1 ? dst_mapping_y0 : dst_mapping_y1; |
| 8080 dstX1 = dstX0 < dstX1 ? dst_mapping_x1 : dst_mapping_x0; |
| 8081 dstY1 = dstY0 < dstY1 ? dst_mapping_y1 : dst_mapping_y0; |
| 8082 } |
| 8083 } |
| 8084 |
| 7995 bool enable_srgb = | 8085 bool enable_srgb = |
| 7996 (read_buffer_has_srgb || draw_buffers_has_srgb) && | 8086 (read_buffer_has_srgb || draw_buffers_has_srgb) && |
| 7997 ((mask & GL_COLOR_BUFFER_BIT) != 0); | 8087 ((mask & GL_COLOR_BUFFER_BIT) != 0); |
| 7998 bool encode_srgb_only = | 8088 bool encode_srgb_only = |
| 7999 (draw_buffers_has_srgb && !read_buffer_has_srgb) && | 8089 (draw_buffers_has_srgb && !read_buffer_has_srgb) && |
| 8000 ((mask & GL_COLOR_BUFFER_BIT) != 0); | 8090 ((mask & GL_COLOR_BUFFER_BIT) != 0); |
| 8001 if (!enable_srgb || | 8091 if (!enable_srgb || |
| 8002 read_buffer_samples > 0 || | 8092 read_buffer_samples > 0 || |
| 8003 !feature_info_->feature_flags().desktop_srgb_support || | 8093 !feature_info_->feature_flags().desktop_srgb_support || |
| 8004 gl_version_info().IsAtLeastGL(4, 4) || | 8094 gl_version_info().IsAtLeastGL(4, 4) || |
| (...skipping 10512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18517 } | 18607 } |
| 18518 | 18608 |
| 18519 // Include the auto-generated part of this file. We split this because it means | 18609 // Include the auto-generated part of this file. We split this because it means |
| 18520 // we can easily edit the non-auto generated parts right here in this file | 18610 // we can easily edit the non-auto generated parts right here in this file |
| 18521 // instead of having to edit some template or the code generator. | 18611 // instead of having to edit some template or the code generator. |
| 18522 #include "base/macros.h" | 18612 #include "base/macros.h" |
| 18523 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18613 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18524 | 18614 |
| 18525 } // namespace gles2 | 18615 } // namespace gles2 |
| 18526 } // namespace gpu | 18616 } // namespace gpu |
| OLD | NEW |