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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 DecoderTextureState* texture_state, | 1932 DecoderTextureState* texture_state, |
1933 ContextState* state, | 1933 ContextState* state, |
1934 DecoderFramebufferState* framebuffer_state, | 1934 DecoderFramebufferState* framebuffer_state, |
1935 const char* function_name, | 1935 const char* function_name, |
1936 const DoTexImageArguments& args) { | 1936 const DoTexImageArguments& args) { |
1937 TextureRef* texture_ref; | 1937 TextureRef* texture_ref; |
1938 if (!ValidateTexImage(state, function_name, args, &texture_ref)) { | 1938 if (!ValidateTexImage(state, function_name, args, &texture_ref)) { |
1939 return; | 1939 return; |
1940 } | 1940 } |
1941 | 1941 |
1942 if (texture_state->force_cube_map_positive_x_allocation) { | |
1943 DoTexImage2DCubeMapPositiveXIfNeeded(texture_state, state->GetErrorState(), | |
1944 framebuffer_state, function_name, | |
1945 texture_ref, args); | |
1946 } | |
1947 | |
1948 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, | 1942 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, |
1949 function_name, texture_ref, args); | 1943 function_name, texture_ref, args); |
1950 } | 1944 } |
1951 | 1945 |
1952 GLenum TextureManager::AdjustTexFormat(GLenum format) const { | 1946 GLenum TextureManager::AdjustTexFormat(GLenum format) const { |
1953 // TODO(bajones): GLES 3 allows for internal format and format to differ. | 1947 // TODO(bajones): GLES 3 allows for internal format and format to differ. |
1954 // This logic may need to change as a result. | 1948 // This logic may need to change as a result. |
1955 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { | 1949 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { |
1956 if (format == GL_SRGB_EXT) | 1950 if (format == GL_SRGB_EXT) |
1957 return GL_RGB; | 1951 return GL_RGB; |
1958 if (format == GL_SRGB_ALPHA_EXT) | 1952 if (format == GL_SRGB_ALPHA_EXT) |
1959 return GL_RGBA; | 1953 return GL_RGBA; |
1960 } | 1954 } |
1961 return format; | 1955 return format; |
1962 } | 1956 } |
1963 | 1957 |
1964 // Nexus 5 crashes on allocating a cube map texture bound to FBO, if | |
1965 // the CUBE_MAP_POSITIVE_X texture is not allocated yet. | |
1966 void TextureManager::DoTexImage2DCubeMapPositiveXIfNeeded( | |
1967 DecoderTextureState* texture_state, | |
1968 ErrorState* error_state, | |
1969 DecoderFramebufferState* framebuffer_state, | |
1970 const char* function_name, | |
1971 TextureRef* texture_ref, | |
1972 const DoTexImageArguments& args) { | |
1973 switch (args.target) { | |
1974 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | |
1975 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | |
1976 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | |
1977 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | |
1978 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | |
1979 break; | |
1980 default: | |
1981 return; | |
1982 } | |
1983 | |
1984 // ValidateTexImage is passed already. | |
1985 Texture* texture = texture_ref->texture(); | |
1986 int width = 0; | |
1987 int height = 0; | |
1988 bool positive_x_level_defined = texture->GetLevelSize( | |
1989 GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level, &width, &height, nullptr); | |
1990 if (!positive_x_level_defined) { | |
1991 DoTexImageArguments positive_x_args = args; | |
1992 positive_x_args.target = GL_TEXTURE_CUBE_MAP_POSITIVE_X; | |
1993 positive_x_args.pixels = nullptr; | |
1994 positive_x_args.pixels_size = 0; | |
1995 DoTexImage(texture_state, error_state, framebuffer_state, function_name, | |
1996 texture_ref, positive_x_args); | |
1997 } | |
1998 } | |
1999 | |
2000 void TextureManager::DoTexImage( | 1958 void TextureManager::DoTexImage( |
2001 DecoderTextureState* texture_state, | 1959 DecoderTextureState* texture_state, |
2002 ErrorState* error_state, | 1960 ErrorState* error_state, |
2003 DecoderFramebufferState* framebuffer_state, | 1961 DecoderFramebufferState* framebuffer_state, |
2004 const char* function_name, | 1962 const char* function_name, |
2005 TextureRef* texture_ref, | 1963 TextureRef* texture_ref, |
2006 const DoTexImageArguments& args) { | 1964 const DoTexImageArguments& args) { |
2007 Texture* texture = texture_ref->texture(); | 1965 Texture* texture = texture_ref->texture(); |
2008 GLsizei tex_width = 0; | 1966 GLsizei tex_width = 0; |
2009 GLsizei tex_height = 0; | 1967 GLsizei tex_height = 0; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 // The link to the memory tracking |client_id| is given a higher importance | 2099 // The link to the memory tracking |client_id| is given a higher importance |
2142 // than other refs. | 2100 // than other refs. |
2143 if (ref == ref->texture()->memory_tracking_ref_) | 2101 if (ref == ref->texture()->memory_tracking_ref_) |
2144 importance = 2; | 2102 importance = 2; |
2145 | 2103 |
2146 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2104 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
2147 } | 2105 } |
2148 | 2106 |
2149 } // namespace gles2 | 2107 } // namespace gles2 |
2150 } // namespace gpu | 2108 } // namespace gpu |
OLD | NEW |