OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/atomicops.h" | 15 #include "base/atomicops.h" |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #if defined(OS_MACOSX) | |
19 #include "base/mac/scoped_cftyperef.h" | |
20 #endif | |
18 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
20 #include "build/build_config.h" | 23 #include "build/build_config.h" |
21 #define GLES2_GPU_SERVICE 1 | 24 #define GLES2_GPU_SERVICE 1 |
22 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 25 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
23 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
24 #include "gpu/command_buffer/common/id_allocator.h" | 27 #include "gpu/command_buffer/common/id_allocator.h" |
25 #include "gpu/command_buffer/common/trace_event.h" | 28 #include "gpu/command_buffer/common/trace_event.h" |
26 #include "gpu/command_buffer/service/buffer_manager.h" | 29 #include "gpu/command_buffer/service/buffer_manager.h" |
27 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 30 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
28 #include "gpu/command_buffer/service/context_group.h" | 31 #include "gpu/command_buffer/service/context_group.h" |
29 #include "gpu/command_buffer/service/feature_info.h" | 32 #include "gpu/command_buffer/service/feature_info.h" |
30 #include "gpu/command_buffer/service/framebuffer_manager.h" | 33 #include "gpu/command_buffer/service/framebuffer_manager.h" |
31 #include "gpu/command_buffer/service/gl_utils.h" | 34 #include "gpu/command_buffer/service/gl_utils.h" |
32 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 35 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
33 #include "gpu/command_buffer/service/program_manager.h" | 36 #include "gpu/command_buffer/service/program_manager.h" |
34 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 37 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
35 #include "gpu/command_buffer/service/shader_manager.h" | 38 #include "gpu/command_buffer/service/shader_manager.h" |
36 #include "gpu/command_buffer/service/shader_translator.h" | 39 #include "gpu/command_buffer/service/shader_translator.h" |
37 #include "gpu/command_buffer/service/stream_texture.h" | 40 #include "gpu/command_buffer/service/stream_texture.h" |
38 #include "gpu/command_buffer/service/stream_texture_manager.h" | 41 #include "gpu/command_buffer/service/stream_texture_manager.h" |
39 #include "gpu/command_buffer/service/texture_manager.h" | 42 #include "gpu/command_buffer/service/texture_manager.h" |
40 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 43 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
41 #include "ui/gfx/gl/gl_context.h" | 44 #include "ui/gfx/gl/gl_context.h" |
42 #include "ui/gfx/gl/gl_implementation.h" | 45 #include "ui/gfx/gl/gl_implementation.h" |
43 #include "ui/gfx/gl/gl_surface.h" | 46 #include "ui/gfx/gl/gl_surface.h" |
47 #if defined(OS_MACOSX) | |
48 #include "ui/gfx/surface/io_surface_support_mac.h" | |
49 #endif | |
44 | 50 |
45 #if !defined(GL_DEPTH24_STENCIL8) | 51 #if !defined(GL_DEPTH24_STENCIL8) |
46 #define GL_DEPTH24_STENCIL8 0x88F0 | 52 #define GL_DEPTH24_STENCIL8 0x88F0 |
47 #endif | 53 #endif |
48 | 54 |
49 namespace gpu { | 55 namespace gpu { |
50 namespace gles2 { | 56 namespace gles2 { |
51 | 57 |
52 namespace { | 58 namespace { |
53 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; | 59 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 TextureManager::TextureInfo::Ref bound_texture_2d; | 559 TextureManager::TextureInfo::Ref bound_texture_2d; |
554 | 560 |
555 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with | 561 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with |
556 // glBindTexture | 562 // glBindTexture |
557 TextureManager::TextureInfo::Ref bound_texture_cube_map; | 563 TextureManager::TextureInfo::Ref bound_texture_cube_map; |
558 | 564 |
559 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with | 565 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with |
560 // glBindTexture | 566 // glBindTexture |
561 TextureManager::TextureInfo::Ref bound_texture_external_oes; | 567 TextureManager::TextureInfo::Ref bound_texture_external_oes; |
562 | 568 |
569 // texture currently bound to this unit's GL_TEXTURE_RECTANGLE_ARB with | |
570 // glBindTexture | |
571 TextureManager::TextureInfo::Ref bound_texture_rectangle_arb; | |
572 | |
563 TextureManager::TextureInfo::Ref GetInfoForSamplerType(GLenum type) { | 573 TextureManager::TextureInfo::Ref GetInfoForSamplerType(GLenum type) { |
564 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 574 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
565 type == GL_SAMPLER_EXTERNAL_OES); | 575 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); |
566 return type == GL_SAMPLER_2D ? bound_texture_2d : | 576 switch (type) { |
567 (type == GL_SAMPLER_EXTERNAL_OES ? bound_texture_external_oes : | 577 case GL_SAMPLER_2D: |
568 bound_texture_cube_map); | 578 return bound_texture_2d; |
579 case GL_SAMPLER_CUBE: | |
580 return bound_texture_cube_map; | |
581 case GL_SAMPLER_EXTERNAL_OES: | |
582 return bound_texture_external_oes; | |
583 case GL_SAMPLER_2D_RECT_ARB: | |
584 return bound_texture_rectangle_arb; | |
585 } | |
586 | |
587 NOTREACHED(); | |
588 return NULL; | |
569 } | 589 } |
570 | 590 |
571 void Unbind(TextureManager::TextureInfo* texture) { | 591 void Unbind(TextureManager::TextureInfo* texture) { |
572 if (bound_texture_2d == texture) { | 592 if (bound_texture_2d == texture) { |
573 bound_texture_2d = NULL; | 593 bound_texture_2d = NULL; |
574 } | 594 } |
575 if (bound_texture_cube_map == texture) { | 595 if (bound_texture_cube_map == texture) { |
576 bound_texture_cube_map = NULL; | 596 bound_texture_cube_map = NULL; |
577 } | 597 } |
578 if (bound_texture_external_oes == texture) { | 598 if (bound_texture_external_oes == texture) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
716 GLenum target, | 736 GLenum target, |
717 GLint level, | 737 GLint level, |
718 GLint xoffset, | 738 GLint xoffset, |
719 GLint yoffset, | 739 GLint yoffset, |
720 GLsizei width, | 740 GLsizei width, |
721 GLsizei height, | 741 GLsizei height, |
722 GLenum format, | 742 GLenum format, |
723 GLenum type, | 743 GLenum type, |
724 const void * data); | 744 const void * data); |
725 | 745 |
746 // Wrapper for TexImageIOSurface2DCHROMIUM. | |
747 void DoTexImageIOSurface2DCHROMIUM( | |
748 GLenum target, | |
749 GLsizei width, | |
750 GLsizei height, | |
751 GLuint io_surface_id, | |
752 GLuint plane); | |
753 | |
726 // Creates a ProgramInfo for the given program. | 754 // Creates a ProgramInfo for the given program. |
727 ProgramManager::ProgramInfo* CreateProgramInfo( | 755 ProgramManager::ProgramInfo* CreateProgramInfo( |
728 GLuint client_id, GLuint service_id) { | 756 GLuint client_id, GLuint service_id) { |
729 return program_manager()->CreateProgramInfo(client_id, service_id); | 757 return program_manager()->CreateProgramInfo(client_id, service_id); |
730 } | 758 } |
731 | 759 |
732 // Gets the program info for the given program. Returns NULL if none exists. | 760 // Gets the program info for the given program. Returns NULL if none exists. |
733 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { | 761 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { |
734 return program_manager()->GetProgramInfo(client_id); | 762 return program_manager()->GetProgramInfo(client_id); |
735 } | 763 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | 1202 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
1175 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | 1203 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
1176 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | 1204 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
1177 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | 1205 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
1178 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | 1206 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
1179 info = unit.bound_texture_cube_map; | 1207 info = unit.bound_texture_cube_map; |
1180 break; | 1208 break; |
1181 case GL_TEXTURE_EXTERNAL_OES: | 1209 case GL_TEXTURE_EXTERNAL_OES: |
1182 info = unit.bound_texture_external_oes; | 1210 info = unit.bound_texture_external_oes; |
1183 break; | 1211 break; |
1184 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to | 1212 case GL_TEXTURE_RECTANGLE_ARB: |
1185 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, | 1213 info = unit.bound_texture_rectangle_arb; |
1186 // because |texture_| is used by the FBO rendering mechanism for readback | 1214 break; |
1187 // to the bits that get sent to the browser. | |
1188 default: | 1215 default: |
1189 NOTREACHED(); | 1216 NOTREACHED(); |
1190 return NULL; | 1217 return NULL; |
1191 } | 1218 } |
1192 return info; | 1219 return info; |
1193 } | 1220 } |
1194 | 1221 |
1195 GLenum GetBindTargetForSamplerType(GLenum type) { | 1222 GLenum GetBindTargetForSamplerType(GLenum type) { |
1196 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 1223 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
1197 type == GL_SAMPLER_EXTERNAL_OES); | 1224 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); |
1198 return type == GL_SAMPLER_2D ? GL_TEXTURE_2D : | 1225 switch (type) { |
1199 (type == GL_SAMPLER_EXTERNAL_OES ? GL_TEXTURE_EXTERNAL_OES : | 1226 case GL_SAMPLER_2D: |
1200 GL_TEXTURE_CUBE_MAP); | 1227 return GL_TEXTURE_2D; |
1228 case GL_SAMPLER_CUBE: | |
1229 return GL_TEXTURE_CUBE_MAP; | |
1230 case GL_SAMPLER_EXTERNAL_OES: | |
1231 return GL_TEXTURE_EXTERNAL_OES; | |
1232 case GL_SAMPLER_2D_RECT_ARB: | |
1233 return GL_TEXTURE_RECTANGLE_ARB; | |
1234 } | |
1235 | |
1236 NOTREACHED(); | |
1237 return 0; | |
1201 } | 1238 } |
1202 | 1239 |
1203 // Gets the framebuffer info for a particular target. | 1240 // Gets the framebuffer info for a particular target. |
1204 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( | 1241 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( |
1205 GLenum target) { | 1242 GLenum target) { |
1206 FramebufferManager::FramebufferInfo* info = NULL; | 1243 FramebufferManager::FramebufferInfo* info = NULL; |
1207 switch (target) { | 1244 switch (target) { |
1208 case GL_FRAMEBUFFER: | 1245 case GL_FRAMEBUFFER: |
1209 case GL_DRAW_FRAMEBUFFER: | 1246 case GL_DRAW_FRAMEBUFFER: |
1210 info = bound_draw_framebuffer_; | 1247 info = bound_draw_framebuffer_; |
(...skipping 27 matching lines...) Expand all Loading... | |
1238 // should be called. | 1275 // should be called. |
1239 bool GetUniformSetup( | 1276 bool GetUniformSetup( |
1240 GLuint program, GLint location, | 1277 GLuint program, GLint location, |
1241 uint32 shm_id, uint32 shm_offset, | 1278 uint32 shm_id, uint32 shm_offset, |
1242 error::Error* error, GLuint* service_id, void** result, | 1279 error::Error* error, GLuint* service_id, void** result, |
1243 GLenum* result_type); | 1280 GLenum* result_type); |
1244 | 1281 |
1245 // Returns true if the context was just lost due to e.g. GL_ARB_robustness. | 1282 // Returns true if the context was just lost due to e.g. GL_ARB_robustness. |
1246 bool WasContextLost(); | 1283 bool WasContextLost(); |
1247 | 1284 |
1285 #if defined(OS_MACOSX) | |
1286 void ReleaseIOSurfaceForTexture(GLuint texture_id); | |
1287 #endif | |
1288 | |
1248 // Generate a member function prototype for each command in an automated and | 1289 // Generate a member function prototype for each command in an automated and |
1249 // typesafe way. | 1290 // typesafe way. |
1250 #define GLES2_CMD_OP(name) \ | 1291 #define GLES2_CMD_OP(name) \ |
1251 Error Handle ## name( \ | 1292 Error Handle ## name( \ |
1252 uint32 immediate_data_size, \ | 1293 uint32 immediate_data_size, \ |
1253 const gles2::name& args); \ | 1294 const gles2::name& args); \ |
1254 | 1295 |
1255 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1296 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1256 | 1297 |
1257 #undef GLES2_CMD_OP | 1298 #undef GLES2_CMD_OP |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1415 bool needs_glsl_built_in_function_emulation_; | 1456 bool needs_glsl_built_in_function_emulation_; |
1416 | 1457 |
1417 // These flags are used to override the state of the shared feature_info_ | 1458 // These flags are used to override the state of the shared feature_info_ |
1418 // member. Because the same FeatureInfo instance may be shared among many | 1459 // member. Because the same FeatureInfo instance may be shared among many |
1419 // contexts, the assumptions on the availablity of extensions in WebGL | 1460 // contexts, the assumptions on the availablity of extensions in WebGL |
1420 // contexts may be broken. These flags override the shared state to preserve | 1461 // contexts may be broken. These flags override the shared state to preserve |
1421 // WebGL semantics. | 1462 // WebGL semantics. |
1422 bool force_webgl_glsl_validation_; | 1463 bool force_webgl_glsl_validation_; |
1423 bool derivatives_explicitly_enabled_; | 1464 bool derivatives_explicitly_enabled_; |
1424 | 1465 |
1466 #if defined(OS_MACOSX) | |
1467 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | |
1468 TextureToIOSurfaceMap texture_to_io_surface_map_; | |
1469 #endif | |
1470 | |
1425 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1471 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1426 }; | 1472 }; |
1427 | 1473 |
1428 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1474 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1429 : decoder_(decoder) { | 1475 : decoder_(decoder) { |
1430 decoder_->CopyRealGLErrorsToWrapper(); | 1476 decoder_->CopyRealGLErrorsToWrapper(); |
1431 } | 1477 } |
1432 | 1478 |
1433 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1479 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
1434 decoder_->ClearRealGLErrors(); | 1480 decoder_->ClearRealGLErrors(); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1876 new TextureUnit[group_->max_texture_units()]); | 1922 new TextureUnit[group_->max_texture_units()]); |
1877 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { | 1923 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { |
1878 glActiveTexture(GL_TEXTURE0 + tt); | 1924 glActiveTexture(GL_TEXTURE0 + tt); |
1879 // We want the last bind to be 2D. | 1925 // We want the last bind to be 2D. |
1880 TextureManager::TextureInfo* info; | 1926 TextureManager::TextureInfo* info; |
1881 if (feature_info_->feature_flags().oes_egl_image_external) { | 1927 if (feature_info_->feature_flags().oes_egl_image_external) { |
1882 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); | 1928 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); |
1883 texture_units_[tt].bound_texture_external_oes = info; | 1929 texture_units_[tt].bound_texture_external_oes = info; |
1884 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); | 1930 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); |
1885 } | 1931 } |
1932 if (feature_info_->feature_flags().arb_texture_rectangle) { | |
1933 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB); | |
1934 texture_units_[tt].bound_texture_rectangle_arb = info; | |
1935 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, info->service_id()); | |
1936 } | |
1886 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | 1937 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); |
1887 texture_units_[tt].bound_texture_cube_map = info; | 1938 texture_units_[tt].bound_texture_cube_map = info; |
1888 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id()); | 1939 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id()); |
1889 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | 1940 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); |
1890 texture_units_[tt].bound_texture_2d = info; | 1941 texture_units_[tt].bound_texture_2d = info; |
1891 glBindTexture(GL_TEXTURE_2D, info->service_id()); | 1942 glBindTexture(GL_TEXTURE_2D, info->service_id()); |
1892 } | 1943 } |
1893 glActiveTexture(GL_TEXTURE0); | 1944 glActiveTexture(GL_TEXTURE0); |
1894 CHECK_GL_ERROR(); | 1945 CHECK_GL_ERROR(); |
1895 | 1946 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2096 resources.MaxTextureImageUnits = group_->max_texture_image_units(); | 2147 resources.MaxTextureImageUnits = group_->max_texture_image_units(); |
2097 resources.MaxFragmentUniformVectors = | 2148 resources.MaxFragmentUniformVectors = |
2098 group_->max_fragment_uniform_vectors(); | 2149 group_->max_fragment_uniform_vectors(); |
2099 resources.MaxDrawBuffers = 1; | 2150 resources.MaxDrawBuffers = 1; |
2100 | 2151 |
2101 if (force_webgl_glsl_validation_) { | 2152 if (force_webgl_glsl_validation_) { |
2102 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 2153 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
2103 } else { | 2154 } else { |
2104 resources.OES_standard_derivatives = | 2155 resources.OES_standard_derivatives = |
2105 feature_info_->feature_flags().oes_standard_derivatives ? 1 : 0; | 2156 feature_info_->feature_flags().oes_standard_derivatives ? 1 : 0; |
2157 resources.ARB_texture_rectangle = | |
2158 feature_info_->feature_flags().arb_texture_rectangle ? 1 : 0; | |
2106 } | 2159 } |
2107 | 2160 |
2108 vertex_translator_.reset(new ShaderTranslator); | 2161 vertex_translator_.reset(new ShaderTranslator); |
2109 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || | 2162 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || |
2110 feature_info_->feature_flags().chromium_webglsl ? | 2163 feature_info_->feature_flags().chromium_webglsl ? |
2111 SH_WEBGL_SPEC : SH_GLES2_SPEC; | 2164 SH_WEBGL_SPEC : SH_GLES2_SPEC; |
2112 ShaderTranslatorInterface::GlslImplementationType implementation_type = | 2165 ShaderTranslatorInterface::GlslImplementationType implementation_type = |
2113 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? | 2166 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? |
2114 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; | 2167 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; |
2115 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior function_behavior = | 2168 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior function_behavior = |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2299 } | 2352 } |
2300 } else { | 2353 } else { |
2301 if (bound_draw_framebuffer_) { | 2354 if (bound_draw_framebuffer_) { |
2302 bound_draw_framebuffer_->UnbindTexture(GL_FRAMEBUFFER, texture); | 2355 bound_draw_framebuffer_->UnbindTexture(GL_FRAMEBUFFER, texture); |
2303 } | 2356 } |
2304 } | 2357 } |
2305 GLuint service_id = texture->service_id(); | 2358 GLuint service_id = texture->service_id(); |
2306 if (texture->IsStreamTexture() && stream_texture_manager_) { | 2359 if (texture->IsStreamTexture() && stream_texture_manager_) { |
2307 stream_texture_manager_->DestroyStreamTexture(service_id); | 2360 stream_texture_manager_->DestroyStreamTexture(service_id); |
2308 } | 2361 } |
2362 #if defined(OS_MACOSX) | |
2363 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { | |
2364 ReleaseIOSurfaceForTexture(service_id); | |
2365 } | |
2366 #endif | |
2309 glDeleteTextures(1, &service_id); | 2367 glDeleteTextures(1, &service_id); |
2310 RemoveTextureInfo(client_ids[ii]); | 2368 RemoveTextureInfo(client_ids[ii]); |
2311 } | 2369 } |
2312 } | 2370 } |
2313 } | 2371 } |
2314 | 2372 |
2315 // } // anonymous namespace | 2373 // } // anonymous namespace |
2316 | 2374 |
2317 bool GLES2DecoderImpl::MakeCurrent() { | 2375 bool GLES2DecoderImpl::MakeCurrent() { |
2318 bool result = context_.get() ? context_->MakeCurrent(surface_.get()) : false; | 2376 bool result = context_.get() ? context_->MakeCurrent(surface_.get()) : false; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2611 | 2669 |
2612 offscreen_target_frame_buffer_.reset(); | 2670 offscreen_target_frame_buffer_.reset(); |
2613 offscreen_target_color_texture_.reset(); | 2671 offscreen_target_color_texture_.reset(); |
2614 offscreen_target_color_render_buffer_.reset(); | 2672 offscreen_target_color_render_buffer_.reset(); |
2615 offscreen_target_depth_render_buffer_.reset(); | 2673 offscreen_target_depth_render_buffer_.reset(); |
2616 offscreen_target_stencil_render_buffer_.reset(); | 2674 offscreen_target_stencil_render_buffer_.reset(); |
2617 offscreen_saved_frame_buffer_.reset(); | 2675 offscreen_saved_frame_buffer_.reset(); |
2618 offscreen_saved_color_texture_.reset(); | 2676 offscreen_saved_color_texture_.reset(); |
2619 offscreen_resolved_frame_buffer_.reset(); | 2677 offscreen_resolved_frame_buffer_.reset(); |
2620 offscreen_resolved_color_texture_.reset(); | 2678 offscreen_resolved_color_texture_.reset(); |
2679 | |
2680 #if defined(OS_MACOSX) | |
2681 for (TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.begin(); | |
2682 it != texture_to_io_surface_map_.end(); ++it) { | |
2683 CFRelease(it->second); | |
2684 } | |
2685 texture_to_io_surface_map_.clear(); | |
2686 #endif | |
2621 } | 2687 } |
2622 | 2688 |
2623 bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent, | 2689 bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent, |
2624 uint32 new_parent_texture_id) { | 2690 uint32 new_parent_texture_id) { |
2625 if (!offscreen_saved_color_texture_.get()) | 2691 if (!offscreen_saved_color_texture_.get()) |
2626 return false; | 2692 return false; |
2627 | 2693 |
2628 // Remove the saved frame buffer mapping from the parent decoder. The | 2694 // Remove the saved frame buffer mapping from the parent decoder. The |
2629 // parent pointer is a weak pointer so it will be null if the parent has | 2695 // parent pointer is a weak pointer so it will be null if the parent has |
2630 // already been destroyed. | 2696 // already been destroyed. |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3124 case GL_TEXTURE_EXTERNAL_OES: | 3190 case GL_TEXTURE_EXTERNAL_OES: |
3125 unit.bound_texture_external_oes = info; | 3191 unit.bound_texture_external_oes = info; |
3126 if (info->IsStreamTexture()) { | 3192 if (info->IsStreamTexture()) { |
3127 DCHECK(stream_texture_manager_); | 3193 DCHECK(stream_texture_manager_); |
3128 StreamTexture* stream_tex = | 3194 StreamTexture* stream_tex = |
3129 stream_texture_manager_->LookupStreamTexture(info->service_id()); | 3195 stream_texture_manager_->LookupStreamTexture(info->service_id()); |
3130 if (stream_tex) | 3196 if (stream_tex) |
3131 stream_tex->Update(); | 3197 stream_tex->Update(); |
3132 } | 3198 } |
3133 break; | 3199 break; |
3200 case GL_TEXTURE_RECTANGLE_ARB: | |
3201 unit.bound_texture_rectangle_arb = info; | |
3202 break; | |
3134 default: | 3203 default: |
3135 NOTREACHED(); // Validation should prevent us getting here. | 3204 NOTREACHED(); // Validation should prevent us getting here. |
3136 break; | 3205 break; |
3137 } | 3206 } |
3138 } | 3207 } |
3139 | 3208 |
3140 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { | 3209 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { |
3141 if (vertex_attrib_manager_.Enable(index, false)) { | 3210 if (vertex_attrib_manager_.Enable(index, false)) { |
3142 if (index != 0 || | 3211 if (index != 0 || |
3143 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 3212 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3466 if (unit.bound_texture_external_oes) { | 3535 if (unit.bound_texture_external_oes) { |
3467 GLuint client_id = 0; | 3536 GLuint client_id = 0; |
3468 texture_manager()->GetClientId( | 3537 texture_manager()->GetClientId( |
3469 unit.bound_texture_external_oes->service_id(), &client_id); | 3538 unit.bound_texture_external_oes->service_id(), &client_id); |
3470 *params = client_id; | 3539 *params = client_id; |
3471 } else { | 3540 } else { |
3472 *params = 0; | 3541 *params = 0; |
3473 } | 3542 } |
3474 } | 3543 } |
3475 return true; | 3544 return true; |
3545 case GL_TEXTURE_BINDING_RECTANGLE_ARB: | |
3546 *num_written = 1; | |
3547 if (params) { | |
3548 TextureUnit& unit = texture_units_[active_texture_unit_]; | |
3549 if (unit.bound_texture_rectangle_arb) { | |
3550 GLuint client_id = 0; | |
3551 texture_manager()->GetClientId( | |
3552 unit.bound_texture_rectangle_arb->service_id(), &client_id); | |
3553 *params = client_id; | |
3554 } else { | |
3555 *params = 0; | |
3556 } | |
3557 } | |
3558 return true; | |
3476 default: | 3559 default: |
3477 *num_written = util_.GLGetNumValuesReturned(pname); | 3560 *num_written = util_.GLGetNumValuesReturned(pname); |
3478 return false; | 3561 return false; |
3479 } | 3562 } |
3480 } | 3563 } |
3481 | 3564 |
3482 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( | 3565 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( |
3483 GLenum pname, GLsizei* num_values) { | 3566 GLenum pname, GLsizei* num_values) { |
3484 return GetHelper(pname, NULL, num_values); | 3567 return GetHelper(pname, NULL, num_values); |
3485 } | 3568 } |
(...skipping 3993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7479 info->SetStreamTexture(false); | 7562 info->SetStreamTexture(false); |
7480 texture_manager()->SetInfoTarget(feature_info_, info, 0); | 7563 texture_manager()->SetInfoTarget(feature_info_, info, 0); |
7481 } else { | 7564 } else { |
7482 SetGLError(GL_INVALID_VALUE, | 7565 SetGLError(GL_INVALID_VALUE, |
7483 "glDestroyStreamTextureCHROMIUM: bad texture id."); | 7566 "glDestroyStreamTextureCHROMIUM: bad texture id."); |
7484 } | 7567 } |
7485 | 7568 |
7486 return error::kNoError; | 7569 return error::kNoError; |
7487 } | 7570 } |
7488 | 7571 |
7572 #if defined(OS_MACOSX) | |
7573 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) { | |
7574 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find( | |
7575 texture_id); | |
7576 if (it != texture_to_io_surface_map_.end()) { | |
greggman
2011/11/28 22:58:11
I don't know the use case but is there any issue w
| |
7577 // Found a previous IOSurface bound to this texture; release it. | |
7578 CFTypeRef surface = it->second; | |
7579 CFRelease(surface); | |
7580 texture_to_io_surface_map_.erase(it); | |
7581 } | |
7582 } | |
7583 #endif | |
7584 | |
7585 void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM( | |
7586 GLenum target, GLsizei width, GLsizei height, | |
7587 GLuint io_surface_id, GLuint plane) { | |
7588 #if defined(OS_MACOSX) | |
7589 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { | |
7590 SetGLError(GL_INVALID_OPERATION, | |
7591 "glTexImageIOSurface2DCHROMIUM: only supported on desktop GL."); | |
7592 return; | |
7593 } | |
7594 | |
7595 IOSurfaceSupport* surface_support = IOSurfaceSupport::Initialize(); | |
7596 if (!surface_support) { | |
7597 SetGLError(GL_INVALID_OPERATION, | |
7598 "glTexImageIOSurface2DCHROMIUM: only supported on 10.6."); | |
7599 return; | |
7600 } | |
7601 | |
7602 if (target != GL_TEXTURE_RECTANGLE_ARB) { | |
7603 // This might be supported in the future, and if we could require | |
7604 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we | |
7605 // could delete a lot of code. For now, perform strict validation so we | |
7606 // know what's going on. | |
7607 SetGLError( | |
7608 GL_INVALID_OPERATION, | |
7609 "glTexImageIOSurface2DCHROMIUM: requires TEXTURE_RECTANGLE_ARB target"); | |
7610 return; | |
7611 } | |
7612 | |
7613 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | |
7614 if (!info) { | |
7615 SetGLError(GL_INVALID_OPERATION, | |
7616 "glTexImageIOSurface2DCHROMIUM: no rectangle texture bound"); | |
7617 return; | |
7618 } | |
7619 if (info == texture_manager()->GetDefaultTextureInfo(target)) { | |
greggman
2011/11/28 22:58:11
This check is not needed. GetTextureInfoForTarget
| |
7620 // Maybe this is conceptually valid, but disallow it to avoid accidents. | |
7621 SetGLError(GL_INVALID_OPERATION, | |
7622 "glTexImageIOSurface2DCHROMIUM: can't bind default texture"); | |
7623 return; | |
7624 } | |
7625 | |
7626 // Look up the new IOSurface. Note that because of asynchrony | |
7627 // between processes this might fail; during live resizing the | |
7628 // plugin process might allocate and release an IOSurface before | |
7629 // this process gets a chance to look it up. Hold on to any old | |
7630 // IOSurface in this case. | |
7631 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); | |
7632 if (!surface) { | |
7633 SetGLError(GL_INVALID_OPERATION, | |
7634 "glTexImageIOSurface2DCHROMIUM: no IOSurface with the given ID"); | |
7635 return; | |
7636 } | |
7637 | |
7638 // Release any IOSurface previously bound to this texture. | |
7639 ReleaseIOSurfaceForTexture(info->service_id()); | |
7640 | |
7641 // Make sure we release the IOSurface even if CGLTexImageIOSurface2D fails. | |
7642 texture_to_io_surface_map_.insert( | |
7643 std::make_pair(info->service_id(), surface)); | |
7644 | |
7645 CGLContextObj context = | |
7646 static_cast<CGLContextObj>(context_->GetHandle()); | |
7647 | |
7648 CGLError err = surface_support->CGLTexImageIOSurface2D( | |
7649 context, | |
7650 target, | |
7651 GL_RGBA, | |
7652 width, | |
7653 height, | |
7654 GL_BGRA, | |
7655 GL_UNSIGNED_INT_8_8_8_8_REV, | |
7656 surface, | |
7657 plane); | |
7658 | |
7659 if (err != kCGLNoError) { | |
7660 SetGLError( | |
7661 GL_INVALID_OPERATION, | |
7662 "glTexImageIOSurface2DCHROMIUM: error in CGLTexImageIOSurface2D"); | |
7663 return; | |
7664 } | |
7665 | |
7666 texture_manager()->SetLevelInfo( | |
7667 feature_info_, info, | |
7668 target, 0, GL_RGBA, width, height, 1, 0, | |
7669 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); | |
greggman
2011/11/28 22:58:11
Do you need to check in feature_info that GL_BGRA
| |
7670 | |
7671 #else | |
7672 SetGLError(GL_INVALID_OPERATION, | |
7673 "glTexImageIOSurface2DCHROMIUM: not supported."); | |
7674 #endif | |
7675 } | |
7676 | |
7677 | |
7489 // Include the auto-generated part of this file. We split this because it means | 7678 // Include the auto-generated part of this file. We split this because it means |
7490 // we can easily edit the non-auto generated parts right here in this file | 7679 // we can easily edit the non-auto generated parts right here in this file |
7491 // instead of having to edit some template or the code generator. | 7680 // instead of having to edit some template or the code generator. |
7492 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 7681 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
7493 | 7682 |
7494 } // namespace gles2 | 7683 } // namespace gles2 |
7495 } // namespace gpu | 7684 } // namespace gpu |
OLD | NEW |