| 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 GLenum target, | 1008 GLenum target, |
| 1009 const volatile GLbyte* data); | 1009 const volatile GLbyte* data); |
| 1010 | 1010 |
| 1011 void EnsureTextureForClientId(GLenum target, GLuint client_id); | 1011 void EnsureTextureForClientId(GLenum target, GLuint client_id); |
| 1012 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); | 1012 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); |
| 1013 void DoCreateAndConsumeTextureINTERNAL(GLenum target, | 1013 void DoCreateAndConsumeTextureINTERNAL(GLenum target, |
| 1014 GLuint client_id, | 1014 GLuint client_id, |
| 1015 const volatile GLbyte* key); | 1015 const volatile GLbyte* key); |
| 1016 void DoApplyScreenSpaceAntialiasingCHROMIUM(); | 1016 void DoApplyScreenSpaceAntialiasingCHROMIUM(); |
| 1017 | 1017 |
| 1018 void DoBindTexImage2DCHROMIUM( | 1018 void DoBindTexImage2DCHROMIUM(GLenum target, GLint image_id, GLint fence_id); |
| 1019 GLenum target, | 1019 void DoReleaseTexImage2DCHROMIUM(GLenum target, GLint image_id); |
| 1020 GLint image_id); | |
| 1021 void DoReleaseTexImage2DCHROMIUM( | |
| 1022 GLenum target, | |
| 1023 GLint image_id); | |
| 1024 | 1020 |
| 1025 void DoTraceEndCHROMIUM(void); | 1021 void DoTraceEndCHROMIUM(void); |
| 1026 | 1022 |
| 1027 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); | 1023 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); |
| 1028 | 1024 |
| 1029 void DoLoseContextCHROMIUM(GLenum current, GLenum other); | 1025 void DoLoseContextCHROMIUM(GLenum current, GLenum other); |
| 1030 | 1026 |
| 1031 void DoFlushDriverCachesCHROMIUM(void); | 1027 void DoFlushDriverCachesCHROMIUM(void); |
| 1032 | 1028 |
| 1033 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 1029 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
| (...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2718 : GL_TEXTURE_2D; | 2714 : GL_TEXTURE_2D; |
| 2719 } | 2715 } |
| 2720 | 2716 |
| 2721 bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, | 2717 bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, |
| 2722 GLenum format, | 2718 GLenum format, |
| 2723 bool zero) { | 2719 bool zero) { |
| 2724 gfx::BufferFormat buffer_format = gfx::BufferFormat::RGBA_8888; | 2720 gfx::BufferFormat buffer_format = gfx::BufferFormat::RGBA_8888; |
| 2725 scoped_refptr<gl::GLImage> image = | 2721 scoped_refptr<gl::GLImage> image = |
| 2726 decoder_->GetContextGroup()->image_factory()->CreateAnonymousImage( | 2722 decoder_->GetContextGroup()->image_factory()->CreateAnonymousImage( |
| 2727 size, buffer_format, format); | 2723 size, buffer_format, format); |
| 2728 if (!image || !image->BindTexImage(Target())) | 2724 if (!image || !image->BindTexImage(Target(), nullptr)) |
| 2729 return false; | 2725 return false; |
| 2730 | 2726 |
| 2731 image_ = image; | 2727 image_ = image; |
| 2732 decoder_->texture_manager()->SetLevelInfo( | 2728 decoder_->texture_manager()->SetLevelInfo( |
| 2733 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), | 2729 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), |
| 2734 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), | 2730 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), |
| 2735 GL_UNSIGNED_BYTE, gfx::Rect(size)); | 2731 GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 2736 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, | 2732 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, |
| 2737 image_.get(), Texture::BOUND); | 2733 image_.get(), Texture::BOUND); |
| 2738 | 2734 |
| (...skipping 14205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16944 length ? std::string(marker, length) : std::string(marker)); | 16940 length ? std::string(marker, length) : std::string(marker)); |
| 16945 } | 16941 } |
| 16946 | 16942 |
| 16947 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 16943 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
| 16948 GLsizei /*length*/, const GLchar* /*marker*/) { | 16944 GLsizei /*length*/, const GLchar* /*marker*/) { |
| 16949 } | 16945 } |
| 16950 | 16946 |
| 16951 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { | 16947 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
| 16952 } | 16948 } |
| 16953 | 16949 |
| 16954 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( | 16950 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM(GLenum target, |
| 16955 GLenum target, GLint image_id) { | 16951 GLint image_id, |
| 16952 GLint fence_id) { |
| 16956 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); | 16953 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); |
| 16957 | 16954 |
| 16958 if (target == GL_TEXTURE_CUBE_MAP) { | 16955 if (target == GL_TEXTURE_CUBE_MAP) { |
| 16959 LOCAL_SET_GL_ERROR( | 16956 LOCAL_SET_GL_ERROR( |
| 16960 GL_INVALID_ENUM, | 16957 GL_INVALID_ENUM, |
| 16961 "glBindTexImage2DCHROMIUM", "invalid target"); | 16958 "glBindTexImage2DCHROMIUM", "invalid target"); |
| 16962 return; | 16959 return; |
| 16963 } | 16960 } |
| 16964 | 16961 |
| 16965 // Default target might be conceptually valid, but disallow it to avoid | 16962 // Default target might be conceptually valid, but disallow it to avoid |
| 16966 // accidents. | 16963 // accidents. |
| 16967 TextureRef* texture_ref = | 16964 TextureRef* texture_ref = |
| 16968 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 16965 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
| 16969 if (!texture_ref) { | 16966 if (!texture_ref) { |
| 16970 LOCAL_SET_GL_ERROR( | 16967 LOCAL_SET_GL_ERROR( |
| 16971 GL_INVALID_OPERATION, | 16968 GL_INVALID_OPERATION, |
| 16972 "glBindTexImage2DCHROMIUM", "no texture bound"); | 16969 "glBindTexImage2DCHROMIUM", "no texture bound"); |
| 16973 return; | 16970 return; |
| 16974 } | 16971 } |
| 16975 | 16972 |
| 16976 gl::GLImage* image = image_manager()->LookupImage(image_id); | 16973 gl::GLImage* image = image_manager()->LookupImage(image_id); |
| 16977 if (!image) { | 16974 if (!image) { |
| 16978 LOCAL_SET_GL_ERROR( | 16975 LOCAL_SET_GL_ERROR( |
| 16979 GL_INVALID_OPERATION, | 16976 GL_INVALID_OPERATION, |
| 16980 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); | 16977 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); |
| 16981 return; | 16978 return; |
| 16982 } | 16979 } |
| 16983 | 16980 |
| 16981 gl::GLFence* fence = nullptr; |
| 16982 if (fence_id) { |
| 16983 fence = fence_manager()->LookupFence(fence_id); |
| 16984 if (!fence) { |
| 16985 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindTexImage2DCHROMIUM", |
| 16986 "no fence found with the given ID"); |
| 16987 return; |
| 16988 } |
| 16989 } |
| 16990 |
| 16984 Texture::ImageState image_state = Texture::UNBOUND; | 16991 Texture::ImageState image_state = Texture::UNBOUND; |
| 16985 | 16992 |
| 16986 { | 16993 { |
| 16987 ScopedGLErrorSuppressor suppressor( | 16994 ScopedGLErrorSuppressor suppressor( |
| 16988 "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM", GetErrorState()); | 16995 "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM", GetErrorState()); |
| 16989 | 16996 |
| 16990 // Note: We fallback to using CopyTexImage() before the texture is used | 16997 // Note: We fallback to using CopyTexImage() before the texture is used |
| 16991 // when BindTexImage() fails. | 16998 // when BindTexImage() fails. |
| 16992 if (image->BindTexImage(target)) | 16999 if (image->BindTexImage(target, fence)) |
| 16993 image_state = Texture::BOUND; | 17000 image_state = Texture::BOUND; |
| 16994 } | 17001 } |
| 16995 | 17002 |
| 17003 DLOG_IF(WARNING, fence && image_state != Texture::BOUND) |
| 17004 << "BindTexImage2D fence ignored by CopyTexImage() fallback"; |
| 17005 |
| 16996 gfx::Size size = image->GetSize(); | 17006 gfx::Size size = image->GetSize(); |
| 16997 GLenum internalformat = image->GetInternalFormat(); | 17007 GLenum internalformat = image->GetInternalFormat(); |
| 16998 texture_manager()->SetLevelInfo( | 17008 texture_manager()->SetLevelInfo( |
| 16999 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, | 17009 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, |
| 17000 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); | 17010 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 17001 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); | 17011 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); |
| 17002 } | 17012 } |
| 17003 | 17013 |
| 17004 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( | 17014 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM(GLenum target, |
| 17005 GLenum target, GLint image_id) { | 17015 GLint image_id) { |
| 17006 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); | 17016 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); |
| 17007 | 17017 |
| 17008 // Default target might be conceptually valid, but disallow it to avoid | 17018 // Default target might be conceptually valid, but disallow it to avoid |
| 17009 // accidents. | 17019 // accidents. |
| 17010 TextureRef* texture_ref = | 17020 TextureRef* texture_ref = |
| 17011 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 17021 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
| 17012 if (!texture_ref) { | 17022 if (!texture_ref) { |
| 17013 LOCAL_SET_GL_ERROR( | 17023 LOCAL_SET_GL_ERROR( |
| 17014 GL_INVALID_OPERATION, | 17024 GL_INVALID_OPERATION, |
| 17015 "glReleaseTexImage2DCHROMIUM", "no texture bound"); | 17025 "glReleaseTexImage2DCHROMIUM", "no texture bound"); |
| (...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18788 } | 18798 } |
| 18789 | 18799 |
| 18790 // Include the auto-generated part of this file. We split this because it means | 18800 // Include the auto-generated part of this file. We split this because it means |
| 18791 // we can easily edit the non-auto generated parts right here in this file | 18801 // we can easily edit the non-auto generated parts right here in this file |
| 18792 // instead of having to edit some template or the code generator. | 18802 // instead of having to edit some template or the code generator. |
| 18793 #include "base/macros.h" | 18803 #include "base/macros.h" |
| 18794 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18804 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18795 | 18805 |
| 18796 } // namespace gles2 | 18806 } // namespace gles2 |
| 18797 } // namespace gpu | 18807 } // namespace gpu |
| OLD | NEW |