Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 9968113: Addition of GL_CHROMIUM_copy_texture extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: More lint error cleanup. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
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
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
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
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
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
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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
5927 normalized, 5983 normalized,
5928 stride, 5984 stride,
5929 stride != 0 ? stride : component_size * size, 5985 stride != 0 ? stride : component_size * size,
5930 offset); 5986 offset);
5931 if (type != GL_FIXED) { 5987 if (type != GL_FIXED) {
5932 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); 5988 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
5933 } 5989 }
5934 return error::kNoError; 5990 return error::kNoError;
5935 } 5991 }
5936 5992
5993 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width,
5994 GLsizei height) {
5995 viewport_x_ = x;
5996 viewport_y_ = y;
5997 viewport_width_ = std::min(width, viewport_max_width_);
5998 viewport_height_ = std::min(height, viewport_max_height_);
5999 glViewport(x, y, width, height);
6000 }
6001
5937 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( 6002 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE(
5938 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { 6003 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) {
5939 if (!feature_info_->feature_flags().angle_instanced_arrays) { 6004 if (!feature_info_->feature_flags().angle_instanced_arrays) {
5940 SetGLError(GL_INVALID_OPERATION, 6005 SetGLError(GL_INVALID_OPERATION,
5941 "glVertexAttribDivisorANGLE: function not available"); 6006 "glVertexAttribDivisorANGLE: function not available");
5942 } 6007 }
5943 GLuint index = c.index; 6008 GLuint index = c.index;
5944 GLuint divisor = c.divisor; 6009 GLuint divisor = c.divisor;
5945 if (index >= group_->max_vertex_attribs()) { 6010 if (index >= group_->max_vertex_attribs()) {
5946 SetGLError(GL_INVALID_VALUE, 6011 SetGLError(GL_INVALID_VALUE,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
6125 glPixelStorei(pname, param); 6190 glPixelStorei(pname, param);
6126 switch (pname) { 6191 switch (pname) {
6127 case GL_PACK_ALIGNMENT: 6192 case GL_PACK_ALIGNMENT:
6128 pack_alignment_ = param; 6193 pack_alignment_ = param;
6129 break; 6194 break;
6130 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: 6195 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6131 break; 6196 break;
6132 case GL_UNPACK_ALIGNMENT: 6197 case GL_UNPACK_ALIGNMENT:
6133 unpack_alignment_ = param; 6198 unpack_alignment_ = param;
6134 break; 6199 break;
6200 case GL_UNPACK_FLIP_Y_CHROMIUM:
6201 unpack_flip_y_ = (param != 0);
6202 break;
6203 case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM:
6204 unpack_premultiply_alpha_ = (param != 0);
6205 break;
6135 default: 6206 default:
6136 // Validation should have prevented us from getting here. 6207 // Validation should have prevented us from getting here.
6137 NOTREACHED(); 6208 NOTREACHED();
6138 break; 6209 break;
6139 } 6210 }
6140 return error::kNoError; 6211 return error::kNoError;
6141 } 6212 }
6142 6213
6143 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( 6214 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(
6144 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { 6215 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) {
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
8209 return GL_LUMINANCE; 8280 return GL_LUMINANCE;
8210 case GL_LUMINANCE_ALPHA16F_EXT: 8281 case GL_LUMINANCE_ALPHA16F_EXT:
8211 return GL_LUMINANCE_ALPHA; 8282 return GL_LUMINANCE_ALPHA;
8212 case GL_BGRA8_EXT: 8283 case GL_BGRA8_EXT:
8213 return GL_BGRA_EXT; 8284 return GL_BGRA_EXT;
8214 default: 8285 default:
8215 return GL_NONE; 8286 return GL_NONE;
8216 } 8287 }
8217 } 8288 }
8218 8289
8290 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
8291 GLenum target, GLuint source_id, GLuint dest_id, GLint level) {
8292 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id);
8293 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id);
8294
8295 if (!source_info || !dest_info) {
8296 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM: unknown texture id");
8297 return;
8298 }
8299
8300 if (GL_TEXTURE_2D != target) {
8301 SetGLError(GL_INVALID_VALUE,
8302 "glCopyTextureCHROMIUM: invalid texture target");
8303 return;
8304 }
8305
8306 int source_width, source_height, dest_width, dest_height;
8307 if (!source_info->GetLevelSize(GL_TEXTURE_2D, 0, &source_width,
8308 &source_height)) {
8309 SetGLError(GL_INVALID_VALUE,
8310 "glCopyTextureChromium: source texture has no level 0");
8311 return;
8312 }
8313
8314 if (!dest_info->GetLevelSize(GL_TEXTURE_2D, level, &dest_width,
8315 &dest_height)) {
8316 SetGLError(GL_INVALID_VALUE,
8317 "glCopyTextureChromium: destination texture level does not exist");
8318 return;
8319 }
8320
8321 // Resize the destination texture to the dimensions of the source texture.
8322 if (dest_width != source_width && dest_height != source_height) {
8323 GLenum type;
8324 GLenum internal_format;
8325 dest_info->GetLevelType(GL_TEXTURE_2D, level, &type, &internal_format);
8326 glTexImage2D(GL_TEXTURE_2D, level, internal_format, source_width,
8327 source_height, 0, internal_format, type, NULL);
8328
8329 dest_info->SetLevelSize(GL_TEXTURE_2D, level, source_width, source_height);
8330 }
8331
8332 state_dirty_ = true;
8333 glViewport(0, 0, dest_width, dest_height);
8334 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(),
8335 dest_info->service_id(), level,
8336 unpack_flip_y_,
8337 unpack_premultiply_alpha_);
8338 glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_);
8339
8340 // Restore all of the state touched by the extension.
8341 if (current_program_)
8342 glUseProgram(current_program_->service_id());
8343 else
8344 glUseProgram(0);
8345
8346 RestoreCurrentFramebufferBindings();
8347 RestoreCurrentTexture2DBindings();
8348
8349 if (!bound_array_buffer_)
greggman 2012/04/15 22:22:41 This isn't enough to restore the state changed in
Jeff Timanus 2012/04/17 01:27:34 I follow the need to restore the settings. I had
8350 glBindBuffer(GL_ARRAY_BUFFER, 0);
8351 else
8352 glBindBuffer(GL_ARRAY_BUFFER, bound_array_buffer_->service_id());
8353
8354 ApplyDirtyState();
8355 }
8356
8219 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 8357 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
8220 switch (internalformat) { 8358 switch (internalformat) {
8221 case GL_RGB565: 8359 case GL_RGB565:
8222 return GL_UNSIGNED_SHORT_5_6_5; 8360 return GL_UNSIGNED_SHORT_5_6_5;
8223 case GL_RGBA4: 8361 case GL_RGBA4:
8224 return GL_UNSIGNED_SHORT_4_4_4_4; 8362 return GL_UNSIGNED_SHORT_4_4_4_4;
8225 case GL_RGB5_A1: 8363 case GL_RGB5_A1:
8226 return GL_UNSIGNED_SHORT_5_5_5_1; 8364 return GL_UNSIGNED_SHORT_5_5_5_1;
8227 case GL_RGB8_OES: 8365 case GL_RGB8_OES:
8228 return GL_UNSIGNED_BYTE; 8366 return GL_UNSIGNED_BYTE;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
8306 } 8444 }
8307 } 8445 }
8308 8446
8309 // Include the auto-generated part of this file. We split this because it means 8447 // 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 8448 // 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. 8449 // instead of having to edit some template or the code generator.
8312 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 8450 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
8313 8451
8314 } // namespace gles2 8452 } // namespace gles2
8315 } // namespace gpu 8453 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698