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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #define GLES2_GPU_SERVICE 1 | 26 #define GLES2_GPU_SERVICE 1 |
27 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 27 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
29 #include "gpu/command_buffer/common/id_allocator.h" | 29 #include "gpu/command_buffer/common/id_allocator.h" |
30 #include "gpu/command_buffer/service/buffer_manager.h" | 30 #include "gpu/command_buffer/service/buffer_manager.h" |
31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
32 #include "gpu/command_buffer/service/context_group.h" | 32 #include "gpu/command_buffer/service/context_group.h" |
33 #include "gpu/command_buffer/service/feature_info.h" | 33 #include "gpu/command_buffer/service/feature_info.h" |
34 #include "gpu/command_buffer/service/framebuffer_manager.h" | 34 #include "gpu/command_buffer/service/framebuffer_manager.h" |
35 #include "gpu/command_buffer/service/gl_utils.h" | 35 #include "gpu/command_buffer/service/gl_utils.h" |
| 36 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
36 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 37 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
37 #include "gpu/command_buffer/service/gpu_switches.h" | 38 #include "gpu/command_buffer/service/gpu_switches.h" |
38 #include "gpu/command_buffer/service/program_manager.h" | 39 #include "gpu/command_buffer/service/program_manager.h" |
39 #include "gpu/command_buffer/service/query_manager.h" | 40 #include "gpu/command_buffer/service/query_manager.h" |
40 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 41 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
41 #include "gpu/command_buffer/service/shader_manager.h" | 42 #include "gpu/command_buffer/service/shader_manager.h" |
42 #include "gpu/command_buffer/service/shader_translator.h" | 43 #include "gpu/command_buffer/service/shader_translator.h" |
43 #include "gpu/command_buffer/service/stream_texture.h" | 44 #include "gpu/command_buffer/service/stream_texture.h" |
44 #include "gpu/command_buffer/service/stream_texture_manager.h" | 45 #include "gpu/command_buffer/service/stream_texture_manager.h" |
45 #include "gpu/command_buffer/service/texture_manager.h" | 46 #include "gpu/command_buffer/service/texture_manager.h" |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 const void * data); | 720 const void * data); |
720 | 721 |
721 // Wrapper for TexImageIOSurface2DCHROMIUM. | 722 // Wrapper for TexImageIOSurface2DCHROMIUM. |
722 void DoTexImageIOSurface2DCHROMIUM( | 723 void DoTexImageIOSurface2DCHROMIUM( |
723 GLenum target, | 724 GLenum target, |
724 GLsizei width, | 725 GLsizei width, |
725 GLsizei height, | 726 GLsizei height, |
726 GLuint io_surface_id, | 727 GLuint io_surface_id, |
727 GLuint plane); | 728 GLuint plane); |
728 | 729 |
| 730 void DoCopyTextureCHROMIUM( |
| 731 GLenum target, |
| 732 GLuint source_id, |
| 733 GLuint target_id, |
| 734 GLint level); |
| 735 |
729 // Wrapper for TexStorage2DEXT. | 736 // Wrapper for TexStorage2DEXT. |
730 void DoTexStorage2DEXT( | 737 void DoTexStorage2DEXT( |
731 GLenum target, | 738 GLenum target, |
732 GLint levels, | 739 GLint levels, |
733 GLenum internal_format, | 740 GLenum internal_format, |
734 GLsizei width, | 741 GLsizei width, |
735 GLsizei height); | 742 GLsizei height); |
736 | 743 |
737 // Creates a ProgramInfo for the given program. | 744 // Creates a ProgramInfo for the given program. |
738 ProgramManager::ProgramInfo* CreateProgramInfo( | 745 ProgramManager::ProgramInfo* CreateProgramInfo( |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 void DoVertexAttrib1f(GLuint index, GLfloat v0); | 1132 void DoVertexAttrib1f(GLuint index, GLfloat v0); |
1126 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); | 1133 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); |
1127 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); | 1134 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); |
1128 void DoVertexAttrib4f( | 1135 void DoVertexAttrib4f( |
1129 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); | 1136 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); |
1130 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); | 1137 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); |
1131 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); | 1138 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); |
1132 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); | 1139 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); |
1133 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); | 1140 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); |
1134 | 1141 |
| 1142 // Wrapper for glViewport |
| 1143 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height); |
| 1144 |
1135 // Wrapper for glUseProgram | 1145 // Wrapper for glUseProgram |
1136 void DoUseProgram(GLuint program); | 1146 void DoUseProgram(GLuint program); |
1137 | 1147 |
1138 // Wrapper for glValidateProgram. | 1148 // Wrapper for glValidateProgram. |
1139 void DoValidateProgram(GLuint program_client_id); | 1149 void DoValidateProgram(GLuint program_client_id); |
1140 | 1150 |
1141 // Gets the number of values that will be returned by glGetXXX. Returns | 1151 // Gets the number of values that will be returned by glGetXXX. Returns |
1142 // false if pname is unknown. | 1152 // false if pname is unknown. |
1143 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); | 1153 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); |
1144 | 1154 |
(...skipping 14 matching lines...) Expand all Loading... |
1159 // errors caused by GL calls that it was not responsible for issuing. | 1169 // errors caused by GL calls that it was not responsible for issuing. |
1160 void ClearRealGLErrors(); | 1170 void ClearRealGLErrors(); |
1161 | 1171 |
1162 // Checks if the current program and vertex attributes are valid for drawing. | 1172 // Checks if the current program and vertex attributes are valid for drawing. |
1163 bool IsDrawValid(GLuint max_vertex_accessed, GLsizei primcount); | 1173 bool IsDrawValid(GLuint max_vertex_accessed, GLsizei primcount); |
1164 | 1174 |
1165 // Returns true if successful, simulated will be true if attrib0 was | 1175 // Returns true if successful, simulated will be true if attrib0 was |
1166 // simulated. | 1176 // simulated. |
1167 bool SimulateAttrib0( | 1177 bool SimulateAttrib0( |
1168 GLuint max_vertex_accessed, bool* simulated); | 1178 GLuint max_vertex_accessed, bool* simulated); |
1169 void RestoreStateForSimulatedAttrib0(); | 1179 void RestoreStateForAttrib(GLuint attrib); |
1170 | 1180 |
1171 // Returns true if textures were set. | 1181 // Returns true if textures were set. |
1172 bool SetBlackTextureForNonRenderableTextures(); | 1182 bool SetBlackTextureForNonRenderableTextures(); |
1173 void RestoreStateForNonRenderableTextures(); | 1183 void RestoreStateForNonRenderableTextures(); |
1174 | 1184 |
1175 // Returns true if GL_FIXED attribs were simulated. | 1185 // Returns true if GL_FIXED attribs were simulated. |
1176 bool SimulateFixedAttribs( | 1186 bool SimulateFixedAttribs( |
1177 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); | 1187 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); |
1178 void RestoreStateForSimulatedFixedAttribs(); | 1188 void RestoreStateForSimulatedFixedAttribs(); |
1179 | 1189 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 | 1335 |
1326 // Util to help with GL. | 1336 // Util to help with GL. |
1327 GLES2Util util_; | 1337 GLES2Util util_; |
1328 | 1338 |
1329 // pack alignment as last set by glPixelStorei | 1339 // pack alignment as last set by glPixelStorei |
1330 GLint pack_alignment_; | 1340 GLint pack_alignment_; |
1331 | 1341 |
1332 // unpack alignment as last set by glPixelStorei | 1342 // unpack alignment as last set by glPixelStorei |
1333 GLint unpack_alignment_; | 1343 GLint unpack_alignment_; |
1334 | 1344 |
| 1345 // unpack flip y as last set by glPixelStorei |
| 1346 bool unpack_flip_y_; |
| 1347 |
| 1348 // unpack premultiply alpha as last set by glPixelStorei |
| 1349 bool unpack_premultiply_alpha_; |
| 1350 |
1335 // The currently bound array buffer. If this is 0 it is illegal to call | 1351 // The currently bound array buffer. If this is 0 it is illegal to call |
1336 // glVertexAttribPointer. | 1352 // glVertexAttribPointer. |
1337 BufferManager::BufferInfo::Ref bound_array_buffer_; | 1353 BufferManager::BufferInfo::Ref bound_array_buffer_; |
1338 | 1354 |
1339 // The currently bound element array buffer. If this is 0 it is illegal | 1355 // The currently bound element array buffer. If this is 0 it is illegal |
1340 // to call glDrawElements. | 1356 // to call glDrawElements. |
1341 BufferManager::BufferInfo::Ref bound_element_array_buffer_; | 1357 BufferManager::BufferInfo::Ref bound_element_array_buffer_; |
1342 | 1358 |
1343 // Class that manages vertex attribs. | 1359 // Class that manages vertex attribs. |
1344 scoped_ptr<VertexAttribManager> vertex_attrib_manager_; | 1360 scoped_ptr<VertexAttribManager> vertex_attrib_manager_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 GLclampf clear_alpha_; | 1393 GLclampf clear_alpha_; |
1378 GLboolean mask_red_; | 1394 GLboolean mask_red_; |
1379 GLboolean mask_green_; | 1395 GLboolean mask_green_; |
1380 GLboolean mask_blue_; | 1396 GLboolean mask_blue_; |
1381 GLboolean mask_alpha_; | 1397 GLboolean mask_alpha_; |
1382 GLint clear_stencil_; | 1398 GLint clear_stencil_; |
1383 GLuint mask_stencil_front_; | 1399 GLuint mask_stencil_front_; |
1384 GLuint mask_stencil_back_; | 1400 GLuint mask_stencil_back_; |
1385 GLclampf clear_depth_; | 1401 GLclampf clear_depth_; |
1386 GLboolean mask_depth_; | 1402 GLboolean mask_depth_; |
| 1403 bool enable_cull_face_; |
1387 bool enable_scissor_test_; | 1404 bool enable_scissor_test_; |
1388 bool enable_depth_test_; | 1405 bool enable_depth_test_; |
1389 bool enable_stencil_test_; | 1406 bool enable_stencil_test_; |
1390 bool state_dirty_; | 1407 bool state_dirty_; |
1391 | 1408 |
1392 // The program in use by glUseProgram | 1409 // The program in use by glUseProgram |
1393 ProgramManager::ProgramInfo::Ref current_program_; | 1410 ProgramManager::ProgramInfo::Ref current_program_; |
1394 | 1411 |
1395 // The currently bound framebuffers | 1412 // The currently bound framebuffers |
1396 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; | 1413 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 bool compile_shader_always_succeeds_; | 1497 bool compile_shader_always_succeeds_; |
1481 | 1498 |
1482 #if defined(OS_MACOSX) | 1499 #if defined(OS_MACOSX) |
1483 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | 1500 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; |
1484 TextureToIOSurfaceMap texture_to_io_surface_map_; | 1501 TextureToIOSurfaceMap texture_to_io_surface_map_; |
1485 #endif | 1502 #endif |
1486 | 1503 |
1487 typedef std::vector<GLES2DecoderImpl*> ChildList; | 1504 typedef std::vector<GLES2DecoderImpl*> ChildList; |
1488 ChildList children_; | 1505 ChildList children_; |
1489 | 1506 |
| 1507 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
| 1508 |
| 1509 // Cached values of the currently assigned viewport dimensions. |
| 1510 GLint viewport_x_, viewport_y_; |
| 1511 GLsizei viewport_width_, viewport_height_; |
| 1512 GLsizei viewport_max_width_, viewport_max_height_; |
| 1513 |
1490 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1514 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1491 }; | 1515 }; |
1492 | 1516 |
1493 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1517 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1494 : decoder_(decoder) { | 1518 : decoder_(decoder) { |
1495 decoder_->CopyRealGLErrorsToWrapper(); | 1519 decoder_->CopyRealGLErrorsToWrapper(); |
1496 } | 1520 } |
1497 | 1521 |
1498 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1522 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
1499 decoder_->ClearRealGLErrors(); | 1523 decoder_->ClearRealGLErrors(); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 1847 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
1824 return new GLES2DecoderImpl(group); | 1848 return new GLES2DecoderImpl(group); |
1825 } | 1849 } |
1826 | 1850 |
1827 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) | 1851 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
1828 : GLES2Decoder(), | 1852 : GLES2Decoder(), |
1829 group_(group), | 1853 group_(group), |
1830 error_bits_(0), | 1854 error_bits_(0), |
1831 pack_alignment_(4), | 1855 pack_alignment_(4), |
1832 unpack_alignment_(4), | 1856 unpack_alignment_(4), |
| 1857 unpack_flip_y_(false), |
| 1858 unpack_premultiply_alpha_(false), |
1833 attrib_0_buffer_id_(0), | 1859 attrib_0_buffer_id_(0), |
1834 attrib_0_buffer_matches_value_(true), | 1860 attrib_0_buffer_matches_value_(true), |
1835 attrib_0_size_(0), | 1861 attrib_0_size_(0), |
1836 fixed_attrib_buffer_id_(0), | 1862 fixed_attrib_buffer_id_(0), |
1837 fixed_attrib_buffer_size_(0), | 1863 fixed_attrib_buffer_size_(0), |
1838 active_texture_unit_(0), | 1864 active_texture_unit_(0), |
1839 clear_red_(0), | 1865 clear_red_(0), |
1840 clear_green_(0), | 1866 clear_green_(0), |
1841 clear_blue_(0), | 1867 clear_blue_(0), |
1842 clear_alpha_(0), | 1868 clear_alpha_(0), |
1843 mask_red_(true), | 1869 mask_red_(true), |
1844 mask_green_(true), | 1870 mask_green_(true), |
1845 mask_blue_(true), | 1871 mask_blue_(true), |
1846 mask_alpha_(true), | 1872 mask_alpha_(true), |
1847 clear_stencil_(0), | 1873 clear_stencil_(0), |
1848 mask_stencil_front_(-1), | 1874 mask_stencil_front_(-1), |
1849 mask_stencil_back_(-1), | 1875 mask_stencil_back_(-1), |
1850 clear_depth_(1.0f), | 1876 clear_depth_(1.0f), |
1851 mask_depth_(true), | 1877 mask_depth_(true), |
| 1878 enable_cull_face_(false), |
1852 enable_scissor_test_(false), | 1879 enable_scissor_test_(false), |
1853 enable_depth_test_(false), | 1880 enable_depth_test_(false), |
1854 enable_stencil_test_(false), | 1881 enable_stencil_test_(false), |
1855 state_dirty_(true), | 1882 state_dirty_(true), |
1856 offscreen_target_color_format_(0), | 1883 offscreen_target_color_format_(0), |
1857 offscreen_target_depth_format_(0), | 1884 offscreen_target_depth_format_(0), |
1858 offscreen_target_stencil_format_(0), | 1885 offscreen_target_stencil_format_(0), |
1859 offscreen_target_samples_(0), | 1886 offscreen_target_samples_(0), |
1860 offscreen_target_buffer_preserved_(true), | 1887 offscreen_target_buffer_preserved_(true), |
1861 offscreen_saved_color_format_(0), | 1888 offscreen_saved_color_format_(0), |
1862 stream_texture_manager_(NULL), | 1889 stream_texture_manager_(NULL), |
1863 back_buffer_color_format_(0), | 1890 back_buffer_color_format_(0), |
1864 back_buffer_has_depth_(false), | 1891 back_buffer_has_depth_(false), |
1865 back_buffer_has_stencil_(false), | 1892 back_buffer_has_stencil_(false), |
1866 teximage2d_faster_than_texsubimage2d_(true), | 1893 teximage2d_faster_than_texsubimage2d_(true), |
1867 bufferdata_faster_than_buffersubdata_(true), | 1894 bufferdata_faster_than_buffersubdata_(true), |
1868 current_decoder_error_(error::kNoError), | 1895 current_decoder_error_(error::kNoError), |
1869 use_shader_translator_(true), | 1896 use_shader_translator_(true), |
1870 validators_(group_->feature_info()->validators()), | 1897 validators_(group_->feature_info()->validators()), |
1871 feature_info_(group_->feature_info()), | 1898 feature_info_(group_->feature_info()), |
1872 tex_image_2d_failed_(false), | 1899 tex_image_2d_failed_(false), |
1873 frame_number_(0), | 1900 frame_number_(0), |
1874 has_arb_robustness_(false), | 1901 has_arb_robustness_(false), |
1875 reset_status_(GL_NO_ERROR), | 1902 reset_status_(GL_NO_ERROR), |
1876 needs_mac_nvidia_driver_workaround_(false), | 1903 needs_mac_nvidia_driver_workaround_(false), |
1877 needs_glsl_built_in_function_emulation_(false), | 1904 needs_glsl_built_in_function_emulation_(false), |
1878 force_webgl_glsl_validation_(false), | 1905 force_webgl_glsl_validation_(false), |
1879 derivatives_explicitly_enabled_(false), | 1906 derivatives_explicitly_enabled_(false), |
1880 compile_shader_always_succeeds_(false) { | 1907 compile_shader_always_succeeds_(false), |
| 1908 viewport_x_(0), |
| 1909 viewport_y_(0), |
| 1910 viewport_width_(0), |
| 1911 viewport_height_(0), |
| 1912 viewport_max_width_(0), |
| 1913 viewport_max_height_(0) { |
1881 DCHECK(group); | 1914 DCHECK(group); |
1882 | 1915 |
1883 attrib_0_value_.v[0] = 0.0f; | 1916 attrib_0_value_.v[0] = 0.0f; |
1884 attrib_0_value_.v[1] = 0.0f; | 1917 attrib_0_value_.v[1] = 0.0f; |
1885 attrib_0_value_.v[2] = 0.0f; | 1918 attrib_0_value_.v[2] = 0.0f; |
1886 attrib_0_value_.v[3] = 1.0f; | 1919 attrib_0_value_.v[3] = 1.0f; |
1887 | 1920 |
1888 // The shader translator is used for WebGL even when running on EGL | 1921 // The shader translator is used for WebGL even when running on EGL |
1889 // because additional restrictions are needed (like only enabling | 1922 // because additional restrictions are needed (like only enabling |
1890 // GL_OES_standard_derivatives on demand). It is used for the unit | 1923 // GL_OES_standard_derivatives on demand). It is used for the unit |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 return false; | 1985 return false; |
1953 } | 1986 } |
1954 | 1987 |
1955 if (!group_->Initialize(disallowed_features, allowed_extensions)) { | 1988 if (!group_->Initialize(disallowed_features, allowed_extensions)) { |
1956 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 1989 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
1957 << "failed to initialize."; | 1990 << "failed to initialize."; |
1958 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 1991 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
1959 Destroy(); | 1992 Destroy(); |
1960 return false; | 1993 return false; |
1961 } | 1994 } |
| 1995 CHECK_GL_ERROR(); |
1962 | 1996 |
| 1997 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 1998 copy_texture_CHROMIUM_->Initialize(); |
1963 CHECK_GL_ERROR(); | 1999 CHECK_GL_ERROR(); |
| 2000 |
1964 disallowed_features_ = disallowed_features; | 2001 disallowed_features_ = disallowed_features; |
1965 | 2002 |
1966 vertex_attrib_manager_.reset(new VertexAttribManager()); | 2003 vertex_attrib_manager_.reset(new VertexAttribManager()); |
1967 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); | 2004 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); |
1968 | 2005 |
1969 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags( | 2006 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags( |
1970 ).use_arb_occlusion_query2_for_occlusion_query_boolean)); | 2007 ).use_arb_occlusion_query2_for_occlusion_query_boolean)); |
1971 | 2008 |
1972 util_.set_num_compressed_texture_formats( | 2009 util_.set_num_compressed_texture_formats( |
1973 validators_->compressed_texture_format.GetValues().size()); | 2010 validators_->compressed_texture_format.GetValues().size()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 vendor_str && strstr(vendor_str, "NVIDIA"); | 2210 vendor_str && strstr(vendor_str, "NVIDIA"); |
2174 needs_glsl_built_in_function_emulation_ = | 2211 needs_glsl_built_in_function_emulation_ = |
2175 vendor_str && (strstr(vendor_str, "ATI") || strstr(vendor_str, "AMD")); | 2212 vendor_str && (strstr(vendor_str, "ATI") || strstr(vendor_str, "AMD")); |
2176 #endif | 2213 #endif |
2177 } | 2214 } |
2178 | 2215 |
2179 if (!InitializeShaderTranslator()) { | 2216 if (!InitializeShaderTranslator()) { |
2180 return false; | 2217 return false; |
2181 } | 2218 } |
2182 | 2219 |
| 2220 GLint viewport_params[4]; |
| 2221 glGetIntegerv(GL_VIEWPORT, viewport_params); |
| 2222 viewport_x_ = viewport_params[0]; |
| 2223 viewport_y_ = viewport_params[1]; |
| 2224 viewport_width_ = viewport_params[2]; |
| 2225 viewport_height_ = viewport_params[3]; |
| 2226 |
| 2227 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
| 2228 viewport_max_width_ = viewport_params[0]; |
| 2229 viewport_max_height_ = viewport_params[0]; |
| 2230 |
2183 return true; | 2231 return true; |
2184 } | 2232 } |
2185 | 2233 |
2186 void GLES2DecoderImpl::UpdateCapabilities() { | 2234 void GLES2DecoderImpl::UpdateCapabilities() { |
2187 util_.set_num_compressed_texture_formats( | 2235 util_.set_num_compressed_texture_formats( |
2188 validators_->compressed_texture_format.GetValues().size()); | 2236 validators_->compressed_texture_format.GetValues().size()); |
2189 util_.set_num_shader_binary_formats( | 2237 util_.set_num_shader_binary_formats( |
2190 validators_->shader_binary_format.GetValues().size()); | 2238 validators_->shader_binary_format.GetValues().size()); |
2191 } | 2239 } |
2192 | 2240 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 texture_units_.reset(); | 2727 texture_units_.reset(); |
2680 bound_array_buffer_ = NULL; | 2728 bound_array_buffer_ = NULL; |
2681 bound_element_array_buffer_ = NULL; | 2729 bound_element_array_buffer_ = NULL; |
2682 current_query_ = NULL; | 2730 current_query_ = NULL; |
2683 current_program_ = NULL; | 2731 current_program_ = NULL; |
2684 bound_read_framebuffer_ = NULL; | 2732 bound_read_framebuffer_ = NULL; |
2685 bound_draw_framebuffer_ = NULL; | 2733 bound_draw_framebuffer_ = NULL; |
2686 bound_renderbuffer_ = NULL; | 2734 bound_renderbuffer_ = NULL; |
2687 | 2735 |
2688 if (have_context) { | 2736 if (have_context) { |
| 2737 copy_texture_CHROMIUM_->Destroy(); |
| 2738 |
2689 if (current_program_) { | 2739 if (current_program_) { |
2690 program_manager()->UnuseProgram(shader_manager(), current_program_); | 2740 program_manager()->UnuseProgram(shader_manager(), current_program_); |
2691 current_program_ = NULL; | 2741 current_program_ = NULL; |
2692 } | 2742 } |
2693 | 2743 |
2694 if (attrib_0_buffer_id_) { | 2744 if (attrib_0_buffer_id_) { |
2695 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 2745 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
2696 } | 2746 } |
2697 if (fixed_attrib_buffer_id_) { | 2747 if (fixed_attrib_buffer_id_) { |
2698 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); | 2748 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); |
(...skipping 30 matching lines...) Expand all Loading... |
2729 offscreen_target_stencil_render_buffer_->Invalidate(); | 2779 offscreen_target_stencil_render_buffer_->Invalidate(); |
2730 if (offscreen_saved_frame_buffer_.get()) | 2780 if (offscreen_saved_frame_buffer_.get()) |
2731 offscreen_saved_frame_buffer_->Invalidate(); | 2781 offscreen_saved_frame_buffer_->Invalidate(); |
2732 if (offscreen_saved_color_texture_.get()) | 2782 if (offscreen_saved_color_texture_.get()) |
2733 offscreen_saved_color_texture_->Invalidate(); | 2783 offscreen_saved_color_texture_->Invalidate(); |
2734 if (offscreen_resolved_frame_buffer_.get()) | 2784 if (offscreen_resolved_frame_buffer_.get()) |
2735 offscreen_resolved_frame_buffer_->Invalidate(); | 2785 offscreen_resolved_frame_buffer_->Invalidate(); |
2736 if (offscreen_resolved_color_texture_.get()) | 2786 if (offscreen_resolved_color_texture_.get()) |
2737 offscreen_resolved_color_texture_->Invalidate(); | 2787 offscreen_resolved_color_texture_->Invalidate(); |
2738 } | 2788 } |
| 2789 copy_texture_CHROMIUM_.reset(); |
2739 | 2790 |
2740 if (query_manager_.get()) { | 2791 if (query_manager_.get()) { |
2741 query_manager_->Destroy(have_context); | 2792 query_manager_->Destroy(have_context); |
2742 query_manager_.reset(); | 2793 query_manager_.reset(); |
2743 } | 2794 } |
2744 | 2795 |
2745 if (group_) { | 2796 if (group_) { |
2746 group_->Destroy(have_context); | 2797 group_->Destroy(have_context); |
2747 group_ = NULL; | 2798 group_ = NULL; |
2748 } | 2799 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3193 glColorMask( | 3244 glColorMask( |
3194 mask_red_, mask_green_, mask_blue_, | 3245 mask_red_, mask_green_, mask_blue_, |
3195 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha()); | 3246 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha()); |
3196 bool have_depth = BoundFramebufferHasDepthAttachment(); | 3247 bool have_depth = BoundFramebufferHasDepthAttachment(); |
3197 glDepthMask(mask_depth_ && have_depth); | 3248 glDepthMask(mask_depth_ && have_depth); |
3198 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); | 3249 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); |
3199 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3250 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
3200 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); | 3251 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); |
3201 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); | 3252 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); |
3202 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); | 3253 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); |
| 3254 EnableDisable(GL_CULL_FACE, enable_cull_face_); |
| 3255 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); |
3203 state_dirty_ = false; | 3256 state_dirty_ = false; |
3204 } | 3257 } |
3205 } | 3258 } |
3206 | 3259 |
3207 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { | 3260 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { |
3208 return (offscreen_target_frame_buffer_.get()) ? | 3261 return (offscreen_target_frame_buffer_.get()) ? |
3209 offscreen_target_frame_buffer_->id() : | 3262 offscreen_target_frame_buffer_->id() : |
3210 surface_->GetBackingFrameBufferObject(); | 3263 surface_->GetBackingFrameBufferObject(); |
3211 } | 3264 } |
3212 | 3265 |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4003 if (error == GL_NO_ERROR) { | 4056 if (error == GL_NO_ERROR) { |
4004 framebuffer_info->AttachRenderbuffer(attachment, info); | 4057 framebuffer_info->AttachRenderbuffer(attachment, info); |
4005 } | 4058 } |
4006 if (framebuffer_info == bound_draw_framebuffer_) { | 4059 if (framebuffer_info == bound_draw_framebuffer_) { |
4007 state_dirty_ = true; | 4060 state_dirty_ = true; |
4008 } | 4061 } |
4009 } | 4062 } |
4010 | 4063 |
4011 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { | 4064 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { |
4012 switch (cap) { | 4065 switch (cap) { |
| 4066 case GL_CULL_FACE: |
| 4067 enable_cull_face_ = enabled; |
| 4068 return true; |
4013 case GL_SCISSOR_TEST: | 4069 case GL_SCISSOR_TEST: |
4014 enable_scissor_test_ = enabled; | 4070 enable_scissor_test_ = enabled; |
4015 return true; | 4071 return true; |
4016 case GL_DEPTH_TEST: { | 4072 case GL_DEPTH_TEST: { |
4017 if (enable_depth_test_ != enabled) { | 4073 if (enable_depth_test_ != enabled) { |
4018 enable_depth_test_ = enabled; | 4074 enable_depth_test_ = enabled; |
4019 state_dirty_ = true; | 4075 state_dirty_ = true; |
4020 } | 4076 } |
4021 return false; | 4077 return false; |
4022 } | 4078 } |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4991 | 5047 |
4992 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); | 5048 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); |
4993 | 5049 |
4994 if (info->divisor()) | 5050 if (info->divisor()) |
4995 glVertexAttribDivisorANGLE(0, 0); | 5051 glVertexAttribDivisorANGLE(0, 0); |
4996 | 5052 |
4997 *simulated = true; | 5053 *simulated = true; |
4998 return true; | 5054 return true; |
4999 } | 5055 } |
5000 | 5056 |
5001 void GLES2DecoderImpl::RestoreStateForSimulatedAttrib0() { | 5057 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) { |
5002 const VertexAttribManager::VertexAttribInfo* info = | 5058 const VertexAttribManager::VertexAttribInfo* info = |
5003 vertex_attrib_manager_->GetVertexAttribInfo(0); | 5059 vertex_attrib_manager_->GetVertexAttribInfo(attrib); |
5004 const void* ptr = reinterpret_cast<const void*>(info->offset()); | 5060 const void* ptr = reinterpret_cast<const void*>(info->offset()); |
5005 BufferManager::BufferInfo* buffer_info = info->buffer(); | 5061 BufferManager::BufferInfo* buffer_info = info->buffer(); |
5006 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); | 5062 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); |
5007 glVertexAttribPointer( | 5063 glVertexAttribPointer( |
5008 0, info->size(), info->type(), info->normalized(), info->gl_stride(), | 5064 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(), |
5009 ptr); | 5065 ptr); |
5010 if (info->divisor()) | 5066 if (info->divisor()) |
5011 glVertexAttribDivisorANGLE(0, info->divisor()); | 5067 glVertexAttribDivisorANGLE(attrib, info->divisor()); |
5012 glBindBuffer(GL_ARRAY_BUFFER, | 5068 glBindBuffer(GL_ARRAY_BUFFER, |
5013 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0); | 5069 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0); |
| 5070 |
| 5071 if (info->enabled()) { |
| 5072 glEnableVertexAttribArray(attrib); |
| 5073 } else { |
| 5074 glDisableVertexAttribArray(attrib); |
| 5075 } |
5014 } | 5076 } |
5015 | 5077 |
5016 bool GLES2DecoderImpl::SimulateFixedAttribs( | 5078 bool GLES2DecoderImpl::SimulateFixedAttribs( |
5017 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { | 5079 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { |
5018 DCHECK(simulated); | 5080 DCHECK(simulated); |
5019 *simulated = false; | 5081 *simulated = false; |
5020 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) | 5082 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
5021 return true; | 5083 return true; |
5022 | 5084 |
5023 if (!vertex_attrib_manager_->HaveFixedAttribs()) { | 5085 if (!vertex_attrib_manager_->HaveFixedAttribs()) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5176 } | 5238 } |
5177 ProcessPendingQueries(); | 5239 ProcessPendingQueries(); |
5178 if (textures_set) { | 5240 if (textures_set) { |
5179 RestoreStateForNonRenderableTextures(); | 5241 RestoreStateForNonRenderableTextures(); |
5180 } | 5242 } |
5181 if (simulated_fixed_attribs) { | 5243 if (simulated_fixed_attribs) { |
5182 RestoreStateForSimulatedFixedAttribs(); | 5244 RestoreStateForSimulatedFixedAttribs(); |
5183 } | 5245 } |
5184 } | 5246 } |
5185 if (simulated_attrib_0) { | 5247 if (simulated_attrib_0) { |
5186 RestoreStateForSimulatedAttrib0(); | 5248 RestoreStateForAttrib(0); |
5187 } | 5249 } |
5188 if (WasContextLost()) { | 5250 if (WasContextLost()) { |
5189 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays."; | 5251 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays."; |
5190 return error::kLostContext; | 5252 return error::kLostContext; |
5191 } | 5253 } |
5192 } | 5254 } |
5193 return error::kNoError; | 5255 return error::kNoError; |
5194 } | 5256 } |
5195 | 5257 |
5196 error::Error GLES2DecoderImpl::HandleDrawArrays( | 5258 error::Error GLES2DecoderImpl::HandleDrawArrays( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5287 } | 5349 } |
5288 ProcessPendingQueries(); | 5350 ProcessPendingQueries(); |
5289 if (textures_set) { | 5351 if (textures_set) { |
5290 RestoreStateForNonRenderableTextures(); | 5352 RestoreStateForNonRenderableTextures(); |
5291 } | 5353 } |
5292 if (simulated_fixed_attribs) { | 5354 if (simulated_fixed_attribs) { |
5293 RestoreStateForSimulatedFixedAttribs(); | 5355 RestoreStateForSimulatedFixedAttribs(); |
5294 } | 5356 } |
5295 } | 5357 } |
5296 if (simulated_attrib_0) { | 5358 if (simulated_attrib_0) { |
5297 RestoreStateForSimulatedAttrib0(); | 5359 RestoreStateForAttrib(0); |
5298 } | 5360 } |
5299 if (WasContextLost()) { | 5361 if (WasContextLost()) { |
5300 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawElements."; | 5362 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawElements."; |
5301 return error::kLostContext; | 5363 return error::kLostContext; |
5302 } | 5364 } |
5303 } | 5365 } |
5304 return error::kNoError; | 5366 return error::kNoError; |
5305 } | 5367 } |
5306 | 5368 |
5307 error::Error GLES2DecoderImpl::HandleDrawElements( | 5369 error::Error GLES2DecoderImpl::HandleDrawElements( |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5927 normalized, | 5989 normalized, |
5928 stride, | 5990 stride, |
5929 stride != 0 ? stride : component_size * size, | 5991 stride != 0 ? stride : component_size * size, |
5930 offset); | 5992 offset); |
5931 if (type != GL_FIXED) { | 5993 if (type != GL_FIXED) { |
5932 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 5994 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
5933 } | 5995 } |
5934 return error::kNoError; | 5996 return error::kNoError; |
5935 } | 5997 } |
5936 | 5998 |
| 5999 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
| 6000 GLsizei height) { |
| 6001 viewport_x_ = x; |
| 6002 viewport_y_ = y; |
| 6003 viewport_width_ = std::min(width, viewport_max_width_); |
| 6004 viewport_height_ = std::min(height, viewport_max_height_); |
| 6005 glViewport(x, y, width, height); |
| 6006 } |
| 6007 |
5937 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( | 6008 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( |
5938 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { | 6009 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { |
5939 if (!feature_info_->feature_flags().angle_instanced_arrays) { | 6010 if (!feature_info_->feature_flags().angle_instanced_arrays) { |
5940 SetGLError(GL_INVALID_OPERATION, | 6011 SetGLError(GL_INVALID_OPERATION, |
5941 "glVertexAttribDivisorANGLE: function not available"); | 6012 "glVertexAttribDivisorANGLE: function not available"); |
5942 } | 6013 } |
5943 GLuint index = c.index; | 6014 GLuint index = c.index; |
5944 GLuint divisor = c.divisor; | 6015 GLuint divisor = c.divisor; |
5945 if (index >= group_->max_vertex_attribs()) { | 6016 if (index >= group_->max_vertex_attribs()) { |
5946 SetGLError(GL_INVALID_VALUE, | 6017 SetGLError(GL_INVALID_VALUE, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6125 glPixelStorei(pname, param); | 6196 glPixelStorei(pname, param); |
6126 switch (pname) { | 6197 switch (pname) { |
6127 case GL_PACK_ALIGNMENT: | 6198 case GL_PACK_ALIGNMENT: |
6128 pack_alignment_ = param; | 6199 pack_alignment_ = param; |
6129 break; | 6200 break; |
6130 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: | 6201 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
6131 break; | 6202 break; |
6132 case GL_UNPACK_ALIGNMENT: | 6203 case GL_UNPACK_ALIGNMENT: |
6133 unpack_alignment_ = param; | 6204 unpack_alignment_ = param; |
6134 break; | 6205 break; |
| 6206 case GL_UNPACK_FLIP_Y_CHROMIUM: |
| 6207 unpack_flip_y_ = (param != 0); |
| 6208 break; |
| 6209 case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM: |
| 6210 unpack_premultiply_alpha_ = (param != 0); |
| 6211 break; |
6135 default: | 6212 default: |
6136 // Validation should have prevented us from getting here. | 6213 // Validation should have prevented us from getting here. |
6137 NOTREACHED(); | 6214 NOTREACHED(); |
6138 break; | 6215 break; |
6139 } | 6216 } |
6140 return error::kNoError; | 6217 return error::kNoError; |
6141 } | 6218 } |
6142 | 6219 |
6143 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6220 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
6144 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { | 6221 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { |
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8209 return GL_LUMINANCE; | 8286 return GL_LUMINANCE; |
8210 case GL_LUMINANCE_ALPHA16F_EXT: | 8287 case GL_LUMINANCE_ALPHA16F_EXT: |
8211 return GL_LUMINANCE_ALPHA; | 8288 return GL_LUMINANCE_ALPHA; |
8212 case GL_BGRA8_EXT: | 8289 case GL_BGRA8_EXT: |
8213 return GL_BGRA_EXT; | 8290 return GL_BGRA_EXT; |
8214 default: | 8291 default: |
8215 return GL_NONE; | 8292 return GL_NONE; |
8216 } | 8293 } |
8217 } | 8294 } |
8218 | 8295 |
| 8296 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| 8297 GLenum target, GLuint source_id, GLuint dest_id, GLint level) { |
| 8298 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id); |
| 8299 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id); |
| 8300 |
| 8301 if (!source_info || !dest_info) { |
| 8302 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM: unknown texture id"); |
| 8303 return; |
| 8304 } |
| 8305 |
| 8306 if (GL_TEXTURE_2D != target) { |
| 8307 SetGLError(GL_INVALID_VALUE, |
| 8308 "glCopyTextureCHROMIUM: invalid texture target"); |
| 8309 return; |
| 8310 } |
| 8311 |
| 8312 int source_width, source_height, dest_width, dest_height; |
| 8313 if (!source_info->GetLevelSize(GL_TEXTURE_2D, 0, &source_width, |
| 8314 &source_height)) { |
| 8315 SetGLError(GL_INVALID_VALUE, |
| 8316 "glCopyTextureChromium: source texture has no level 0"); |
| 8317 return; |
| 8318 } |
| 8319 |
| 8320 if (!dest_info->GetLevelSize(GL_TEXTURE_2D, level, &dest_width, |
| 8321 &dest_height)) { |
| 8322 SetGLError(GL_INVALID_VALUE, |
| 8323 "glCopyTextureChromium: destination texture level does not exist"); |
| 8324 return; |
| 8325 } |
| 8326 |
| 8327 // Check that this type of texture is allowed. |
| 8328 if (!texture_manager()->ValidForTarget(GL_TEXTURE_2D, level, source_width, |
| 8329 source_height, 1)) { |
| 8330 SetGLError(GL_INVALID_VALUE, |
| 8331 "glCopyTextureCHROMIUM: Bad dimensions"); |
| 8332 return; |
| 8333 } |
| 8334 |
| 8335 // Resize the destination texture to the dimensions of the source texture. |
| 8336 if (dest_width != source_width && dest_height != source_height) { |
| 8337 GLenum type; |
| 8338 GLenum internal_format; |
| 8339 dest_info->GetLevelType(GL_TEXTURE_2D, level, &type, &internal_format); |
| 8340 |
| 8341 // Ensure that the glTexImage2D succeeds. |
| 8342 CopyRealGLErrorsToWrapper(); |
| 8343 WrappedTexImage2D( |
| 8344 GL_TEXTURE_2D, level, internal_format, source_width, source_height, |
| 8345 0, internal_format, type, NULL); |
| 8346 GLenum error = PeekGLError(); |
| 8347 if (error != GL_NO_ERROR) |
| 8348 return; |
| 8349 |
| 8350 texture_manager()->SetLevelInfo( |
| 8351 dest_info, GL_TEXTURE_2D, level, internal_format, source_width, |
| 8352 source_height, 1, 0, internal_format, type, true); |
| 8353 } |
| 8354 |
| 8355 state_dirty_ = true; |
| 8356 glViewport(0, 0, dest_width, dest_height); |
| 8357 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(), |
| 8358 dest_info->service_id(), level, |
| 8359 unpack_flip_y_, |
| 8360 unpack_premultiply_alpha_); |
| 8361 glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_); |
| 8362 |
| 8363 // Restore all of the state touched by the extension. |
| 8364 if (current_program_) |
| 8365 glUseProgram(current_program_->service_id()); |
| 8366 else |
| 8367 glUseProgram(0); |
| 8368 |
| 8369 RestoreCurrentFramebufferBindings(); |
| 8370 RestoreCurrentTexture2DBindings(); |
| 8371 RestoreStateForAttrib( |
| 8372 CopyTextureCHROMIUMResourceManager::kVertexPositionAttrib); |
| 8373 RestoreStateForAttrib( |
| 8374 CopyTextureCHROMIUMResourceManager::kVertexTextureAttrib); |
| 8375 |
| 8376 ApplyDirtyState(); |
| 8377 } |
| 8378 |
8219 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 8379 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
8220 switch (internalformat) { | 8380 switch (internalformat) { |
8221 case GL_RGB565: | 8381 case GL_RGB565: |
8222 return GL_UNSIGNED_SHORT_5_6_5; | 8382 return GL_UNSIGNED_SHORT_5_6_5; |
8223 case GL_RGBA4: | 8383 case GL_RGBA4: |
8224 return GL_UNSIGNED_SHORT_4_4_4_4; | 8384 return GL_UNSIGNED_SHORT_4_4_4_4; |
8225 case GL_RGB5_A1: | 8385 case GL_RGB5_A1: |
8226 return GL_UNSIGNED_SHORT_5_5_5_1; | 8386 return GL_UNSIGNED_SHORT_5_5_5_1; |
8227 case GL_RGB8_OES: | 8387 case GL_RGB8_OES: |
8228 return GL_UNSIGNED_BYTE; | 8388 return GL_UNSIGNED_BYTE; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8306 } | 8466 } |
8307 } | 8467 } |
8308 | 8468 |
8309 // Include the auto-generated part of this file. We split this because it means | 8469 // Include the auto-generated part of this file. We split this because it means |
8310 // we can easily edit the non-auto generated parts right here in this file | 8470 // we can easily edit the non-auto generated parts right here in this file |
8311 // instead of having to edit some template or the code generator. | 8471 // instead of having to edit some template or the code generator. |
8312 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8472 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8313 | 8473 |
8314 } // namespace gles2 | 8474 } // namespace gles2 |
8315 } // namespace gpu | 8475 } // namespace gpu |
OLD | NEW |