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 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1912 // Returns true if successful, simulated will be true if attrib0 was | 1912 // Returns true if successful, simulated will be true if attrib0 was |
| 1913 // simulated. | 1913 // simulated. |
| 1914 bool SimulateAttrib0( | 1914 bool SimulateAttrib0( |
| 1915 const char* function_name, GLuint max_vertex_accessed, bool* simulated); | 1915 const char* function_name, GLuint max_vertex_accessed, bool* simulated); |
| 1916 void RestoreStateForAttrib(GLuint attrib, bool restore_array_binding); | 1916 void RestoreStateForAttrib(GLuint attrib, bool restore_array_binding); |
| 1917 | 1917 |
| 1918 // Copies the image to the texture currently bound to |textarget|. The image | 1918 // Copies the image to the texture currently bound to |textarget|. The image |
| 1919 // state of |texture| is updated to reflect the new state. | 1919 // state of |texture| is updated to reflect the new state. |
| 1920 void DoCopyTexImage(Texture* texture, GLenum textarget, gl::GLImage* image); | 1920 void DoCopyTexImage(Texture* texture, GLenum textarget, gl::GLImage* image); |
| 1921 | 1921 |
| 1922 // This will call DoCopyTexImage if texture has an image but that image is | 1922 // If the texture has an image but that image is not bound or copied to the |
| 1923 // not bound or copied to the texture. | 1923 // texture, this will first attempt to bind it, and if that fails |
| 1924 void DoCopyTexImageIfNeeded(Texture* texture, GLenum textarget); | 1924 // DoCopyTexImage on it. texture_unit is the texture unit it should be bound |
| 1925 // to, or 0 if it doesn't matter - setting it to 0 will cause the previous | |
| 1926 // binding to be restored after the operation. This returns true if a copy | |
| 1927 // or bind happened. | |
|
Zhenyao Mo
2017/05/26 01:11:07
Can you add it here that it is the caller's respon
| |
| 1928 bool DoBindOrCopyTexImageIfNeeded(Texture* texture, | |
| 1929 GLenum textarget, | |
| 1930 GLuint texture_unit); | |
| 1925 | 1931 |
| 1926 // Returns false if textures were replaced. | 1932 // Returns false if textures were replaced. |
| 1927 bool PrepareTexturesForRender(); | 1933 bool PrepareTexturesForRender(); |
| 1928 void RestoreStateForTextures(); | 1934 void RestoreStateForTextures(); |
| 1929 | 1935 |
| 1930 // Returns true if GL_FIXED attribs were simulated. | 1936 // Returns true if GL_FIXED attribs were simulated. |
| 1931 bool SimulateFixedAttribs( | 1937 bool SimulateFixedAttribs( |
| 1932 const char* function_name, | 1938 const char* function_name, |
| 1933 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); | 1939 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); |
| 1934 void RestoreStateForSimulatedFixedAttribs(); | 1940 void RestoreStateForSimulatedFixedAttribs(); |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2517 const char* function_name, ErrorState* error_state) | 2523 const char* function_name, ErrorState* error_state) |
| 2518 : function_name_(function_name), | 2524 : function_name_(function_name), |
| 2519 error_state_(error_state) { | 2525 error_state_(error_state) { |
| 2520 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state_, function_name_); | 2526 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state_, function_name_); |
| 2521 } | 2527 } |
| 2522 | 2528 |
| 2523 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 2529 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
| 2524 ERRORSTATE_CLEAR_REAL_GL_ERRORS(error_state_, function_name_); | 2530 ERRORSTATE_CLEAR_REAL_GL_ERRORS(error_state_, function_name_); |
| 2525 } | 2531 } |
| 2526 | 2532 |
| 2527 static void RestoreCurrentTextureBindings(ContextState* state, GLenum target) { | 2533 static void RestoreCurrentTextureBindings(ContextState* state, |
| 2534 GLenum target, | |
| 2535 GLuint texture_unit) { | |
| 2528 DCHECK(!state->texture_units.empty()); | 2536 DCHECK(!state->texture_units.empty()); |
| 2529 TextureUnit& info = state->texture_units[0]; | 2537 DCHECK_LT(texture_unit, state->texture_units.size()); |
| 2538 TextureUnit& info = state->texture_units[texture_unit]; | |
| 2530 GLuint last_id; | 2539 GLuint last_id; |
| 2531 TextureRef* texture_ref = info.GetInfoForTarget(target); | 2540 TextureRef* texture_ref = info.GetInfoForTarget(target); |
| 2532 if (texture_ref) { | 2541 if (texture_ref) { |
| 2533 last_id = texture_ref->service_id(); | 2542 last_id = texture_ref->service_id(); |
| 2534 } else { | 2543 } else { |
| 2535 last_id = 0; | 2544 last_id = 0; |
| 2536 } | 2545 } |
| 2537 | 2546 |
| 2538 glBindTexture(target, last_id); | 2547 glBindTexture(target, last_id); |
| 2539 glActiveTexture(GL_TEXTURE0 + state->active_texture_unit); | |
| 2540 } | 2548 } |
| 2541 | 2549 |
| 2542 ScopedTextureBinder::ScopedTextureBinder(ContextState* state, | 2550 ScopedTextureBinder::ScopedTextureBinder(ContextState* state, |
| 2543 GLuint id, | 2551 GLuint id, |
| 2544 GLenum target) | 2552 GLenum target) |
| 2545 : state_(state), | 2553 : state_(state), |
| 2546 target_(target) { | 2554 target_(target) { |
| 2547 ScopedGLErrorSuppressor suppressor( | 2555 ScopedGLErrorSuppressor suppressor( |
| 2548 "ScopedTextureBinder::ctor", state_->GetErrorState()); | 2556 "ScopedTextureBinder::ctor", state_->GetErrorState()); |
| 2549 | 2557 |
| 2550 // TODO(apatrick): Check if there are any other states that need to be reset | 2558 // TODO(apatrick): Check if there are any other states that need to be reset |
| 2551 // before binding a new texture. | 2559 // before binding a new texture. |
| 2552 glActiveTexture(GL_TEXTURE0); | 2560 glActiveTexture(GL_TEXTURE0); |
| 2553 glBindTexture(target, id); | 2561 glBindTexture(target, id); |
| 2554 } | 2562 } |
| 2555 | 2563 |
| 2556 ScopedTextureBinder::~ScopedTextureBinder() { | 2564 ScopedTextureBinder::~ScopedTextureBinder() { |
| 2557 ScopedGLErrorSuppressor suppressor( | 2565 ScopedGLErrorSuppressor suppressor( |
| 2558 "ScopedTextureBinder::dtor", state_->GetErrorState()); | 2566 "ScopedTextureBinder::dtor", state_->GetErrorState()); |
| 2559 RestoreCurrentTextureBindings(state_, target_); | 2567 RestoreCurrentTextureBindings(state_, target_, 0); |
| 2568 state_->RestoreActiveTexture(); | |
| 2560 } | 2569 } |
| 2561 | 2570 |
| 2562 ScopedRenderBufferBinder::ScopedRenderBufferBinder(ContextState* state, | 2571 ScopedRenderBufferBinder::ScopedRenderBufferBinder(ContextState* state, |
| 2563 GLuint id) | 2572 GLuint id) |
| 2564 : state_(state) { | 2573 : state_(state) { |
| 2565 ScopedGLErrorSuppressor suppressor( | 2574 ScopedGLErrorSuppressor suppressor( |
| 2566 "ScopedRenderBufferBinder::ctor", state_->GetErrorState()); | 2575 "ScopedRenderBufferBinder::ctor", state_->GetErrorState()); |
| 2567 glBindRenderbufferEXT(GL_RENDERBUFFER, id); | 2576 glBindRenderbufferEXT(GL_RENDERBUFFER, id); |
| 2568 } | 2577 } |
| 2569 | 2578 |
| (...skipping 5203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7773 | 7782 |
| 7774 if ((level > 0 && !feature_info_->IsWebGL2OrES3Context()) || | 7783 if ((level > 0 && !feature_info_->IsWebGL2OrES3Context()) || |
| 7775 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { | 7784 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { |
| 7776 LOCAL_SET_GL_ERROR( | 7785 LOCAL_SET_GL_ERROR( |
| 7777 GL_INVALID_VALUE, | 7786 GL_INVALID_VALUE, |
| 7778 name, "level out of range"); | 7787 name, "level out of range"); |
| 7779 return; | 7788 return; |
| 7780 } | 7789 } |
| 7781 | 7790 |
| 7782 if (texture_ref) | 7791 if (texture_ref) |
| 7783 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); | 7792 DoBindOrCopyTexImageIfNeeded(texture_ref->texture(), textarget, 0); |
| 7784 | 7793 |
| 7785 std::vector<GLenum> attachments; | 7794 std::vector<GLenum> attachments; |
| 7786 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 7795 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 7787 attachments.push_back(GL_DEPTH_ATTACHMENT); | 7796 attachments.push_back(GL_DEPTH_ATTACHMENT); |
| 7788 attachments.push_back(GL_STENCIL_ATTACHMENT); | 7797 attachments.push_back(GL_STENCIL_ATTACHMENT); |
| 7789 } else { | 7798 } else { |
| 7790 attachments.push_back(attachment); | 7799 attachments.push_back(attachment); |
| 7791 } | 7800 } |
| 7792 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); | 7801 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); |
| 7793 for (size_t ii = 0; ii < attachments.size(); ++ii) { | 7802 for (size_t ii = 0; ii < attachments.size(); ++ii) { |
| (...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9651 gl::GLImage* image) { | 9660 gl::GLImage* image) { |
| 9652 // Note: We update the state to COPIED prior to calling CopyTexImage() | 9661 // Note: We update the state to COPIED prior to calling CopyTexImage() |
| 9653 // as that allows the GLImage implemenatation to set it back to UNBOUND | 9662 // as that allows the GLImage implemenatation to set it back to UNBOUND |
| 9654 // and ensure that CopyTexImage() is called each time the texture is | 9663 // and ensure that CopyTexImage() is called each time the texture is |
| 9655 // used. | 9664 // used. |
| 9656 texture->SetLevelImageState(textarget, 0, Texture::COPIED); | 9665 texture->SetLevelImageState(textarget, 0, Texture::COPIED); |
| 9657 bool rv = image->CopyTexImage(textarget); | 9666 bool rv = image->CopyTexImage(textarget); |
| 9658 DCHECK(rv) << "CopyTexImage() failed"; | 9667 DCHECK(rv) << "CopyTexImage() failed"; |
| 9659 } | 9668 } |
| 9660 | 9669 |
| 9661 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, | 9670 bool GLES2DecoderImpl::DoBindOrCopyTexImageIfNeeded(Texture* texture, |
| 9662 GLenum textarget) { | 9671 GLenum textarget, |
| 9672 GLuint texture_unit) { | |
| 9663 // Image is already in use if texture is attached to a framebuffer. | 9673 // Image is already in use if texture is attached to a framebuffer. |
| 9664 if (texture && !texture->IsAttachedToFramebuffer()) { | 9674 if (texture && !texture->IsAttachedToFramebuffer()) { |
| 9665 Texture::ImageState image_state; | 9675 Texture::ImageState image_state; |
| 9666 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); | 9676 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); |
| 9667 if (image && image_state == Texture::UNBOUND) { | 9677 if (image && image_state == Texture::UNBOUND) { |
| 9668 ScopedGLErrorSuppressor suppressor( | 9678 ScopedGLErrorSuppressor suppressor( |
| 9669 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 9679 "GLES2DecoderImpl::DoBindOrCopyTexImageIfNeeded", GetErrorState()); |
| 9680 if (texture_unit) | |
| 9681 glActiveTexture(texture_unit); | |
| 9670 glBindTexture(textarget, texture->service_id()); | 9682 glBindTexture(textarget, texture->service_id()); |
| 9671 DoCopyTexImage(texture, textarget, image); | 9683 if (image->BindTexImage(textarget)) { |
| 9672 RestoreCurrentTextureBindings(&state_, textarget); | 9684 image_state = Texture::BOUND; |
| 9685 } else { | |
| 9686 DoCopyTexImage(texture, textarget, image); | |
| 9687 } | |
| 9688 if (!texture_unit) | |
| 9689 RestoreCurrentTextureBindings(&state_, textarget, | |
| 9690 state_.active_texture_unit); | |
| 9691 return true; | |
| 9673 } | 9692 } |
| 9674 } | 9693 } |
| 9694 return false; | |
| 9675 } | 9695 } |
| 9676 | 9696 |
| 9677 void GLES2DecoderImpl::DoCopyBufferSubData(GLenum readtarget, | 9697 void GLES2DecoderImpl::DoCopyBufferSubData(GLenum readtarget, |
| 9678 GLenum writetarget, | 9698 GLenum writetarget, |
| 9679 GLintptr readoffset, | 9699 GLintptr readoffset, |
| 9680 GLintptr writeoffset, | 9700 GLintptr writeoffset, |
| 9681 GLsizeiptr size) { | 9701 GLsizeiptr size) { |
| 9682 // Just delegate it. Some validation is actually done before this. | 9702 // Just delegate it. Some validation is actually done before this. |
| 9683 buffer_manager()->ValidateAndDoCopyBufferSubData( | 9703 buffer_manager()->ValidateAndDoCopyBufferSubData( |
| 9684 &state_, readtarget, writetarget, readoffset, writeoffset, size); | 9704 &state_, readtarget, writetarget, readoffset, writeoffset, size); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9719 std::string("texture bound to texture unit ") + | 9739 std::string("texture bound to texture unit ") + |
| 9720 base::UintToString(texture_unit_index) + | 9740 base::UintToString(texture_unit_index) + |
| 9721 " is not renderable. It maybe non-power-of-2 and have" | 9741 " is not renderable. It maybe non-power-of-2 and have" |
| 9722 " incompatible texture filtering."); | 9742 " incompatible texture filtering."); |
| 9723 } | 9743 } |
| 9724 continue; | 9744 continue; |
| 9725 } | 9745 } |
| 9726 | 9746 |
| 9727 if (textarget != GL_TEXTURE_CUBE_MAP) { | 9747 if (textarget != GL_TEXTURE_CUBE_MAP) { |
| 9728 Texture* texture = texture_ref->texture(); | 9748 Texture* texture = texture_ref->texture(); |
| 9729 Texture::ImageState image_state; | 9749 if (DoBindOrCopyTexImageIfNeeded(texture, textarget, |
| 9730 gl::GLImage* image = | 9750 GL_TEXTURE0 + texture_unit_index)) { |
| 9731 texture->GetLevelImage(textarget, 0, &image_state); | |
| 9732 if (image && image_state == Texture::UNBOUND && | |
| 9733 !texture->IsAttachedToFramebuffer()) { | |
| 9734 ScopedGLErrorSuppressor suppressor( | |
| 9735 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); | |
| 9736 textures_set = true; | 9751 textures_set = true; |
| 9737 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | |
| 9738 DoCopyTexImage(texture, textarget, image); | |
| 9739 continue; | 9752 continue; |
| 9740 } | 9753 } |
| 9741 } | 9754 } |
| 9742 } | 9755 } |
| 9743 // else: should this be an error? | 9756 // else: should this be an error? |
| 9744 } | 9757 } |
| 9745 } | 9758 } |
| 9746 return !textures_set; | 9759 return !textures_set; |
| 9747 } | 9760 } |
| 9748 | 9761 |
| (...skipping 7166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16915 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); | 16928 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
| 16916 glBindTexture(dest_binding_target, dest_texture->service_id()); | 16929 glBindTexture(dest_binding_target, dest_texture->service_id()); |
| 16917 glTexImage2D(dest_target, dest_level, | 16930 glTexImage2D(dest_target, dest_level, |
| 16918 TextureManager::AdjustTexInternalFormat(feature_info_.get(), | 16931 TextureManager::AdjustTexInternalFormat(feature_info_.get(), |
| 16919 internal_format), | 16932 internal_format), |
| 16920 source_width, source_height, 0, | 16933 source_width, source_height, 0, |
| 16921 TextureManager::AdjustTexFormat(feature_info_.get(), format), | 16934 TextureManager::AdjustTexFormat(feature_info_.get(), format), |
| 16922 dest_type, nullptr); | 16935 dest_type, nullptr); |
| 16923 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); | 16936 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
| 16924 if (error != GL_NO_ERROR) { | 16937 if (error != GL_NO_ERROR) { |
| 16925 RestoreCurrentTextureBindings(&state_, dest_binding_target); | 16938 RestoreCurrentTextureBindings(&state_, dest_binding_target, |
| 16939 state_.active_texture_unit); | |
| 16926 return; | 16940 return; |
| 16927 } | 16941 } |
| 16928 | 16942 |
| 16929 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, dest_level, | 16943 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, dest_level, |
| 16930 internal_format, source_width, | 16944 internal_format, source_width, |
| 16931 source_height, 1, 0, format, dest_type, | 16945 source_height, 1, 0, format, dest_type, |
| 16932 gfx::Rect(source_width, source_height)); | 16946 gfx::Rect(source_width, source_height)); |
| 16933 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); | 16947 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); |
| 16934 } else { | 16948 } else { |
| 16935 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, | 16949 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, |
| 16936 dest_level, true); | 16950 dest_level, true); |
| 16937 } | 16951 } |
| 16938 | 16952 |
| 16939 // Try using GLImage::CopyTexImage when possible. | 16953 // Try using GLImage::CopyTexImage when possible. |
| 16940 bool unpack_premultiply_alpha_change = | 16954 bool unpack_premultiply_alpha_change = |
| 16941 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 16955 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| 16942 // TODO(qiankun.miao@intel.com): Support level > 0 for CopyTexImage. | 16956 // TODO(qiankun.miao@intel.com): Support level > 0 for CopyTexImage. |
| 16943 if (image && dest_level == 0 && !unpack_flip_y && | 16957 if (image && dest_level == 0 && !unpack_flip_y && |
| 16944 !unpack_premultiply_alpha_change) { | 16958 !unpack_premultiply_alpha_change) { |
| 16945 glBindTexture(dest_binding_target, dest_texture->service_id()); | 16959 glBindTexture(dest_binding_target, dest_texture->service_id()); |
| 16946 if (image->CopyTexImage(dest_target)) | 16960 if (image->CopyTexImage(dest_target)) |
| 16947 return; | 16961 return; |
| 16948 } | 16962 } |
| 16949 | 16963 |
| 16950 DoCopyTexImageIfNeeded(source_texture, source_target); | 16964 DoBindOrCopyTexImageIfNeeded(source_texture, source_target, 0); |
| 16951 | 16965 |
| 16952 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix | 16966 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix |
| 16953 // before presenting. | 16967 // before presenting. |
| 16954 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 16968 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 16955 if (GLStreamTextureImage* image = | 16969 if (GLStreamTextureImage* image = |
| 16956 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 16970 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
| 16957 source_level)) { | 16971 source_level)) { |
| 16958 GLfloat transform_matrix[16]; | 16972 GLfloat transform_matrix[16]; |
| 16959 image->GetTextureMatrix(transform_matrix); | 16973 image->GetTextureMatrix(transform_matrix); |
| 16960 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 16974 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17152 if (image && dest_level == 0 && !unpack_flip_y && | 17166 if (image && dest_level == 0 && !unpack_flip_y && |
| 17153 !unpack_premultiply_alpha_change) { | 17167 !unpack_premultiply_alpha_change) { |
| 17154 ScopedTextureBinder binder(&state_, dest_texture->service_id(), | 17168 ScopedTextureBinder binder(&state_, dest_texture->service_id(), |
| 17155 dest_binding_target); | 17169 dest_binding_target); |
| 17156 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), | 17170 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), |
| 17157 gfx::Rect(x, y, width, height))) { | 17171 gfx::Rect(x, y, width, height))) { |
| 17158 return; | 17172 return; |
| 17159 } | 17173 } |
| 17160 } | 17174 } |
| 17161 | 17175 |
| 17162 DoCopyTexImageIfNeeded(source_texture, source_target); | 17176 DoBindOrCopyTexImageIfNeeded(source_texture, source_target, 0); |
| 17163 | 17177 |
| 17164 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 17178 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 17165 // before presenting. | 17179 // before presenting. |
| 17166 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 17180 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 17167 if (GLStreamTextureImage* image = | 17181 if (GLStreamTextureImage* image = |
| 17168 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 17182 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
| 17169 source_level)) { | 17183 source_level)) { |
| 17170 GLfloat transform_matrix[16]; | 17184 GLfloat transform_matrix[16]; |
| 17171 image->GetTextureMatrix(transform_matrix); | 17185 image->GetTextureMatrix(transform_matrix); |
| 17172 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( | 17186 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17329 &source_size); | 17343 &source_size); |
| 17330 DCHECK(did_get_size); | 17344 DCHECK(did_get_size); |
| 17331 | 17345 |
| 17332 // Ensure that the glCompressedTexImage2D succeeds. | 17346 // Ensure that the glCompressedTexImage2D succeeds. |
| 17333 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); | 17347 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
| 17334 glCompressedTexImage2D(GL_TEXTURE_2D, 0, source_internal_format, | 17348 glCompressedTexImage2D(GL_TEXTURE_2D, 0, source_internal_format, |
| 17335 source_width, source_height, 0, source_size, | 17349 source_width, source_height, 0, source_size, |
| 17336 NULL); | 17350 NULL); |
| 17337 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); | 17351 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
| 17338 if (error != GL_NO_ERROR) { | 17352 if (error != GL_NO_ERROR) { |
| 17339 RestoreCurrentTextureBindings(&state_, dest_texture->target()); | 17353 RestoreCurrentTextureBindings(&state_, dest_texture->target(), |
| 17354 state_.active_texture_unit); | |
| 17340 return; | 17355 return; |
| 17341 } | 17356 } |
| 17342 | 17357 |
| 17343 texture_manager()->SetLevelInfo( | 17358 texture_manager()->SetLevelInfo( |
| 17344 dest_texture_ref, dest_texture->target(), 0, source_internal_format, | 17359 dest_texture_ref, dest_texture->target(), 0, source_internal_format, |
| 17345 source_width, source_height, 1, 0, source_internal_format, | 17360 source_width, source_height, 1, 0, source_internal_format, |
| 17346 source_type, gfx::Rect(source_width, source_height)); | 17361 source_type, gfx::Rect(source_width, source_height)); |
| 17347 } else { | 17362 } else { |
| 17348 texture_manager()->SetLevelCleared( | 17363 texture_manager()->SetLevelCleared( |
| 17349 dest_texture_ref, dest_texture->target(), 0, true); | 17364 dest_texture_ref, dest_texture->target(), 0, true); |
| 17350 } | 17365 } |
| 17351 | 17366 |
| 17352 if (image->CopyTexImage(dest_texture->target())) | 17367 if (image->CopyTexImage(dest_texture->target())) |
| 17353 return; | 17368 return; |
| 17354 } | 17369 } |
| 17355 | 17370 |
| 17356 TRACE_EVENT0( | 17371 TRACE_EVENT0( |
| 17357 "gpu", | 17372 "gpu", |
| 17358 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback"); | 17373 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback"); |
| 17359 | 17374 |
| 17360 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); | 17375 DoBindOrCopyTexImageIfNeeded(source_texture, source_texture->target(), 0); |
| 17361 | 17376 |
| 17362 // As a fallback, copy into a non-compressed GL_RGBA texture. | 17377 // As a fallback, copy into a non-compressed GL_RGBA texture. |
| 17363 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); | 17378 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
| 17364 glTexImage2D(dest_texture->target(), 0, GL_RGBA, source_width, source_height, | 17379 glTexImage2D(dest_texture->target(), 0, GL_RGBA, source_width, source_height, |
| 17365 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 17380 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| 17366 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); | 17381 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
| 17367 if (error != GL_NO_ERROR) { | 17382 if (error != GL_NO_ERROR) { |
| 17368 RestoreCurrentTextureBindings(&state_, dest_texture->target()); | 17383 RestoreCurrentTextureBindings(&state_, dest_texture->target(), |
| 17384 state_.active_texture_unit); | |
| 17369 return; | 17385 return; |
| 17370 } | 17386 } |
| 17371 | 17387 |
| 17372 texture_manager()->SetLevelInfo( | 17388 texture_manager()->SetLevelInfo( |
| 17373 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, | 17389 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, |
| 17374 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 17390 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 17375 gfx::Rect(source_width, source_height)); | 17391 gfx::Rect(source_width, source_height)); |
| 17376 | 17392 |
| 17377 copy_texture_CHROMIUM_->DoCopyTexture( | 17393 copy_texture_CHROMIUM_->DoCopyTexture( |
| 17378 this, source_texture->target(), source_texture->service_id(), 0, | 17394 this, source_texture->target(), source_texture->service_id(), 0, |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17676 GLenum target, | 17692 GLenum target, |
| 17677 GLuint client_id) { | 17693 GLuint client_id) { |
| 17678 TextureRef* texture_ref = GetTexture(client_id); | 17694 TextureRef* texture_ref = GetTexture(client_id); |
| 17679 if (!texture_ref) { | 17695 if (!texture_ref) { |
| 17680 GLuint service_id; | 17696 GLuint service_id; |
| 17681 glGenTextures(1, &service_id); | 17697 glGenTextures(1, &service_id); |
| 17682 DCHECK_NE(0u, service_id); | 17698 DCHECK_NE(0u, service_id); |
| 17683 texture_ref = CreateTexture(client_id, service_id); | 17699 texture_ref = CreateTexture(client_id, service_id); |
| 17684 texture_manager()->SetTarget(texture_ref, target); | 17700 texture_manager()->SetTarget(texture_ref, target); |
| 17685 glBindTexture(target, service_id); | 17701 glBindTexture(target, service_id); |
| 17686 RestoreCurrentTextureBindings(&state_, target); | 17702 RestoreCurrentTextureBindings(&state_, target, state_.active_texture_unit); |
| 17687 } | 17703 } |
| 17688 } | 17704 } |
| 17689 | 17705 |
| 17690 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL( | 17706 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL( |
| 17691 GLenum target, | 17707 GLenum target, |
| 17692 GLuint client_id, | 17708 GLuint client_id, |
| 17693 const volatile GLbyte* data) { | 17709 const volatile GLbyte* data) { |
| 17694 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", | 17710 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", |
| 17695 "context", logger_.GetLogPrefix(), | 17711 "context", logger_.GetLogPrefix(), |
| 17696 "mailbox[0]", static_cast<unsigned char>(data[0])); | 17712 "mailbox[0]", static_cast<unsigned char>(data[0])); |
| (...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19725 } | 19741 } |
| 19726 | 19742 |
| 19727 // Include the auto-generated part of this file. We split this because it means | 19743 // Include the auto-generated part of this file. We split this because it means |
| 19728 // we can easily edit the non-auto generated parts right here in this file | 19744 // we can easily edit the non-auto generated parts right here in this file |
| 19729 // instead of having to edit some template or the code generator. | 19745 // instead of having to edit some template or the code generator. |
| 19730 #include "base/macros.h" | 19746 #include "base/macros.h" |
| 19731 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19747 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19732 | 19748 |
| 19733 } // namespace gles2 | 19749 } // namespace gles2 |
| 19734 } // namespace gpu | 19750 } // namespace gpu |
| OLD | NEW |