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

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: Adding extension implementation files. 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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 const void * data); 815 const void * data);
815 816
816 // Wrapper for TexImageIOSurface2DCHROMIUM. 817 // Wrapper for TexImageIOSurface2DCHROMIUM.
817 void DoTexImageIOSurface2DCHROMIUM( 818 void DoTexImageIOSurface2DCHROMIUM(
818 GLenum target, 819 GLenum target,
819 GLsizei width, 820 GLsizei width,
820 GLsizei height, 821 GLsizei height,
821 GLuint io_surface_id, 822 GLuint io_surface_id,
822 GLuint plane); 823 GLuint plane);
823 824
825 void DoCopyTextureCHROMIUM(
826 GLenum target,
827 GLuint source_id,
828 GLuint target_id,
829 GLint level);
830
824 // Wrapper for TexStorage2DEXT. 831 // Wrapper for TexStorage2DEXT.
825 void DoTexStorage2DEXT( 832 void DoTexStorage2DEXT(
826 GLenum target, 833 GLenum target,
827 GLint levels, 834 GLint levels,
828 GLenum internal_format, 835 GLenum internal_format,
829 GLsizei width, 836 GLsizei width,
830 GLsizei height); 837 GLsizei height);
831 838
832 // Creates a ProgramInfo for the given program. 839 // Creates a ProgramInfo for the given program.
833 ProgramManager::ProgramInfo* CreateProgramInfo( 840 ProgramManager::ProgramInfo* CreateProgramInfo(
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 void DoVertexAttrib1f(GLuint index, GLfloat v0); 1227 void DoVertexAttrib1f(GLuint index, GLfloat v0);
1221 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); 1228 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1);
1222 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); 1229 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2);
1223 void DoVertexAttrib4f( 1230 void DoVertexAttrib4f(
1224 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); 1231 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
1225 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); 1232 void DoVertexAttrib1fv(GLuint index, const GLfloat *v);
1226 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); 1233 void DoVertexAttrib2fv(GLuint index, const GLfloat *v);
1227 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); 1234 void DoVertexAttrib3fv(GLuint index, const GLfloat *v);
1228 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); 1235 void DoVertexAttrib4fv(GLuint index, const GLfloat *v);
1229 1236
1237 // Wrapper for glViewport
1238 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height);
1239
1230 // Wrapper for glUseProgram 1240 // Wrapper for glUseProgram
1231 void DoUseProgram(GLuint program); 1241 void DoUseProgram(GLuint program);
1232 1242
1233 // Wrapper for glValidateProgram. 1243 // Wrapper for glValidateProgram.
1234 void DoValidateProgram(GLuint program_client_id); 1244 void DoValidateProgram(GLuint program_client_id);
1235 1245
1236 // Gets the number of values that will be returned by glGetXXX. Returns 1246 // Gets the number of values that will be returned by glGetXXX. Returns
1237 // false if pname is unknown. 1247 // false if pname is unknown.
1238 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); 1248 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values);
1239 1249
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1430
1421 // Util to help with GL. 1431 // Util to help with GL.
1422 GLES2Util util_; 1432 GLES2Util util_;
1423 1433
1424 // pack alignment as last set by glPixelStorei 1434 // pack alignment as last set by glPixelStorei
1425 GLint pack_alignment_; 1435 GLint pack_alignment_;
1426 1436
1427 // unpack alignment as last set by glPixelStorei 1437 // unpack alignment as last set by glPixelStorei
1428 GLint unpack_alignment_; 1438 GLint unpack_alignment_;
1429 1439
1440 // unpack flip y as last set by glPixelStorei
1441 bool unpack_flip_y_;
1442
1443 // unpack premultiply alpha as last set by glPixelStorei
1444 bool unpack_premultiply_alpha_;
1445
1430 // The currently bound array buffer. If this is 0 it is illegal to call 1446 // The currently bound array buffer. If this is 0 it is illegal to call
1431 // glVertexAttribPointer. 1447 // glVertexAttribPointer.
1432 BufferManager::BufferInfo::Ref bound_array_buffer_; 1448 BufferManager::BufferInfo::Ref bound_array_buffer_;
1433 1449
1434 // The currently bound element array buffer. If this is 0 it is illegal 1450 // The currently bound element array buffer. If this is 0 it is illegal
1435 // to call glDrawElements. 1451 // to call glDrawElements.
1436 BufferManager::BufferInfo::Ref bound_element_array_buffer_; 1452 BufferManager::BufferInfo::Ref bound_element_array_buffer_;
1437 1453
1438 // Class that manages vertex attribs. 1454 // Class that manages vertex attribs.
1439 scoped_ptr<VertexAttribManager> vertex_attrib_manager_; 1455 scoped_ptr<VertexAttribManager> vertex_attrib_manager_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 GLclampf clear_alpha_; 1488 GLclampf clear_alpha_;
1473 GLboolean mask_red_; 1489 GLboolean mask_red_;
1474 GLboolean mask_green_; 1490 GLboolean mask_green_;
1475 GLboolean mask_blue_; 1491 GLboolean mask_blue_;
1476 GLboolean mask_alpha_; 1492 GLboolean mask_alpha_;
1477 GLint clear_stencil_; 1493 GLint clear_stencil_;
1478 GLuint mask_stencil_front_; 1494 GLuint mask_stencil_front_;
1479 GLuint mask_stencil_back_; 1495 GLuint mask_stencil_back_;
1480 GLclampf clear_depth_; 1496 GLclampf clear_depth_;
1481 GLboolean mask_depth_; 1497 GLboolean mask_depth_;
1498 bool enable_cull_face_;
1482 bool enable_scissor_test_; 1499 bool enable_scissor_test_;
1483 bool enable_depth_test_; 1500 bool enable_depth_test_;
1484 bool enable_stencil_test_; 1501 bool enable_stencil_test_;
1485 bool state_dirty_; 1502 bool state_dirty_;
1486 1503
1487 // The program in use by glUseProgram 1504 // The program in use by glUseProgram
1488 ProgramManager::ProgramInfo::Ref current_program_; 1505 ProgramManager::ProgramInfo::Ref current_program_;
1489 1506
1490 // The currently bound framebuffers 1507 // The currently bound framebuffers
1491 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; 1508 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 bool compile_shader_always_succeeds_; 1592 bool compile_shader_always_succeeds_;
1576 1593
1577 #if defined(OS_MACOSX) 1594 #if defined(OS_MACOSX)
1578 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; 1595 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap;
1579 TextureToIOSurfaceMap texture_to_io_surface_map_; 1596 TextureToIOSurfaceMap texture_to_io_surface_map_;
1580 #endif 1597 #endif
1581 1598
1582 typedef std::vector<GLES2DecoderImpl*> ChildList; 1599 typedef std::vector<GLES2DecoderImpl*> ChildList;
1583 ChildList children_; 1600 ChildList children_;
1584 1601
1602 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
1603
1604 // Cached values of the currently assigned viewport dimensions.
1605 GLint viewport_x_, viewport_y_;
1606 GLsizei viewport_width_, viewport_height_;
1607
1585 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); 1608 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
1586 }; 1609 };
1587 1610
1588 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) 1611 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder)
1589 : decoder_(decoder) { 1612 : decoder_(decoder) {
1590 decoder_->CopyRealGLErrorsToWrapper(); 1613 decoder_->CopyRealGLErrorsToWrapper();
1591 } 1614 }
1592 1615
1593 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { 1616 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() {
1594 decoder_->ClearRealGLErrors(); 1617 decoder_->ClearRealGLErrors();
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { 1940 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
1918 return new GLES2DecoderImpl(group); 1941 return new GLES2DecoderImpl(group);
1919 } 1942 }
1920 1943
1921 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) 1944 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
1922 : GLES2Decoder(), 1945 : GLES2Decoder(),
1923 group_(group), 1946 group_(group),
1924 error_bits_(0), 1947 error_bits_(0),
1925 pack_alignment_(4), 1948 pack_alignment_(4),
1926 unpack_alignment_(4), 1949 unpack_alignment_(4),
1950 unpack_flip_y_(false),
1951 unpack_premultiply_alpha_(false),
1927 attrib_0_buffer_id_(0), 1952 attrib_0_buffer_id_(0),
1928 attrib_0_buffer_matches_value_(true), 1953 attrib_0_buffer_matches_value_(true),
1929 attrib_0_size_(0), 1954 attrib_0_size_(0),
1930 fixed_attrib_buffer_id_(0), 1955 fixed_attrib_buffer_id_(0),
1931 fixed_attrib_buffer_size_(0), 1956 fixed_attrib_buffer_size_(0),
1932 active_texture_unit_(0), 1957 active_texture_unit_(0),
1933 clear_red_(0), 1958 clear_red_(0),
1934 clear_green_(0), 1959 clear_green_(0),
1935 clear_blue_(0), 1960 clear_blue_(0),
1936 clear_alpha_(0), 1961 clear_alpha_(0),
1937 mask_red_(true), 1962 mask_red_(true),
1938 mask_green_(true), 1963 mask_green_(true),
1939 mask_blue_(true), 1964 mask_blue_(true),
1940 mask_alpha_(true), 1965 mask_alpha_(true),
1941 clear_stencil_(0), 1966 clear_stencil_(0),
1942 mask_stencil_front_(-1), 1967 mask_stencil_front_(-1),
1943 mask_stencil_back_(-1), 1968 mask_stencil_back_(-1),
1944 clear_depth_(1.0f), 1969 clear_depth_(1.0f),
1945 mask_depth_(true), 1970 mask_depth_(true),
1971 enable_cull_face_(false),
1946 enable_scissor_test_(false), 1972 enable_scissor_test_(false),
1947 enable_depth_test_(false), 1973 enable_depth_test_(false),
1948 enable_stencil_test_(false), 1974 enable_stencil_test_(false),
1949 state_dirty_(true), 1975 state_dirty_(true),
1950 offscreen_target_color_format_(0), 1976 offscreen_target_color_format_(0),
1951 offscreen_target_depth_format_(0), 1977 offscreen_target_depth_format_(0),
1952 offscreen_target_stencil_format_(0), 1978 offscreen_target_stencil_format_(0),
1953 offscreen_target_samples_(0), 1979 offscreen_target_samples_(0),
1954 offscreen_target_buffer_preserved_(true), 1980 offscreen_target_buffer_preserved_(true),
1955 offscreen_saved_color_format_(0), 1981 offscreen_saved_color_format_(0),
1956 stream_texture_manager_(NULL), 1982 stream_texture_manager_(NULL),
1957 back_buffer_color_format_(0), 1983 back_buffer_color_format_(0),
1958 back_buffer_has_depth_(false), 1984 back_buffer_has_depth_(false),
1959 back_buffer_has_stencil_(false), 1985 back_buffer_has_stencil_(false),
1960 teximage2d_faster_than_texsubimage2d_(true), 1986 teximage2d_faster_than_texsubimage2d_(true),
1961 bufferdata_faster_than_buffersubdata_(true), 1987 bufferdata_faster_than_buffersubdata_(true),
1962 current_decoder_error_(error::kNoError), 1988 current_decoder_error_(error::kNoError),
1963 use_shader_translator_(true), 1989 use_shader_translator_(true),
1964 validators_(group_->feature_info()->validators()), 1990 validators_(group_->feature_info()->validators()),
1965 feature_info_(group_->feature_info()), 1991 feature_info_(group_->feature_info()),
1966 tex_image_2d_failed_(false), 1992 tex_image_2d_failed_(false),
1967 frame_number_(0), 1993 frame_number_(0),
1968 has_arb_robustness_(false), 1994 has_arb_robustness_(false),
1969 reset_status_(GL_NO_ERROR), 1995 reset_status_(GL_NO_ERROR),
1970 needs_mac_nvidia_driver_workaround_(false), 1996 needs_mac_nvidia_driver_workaround_(false),
1971 needs_glsl_built_in_function_emulation_(false), 1997 needs_glsl_built_in_function_emulation_(false),
1972 force_webgl_glsl_validation_(false), 1998 force_webgl_glsl_validation_(false),
1973 derivatives_explicitly_enabled_(false), 1999 derivatives_explicitly_enabled_(false),
1974 compile_shader_always_succeeds_(false) { 2000 compile_shader_always_succeeds_(false),
2001 viewport_x_(0),
2002 viewport_y_(0),
2003 viewport_width_(0),
2004 viewport_height_(0) {
1975 DCHECK(group); 2005 DCHECK(group);
1976 2006
1977 attrib_0_value_.v[0] = 0.0f; 2007 attrib_0_value_.v[0] = 0.0f;
1978 attrib_0_value_.v[1] = 0.0f; 2008 attrib_0_value_.v[1] = 0.0f;
1979 attrib_0_value_.v[2] = 0.0f; 2009 attrib_0_value_.v[2] = 0.0f;
1980 attrib_0_value_.v[3] = 1.0f; 2010 attrib_0_value_.v[3] = 1.0f;
1981 2011
1982 // The shader translator is used for WebGL even when running on EGL 2012 // The shader translator is used for WebGL even when running on EGL
1983 // because additional restrictions are needed (like only enabling 2013 // because additional restrictions are needed (like only enabling
1984 // GL_OES_standard_derivatives on demand). It is used for the unit 2014 // GL_OES_standard_derivatives on demand). It is used for the unit
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 return false; 2069 return false;
2040 } 2070 }
2041 2071
2042 if (!group_->Initialize(disallowed_features, allowed_extensions)) { 2072 if (!group_->Initialize(disallowed_features, allowed_extensions)) {
2043 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " 2073 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group "
2044 << "failed to initialize."; 2074 << "failed to initialize.";
2045 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 2075 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
2046 Destroy(); 2076 Destroy();
2047 return false; 2077 return false;
2048 } 2078 }
2079 CHECK_GL_ERROR();
2049 2080
2081 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
2082 copy_texture_CHROMIUM_->Initialize();
2050 CHECK_GL_ERROR(); 2083 CHECK_GL_ERROR();
2084
2051 disallowed_features_ = disallowed_features; 2085 disallowed_features_ = disallowed_features;
2052 2086
2053 vertex_attrib_manager_.reset(new VertexAttribManager()); 2087 vertex_attrib_manager_.reset(new VertexAttribManager());
2054 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); 2088 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs());
2055 2089
2056 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags( 2090 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags(
2057 ).use_arb_occlusion_query2_for_occlusion_query_boolean)); 2091 ).use_arb_occlusion_query2_for_occlusion_query_boolean));
2058 2092
2059 util_.set_num_compressed_texture_formats( 2093 util_.set_num_compressed_texture_formats(
2060 validators_->compressed_texture_format.GetValues().size()); 2094 validators_->compressed_texture_format.GetValues().size());
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 #elif defined(OS_WIN) 2297 #elif defined(OS_WIN)
2264 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) 2298 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
2265 needs_glsl_built_in_function_emulation_ = true; 2299 needs_glsl_built_in_function_emulation_ = true;
2266 #endif 2300 #endif
2267 } 2301 }
2268 2302
2269 if (!InitializeShaderTranslator()) { 2303 if (!InitializeShaderTranslator()) {
2270 return false; 2304 return false;
2271 } 2305 }
2272 2306
2307 GLint viewport_params[4];
2308 glGetIntegerv(GL_VIEWPORT, viewport_params);
2309 viewport_x_ = viewport_params[0];
2310 viewport_y_ = viewport_params[1];
2311 viewport_width_ = viewport_params[2];
2312 viewport_height_ = viewport_params[3];
2313
2273 return true; 2314 return true;
2274 } 2315 }
2275 2316
2276 void GLES2DecoderImpl::UpdateCapabilities() { 2317 void GLES2DecoderImpl::UpdateCapabilities() {
2277 util_.set_num_compressed_texture_formats( 2318 util_.set_num_compressed_texture_formats(
2278 validators_->compressed_texture_format.GetValues().size()); 2319 validators_->compressed_texture_format.GetValues().size());
2279 util_.set_num_shader_binary_formats( 2320 util_.set_num_shader_binary_formats(
2280 validators_->shader_binary_format.GetValues().size()); 2321 validators_->shader_binary_format.GetValues().size());
2281 } 2322 }
2282 2323
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 glColorMask( 3329 glColorMask(
3289 mask_red_, mask_green_, mask_blue_, 3330 mask_red_, mask_green_, mask_blue_,
3290 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha()); 3331 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha());
3291 bool have_depth = BoundFramebufferHasDepthAttachment(); 3332 bool have_depth = BoundFramebufferHasDepthAttachment();
3292 glDepthMask(mask_depth_ && have_depth); 3333 glDepthMask(mask_depth_ && have_depth);
3293 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); 3334 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth);
3294 bool have_stencil = BoundFramebufferHasStencilAttachment(); 3335 bool have_stencil = BoundFramebufferHasStencilAttachment();
3295 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); 3336 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0);
3296 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); 3337 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0);
3297 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); 3338 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil);
3339 EnableDisable(GL_CULL_FACE, enable_cull_face_);
3340 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_);
3298 state_dirty_ = false; 3341 state_dirty_ = false;
3299 } 3342 }
3300 } 3343 }
3301 3344
3302 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { 3345 GLuint GLES2DecoderImpl::GetBackbufferServiceId() {
3303 return (offscreen_target_frame_buffer_.get()) ? 3346 return (offscreen_target_frame_buffer_.get()) ?
3304 offscreen_target_frame_buffer_->id() : 3347 offscreen_target_frame_buffer_->id() :
3305 surface_->GetBackingFrameBufferObject(); 3348 surface_->GetBackingFrameBufferObject();
3306 } 3349 }
3307 3350
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 if (error == GL_NO_ERROR) { 4133 if (error == GL_NO_ERROR) {
4091 framebuffer_info->AttachRenderbuffer(attachment, info); 4134 framebuffer_info->AttachRenderbuffer(attachment, info);
4092 } 4135 }
4093 if (framebuffer_info == bound_draw_framebuffer_) { 4136 if (framebuffer_info == bound_draw_framebuffer_) {
4094 state_dirty_ = true; 4137 state_dirty_ = true;
4095 } 4138 }
4096 } 4139 }
4097 4140
4098 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { 4141 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
4099 switch (cap) { 4142 switch (cap) {
4143 case GL_CULL_FACE:
4144 enable_cull_face_ = enabled;
4145 return true;
4100 case GL_SCISSOR_TEST: 4146 case GL_SCISSOR_TEST:
4101 enable_scissor_test_ = enabled; 4147 enable_scissor_test_ = enabled;
4102 return true; 4148 return true;
4103 case GL_DEPTH_TEST: { 4149 case GL_DEPTH_TEST: {
4104 if (enable_depth_test_ != enabled) { 4150 if (enable_depth_test_ != enabled) {
4105 enable_depth_test_ = enabled; 4151 enable_depth_test_ = enabled;
4106 state_dirty_ = true; 4152 state_dirty_ = true;
4107 } 4153 }
4108 return false; 4154 return false;
4109 } 4155 }
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
6013 normalized, 6059 normalized,
6014 stride, 6060 stride,
6015 stride != 0 ? stride : component_size * size, 6061 stride != 0 ? stride : component_size * size,
6016 offset); 6062 offset);
6017 if (type != GL_FIXED) { 6063 if (type != GL_FIXED) {
6018 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); 6064 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
6019 } 6065 }
6020 return error::kNoError; 6066 return error::kNoError;
6021 } 6067 }
6022 6068
6069 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width,
6070 GLsizei height) {
6071 viewport_x_ = x;
greggman 2012/04/04 20:12:24 The viewport will be clipped to the max size and I
Jeff Timanus 2012/04/04 22:34:14 The arguments are validated against 0 in the auto-
6072 viewport_y_ = y;
6073 viewport_width_ = width;
6074 viewport_height_ = height;
6075 glViewport(x, y, width, height);
6076 }
6077
6023 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( 6078 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE(
6024 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { 6079 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) {
6025 if (!feature_info_->feature_flags().angle_instanced_arrays) { 6080 if (!feature_info_->feature_flags().angle_instanced_arrays) {
6026 SetGLError(GL_INVALID_OPERATION, 6081 SetGLError(GL_INVALID_OPERATION,
6027 "glVertexAttribDivisorANGLE: function not available"); 6082 "glVertexAttribDivisorANGLE: function not available");
6028 } 6083 }
6029 GLuint index = c.index; 6084 GLuint index = c.index;
6030 GLuint divisor = c.divisor; 6085 GLuint divisor = c.divisor;
6031 if (index >= group_->max_vertex_attribs()) { 6086 if (index >= group_->max_vertex_attribs()) {
6032 SetGLError(GL_INVALID_VALUE, 6087 SetGLError(GL_INVALID_VALUE,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
6225 glPixelStorei(pname, param); 6280 glPixelStorei(pname, param);
6226 switch (pname) { 6281 switch (pname) {
6227 case GL_PACK_ALIGNMENT: 6282 case GL_PACK_ALIGNMENT:
6228 pack_alignment_ = param; 6283 pack_alignment_ = param;
6229 break; 6284 break;
6230 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: 6285 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6231 break; 6286 break;
6232 case GL_UNPACK_ALIGNMENT: 6287 case GL_UNPACK_ALIGNMENT:
6233 unpack_alignment_ = param; 6288 unpack_alignment_ = param;
6234 break; 6289 break;
6290 case GL_UNPACK_FLIP_Y_CHROMIUM:
6291 unpack_flip_y_ = (param != 0);
6292 break;
6293 case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM:
6294 unpack_premultiply_alpha_ = (param != 0);
6295 break;
6235 default: 6296 default:
6236 // Validation should have prevented us from getting here. 6297 // Validation should have prevented us from getting here.
6237 NOTREACHED(); 6298 NOTREACHED();
6238 break; 6299 break;
6239 } 6300 }
6240 return error::kNoError; 6301 return error::kNoError;
6241 } 6302 }
6242 6303
6243 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( 6304 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(
6244 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { 6305 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) {
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after
8304 return GL_LUMINANCE; 8365 return GL_LUMINANCE;
8305 case GL_LUMINANCE_ALPHA16F_EXT: 8366 case GL_LUMINANCE_ALPHA16F_EXT:
8306 return GL_LUMINANCE_ALPHA; 8367 return GL_LUMINANCE_ALPHA;
8307 case GL_BGRA8_EXT: 8368 case GL_BGRA8_EXT:
8308 return GL_BGRA_EXT; 8369 return GL_BGRA_EXT;
8309 default: 8370 default:
8310 return GL_NONE; 8371 return GL_NONE;
8311 } 8372 }
8312 } 8373 }
8313 8374
8375 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
8376 GLenum target, GLuint source_id, GLuint dest_id, GLint level) {
8377 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id);
8378 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id);
8379
8380 if (!source_info || !dest_info) {
8381 SetGLError(GL_INVALID_VALUE, "");
greggman 2012/04/04 20:12:24 Do you mind filling out the "" here and below?
Jeff Timanus 2012/04/04 22:34:14 Done.
8382 return;
8383 }
8384
8385 if (GL_TEXTURE_2D != target) {
8386 SetGLError(GL_INVALID_VALUE, "");
8387 return;
8388 }
8389
8390 int source_width, source_height, dest_width, dest_height;
8391 if (!source_info->GetLevelSize(GL_TEXTURE_2D, level, &source_width,
8392 &source_height)) {
8393 SetGLError(GL_INVALID_VALUE, "");
8394 return;
8395 }
8396
8397 if (!dest_info->GetLevelSize(GL_TEXTURE_2D, level, &dest_width,
8398 &dest_height)) {
8399 SetGLError(GL_INVALID_VALUE, "");
8400 return;
8401 }
8402
8403 if (dest_width != source_width && dest_height != source_height) {
greggman 2012/04/04 20:12:24 Should it be ok to copy to a new size? CopyTexImag
Jeff Timanus 2012/04/04 22:34:14 It should be ok to copy to a new size. I'm lookin
8404 SetGLError(GL_INVALID_VALUE, "");
8405 return;
8406 }
8407
8408 state_dirty_ = true;
8409 glViewport(0, 0, dest_width, dest_height);
8410 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(),
8411 dest_info->service_id(), level,
8412 unpack_flip_y_,
8413 unpack_premultiply_alpha_);
8414 glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_);
8415
8416 // Restore all of the state touched by the extension.
8417 if (current_program_)
8418 glUseProgram(current_program_->service_id());
8419
8420 RestoreCurrentFramebufferBindings();
8421
8422 if (!bound_array_buffer_)
8423 glBindBuffer(GL_ARRAY_BUFFER, 0);
8424 else
8425 glBindBuffer(GL_ARRAY_BUFFER, bound_array_buffer_->service_id());
8426
8427 ApplyDirtyState();
greggman 2012/04/04 20:12:24 I get the impression more things need to be restor
Jeff Timanus 2012/04/04 22:34:14 Ongoing. I'll add the extra state tracking to dou
8428 }
8429
8314 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 8430 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
8315 switch (internalformat) { 8431 switch (internalformat) {
8316 case GL_RGB565: 8432 case GL_RGB565:
8317 return GL_UNSIGNED_SHORT_5_6_5; 8433 return GL_UNSIGNED_SHORT_5_6_5;
8318 case GL_RGBA4: 8434 case GL_RGBA4:
8319 return GL_UNSIGNED_SHORT_4_4_4_4; 8435 return GL_UNSIGNED_SHORT_4_4_4_4;
8320 case GL_RGB5_A1: 8436 case GL_RGB5_A1:
8321 return GL_UNSIGNED_SHORT_5_5_5_1; 8437 return GL_UNSIGNED_SHORT_5_5_5_1;
8322 case GL_RGB8_OES: 8438 case GL_RGB8_OES:
8323 return GL_UNSIGNED_BYTE; 8439 return GL_UNSIGNED_BYTE;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
8401 } 8517 }
8402 } 8518 }
8403 8519
8404 // Include the auto-generated part of this file. We split this because it means 8520 // Include the auto-generated part of this file. We split this because it means
8405 // we can easily edit the non-auto generated parts right here in this file 8521 // we can easily edit the non-auto generated parts right here in this file
8406 // instead of having to edit some template or the code generator. 8522 // instead of having to edit some template or the code generator.
8407 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 8523 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
8408 8524
8409 } // namespace gles2 8525 } // namespace gles2
8410 } // namespace gpu 8526 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698