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 <cmath> | 10 #include <cmath> |
(...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 GLsizei primcount); | 1916 GLsizei primcount); |
1917 | 1917 |
1918 // Returns true if successful, simulated will be true if attrib0 was | 1918 // Returns true if successful, simulated will be true if attrib0 was |
1919 // simulated. | 1919 // simulated. |
1920 bool SimulateAttrib0( | 1920 bool SimulateAttrib0( |
1921 const char* function_name, GLuint max_vertex_accessed, bool* simulated); | 1921 const char* function_name, GLuint max_vertex_accessed, bool* simulated); |
1922 void RestoreStateForAttrib(GLuint attrib, bool restore_array_binding); | 1922 void RestoreStateForAttrib(GLuint attrib, bool restore_array_binding); |
1923 | 1923 |
1924 // Copies the image to the texture currently bound to |textarget|. The image | 1924 // Copies the image to the texture currently bound to |textarget|. The image |
1925 // state of |texture| is updated to reflect the new state. | 1925 // state of |texture| is updated to reflect the new state. |
1926 void DoCopyTexImage(Texture* texture, GLenum textarget, gfx::GLImage* image); | 1926 void DoCopyTexImage(Texture* texture, GLenum textarget, gl::GLImage* image); |
1927 | 1927 |
1928 // This will call DoCopyTexImage if texture has an image but that image is | 1928 // This will call DoCopyTexImage if texture has an image but that image is |
1929 // not bound or copied to the texture. | 1929 // not bound or copied to the texture. |
1930 void DoCopyTexImageIfNeeded(Texture* texture, GLenum textarget); | 1930 void DoCopyTexImageIfNeeded(Texture* texture, GLenum textarget); |
1931 | 1931 |
1932 // Returns false if textures were replaced. | 1932 // Returns false if textures were replaced. |
1933 bool PrepareTexturesForRender(); | 1933 bool PrepareTexturesForRender(); |
1934 void RestoreStateForTextures(); | 1934 void RestoreStateForTextures(); |
1935 | 1935 |
1936 // Returns true if GL_FIXED attribs were simulated. | 1936 // Returns true if GL_FIXED attribs were simulated. |
(...skipping 5615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7552 } | 7552 } |
7553 | 7553 |
7554 void GLES2DecoderImpl::PerformanceWarning( | 7554 void GLES2DecoderImpl::PerformanceWarning( |
7555 const char* filename, int line, const std::string& msg) { | 7555 const char* filename, int line, const std::string& msg) { |
7556 logger_.LogMessage(filename, line, | 7556 logger_.LogMessage(filename, line, |
7557 std::string("PERFORMANCE WARNING: ") + msg); | 7557 std::string("PERFORMANCE WARNING: ") + msg); |
7558 } | 7558 } |
7559 | 7559 |
7560 void GLES2DecoderImpl::DoCopyTexImage(Texture* texture, | 7560 void GLES2DecoderImpl::DoCopyTexImage(Texture* texture, |
7561 GLenum textarget, | 7561 GLenum textarget, |
7562 gfx::GLImage* image) { | 7562 gl::GLImage* image) { |
7563 // Note: We update the state to COPIED prior to calling CopyTexImage() | 7563 // Note: We update the state to COPIED prior to calling CopyTexImage() |
7564 // as that allows the GLImage implemenatation to set it back to UNBOUND | 7564 // as that allows the GLImage implemenatation to set it back to UNBOUND |
7565 // and ensure that CopyTexImage() is called each time the texture is | 7565 // and ensure that CopyTexImage() is called each time the texture is |
7566 // used. | 7566 // used. |
7567 texture->SetLevelImage(textarget, 0, image, Texture::COPIED); | 7567 texture->SetLevelImage(textarget, 0, image, Texture::COPIED); |
7568 bool rv = image->CopyTexImage(textarget); | 7568 bool rv = image->CopyTexImage(textarget); |
7569 DCHECK(rv) << "Both BindTexImage() and CopyTexImage() failed"; | 7569 DCHECK(rv) << "Both BindTexImage() and CopyTexImage() failed"; |
7570 } | 7570 } |
7571 | 7571 |
7572 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, | 7572 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, |
7573 GLenum textarget) { | 7573 GLenum textarget) { |
7574 // Image is already in use if texture is attached to a framebuffer. | 7574 // Image is already in use if texture is attached to a framebuffer. |
7575 if (texture && !texture->IsAttachedToFramebuffer()) { | 7575 if (texture && !texture->IsAttachedToFramebuffer()) { |
7576 Texture::ImageState image_state; | 7576 Texture::ImageState image_state; |
7577 gfx::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); | 7577 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); |
7578 if (image && image_state == Texture::UNBOUND) { | 7578 if (image && image_state == Texture::UNBOUND) { |
7579 ScopedGLErrorSuppressor suppressor( | 7579 ScopedGLErrorSuppressor suppressor( |
7580 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 7580 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); |
7581 glBindTexture(textarget, texture->service_id()); | 7581 glBindTexture(textarget, texture->service_id()); |
7582 DoCopyTexImage(texture, textarget, image); | 7582 DoCopyTexImage(texture, textarget, image); |
7583 RestoreCurrentTextureBindings(&state_, textarget); | 7583 RestoreCurrentTextureBindings(&state_, textarget); |
7584 } | 7584 } |
7585 } | 7585 } |
7586 } | 7586 } |
7587 | 7587 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7621 base::UintToString(texture_unit_index) + | 7621 base::UintToString(texture_unit_index) + |
7622 " is not renderable. It maybe non-power-of-2 and have" | 7622 " is not renderable. It maybe non-power-of-2 and have" |
7623 " incompatible texture filtering."); | 7623 " incompatible texture filtering."); |
7624 } | 7624 } |
7625 continue; | 7625 continue; |
7626 } | 7626 } |
7627 | 7627 |
7628 if (textarget != GL_TEXTURE_CUBE_MAP) { | 7628 if (textarget != GL_TEXTURE_CUBE_MAP) { |
7629 Texture* texture = texture_ref->texture(); | 7629 Texture* texture = texture_ref->texture(); |
7630 Texture::ImageState image_state; | 7630 Texture::ImageState image_state; |
7631 gfx::GLImage* image = | 7631 gl::GLImage* image = |
7632 texture->GetLevelImage(textarget, 0, &image_state); | 7632 texture->GetLevelImage(textarget, 0, &image_state); |
7633 if (image && image_state == Texture::UNBOUND && | 7633 if (image && image_state == Texture::UNBOUND && |
7634 !texture->IsAttachedToFramebuffer()) { | 7634 !texture->IsAttachedToFramebuffer()) { |
7635 ScopedGLErrorSuppressor suppressor( | 7635 ScopedGLErrorSuppressor suppressor( |
7636 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); | 7636 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); |
7637 textures_set = true; | 7637 textures_set = true; |
7638 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7638 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7639 DoCopyTexImage(texture, textarget, image); | 7639 DoCopyTexImage(texture, textarget, image); |
7640 continue; | 7640 continue; |
7641 } | 7641 } |
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9386 const gles2::cmds::ScheduleOverlayPlaneCHROMIUM& c = | 9386 const gles2::cmds::ScheduleOverlayPlaneCHROMIUM& c = |
9387 *static_cast<const gles2::cmds::ScheduleOverlayPlaneCHROMIUM*>(cmd_data); | 9387 *static_cast<const gles2::cmds::ScheduleOverlayPlaneCHROMIUM*>(cmd_data); |
9388 TextureRef* ref = texture_manager()->GetTexture(c.overlay_texture_id); | 9388 TextureRef* ref = texture_manager()->GetTexture(c.overlay_texture_id); |
9389 if (!ref) { | 9389 if (!ref) { |
9390 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, | 9390 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
9391 "glScheduleOverlayPlaneCHROMIUM", | 9391 "glScheduleOverlayPlaneCHROMIUM", |
9392 "unknown texture"); | 9392 "unknown texture"); |
9393 return error::kNoError; | 9393 return error::kNoError; |
9394 } | 9394 } |
9395 Texture::ImageState image_state; | 9395 Texture::ImageState image_state; |
9396 gfx::GLImage* image = | 9396 gl::GLImage* image = |
9397 ref->texture()->GetLevelImage(ref->texture()->target(), 0, &image_state); | 9397 ref->texture()->GetLevelImage(ref->texture()->target(), 0, &image_state); |
9398 if (!image || image_state != Texture::BOUND) { | 9398 if (!image || image_state != Texture::BOUND) { |
9399 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, | 9399 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
9400 "glScheduleOverlayPlaneCHROMIUM", | 9400 "glScheduleOverlayPlaneCHROMIUM", |
9401 "unsupported texture format"); | 9401 "unsupported texture format"); |
9402 return error::kNoError; | 9402 return error::kNoError; |
9403 } | 9403 } |
9404 gfx::OverlayTransform transform = GetGFXOverlayTransform(c.plane_transform); | 9404 gfx::OverlayTransform transform = GetGFXOverlayTransform(c.plane_transform); |
9405 if (transform == gfx::OVERLAY_TRANSFORM_INVALID) { | 9405 if (transform == gfx::OVERLAY_TRANSFORM_INVALID) { |
9406 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, | 9406 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, |
(...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13019 GLboolean unpack_premultiply_alpha, | 13019 GLboolean unpack_premultiply_alpha, |
13020 GLboolean unpack_unmultiply_alpha) { | 13020 GLboolean unpack_unmultiply_alpha) { |
13021 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); | 13021 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); |
13022 | 13022 |
13023 TextureRef* source_texture_ref = GetTexture(source_id); | 13023 TextureRef* source_texture_ref = GetTexture(source_id); |
13024 TextureRef* dest_texture_ref = GetTexture(dest_id); | 13024 TextureRef* dest_texture_ref = GetTexture(dest_id); |
13025 Texture* source_texture = source_texture_ref->texture(); | 13025 Texture* source_texture = source_texture_ref->texture(); |
13026 Texture* dest_texture = dest_texture_ref->texture(); | 13026 Texture* dest_texture = dest_texture_ref->texture(); |
13027 int source_width = 0; | 13027 int source_width = 0; |
13028 int source_height = 0; | 13028 int source_height = 0; |
13029 gfx::GLImage* image = | 13029 gl::GLImage* image = |
13030 source_texture->GetLevelImage(source_texture->target(), 0); | 13030 source_texture->GetLevelImage(source_texture->target(), 0); |
13031 if (image) { | 13031 if (image) { |
13032 gfx::Size size = image->GetSize(); | 13032 gfx::Size size = image->GetSize(); |
13033 source_width = size.width(); | 13033 source_width = size.width(); |
13034 source_height = size.height(); | 13034 source_height = size.height(); |
13035 if (source_width <= 0 || source_height <= 0) { | 13035 if (source_width <= 0 || source_height <= 0) { |
13036 LOCAL_SET_GL_ERROR( | 13036 LOCAL_SET_GL_ERROR( |
13037 GL_INVALID_VALUE, | 13037 GL_INVALID_VALUE, |
13038 "glCopyTextureChromium", "invalid image size"); | 13038 "glCopyTextureChromium", "invalid image size"); |
13039 return; | 13039 return; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13177 GLboolean unpack_premultiply_alpha, | 13177 GLboolean unpack_premultiply_alpha, |
13178 GLboolean unpack_unmultiply_alpha) { | 13178 GLboolean unpack_unmultiply_alpha) { |
13179 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); | 13179 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); |
13180 | 13180 |
13181 TextureRef* source_texture_ref = GetTexture(source_id); | 13181 TextureRef* source_texture_ref = GetTexture(source_id); |
13182 TextureRef* dest_texture_ref = GetTexture(dest_id); | 13182 TextureRef* dest_texture_ref = GetTexture(dest_id); |
13183 Texture* source_texture = source_texture_ref->texture(); | 13183 Texture* source_texture = source_texture_ref->texture(); |
13184 Texture* dest_texture = dest_texture_ref->texture(); | 13184 Texture* dest_texture = dest_texture_ref->texture(); |
13185 int source_width = 0; | 13185 int source_width = 0; |
13186 int source_height = 0; | 13186 int source_height = 0; |
13187 gfx::GLImage* image = | 13187 gl::GLImage* image = |
13188 source_texture->GetLevelImage(source_texture->target(), 0); | 13188 source_texture->GetLevelImage(source_texture->target(), 0); |
13189 if (image) { | 13189 if (image) { |
13190 gfx::Size size = image->GetSize(); | 13190 gfx::Size size = image->GetSize(); |
13191 source_width = size.width(); | 13191 source_width = size.width(); |
13192 source_height = size.height(); | 13192 source_height = size.height(); |
13193 if (source_width <= 0 || source_height <= 0) { | 13193 if (source_width <= 0 || source_height <= 0) { |
13194 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 13194 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
13195 "invalid image size"); | 13195 "invalid image size"); |
13196 return; | 13196 return; |
13197 } | 13197 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13323 GLuint source_id, | 13323 GLuint source_id, |
13324 GLuint dest_id) { | 13324 GLuint dest_id) { |
13325 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); | 13325 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); |
13326 | 13326 |
13327 TextureRef* source_texture_ref = GetTexture(source_id); | 13327 TextureRef* source_texture_ref = GetTexture(source_id); |
13328 TextureRef* dest_texture_ref = GetTexture(dest_id); | 13328 TextureRef* dest_texture_ref = GetTexture(dest_id); |
13329 Texture* source_texture = source_texture_ref->texture(); | 13329 Texture* source_texture = source_texture_ref->texture(); |
13330 Texture* dest_texture = dest_texture_ref->texture(); | 13330 Texture* dest_texture = dest_texture_ref->texture(); |
13331 int source_width = 0; | 13331 int source_width = 0; |
13332 int source_height = 0; | 13332 int source_height = 0; |
13333 gfx::GLImage* image = | 13333 gl::GLImage* image = |
13334 source_texture->GetLevelImage(source_texture->target(), 0); | 13334 source_texture->GetLevelImage(source_texture->target(), 0); |
13335 if (image) { | 13335 if (image) { |
13336 gfx::Size size = image->GetSize(); | 13336 gfx::Size size = image->GetSize(); |
13337 source_width = size.width(); | 13337 source_width = size.width(); |
13338 source_height = size.height(); | 13338 source_height = size.height(); |
13339 if (source_width <= 0 || source_height <= 0) { | 13339 if (source_width <= 0 || source_height <= 0) { |
13340 LOCAL_SET_GL_ERROR( | 13340 LOCAL_SET_GL_ERROR( |
13341 GL_INVALID_VALUE, | 13341 GL_INVALID_VALUE, |
13342 "glCompressedCopyTextureCHROMIUM", "invalid image size"); | 13342 "glCompressedCopyTextureCHROMIUM", "invalid image size"); |
13343 return; | 13343 return; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13499 GLsizei width, | 13499 GLsizei width, |
13500 GLsizei height) { | 13500 GLsizei height) { |
13501 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM"); | 13501 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM"); |
13502 | 13502 |
13503 TextureRef* source_texture_ref = GetTexture(source_id); | 13503 TextureRef* source_texture_ref = GetTexture(source_id); |
13504 TextureRef* dest_texture_ref = GetTexture(dest_id); | 13504 TextureRef* dest_texture_ref = GetTexture(dest_id); |
13505 Texture* source_texture = source_texture_ref->texture(); | 13505 Texture* source_texture = source_texture_ref->texture(); |
13506 Texture* dest_texture = dest_texture_ref->texture(); | 13506 Texture* dest_texture = dest_texture_ref->texture(); |
13507 int source_width = 0; | 13507 int source_width = 0; |
13508 int source_height = 0; | 13508 int source_height = 0; |
13509 gfx::GLImage* image = | 13509 gl::GLImage* image = |
13510 source_texture->GetLevelImage(source_texture->target(), 0); | 13510 source_texture->GetLevelImage(source_texture->target(), 0); |
13511 if (image) { | 13511 if (image) { |
13512 gfx::Size size = image->GetSize(); | 13512 gfx::Size size = image->GetSize(); |
13513 source_width = size.width(); | 13513 source_width = size.width(); |
13514 source_height = size.height(); | 13514 source_height = size.height(); |
13515 if (source_width <= 0 || source_height <= 0) { | 13515 if (source_width <= 0 || source_height <= 0) { |
13516 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", | 13516 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
13517 "invalid image size"); | 13517 "invalid image size"); |
13518 return; | 13518 return; |
13519 } | 13519 } |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14104 // accidents. | 14104 // accidents. |
14105 TextureRef* texture_ref = | 14105 TextureRef* texture_ref = |
14106 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 14106 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
14107 if (!texture_ref) { | 14107 if (!texture_ref) { |
14108 LOCAL_SET_GL_ERROR( | 14108 LOCAL_SET_GL_ERROR( |
14109 GL_INVALID_OPERATION, | 14109 GL_INVALID_OPERATION, |
14110 "glBindTexImage2DCHROMIUM", "no texture bound"); | 14110 "glBindTexImage2DCHROMIUM", "no texture bound"); |
14111 return; | 14111 return; |
14112 } | 14112 } |
14113 | 14113 |
14114 gfx::GLImage* image = image_manager()->LookupImage(image_id); | 14114 gl::GLImage* image = image_manager()->LookupImage(image_id); |
14115 if (!image) { | 14115 if (!image) { |
14116 LOCAL_SET_GL_ERROR( | 14116 LOCAL_SET_GL_ERROR( |
14117 GL_INVALID_OPERATION, | 14117 GL_INVALID_OPERATION, |
14118 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); | 14118 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); |
14119 return; | 14119 return; |
14120 } | 14120 } |
14121 | 14121 |
14122 Texture::ImageState image_state = Texture::UNBOUND; | 14122 Texture::ImageState image_state = Texture::UNBOUND; |
14123 | 14123 |
14124 { | 14124 { |
(...skipping 22 matching lines...) Expand all Loading... |
14147 // accidents. | 14147 // accidents. |
14148 TextureRef* texture_ref = | 14148 TextureRef* texture_ref = |
14149 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 14149 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
14150 if (!texture_ref) { | 14150 if (!texture_ref) { |
14151 LOCAL_SET_GL_ERROR( | 14151 LOCAL_SET_GL_ERROR( |
14152 GL_INVALID_OPERATION, | 14152 GL_INVALID_OPERATION, |
14153 "glReleaseTexImage2DCHROMIUM", "no texture bound"); | 14153 "glReleaseTexImage2DCHROMIUM", "no texture bound"); |
14154 return; | 14154 return; |
14155 } | 14155 } |
14156 | 14156 |
14157 gfx::GLImage* image = image_manager()->LookupImage(image_id); | 14157 gl::GLImage* image = image_manager()->LookupImage(image_id); |
14158 if (!image) { | 14158 if (!image) { |
14159 LOCAL_SET_GL_ERROR( | 14159 LOCAL_SET_GL_ERROR( |
14160 GL_INVALID_OPERATION, | 14160 GL_INVALID_OPERATION, |
14161 "glReleaseTexImage2DCHROMIUM", "no image found with the given ID"); | 14161 "glReleaseTexImage2DCHROMIUM", "no image found with the given ID"); |
14162 return; | 14162 return; |
14163 } | 14163 } |
14164 | 14164 |
14165 Texture::ImageState image_state; | 14165 Texture::ImageState image_state; |
14166 | 14166 |
14167 // Do nothing when image is not currently bound. | 14167 // Do nothing when image is not currently bound. |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15442 return error::kNoError; | 15442 return error::kNoError; |
15443 } | 15443 } |
15444 | 15444 |
15445 // Include the auto-generated part of this file. We split this because it means | 15445 // Include the auto-generated part of this file. We split this because it means |
15446 // we can easily edit the non-auto generated parts right here in this file | 15446 // we can easily edit the non-auto generated parts right here in this file |
15447 // instead of having to edit some template or the code generator. | 15447 // instead of having to edit some template or the code generator. |
15448 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15448 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15449 | 15449 |
15450 } // namespace gles2 | 15450 } // namespace gles2 |
15451 } // namespace gpu | 15451 } // namespace gpu |
OLD | NEW |