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 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 const FeatureInfo::Workarounds& workarounds() const { | 1402 const FeatureInfo::Workarounds& workarounds() const { |
1403 return feature_info_->workarounds(); | 1403 return feature_info_->workarounds(); |
1404 } | 1404 } |
1405 | 1405 |
1406 bool ShouldDeferDraws() { | 1406 bool ShouldDeferDraws() { |
1407 return !offscreen_target_frame_buffer_.get() && | 1407 return !offscreen_target_frame_buffer_.get() && |
1408 state_.bound_draw_framebuffer == NULL && | 1408 state_.bound_draw_framebuffer == NULL && |
1409 surface_->DeferDraws(); | 1409 surface_->DeferDraws(); |
1410 } | 1410 } |
1411 | 1411 |
| 1412 bool ShouldDeferReads() { |
| 1413 return !offscreen_target_frame_buffer_.get() && |
| 1414 state_.bound_read_framebuffer == NULL && |
| 1415 surface_->DeferDraws(); |
| 1416 } |
| 1417 |
1412 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); | 1418 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); |
1413 | 1419 |
1414 // Generate a member function prototype for each command in an automated and | 1420 // Generate a member function prototype for each command in an automated and |
1415 // typesafe way. | 1421 // typesafe way. |
1416 #define GLES2_CMD_OP(name) \ | 1422 #define GLES2_CMD_OP(name) \ |
1417 Error Handle ## name( \ | 1423 Error Handle ## name( \ |
1418 uint32 immediate_data_size, \ | 1424 uint32 immediate_data_size, \ |
1419 const gles2::name& args); \ | 1425 const gles2::name& args); \ |
1420 | 1426 |
1421 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1427 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3117 if (offscreen_resolved_color_texture_.get()) | 3123 if (offscreen_resolved_color_texture_.get()) |
3118 offscreen_resolved_color_texture_->Destroy(); | 3124 offscreen_resolved_color_texture_->Destroy(); |
3119 offscreen_resolved_color_texture_.reset(); | 3125 offscreen_resolved_color_texture_.reset(); |
3120 offscreen_resolved_frame_buffer_.reset(); | 3126 offscreen_resolved_frame_buffer_.reset(); |
3121 | 3127 |
3122 return true; | 3128 return true; |
3123 } | 3129 } |
3124 | 3130 |
3125 error::Error GLES2DecoderImpl::HandleResizeCHROMIUM( | 3131 error::Error GLES2DecoderImpl::HandleResizeCHROMIUM( |
3126 uint32 immediate_data_size, const gles2::ResizeCHROMIUM& c) { | 3132 uint32 immediate_data_size, const gles2::ResizeCHROMIUM& c) { |
3127 if (ShouldDeferDraws()) | 3133 if (!offscreen_target_frame_buffer_.get() && surface_->DeferDraws()) |
3128 return error::kDeferCommandUntilLater; | 3134 return error::kDeferCommandUntilLater; |
3129 | 3135 |
3130 GLuint width = static_cast<GLuint>(c.width); | 3136 GLuint width = static_cast<GLuint>(c.width); |
3131 GLuint height = static_cast<GLuint>(c.height); | 3137 GLuint height = static_cast<GLuint>(c.height); |
3132 TRACE_EVENT2("gpu", "glResizeChromium", "width", width, "height", height); | 3138 TRACE_EVENT2("gpu", "glResizeChromium", "width", width, "height", height); |
3133 #if defined(OS_POSIX) && !defined(OS_MACOSX) && \ | 3139 #if defined(OS_POSIX) && !defined(OS_MACOSX) && \ |
3134 !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 3140 !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
3135 // Make sure that we are done drawing to the back buffer before resizing. | 3141 // Make sure that we are done drawing to the back buffer before resizing. |
3136 glFinish(); | 3142 glFinish(); |
3137 #endif | 3143 #endif |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4230 return error::kNoError; | 4236 return error::kNoError; |
4231 } | 4237 } |
4232 if (ids == NULL) { | 4238 if (ids == NULL) { |
4233 return error::kOutOfBounds; | 4239 return error::kOutOfBounds; |
4234 } | 4240 } |
4235 DoRegisterSharedIdsCHROMIUM(namespace_id, n, ids); | 4241 DoRegisterSharedIdsCHROMIUM(namespace_id, n, ids); |
4236 return error::kNoError; | 4242 return error::kNoError; |
4237 } | 4243 } |
4238 | 4244 |
4239 error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) { | 4245 error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) { |
4240 if (ShouldDeferDraws()) | 4246 DCHECK(!ShouldDeferDraws()); |
4241 return error::kDeferCommandUntilLater; | |
4242 if (CheckBoundFramebuffersValid("glClear")) { | 4247 if (CheckBoundFramebuffersValid("glClear")) { |
4243 UNSHIPPED_TRACE_EVENT_INSTANT2( | 4248 UNSHIPPED_TRACE_EVENT_INSTANT2( |
4244 "test_gpu", "DoClear", | 4249 "test_gpu", "DoClear", |
4245 "red", state_.color_clear_red, | 4250 "red", state_.color_clear_red, |
4246 "green", state_.color_clear_green); | 4251 "green", state_.color_clear_green); |
4247 ApplyDirtyState(); | 4252 ApplyDirtyState(); |
4248 glClear(mask); | 4253 glClear(mask); |
4249 } | 4254 } |
4250 return error::kNoError; | 4255 return error::kNoError; |
4251 } | 4256 } |
4252 | 4257 |
4253 error::Error GLES2DecoderImpl::HandleClear( | |
4254 uint32 immediate_data_size, const gles2::Clear& c) { | |
4255 GLbitfield mask = static_cast<GLbitfield>(c.mask); | |
4256 return DoClear(mask); | |
4257 } | |
4258 | |
4259 void GLES2DecoderImpl::DoFramebufferRenderbuffer( | 4258 void GLES2DecoderImpl::DoFramebufferRenderbuffer( |
4260 GLenum target, GLenum attachment, GLenum renderbuffertarget, | 4259 GLenum target, GLenum attachment, GLenum renderbuffertarget, |
4261 GLuint client_renderbuffer_id) { | 4260 GLuint client_renderbuffer_id) { |
4262 FramebufferManager::FramebufferInfo* framebuffer_info = | 4261 FramebufferManager::FramebufferInfo* framebuffer_info = |
4263 GetFramebufferInfoForTarget(target); | 4262 GetFramebufferInfoForTarget(target); |
4264 if (!framebuffer_info) { | 4263 if (!framebuffer_info) { |
4265 SetGLError(GL_INVALID_OPERATION, | 4264 SetGLError(GL_INVALID_OPERATION, |
4266 "glFramebufferRenderbuffer", "no framebuffer bound"); | 4265 "glFramebufferRenderbuffer", "no framebuffer bound"); |
4267 return; | 4266 return; |
4268 } | 4267 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4497 default: | 4496 default: |
4498 glGetRenderbufferParameterivEXT(target, pname, params); | 4497 glGetRenderbufferParameterivEXT(target, pname, params); |
4499 break; | 4498 break; |
4500 } | 4499 } |
4501 } | 4500 } |
4502 | 4501 |
4503 void GLES2DecoderImpl::DoBlitFramebufferEXT( | 4502 void GLES2DecoderImpl::DoBlitFramebufferEXT( |
4504 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, | 4503 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
4505 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, | 4504 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
4506 GLbitfield mask, GLenum filter) { | 4505 GLbitfield mask, GLenum filter) { |
| 4506 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); |
4507 if (!features().chromium_framebuffer_multisample) { | 4507 if (!features().chromium_framebuffer_multisample) { |
4508 SetGLError(GL_INVALID_OPERATION, | 4508 SetGLError(GL_INVALID_OPERATION, |
4509 "glBlitFramebufferEXT", "function not available"); | 4509 "glBlitFramebufferEXT", "function not available"); |
4510 } | 4510 } |
4511 glDisable(GL_SCISSOR_TEST); | 4511 glDisable(GL_SCISSOR_TEST); |
4512 if (IsAngle()) { | 4512 if (IsAngle()) { |
4513 glBlitFramebufferANGLE( | 4513 glBlitFramebufferANGLE( |
4514 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 4514 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
4515 } else { | 4515 } else { |
4516 glBlitFramebufferEXT( | 4516 glBlitFramebufferEXT( |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6285 | 6285 |
6286 state_.vertex_attrib_manager->SetDivisor( | 6286 state_.vertex_attrib_manager->SetDivisor( |
6287 index, | 6287 index, |
6288 divisor); | 6288 divisor); |
6289 glVertexAttribDivisorANGLE(index, divisor); | 6289 glVertexAttribDivisorANGLE(index, divisor); |
6290 return error::kNoError; | 6290 return error::kNoError; |
6291 } | 6291 } |
6292 | 6292 |
6293 error::Error GLES2DecoderImpl::HandleReadPixels( | 6293 error::Error GLES2DecoderImpl::HandleReadPixels( |
6294 uint32 immediate_data_size, const gles2::ReadPixels& c) { | 6294 uint32 immediate_data_size, const gles2::ReadPixels& c) { |
| 6295 if (ShouldDeferReads()) |
| 6296 return error::kDeferCommandUntilLater; |
6295 GLint x = c.x; | 6297 GLint x = c.x; |
6296 GLint y = c.y; | 6298 GLint y = c.y; |
6297 GLsizei width = c.width; | 6299 GLsizei width = c.width; |
6298 GLsizei height = c.height; | 6300 GLsizei height = c.height; |
6299 GLenum format = c.format; | 6301 GLenum format = c.format; |
6300 GLenum type = c.type; | 6302 GLenum type = c.type; |
6301 if (width < 0 || height < 0) { | 6303 if (width < 0 || height < 0) { |
6302 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); | 6304 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); |
6303 return error::kNoError; | 6305 return error::kNoError; |
6304 } | 6306 } |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7471 | 7473 |
7472 void GLES2DecoderImpl::DoCopyTexImage2D( | 7474 void GLES2DecoderImpl::DoCopyTexImage2D( |
7473 GLenum target, | 7475 GLenum target, |
7474 GLint level, | 7476 GLint level, |
7475 GLenum internal_format, | 7477 GLenum internal_format, |
7476 GLint x, | 7478 GLint x, |
7477 GLint y, | 7479 GLint y, |
7478 GLsizei width, | 7480 GLsizei width, |
7479 GLsizei height, | 7481 GLsizei height, |
7480 GLint border) { | 7482 GLint border) { |
| 7483 DCHECK(!ShouldDeferReads()); |
7481 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 7484 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
7482 if (!info) { | 7485 if (!info) { |
7483 SetGLError(GL_INVALID_OPERATION, | 7486 SetGLError(GL_INVALID_OPERATION, |
7484 "glCopyTexImage2D", "unknown texture for target"); | 7487 "glCopyTexImage2D", "unknown texture for target"); |
7485 return; | 7488 return; |
7486 } | 7489 } |
7487 if (info->IsImmutable()) { | 7490 if (info->IsImmutable()) { |
7488 SetGLError(GL_INVALID_OPERATION, | 7491 SetGLError(GL_INVALID_OPERATION, |
7489 "glCopyTexImage2D", "texture is immutable"); | 7492 "glCopyTexImage2D", "texture is immutable"); |
7490 } | 7493 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7573 | 7576 |
7574 void GLES2DecoderImpl::DoCopyTexSubImage2D( | 7577 void GLES2DecoderImpl::DoCopyTexSubImage2D( |
7575 GLenum target, | 7578 GLenum target, |
7576 GLint level, | 7579 GLint level, |
7577 GLint xoffset, | 7580 GLint xoffset, |
7578 GLint yoffset, | 7581 GLint yoffset, |
7579 GLint x, | 7582 GLint x, |
7580 GLint y, | 7583 GLint y, |
7581 GLsizei width, | 7584 GLsizei width, |
7582 GLsizei height) { | 7585 GLsizei height) { |
| 7586 DCHECK(!ShouldDeferReads()); |
7583 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 7587 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
7584 if (!info) { | 7588 if (!info) { |
7585 SetGLError(GL_INVALID_OPERATION, | 7589 SetGLError(GL_INVALID_OPERATION, |
7586 "glCopyTexSubImage2D", "unknown texture for target"); | 7590 "glCopyTexSubImage2D", "unknown texture for target"); |
7587 return; | 7591 return; |
7588 } | 7592 } |
7589 GLenum type = 0; | 7593 GLenum type = 0; |
7590 GLenum format = 0; | 7594 GLenum format = 0; |
7591 if (!info->GetLevelType(target, level, &type, &format) || | 7595 if (!info->GetLevelType(target, level, &type, &format) || |
7592 !info->ValidForTexture( | 7596 !info->ValidForTexture( |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9365 gpu_trace_stack_.pop(); | 9369 gpu_trace_stack_.pop(); |
9366 } | 9370 } |
9367 | 9371 |
9368 // Include the auto-generated part of this file. We split this because it means | 9372 // Include the auto-generated part of this file. We split this because it means |
9369 // we can easily edit the non-auto generated parts right here in this file | 9373 // we can easily edit the non-auto generated parts right here in this file |
9370 // instead of having to edit some template or the code generator. | 9374 // instead of having to edit some template or the code generator. |
9371 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9375 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9372 | 9376 |
9373 } // namespace gles2 | 9377 } // namespace gles2 |
9374 } // namespace gpu | 9378 } // namespace gpu |
OLD | NEW |