| 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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 GLenum target, | 1029 GLenum target, |
| 1030 const volatile GLbyte* data); | 1030 const volatile GLbyte* data); |
| 1031 | 1031 |
| 1032 void EnsureTextureForClientId(GLenum target, GLuint client_id); | 1032 void EnsureTextureForClientId(GLenum target, GLuint client_id); |
| 1033 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); | 1033 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); |
| 1034 void DoCreateAndConsumeTextureINTERNAL(GLenum target, | 1034 void DoCreateAndConsumeTextureINTERNAL(GLenum target, |
| 1035 GLuint client_id, | 1035 GLuint client_id, |
| 1036 const volatile GLbyte* key); | 1036 const volatile GLbyte* key); |
| 1037 void DoApplyScreenSpaceAntialiasingCHROMIUM(); | 1037 void DoApplyScreenSpaceAntialiasingCHROMIUM(); |
| 1038 | 1038 |
| 1039 void DoBindTexImage2DCHROMIUM( | 1039 void DoBindTexImage2DCHROMIUM(GLenum target, GLint image_id, GLint fence_id); |
| 1040 GLenum target, | 1040 void DoReleaseTexImage2DCHROMIUM(GLenum target, GLint image_id); |
| 1041 GLint image_id); | |
| 1042 void DoReleaseTexImage2DCHROMIUM( | |
| 1043 GLenum target, | |
| 1044 GLint image_id); | |
| 1045 | 1041 |
| 1046 void DoTraceEndCHROMIUM(void); | 1042 void DoTraceEndCHROMIUM(void); |
| 1047 | 1043 |
| 1048 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); | 1044 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); |
| 1049 | 1045 |
| 1050 void DoLoseContextCHROMIUM(GLenum current, GLenum other); | 1046 void DoLoseContextCHROMIUM(GLenum current, GLenum other); |
| 1051 | 1047 |
| 1052 void DoFlushDriverCachesCHROMIUM(void); | 1048 void DoFlushDriverCachesCHROMIUM(void); |
| 1053 | 1049 |
| 1054 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 1050 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 : GL_TEXTURE_2D; | 2690 : GL_TEXTURE_2D; |
| 2695 } | 2691 } |
| 2696 | 2692 |
| 2697 bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, | 2693 bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, |
| 2698 GLenum format, | 2694 GLenum format, |
| 2699 bool zero) { | 2695 bool zero) { |
| 2700 gfx::BufferFormat buffer_format = gfx::BufferFormat::RGBA_8888; | 2696 gfx::BufferFormat buffer_format = gfx::BufferFormat::RGBA_8888; |
| 2701 scoped_refptr<gl::GLImage> image = | 2697 scoped_refptr<gl::GLImage> image = |
| 2702 decoder_->GetContextGroup()->image_factory()->CreateAnonymousImage( | 2698 decoder_->GetContextGroup()->image_factory()->CreateAnonymousImage( |
| 2703 size, buffer_format, format); | 2699 size, buffer_format, format); |
| 2704 if (!image || !image->BindTexImage(Target())) | 2700 if (!image || !image->BindTexImage(Target(), nullptr)) |
| 2705 return false; | 2701 return false; |
| 2706 | 2702 |
| 2707 image_ = image; | 2703 image_ = image; |
| 2708 decoder_->texture_manager()->SetLevelInfo( | 2704 decoder_->texture_manager()->SetLevelInfo( |
| 2709 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), | 2705 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), |
| 2710 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), | 2706 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), |
| 2711 GL_UNSIGNED_BYTE, gfx::Rect(size)); | 2707 GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 2712 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, | 2708 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, |
| 2713 image_.get(), Texture::BOUND); | 2709 image_.get(), Texture::BOUND); |
| 2714 | 2710 |
| (...skipping 13696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16411 length ? std::string(marker, length) : std::string(marker)); | 16407 length ? std::string(marker, length) : std::string(marker)); |
| 16412 } | 16408 } |
| 16413 | 16409 |
| 16414 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 16410 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
| 16415 GLsizei /*length*/, const GLchar* /*marker*/) { | 16411 GLsizei /*length*/, const GLchar* /*marker*/) { |
| 16416 } | 16412 } |
| 16417 | 16413 |
| 16418 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { | 16414 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
| 16419 } | 16415 } |
| 16420 | 16416 |
| 16421 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( | 16417 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM(GLenum target, |
| 16422 GLenum target, GLint image_id) { | 16418 GLint image_id, |
| 16419 GLint fence_id) { |
| 16423 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); | 16420 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); |
| 16424 | 16421 |
| 16425 if (target == GL_TEXTURE_CUBE_MAP) { | 16422 if (target == GL_TEXTURE_CUBE_MAP) { |
| 16426 LOCAL_SET_GL_ERROR( | 16423 LOCAL_SET_GL_ERROR( |
| 16427 GL_INVALID_ENUM, | 16424 GL_INVALID_ENUM, |
| 16428 "glBindTexImage2DCHROMIUM", "invalid target"); | 16425 "glBindTexImage2DCHROMIUM", "invalid target"); |
| 16429 return; | 16426 return; |
| 16430 } | 16427 } |
| 16431 | 16428 |
| 16432 // Default target might be conceptually valid, but disallow it to avoid | 16429 // Default target might be conceptually valid, but disallow it to avoid |
| 16433 // accidents. | 16430 // accidents. |
| 16434 TextureRef* texture_ref = | 16431 TextureRef* texture_ref = |
| 16435 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 16432 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
| 16436 if (!texture_ref) { | 16433 if (!texture_ref) { |
| 16437 LOCAL_SET_GL_ERROR( | 16434 LOCAL_SET_GL_ERROR( |
| 16438 GL_INVALID_OPERATION, | 16435 GL_INVALID_OPERATION, |
| 16439 "glBindTexImage2DCHROMIUM", "no texture bound"); | 16436 "glBindTexImage2DCHROMIUM", "no texture bound"); |
| 16440 return; | 16437 return; |
| 16441 } | 16438 } |
| 16442 | 16439 |
| 16443 gl::GLImage* image = image_manager()->LookupImage(image_id); | 16440 gl::GLImage* image = image_manager()->LookupImage(image_id); |
| 16444 if (!image) { | 16441 if (!image) { |
| 16445 LOCAL_SET_GL_ERROR( | 16442 LOCAL_SET_GL_ERROR( |
| 16446 GL_INVALID_OPERATION, | 16443 GL_INVALID_OPERATION, |
| 16447 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); | 16444 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); |
| 16448 return; | 16445 return; |
| 16449 } | 16446 } |
| 16450 | 16447 |
| 16448 gl::GLFence* fence = nullptr; |
| 16449 if (fence_id) { |
| 16450 fence = fence_manager()->LookupFence(fence_id); |
| 16451 if (!fence) { |
| 16452 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindTexImage2DCHROMIUM", |
| 16453 "no fence found with the given ID"); |
| 16454 return; |
| 16455 } |
| 16456 } |
| 16457 |
| 16451 Texture::ImageState image_state = Texture::UNBOUND; | 16458 Texture::ImageState image_state = Texture::UNBOUND; |
| 16452 | 16459 |
| 16453 { | 16460 { |
| 16454 ScopedGLErrorSuppressor suppressor( | 16461 ScopedGLErrorSuppressor suppressor( |
| 16455 "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM", GetErrorState()); | 16462 "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM", GetErrorState()); |
| 16456 | 16463 |
| 16457 // Note: We fallback to using CopyTexImage() before the texture is used | 16464 // Note: We fallback to using CopyTexImage() before the texture is used |
| 16458 // when BindTexImage() fails. | 16465 // when BindTexImage() fails. |
| 16459 if (image->BindTexImage(target)) | 16466 if (image->BindTexImage(target, fence)) |
| 16460 image_state = Texture::BOUND; | 16467 image_state = Texture::BOUND; |
| 16461 } | 16468 } |
| 16462 | 16469 |
| 16470 DLOG_IF(WARNING, fence && image_state != Texture::BOUND) |
| 16471 << "BindTexImage2D fence ignored by CopyTexImage() fallback"; |
| 16472 |
| 16463 gfx::Size size = image->GetSize(); | 16473 gfx::Size size = image->GetSize(); |
| 16464 GLenum internalformat = image->GetInternalFormat(); | 16474 GLenum internalformat = image->GetInternalFormat(); |
| 16465 texture_manager()->SetLevelInfo( | 16475 texture_manager()->SetLevelInfo( |
| 16466 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, | 16476 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, |
| 16467 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); | 16477 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 16468 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); | 16478 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); |
| 16469 } | 16479 } |
| 16470 | 16480 |
| 16471 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( | 16481 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM(GLenum target, |
| 16472 GLenum target, GLint image_id) { | 16482 GLint image_id) { |
| 16473 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); | 16483 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); |
| 16474 | 16484 |
| 16475 // Default target might be conceptually valid, but disallow it to avoid | 16485 // Default target might be conceptually valid, but disallow it to avoid |
| 16476 // accidents. | 16486 // accidents. |
| 16477 TextureRef* texture_ref = | 16487 TextureRef* texture_ref = |
| 16478 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 16488 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
| 16479 if (!texture_ref) { | 16489 if (!texture_ref) { |
| 16480 LOCAL_SET_GL_ERROR( | 16490 LOCAL_SET_GL_ERROR( |
| 16481 GL_INVALID_OPERATION, | 16491 GL_INVALID_OPERATION, |
| 16482 "glReleaseTexImage2DCHROMIUM", "no texture bound"); | 16492 "glReleaseTexImage2DCHROMIUM", "no texture bound"); |
| (...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18258 } | 18268 } |
| 18259 | 18269 |
| 18260 // Include the auto-generated part of this file. We split this because it means | 18270 // Include the auto-generated part of this file. We split this because it means |
| 18261 // we can easily edit the non-auto generated parts right here in this file | 18271 // we can easily edit the non-auto generated parts right here in this file |
| 18262 // instead of having to edit some template or the code generator. | 18272 // instead of having to edit some template or the code generator. |
| 18263 #include "base/macros.h" | 18273 #include "base/macros.h" |
| 18264 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18274 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18265 | 18275 |
| 18266 } // namespace gles2 | 18276 } // namespace gles2 |
| 18267 } // namespace gpu | 18277 } // namespace gpu |
| OLD | NEW |