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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 3113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 } | 3124 } |
3125 | 3125 |
3126 bool GLES2DecoderImpl::CheckFramebufferValid( | 3126 bool GLES2DecoderImpl::CheckFramebufferValid( |
3127 Framebuffer* framebuffer, | 3127 Framebuffer* framebuffer, |
3128 GLenum target, const char* func_name) { | 3128 GLenum target, const char* func_name) { |
3129 if (!framebuffer) { | 3129 if (!framebuffer) { |
3130 if (surfaceless_) | 3130 if (surfaceless_) |
3131 return false; | 3131 return false; |
3132 if (backbuffer_needs_clear_bits_) { | 3132 if (backbuffer_needs_clear_bits_) { |
3133 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( | 3133 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( |
3134 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); | 3134 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1.f); |
3135 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 3135 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
3136 glClearStencil(0); | 3136 glClearStencil(0); |
3137 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 3137 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
3138 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 3138 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
3139 glClearDepth(1.0f); | 3139 glClearDepth(1.0f); |
3140 state_.SetDeviceDepthMask(GL_TRUE); | 3140 state_.SetDeviceDepthMask(GL_TRUE); |
3141 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 3141 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
3142 bool reset_draw_buffer = false; | 3142 bool reset_draw_buffer = false; |
3143 if ((backbuffer_needs_clear_bits_ | GL_COLOR_BUFFER_BIT) != 0 && | 3143 if ((backbuffer_needs_clear_bits_ | GL_COLOR_BUFFER_BIT) != 0 && |
3144 group_->draw_buffer() == GL_NONE) { | 3144 group_->draw_buffer() == GL_NONE) { |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3688 GL_FRAMEBUFFER_COMPLETE) { | 3688 GL_FRAMEBUFFER_COMPLETE) { |
3689 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3689 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
3690 << "because offscreen FBO was incomplete."; | 3690 << "because offscreen FBO was incomplete."; |
3691 return false; | 3691 return false; |
3692 } | 3692 } |
3693 | 3693 |
3694 // Clear the target frame buffer. | 3694 // Clear the target frame buffer. |
3695 { | 3695 { |
3696 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); | 3696 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); |
3697 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( | 3697 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( |
3698 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); | 3698 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1.f); |
3699 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 3699 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
3700 glClearStencil(0); | 3700 glClearStencil(0); |
3701 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 3701 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
3702 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 3702 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
3703 glClearDepth(0); | 3703 glClearDepth(0); |
3704 state_.SetDeviceDepthMask(GL_TRUE); | 3704 state_.SetDeviceDepthMask(GL_TRUE); |
3705 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 3705 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
3706 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 3706 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
3707 RestoreClearState(); | 3707 RestoreClearState(); |
3708 } | 3708 } |
(...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7208 LOCAL_SET_GL_ERROR( | 7208 LOCAL_SET_GL_ERROR( |
7209 GL_INVALID_VALUE, | 7209 GL_INVALID_VALUE, |
7210 "glVertexAttribPointer", "client side arrays are not allowed"); | 7210 "glVertexAttribPointer", "client side arrays are not allowed"); |
7211 return error::kNoError; | 7211 return error::kNoError; |
7212 } | 7212 } |
7213 } | 7213 } |
7214 | 7214 |
7215 GLuint indx = c.indx; | 7215 GLuint indx = c.indx; |
7216 GLint size = c.size; | 7216 GLint size = c.size; |
7217 GLenum type = c.type; | 7217 GLenum type = c.type; |
7218 GLboolean normalized = c.normalized; | 7218 GLboolean normalized = static_cast<GLboolean>(c.normalized); |
7219 GLsizei stride = c.stride; | 7219 GLsizei stride = c.stride; |
7220 GLsizei offset = c.offset; | 7220 GLsizei offset = c.offset; |
7221 const void* ptr = reinterpret_cast<const void*>(offset); | 7221 const void* ptr = reinterpret_cast<const void*>(offset); |
7222 if (!validators_->vertex_attrib_type.IsValid(type)) { | 7222 if (!validators_->vertex_attrib_type.IsValid(type)) { |
7223 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribPointer", type, "type"); | 7223 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribPointer", type, "type"); |
7224 return error::kNoError; | 7224 return error::kNoError; |
7225 } | 7225 } |
7226 if (!validators_->vertex_attrib_size.IsValid(size)) { | 7226 if (!validators_->vertex_attrib_size.IsValid(size)) { |
7227 LOCAL_SET_GL_ERROR( | 7227 LOCAL_SET_GL_ERROR( |
7228 GL_INVALID_VALUE, "glVertexAttribPointer", "size GL_INVALID_VALUE"); | 7228 GL_INVALID_VALUE, "glVertexAttribPointer", "size GL_INVALID_VALUE"); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7450 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleReadPixels"); | 7450 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleReadPixels"); |
7451 error::Error fbo_error = WillAccessBoundFramebufferForRead(); | 7451 error::Error fbo_error = WillAccessBoundFramebufferForRead(); |
7452 if (fbo_error != error::kNoError) | 7452 if (fbo_error != error::kNoError) |
7453 return fbo_error; | 7453 return fbo_error; |
7454 GLint x = c.x; | 7454 GLint x = c.x; |
7455 GLint y = c.y; | 7455 GLint y = c.y; |
7456 GLsizei width = c.width; | 7456 GLsizei width = c.width; |
7457 GLsizei height = c.height; | 7457 GLsizei height = c.height; |
7458 GLenum format = c.format; | 7458 GLenum format = c.format; |
7459 GLenum type = c.type; | 7459 GLenum type = c.type; |
7460 GLboolean async = c.async; | 7460 GLboolean async = static_cast<GLboolean>(c.async); |
7461 if (width < 0 || height < 0) { | 7461 if (width < 0 || height < 0) { |
7462 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); | 7462 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); |
7463 return error::kNoError; | 7463 return error::kNoError; |
7464 } | 7464 } |
7465 typedef cmds::ReadPixels::Result Result; | 7465 typedef cmds::ReadPixels::Result Result; |
7466 uint32 pixels_size; | 7466 uint32 pixels_size; |
7467 if (!GLES2Util::ComputeImageDataSizes( | 7467 if (!GLES2Util::ComputeImageDataSizes( |
7468 width, height, format, type, state_.pack_alignment, &pixels_size, | 7468 width, height, format, type, state_.pack_alignment, &pixels_size, |
7469 NULL, NULL)) { | 7469 NULL, NULL)) { |
7470 return error::kOutOfBounds; | 7470 return error::kOutOfBounds; |
(...skipping 3718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11189 } | 11189 } |
11190 } | 11190 } |
11191 | 11191 |
11192 // Include the auto-generated part of this file. We split this because it means | 11192 // Include the auto-generated part of this file. We split this because it means |
11193 // we can easily edit the non-auto generated parts right here in this file | 11193 // we can easily edit the non-auto generated parts right here in this file |
11194 // instead of having to edit some template or the code generator. | 11194 // instead of having to edit some template or the code generator. |
11195 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11195 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11196 | 11196 |
11197 } // namespace gles2 | 11197 } // namespace gles2 |
11198 } // namespace gpu | 11198 } // namespace gpu |
OLD | NEW |