| 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 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2832 | 2832 |
| 2833 bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, | 2833 bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size, |
| 2834 GLenum format, | 2834 GLenum format, |
| 2835 bool zero) { | 2835 bool zero) { |
| 2836 DCHECK(format == GL_RGB || format == GL_RGBA); | 2836 DCHECK(format == GL_RGB || format == GL_RGBA); |
| 2837 scoped_refptr<gl::GLImage> image = | 2837 scoped_refptr<gl::GLImage> image = |
| 2838 decoder_->GetContextGroup()->image_factory()->CreateAnonymousImage( | 2838 decoder_->GetContextGroup()->image_factory()->CreateAnonymousImage( |
| 2839 size, | 2839 size, |
| 2840 format == GL_RGB ? gfx::BufferFormat::RGBX_8888 | 2840 format == GL_RGB ? gfx::BufferFormat::RGBX_8888 |
| 2841 : gfx::BufferFormat::RGBA_8888, | 2841 : gfx::BufferFormat::RGBA_8888, |
| 2842 format); | 2842 gfx::BufferUsage::SCANOUT, format); |
| 2843 if (!image || !image->BindTexImage(Target())) | 2843 if (!image || !image->BindTexImage(Target())) |
| 2844 return false; | 2844 return false; |
| 2845 | 2845 |
| 2846 image_ = image; | 2846 image_ = image; |
| 2847 decoder_->texture_manager()->SetLevelInfo( | 2847 decoder_->texture_manager()->SetLevelInfo( |
| 2848 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), | 2848 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), |
| 2849 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), | 2849 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), |
| 2850 GL_UNSIGNED_BYTE, gfx::Rect(size)); | 2850 GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 2851 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, | 2851 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, |
| 2852 image_.get(), Texture::BOUND); | 2852 image_.get(), Texture::BOUND); |
| (...skipping 8017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10870 iparams[0] = texture->swizzle_b(); | 10870 iparams[0] = texture->swizzle_b(); |
| 10871 } | 10871 } |
| 10872 return; | 10872 return; |
| 10873 case GL_TEXTURE_SWIZZLE_A: | 10873 case GL_TEXTURE_SWIZZLE_A: |
| 10874 if (fparams) { | 10874 if (fparams) { |
| 10875 fparams[0] = static_cast<GLfloat>(texture->swizzle_a()); | 10875 fparams[0] = static_cast<GLfloat>(texture->swizzle_a()); |
| 10876 } else { | 10876 } else { |
| 10877 iparams[0] = texture->swizzle_a(); | 10877 iparams[0] = texture->swizzle_a(); |
| 10878 } | 10878 } |
| 10879 return; | 10879 return; |
| 10880 case GL_TEXTURE_BUFFER_USAGE_CHROMIUM: |
| 10881 if (fparams) { |
| 10882 fparams[0] = static_cast<GLfloat>(texture->buffer_usage()); |
| 10883 } else { |
| 10884 iparams[0] = texture->buffer_usage(); |
| 10885 } |
| 10886 return; |
| 10880 default: | 10887 default: |
| 10881 break; | 10888 break; |
| 10882 } | 10889 } |
| 10883 if (fparams) { | 10890 if (fparams) { |
| 10884 glGetTexParameterfv(target, pname, fparams); | 10891 glGetTexParameterfv(target, pname, fparams); |
| 10885 } else { | 10892 } else { |
| 10886 glGetTexParameteriv(target, pname, iparams); | 10893 glGetTexParameteriv(target, pname, iparams); |
| 10887 } | 10894 } |
| 10888 } | 10895 } |
| 10889 | 10896 |
| (...skipping 6495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17385 Texture* texture = texture_ref->texture(); | 17392 Texture* texture = texture_ref->texture(); |
| 17386 if (texture->IsAttachedToFramebuffer()) { | 17393 if (texture->IsAttachedToFramebuffer()) { |
| 17387 framebuffer_state_.clear_state_dirty = true; | 17394 framebuffer_state_.clear_state_dirty = true; |
| 17388 } | 17395 } |
| 17389 if (texture->IsImmutable()) { | 17396 if (texture->IsImmutable()) { |
| 17390 LOCAL_SET_GL_ERROR( | 17397 LOCAL_SET_GL_ERROR( |
| 17391 GL_INVALID_OPERATION, function_name, "texture is immutable"); | 17398 GL_INVALID_OPERATION, function_name, "texture is immutable"); |
| 17392 return; | 17399 return; |
| 17393 } | 17400 } |
| 17394 | 17401 |
| 17402 if (texture->buffer_usage() != GL_NONE) { |
| 17403 ScopedGLErrorSuppressor suppressor("GLES2CmdDecoder::TexStorageImpl", |
| 17404 state_.GetErrorState()); |
| 17405 gfx::Size size(width, height); |
| 17406 gfx::BufferFormat buffer_format; |
| 17407 GLint real_internal_format; |
| 17408 switch (internal_format) { |
| 17409 case GL_RGBA8_OES: |
| 17410 buffer_format = gfx::BufferFormat::RGBA_8888; |
| 17411 real_internal_format = GL_RGBA; |
| 17412 break; |
| 17413 case GL_BGRA8_EXT: |
| 17414 buffer_format = gfx::BufferFormat::BGRA_8888; |
| 17415 real_internal_format = GL_BGRA_EXT; |
| 17416 break; |
| 17417 case GL_RGBA16F_EXT: |
| 17418 buffer_format = gfx::BufferFormat::RGBA_F16; |
| 17419 real_internal_format = GL_RGBA; |
| 17420 break; |
| 17421 default: |
| 17422 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, function_name, |
| 17423 "Invalid buffer format"); |
| 17424 return; |
| 17425 } |
| 17426 |
| 17427 if (levels != 1) { |
| 17428 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 17429 "Levels != 1 for buffer"); |
| 17430 return; |
| 17431 } |
| 17432 if (depth > 1) { |
| 17433 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 17434 "depth > 1 for buffer"); |
| 17435 return; |
| 17436 } |
| 17437 DCHECK_EQ(GL_TEXTURE_BUFFER_SCANOUT_CHROMIUM, texture->buffer_usage()); |
| 17438 |
| 17439 gfx::BufferUsage buffer_usage = gfx::BufferUsage::SCANOUT; |
| 17440 scoped_refptr<gl::GLImage> image = |
| 17441 GetContextGroup()->image_factory()->CreateAnonymousImage( |
| 17442 gfx::Size(width, height), buffer_format, buffer_usage, |
| 17443 real_internal_format); |
| 17444 if (!image || !image->BindTexImage(target)) { |
| 17445 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 17446 "Cannot create GL Image"); |
| 17447 return; |
| 17448 } |
| 17449 |
| 17450 texture_manager()->SetLevelInfo( |
| 17451 texture_ref, target, 0, image->GetInternalFormat(), width, height, 1, 0, |
| 17452 image->GetInternalFormat(), GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 17453 texture_manager()->SetLevelImage(texture_ref, target, 0, image.get(), |
| 17454 Texture::BOUND); |
| 17455 return; |
| 17456 } |
| 17457 |
| 17395 GLenum format = TextureManager::ExtractFormatFromStorageFormat( | 17458 GLenum format = TextureManager::ExtractFormatFromStorageFormat( |
| 17396 internal_format); | 17459 internal_format); |
| 17397 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); | 17460 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); |
| 17398 | 17461 |
| 17399 std::vector<int32_t> level_size(levels); | 17462 std::vector<int32_t> level_size(levels); |
| 17400 { | 17463 { |
| 17401 GLsizei level_width = width; | 17464 GLsizei level_width = width; |
| 17402 GLsizei level_height = height; | 17465 GLsizei level_height = height; |
| 17403 GLsizei level_depth = depth; | 17466 GLsizei level_depth = depth; |
| 17404 base::CheckedNumeric<uint32_t> estimated_size(0); | 17467 base::CheckedNumeric<uint32_t> estimated_size(0); |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19704 } | 19767 } |
| 19705 | 19768 |
| 19706 // Include the auto-generated part of this file. We split this because it means | 19769 // Include the auto-generated part of this file. We split this because it means |
| 19707 // we can easily edit the non-auto generated parts right here in this file | 19770 // we can easily edit the non-auto generated parts right here in this file |
| 19708 // instead of having to edit some template or the code generator. | 19771 // instead of having to edit some template or the code generator. |
| 19709 #include "base/macros.h" | 19772 #include "base/macros.h" |
| 19710 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19773 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19711 | 19774 |
| 19712 } // namespace gles2 | 19775 } // namespace gles2 |
| 19713 } // namespace gpu | 19776 } // namespace gpu |
| OLD | NEW |