Chromium Code Reviews| 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 7972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7983 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != | 7983 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != |
| 7984 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || | 7984 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || |
| 7985 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != | 7985 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != |
| 7986 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { | 7986 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { |
| 7987 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7987 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7988 "src and dst formats differ for depth/stencil"); | 7988 "src and dst formats differ for depth/stencil"); |
| 7989 return; | 7989 return; |
| 7990 } | 7990 } |
| 7991 } | 7991 } |
| 7992 | 7992 |
| 7993 if (workarounds().adjust_src_dst_region_for_blitframebuffer) { | |
| 7994 gfx::Size read_size = GetBoundReadFramebufferSize(); | |
| 7995 gfx::Rect rect(0, 0, read_size.width(), read_size.height()); | |
|
Corentin Wallez
2016/10/14 14:42:42
rect isn't a very descriptive name, use "source_bo
yunchao
2016/10/15 14:34:58
That's true. I have updated the name accordingly.
| |
| 7996 GLuint src_x = srcX1 > srcX0 ? srcX0 : srcX1; | |
| 7997 GLuint src_y = srcY1 > srcY0 ? srcY0 : srcY1; | |
| 7998 base::CheckedNumeric<GLuint> src_width_temp = | |
| 7999 srcX1 > srcX0 ? srcX1 - srcX0 : srcX0 - srcX1; | |
|
Zhenyao Mo
2016/10/14 17:54:15
I am not sure if this will catch the overlow or no
yunchao
2016/10/15 14:34:57
Yes, you are correct, Zhenyao. The overflow happen
| |
| 8000 base::CheckedNumeric<GLuint> src_height_temp = | |
| 8001 srcY1 > srcY0 ? srcY1 - srcY0 : srcY0 - srcY1; | |
| 8002 GLuint src_width = src_width_temp.ValueOrDie(); | |
|
Corentin Wallez
2016/10/14 14:42:42
ValueOrDie just returns the value and does a runti
Zhenyao Mo
2016/10/14 17:54:15
We don't really have an error case defined if widt
Zhenyao Mo
2016/10/14 21:10:32
Per working group discussion, we are going to gene
yunchao
2016/10/15 14:34:57
Done.
yunchao
2016/10/15 14:34:58
Done.
| |
| 8003 GLuint src_height = src_height_temp.ValueOrDie(); | |
| 8004 gfx::Rect src_region(src_x, src_y, src_width, src_height); | |
| 8005 if (!rect.Contains(src_region) && (src_width != 0) && (src_height != 0)) { | |
| 8006 // If pixels lying outside the read framebuffer, adjust src region | |
| 8007 // and dst region to appropriate in-bounds regions respectively. | |
| 8008 rect.Intersect(gfx::Rect(src_x, src_y, src_width, src_height)); | |
|
Corentin Wallez
2016/10/14 14:42:42
rect.Intersect(src_region)
yunchao
2016/10/15 14:34:57
Yeah... Will update the code here.
| |
| 8009 GLuint src_real_width = rect.width(); | |
| 8010 GLuint src_real_height = rect.height(); | |
| 8011 base::CheckedNumeric<GLuint> xoffset_temp = rect.x() - src_x; | |
| 8012 base::CheckedNumeric<GLuint> yoffset_temp = rect.y() - src_y; | |
| 8013 // if X/Y is reversed, use the top/right out-of-bounds region for mapping | |
| 8014 // to dst region, instead of left/bottom out-of-bounds region for mapping. | |
| 8015 if (((srcX1 > srcX0) && (dstX1 < dstX0)) || | |
| 8016 ((srcX1 < srcX0) && (dstX1 > dstX0))) { | |
| 8017 xoffset_temp = src_x + src_width - rect.x() - rect.width(); | |
| 8018 } | |
| 8019 if (((srcY1 > srcY0) && (dstY1 < dstY0)) || | |
| 8020 ((srcY1 < srcY0) && (dstY1 > dstY0))) { | |
| 8021 yoffset_temp = src_y + src_height - rect.y() - rect.height(); | |
| 8022 } | |
| 8023 GLuint xoffset = xoffset_temp.ValueOrDie(); | |
|
Corentin Wallez
2016/10/14 14:42:42
Same as above for the CheckedNumerics
yunchao
2016/10/15 14:34:58
Done
| |
| 8024 GLuint yoffset = yoffset_temp.ValueOrDie(); | |
| 8025 | |
| 8026 GLuint dst_x = dstX1 > dstX0 ? dstX0 : dstX1; | |
| 8027 GLuint dst_y = dstY1 > dstY0 ? dstY0 : dstY1; | |
| 8028 GLuint dst_width = dstX1 > dstX0 ? dstX1 - dstX0 : dstX0 - dstX1; | |
| 8029 GLuint dst_height = dstY1 > dstY0 ? dstY1 - dstY0 : dstY0 - dstY1; | |
| 8030 GLfloat dst_mapping_width = | |
| 8031 static_cast<GLfloat>(src_real_width) * dst_width / src_width; | |
| 8032 GLfloat dst_mapping_height = | |
| 8033 static_cast<GLfloat>(src_real_height) * dst_height / src_height; | |
| 8034 GLfloat dst_mapping_xoffset = | |
| 8035 static_cast<GLfloat>(xoffset) * dst_width / src_width; | |
| 8036 GLfloat dst_mapping_yoffset = | |
| 8037 static_cast<GLfloat>(yoffset) * dst_height / src_height; | |
| 8038 | |
| 8039 GLuint dst_mapping_x0 = | |
|
yunchao
2016/10/14 13:49:05
Use std::round for both NEAREST and LINEAR filter.
| |
| 8040 std::round(dst_x + dst_mapping_xoffset); | |
| 8041 GLuint dst_mapping_y0 = | |
| 8042 std::round(dst_y + dst_mapping_yoffset); | |
| 8043 | |
| 8044 GLuint dst_mapping_x1 = | |
| 8045 std::round(dst_x + dst_mapping_xoffset + dst_mapping_width); | |
| 8046 GLuint dst_mapping_y1 = | |
| 8047 std::round(dst_y + dst_mapping_yoffset + dst_mapping_height); | |
| 8048 | |
| 8049 // adjust the src region and dst region to fit the read framebuffer | |
| 8050 srcX0 = srcX0 < srcX1 ? rect.x() : rect.x() + rect.width(); | |
| 8051 srcY0 = srcY0 < srcY1 ? rect.y() : rect.y() + rect.height(); | |
| 8052 srcX1 = srcX0 < srcX1 ? rect.x() + rect.width() : rect.x(); | |
| 8053 srcY1 = srcY0 < srcY1 ? rect.y() + rect.height() : rect.y(); | |
| 8054 | |
| 8055 dstX0 = dstX0 < dstX1 ? dst_mapping_x0 : dst_mapping_x1; | |
| 8056 dstY0 = dstY0 < dstY1 ? dst_mapping_y0 : dst_mapping_y1; | |
| 8057 dstX1 = dstX0 < dstX1 ? dst_mapping_x1 : dst_mapping_x0; | |
| 8058 dstY1 = dstY0 < dstY1 ? dst_mapping_y1 : dst_mapping_y0; | |
| 8059 } | |
| 8060 } | |
| 8061 | |
| 7993 bool enable_srgb = | 8062 bool enable_srgb = |
| 7994 (read_buffer_has_srgb || draw_buffers_has_srgb) && | 8063 (read_buffer_has_srgb || draw_buffers_has_srgb) && |
| 7995 ((mask & GL_COLOR_BUFFER_BIT) != 0); | 8064 ((mask & GL_COLOR_BUFFER_BIT) != 0); |
| 7996 bool encode_srgb_only = | 8065 bool encode_srgb_only = |
| 7997 (draw_buffers_has_srgb && !read_buffer_has_srgb) && | 8066 (draw_buffers_has_srgb && !read_buffer_has_srgb) && |
| 7998 ((mask & GL_COLOR_BUFFER_BIT) != 0); | 8067 ((mask & GL_COLOR_BUFFER_BIT) != 0); |
| 7999 if (!enable_srgb || | 8068 if (!enable_srgb || |
| 8000 read_buffer_samples > 0 || | 8069 read_buffer_samples > 0 || |
| 8001 !feature_info_->feature_flags().desktop_srgb_support || | 8070 !feature_info_->feature_flags().desktop_srgb_support || |
| 8002 gl_version_info().IsAtLeastGL(4, 4) || | 8071 gl_version_info().IsAtLeastGL(4, 4) || |
| (...skipping 10516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18519 } | 18588 } |
| 18520 | 18589 |
| 18521 // Include the auto-generated part of this file. We split this because it means | 18590 // Include the auto-generated part of this file. We split this because it means |
| 18522 // we can easily edit the non-auto generated parts right here in this file | 18591 // we can easily edit the non-auto generated parts right here in this file |
| 18523 // instead of having to edit some template or the code generator. | 18592 // instead of having to edit some template or the code generator. |
| 18524 #include "base/macros.h" | 18593 #include "base/macros.h" |
| 18525 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18594 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18526 | 18595 |
| 18527 } // namespace gles2 | 18596 } // namespace gles2 |
| 18528 } // namespace gpu | 18597 } // namespace gpu |
| OLD | NEW |