OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 uint32 parent_client_texture_id); | 549 uint32 parent_client_texture_id); |
550 virtual void Destroy(); | 550 virtual void Destroy(); |
551 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size); | 551 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size); |
552 virtual bool UpdateOffscreenFrameBufferSize(); | 552 virtual bool UpdateOffscreenFrameBufferSize(); |
553 virtual bool MakeCurrent(); | 553 virtual bool MakeCurrent(); |
554 virtual GLES2Util* GetGLES2Util() { return &util_; } | 554 virtual GLES2Util* GetGLES2Util() { return &util_; } |
555 virtual gfx::GLContext* GetGLContext() { return context_.get(); } | 555 virtual gfx::GLContext* GetGLContext() { return context_.get(); } |
556 | 556 |
557 virtual void SetSwapBuffersCallback(Callback0::Type* callback); | 557 virtual void SetSwapBuffersCallback(Callback0::Type* callback); |
558 | 558 |
| 559 // Restores the current state to the user's settings. |
| 560 void RestoreCurrentFramebufferBindings(); |
| 561 void RestoreCurrentRenderbufferBindings(); |
| 562 void RestoreCurrentTexture2DBindings(); |
| 563 |
559 private: | 564 private: |
560 friend class ScopedGLErrorSuppressor; | 565 friend class ScopedGLErrorSuppressor; |
561 friend class ScopedTexture2DBinder; | |
562 friend class ScopedFrameBufferBinder; | |
563 friend class ScopedRenderBufferBinder; | |
564 friend class ScopedDefaultGLContext; | 566 friend class ScopedDefaultGLContext; |
565 friend class RenderBuffer; | 567 friend class RenderBuffer; |
566 friend class FrameBuffer; | 568 friend class FrameBuffer; |
567 | 569 |
568 // State associated with each texture unit. | 570 // State associated with each texture unit. |
569 struct TextureUnit { | 571 struct TextureUnit { |
570 TextureUnit() : bind_target(GL_TEXTURE_2D) { } | 572 TextureUnit() : bind_target(GL_TEXTURE_2D) { } |
571 | 573 |
572 // The last target that was bound to this texture unit. | 574 // The last target that was bound to this texture unit. |
573 GLenum bind_target; | 575 GLenum bind_target; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 return (info && !info->IsDeleted()) ? info : NULL; | 630 return (info && !info->IsDeleted()) ? info : NULL; |
629 } | 631 } |
630 | 632 |
631 // Deletes the texture info for the given texture. | 633 // Deletes the texture info for the given texture. |
632 void RemoveTextureInfo(GLuint client_id) { | 634 void RemoveTextureInfo(GLuint client_id) { |
633 texture_manager()->RemoveTextureInfo(client_id); | 635 texture_manager()->RemoveTextureInfo(client_id); |
634 } | 636 } |
635 | 637 |
636 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 638 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
637 // or regular back buffer). | 639 // or regular back buffer). |
638 gfx::Size GetBoundFrameBufferSize(); | 640 gfx::Size GetBoundReadFrameBufferSize(); |
639 | 641 |
640 // Wrapper for CompressedTexImage2D commands. | 642 // Wrapper for CompressedTexImage2D commands. |
641 error::Error DoCompressedTexImage2D( | 643 error::Error DoCompressedTexImage2D( |
642 GLenum target, | 644 GLenum target, |
643 GLint level, | 645 GLint level, |
644 GLenum internal_format, | 646 GLenum internal_format, |
645 GLsizei width, | 647 GLsizei width, |
646 GLsizei height, | 648 GLsizei height, |
647 GLint border, | 649 GLint border, |
648 GLsizei image_size, | 650 GLsizei image_size, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 843 |
842 error::Error GetUniformLocationHelper( | 844 error::Error GetUniformLocationHelper( |
843 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 845 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
844 const std::string& name_str); | 846 const std::string& name_str); |
845 | 847 |
846 // Helper for glShaderSource. | 848 // Helper for glShaderSource. |
847 error::Error ShaderSourceHelper( | 849 error::Error ShaderSourceHelper( |
848 GLuint client_id, const char* data, uint32 data_size); | 850 GLuint client_id, const char* data, uint32 data_size); |
849 | 851 |
850 // Clears any uncleared render buffers attached to the given frame buffer. | 852 // Clears any uncleared render buffers attached to the given frame buffer. |
851 void ClearUnclearedRenderbuffers(FramebufferManager::FramebufferInfo* info); | 853 void ClearUnclearedRenderbuffers( |
| 854 GLenum target, FramebufferManager::FramebufferInfo* info); |
852 | 855 |
853 // Remembers the state of some capabilities. | 856 // Remembers the state of some capabilities. |
854 void SetCapabilityState(GLenum cap, bool enabled); | 857 void SetCapabilityState(GLenum cap, bool enabled); |
855 | 858 |
856 // Checks if the current program exists and is valid. If not generates the | 859 // Checks if the current program exists and is valid. If not generates the |
857 // appropriate GL error. Returns true if the current program is in a usable | 860 // appropriate GL error. Returns true if the current program is in a usable |
858 // state. | 861 // state. |
859 bool CheckCurrentProgram(const char* function_name); | 862 bool CheckCurrentProgram(const char* function_name); |
860 | 863 |
861 // Checks if the current program exists and is valid and that location is not | 864 // Checks if the current program exists and is valid and that location is not |
(...skipping 28 matching lines...) Expand all Loading... |
890 | 893 |
891 // Wrapper for glBindFramebuffer since we need to track the current targets. | 894 // Wrapper for glBindFramebuffer since we need to track the current targets. |
892 void DoBindFramebuffer(GLenum target, GLuint framebuffer); | 895 void DoBindFramebuffer(GLenum target, GLuint framebuffer); |
893 | 896 |
894 // Wrapper for glBindRenderbuffer since we need to track the current targets. | 897 // Wrapper for glBindRenderbuffer since we need to track the current targets. |
895 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); | 898 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); |
896 | 899 |
897 // Wrapper for glBindTexture since we need to track the current targets. | 900 // Wrapper for glBindTexture since we need to track the current targets. |
898 void DoBindTexture(GLenum target, GLuint texture); | 901 void DoBindTexture(GLenum target, GLuint texture); |
899 | 902 |
| 903 // Wrapper for glBlitFramebufferEXT. |
| 904 void DoBlitFramebufferEXT( |
| 905 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 906 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 907 GLbitfield mask, GLenum filter); |
| 908 |
900 // Wrapper for glBufferData. | 909 // Wrapper for glBufferData. |
901 void DoBufferData( | 910 void DoBufferData( |
902 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); | 911 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); |
903 | 912 |
904 // Wrapper for glBufferSubData. | 913 // Wrapper for glBufferSubData. |
905 void DoBufferSubData( | 914 void DoBufferSubData( |
906 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); | 915 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); |
907 | 916 |
908 // Wrapper for glCheckFramebufferStatus | 917 // Wrapper for glCheckFramebufferStatus |
909 GLenum DoCheckFramebufferStatus(GLenum target); | 918 GLenum DoCheckFramebufferStatus(GLenum target); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 // Wrapper for glLinkProgram | 1012 // Wrapper for glLinkProgram |
1004 void DoLinkProgram(GLuint program); | 1013 void DoLinkProgram(GLuint program); |
1005 | 1014 |
1006 // Helper for RegisterSharedIds. | 1015 // Helper for RegisterSharedIds. |
1007 void DoRegisterSharedIds(GLuint namespace_id, GLsizei n, const GLuint* ids); | 1016 void DoRegisterSharedIds(GLuint namespace_id, GLsizei n, const GLuint* ids); |
1008 | 1017 |
1009 // Wrapper for glRenderbufferStorage. | 1018 // Wrapper for glRenderbufferStorage. |
1010 void DoRenderbufferStorage( | 1019 void DoRenderbufferStorage( |
1011 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); | 1020 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); |
1012 | 1021 |
| 1022 // Wrapper for glRenderbufferStorageMultisampleEXT. |
| 1023 void DoRenderbufferStorageMultisample( |
| 1024 GLenum target, GLsizei samples, GLenum internalformat, |
| 1025 GLsizei width, GLsizei height); |
| 1026 |
1013 // Wrapper for glReleaseShaderCompiler. | 1027 // Wrapper for glReleaseShaderCompiler. |
1014 void DoReleaseShaderCompiler() { } | 1028 void DoReleaseShaderCompiler() { } |
1015 | 1029 |
1016 // Wrappers for glTexParameter functions. | 1030 // Wrappers for glTexParameter functions. |
1017 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); | 1031 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); |
1018 void DoTexParameteri(GLenum target, GLenum pname, GLint param); | 1032 void DoTexParameteri(GLenum target, GLenum pname, GLint param); |
1019 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); | 1033 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); |
1020 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); | 1034 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); |
1021 | 1035 |
1022 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 | 1036 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, | 1122 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, |
1109 // because |texture_| is used by the FBO rendering mechanism for readback | 1123 // because |texture_| is used by the FBO rendering mechanism for readback |
1110 // to the bits that get sent to the browser. | 1124 // to the bits that get sent to the browser. |
1111 default: | 1125 default: |
1112 NOTREACHED(); | 1126 NOTREACHED(); |
1113 return NULL; | 1127 return NULL; |
1114 } | 1128 } |
1115 return (info && !info->IsDeleted()) ? info : NULL; | 1129 return (info && !info->IsDeleted()) ? info : NULL; |
1116 } | 1130 } |
1117 | 1131 |
| 1132 // Gets the framebuffer info for a particular target. |
| 1133 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( |
| 1134 GLenum target) { |
| 1135 FramebufferManager::FramebufferInfo* info = NULL; |
| 1136 switch (target) { |
| 1137 case GL_FRAMEBUFFER: |
| 1138 case GL_DRAW_FRAMEBUFFER: |
| 1139 info = bound_draw_framebuffer_; |
| 1140 break; |
| 1141 case GL_READ_FRAMEBUFFER: |
| 1142 info = bound_read_framebuffer_; |
| 1143 break; |
| 1144 default: |
| 1145 NOTREACHED(); |
| 1146 break; |
| 1147 } |
| 1148 return (info && !info->IsDeleted()) ? info : NULL; |
| 1149 } |
| 1150 |
1118 // Validates the program and location for a glGetUniform call and returns | 1151 // Validates the program and location for a glGetUniform call and returns |
1119 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1152 // a SizeResult setup to receive the result. Returns true if glGetUniform |
1120 // should be called. | 1153 // should be called. |
1121 bool GetUniformSetup( | 1154 bool GetUniformSetup( |
1122 GLuint program, GLint location, | 1155 GLuint program, GLint location, |
1123 uint32 shm_id, uint32 shm_offset, | 1156 uint32 shm_id, uint32 shm_offset, |
1124 error::Error* error, GLuint* service_id, void** result, | 1157 error::Error* error, GLuint* service_id, void** result, |
1125 GLenum* result_type); | 1158 GLenum* result_type); |
1126 | 1159 |
1127 // Generate a member function prototype for each command in an automated and | 1160 // Generate a member function prototype for each command in an automated and |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 GLint clear_stencil_; | 1245 GLint clear_stencil_; |
1213 GLuint mask_stencil_front_; | 1246 GLuint mask_stencil_front_; |
1214 GLuint mask_stencil_back_; | 1247 GLuint mask_stencil_back_; |
1215 GLclampf clear_depth_; | 1248 GLclampf clear_depth_; |
1216 GLboolean mask_depth_; | 1249 GLboolean mask_depth_; |
1217 bool enable_scissor_test_; | 1250 bool enable_scissor_test_; |
1218 | 1251 |
1219 // The program in use by glUseProgram | 1252 // The program in use by glUseProgram |
1220 ProgramManager::ProgramInfo::Ref current_program_; | 1253 ProgramManager::ProgramInfo::Ref current_program_; |
1221 | 1254 |
1222 // The currently bound framebuffer | 1255 // The currently bound framebuffers |
1223 FramebufferManager::FramebufferInfo::Ref bound_framebuffer_; | 1256 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; |
| 1257 FramebufferManager::FramebufferInfo::Ref bound_draw_framebuffer_; |
1224 | 1258 |
1225 // The currently bound renderbuffer | 1259 // The currently bound renderbuffer |
1226 RenderbufferManager::RenderbufferInfo::Ref bound_renderbuffer_; | 1260 RenderbufferManager::RenderbufferInfo::Ref bound_renderbuffer_; |
1227 | 1261 |
1228 bool anti_aliased_; | 1262 bool anti_aliased_; |
1229 | 1263 |
1230 // The offscreen frame buffer that the client renders to. With EGL, the | 1264 // The offscreen frame buffer that the client renders to. With EGL, the |
1231 // depth and stencil buffers are separate. With regular GL there is a single | 1265 // depth and stencil buffers are separate. With regular GL there is a single |
1232 // packed depth stencil buffer in offscreen_target_depth_render_buffer_. | 1266 // packed depth stencil buffer in offscreen_target_depth_render_buffer_. |
1233 // offscreen_target_stencil_render_buffer_ is unused. | 1267 // offscreen_target_stencil_render_buffer_ is unused. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 ScopedGLErrorSuppressor suppressor(decoder_); | 1306 ScopedGLErrorSuppressor suppressor(decoder_); |
1273 | 1307 |
1274 // TODO(apatrick): Check if there are any other states that need to be reset | 1308 // TODO(apatrick): Check if there are any other states that need to be reset |
1275 // before binding a new texture. | 1309 // before binding a new texture. |
1276 glActiveTexture(GL_TEXTURE0); | 1310 glActiveTexture(GL_TEXTURE0); |
1277 glBindTexture(GL_TEXTURE_2D, id); | 1311 glBindTexture(GL_TEXTURE_2D, id); |
1278 } | 1312 } |
1279 | 1313 |
1280 ScopedTexture2DBinder::~ScopedTexture2DBinder() { | 1314 ScopedTexture2DBinder::~ScopedTexture2DBinder() { |
1281 ScopedGLErrorSuppressor suppressor(decoder_); | 1315 ScopedGLErrorSuppressor suppressor(decoder_); |
1282 GLES2DecoderImpl::TextureUnit& info = decoder_->texture_units_[0]; | 1316 decoder_->RestoreCurrentTexture2DBindings(); |
1283 GLuint last_id; | |
1284 if (info.bound_texture_2d) | |
1285 last_id = info.bound_texture_2d->service_id(); | |
1286 else | |
1287 last_id = 0; | |
1288 | |
1289 glBindTexture(GL_TEXTURE_2D, last_id); | |
1290 glActiveTexture(GL_TEXTURE0 + decoder_->active_texture_unit_); | |
1291 } | 1317 } |
1292 | 1318 |
1293 ScopedRenderBufferBinder::ScopedRenderBufferBinder(GLES2DecoderImpl* decoder, | 1319 ScopedRenderBufferBinder::ScopedRenderBufferBinder(GLES2DecoderImpl* decoder, |
1294 GLuint id) | 1320 GLuint id) |
1295 : decoder_(decoder) { | 1321 : decoder_(decoder) { |
1296 ScopedGLErrorSuppressor suppressor(decoder_); | 1322 ScopedGLErrorSuppressor suppressor(decoder_); |
1297 glBindRenderbufferEXT(GL_RENDERBUFFER, id); | 1323 glBindRenderbufferEXT(GL_RENDERBUFFER, id); |
1298 } | 1324 } |
1299 | 1325 |
1300 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { | 1326 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { |
1301 ScopedGLErrorSuppressor suppressor(decoder_); | 1327 ScopedGLErrorSuppressor suppressor(decoder_); |
1302 glBindRenderbufferEXT( | 1328 decoder_->RestoreCurrentRenderbufferBindings(); |
1303 GL_RENDERBUFFER, | |
1304 decoder_->bound_renderbuffer_ ? | |
1305 decoder_->bound_renderbuffer_->service_id() : 0); | |
1306 } | 1329 } |
1307 | 1330 |
1308 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, | 1331 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, |
1309 GLuint id) | 1332 GLuint id) |
1310 : decoder_(decoder) { | 1333 : decoder_(decoder) { |
1311 ScopedGLErrorSuppressor suppressor(decoder_); | 1334 ScopedGLErrorSuppressor suppressor(decoder_); |
1312 glBindFramebufferEXT(GL_FRAMEBUFFER, id); | 1335 glBindFramebufferEXT(GL_FRAMEBUFFER, id); |
1313 } | 1336 } |
1314 | 1337 |
1315 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { | 1338 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { |
1316 ScopedGLErrorSuppressor suppressor(decoder_); | 1339 ScopedGLErrorSuppressor suppressor(decoder_); |
1317 FramebufferManager::FramebufferInfo* info = | 1340 decoder_->RestoreCurrentFramebufferBindings(); |
1318 decoder_->bound_framebuffer_.get(); | |
1319 GLuint framebuffer_id = info ? info->service_id() : 0; | |
1320 if (framebuffer_id == 0 && | |
1321 decoder_->offscreen_target_frame_buffer_.get()) { | |
1322 glBindFramebufferEXT(GL_FRAMEBUFFER, | |
1323 decoder_->offscreen_target_frame_buffer_->id()); | |
1324 } else { | |
1325 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_id); | |
1326 } | |
1327 } | 1341 } |
1328 | 1342 |
1329 ScopedDefaultGLContext::ScopedDefaultGLContext(GLES2DecoderImpl* decoder) | 1343 ScopedDefaultGLContext::ScopedDefaultGLContext(GLES2DecoderImpl* decoder) |
1330 : decoder_(decoder) { | 1344 : decoder_(decoder) { |
1331 decoder_->default_context_->MakeCurrent(); | 1345 decoder_->default_context_->MakeCurrent(); |
1332 } | 1346 } |
1333 | 1347 |
1334 ScopedDefaultGLContext::~ScopedDefaultGLContext() { | 1348 ScopedDefaultGLContext::~ScopedDefaultGLContext() { |
1335 decoder_->context_->MakeCurrent(); | 1349 decoder_->context_->MakeCurrent(); |
1336 } | 1350 } |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 } | 1835 } |
1822 } | 1836 } |
1823 } | 1837 } |
1824 | 1838 |
1825 // } // anonymous namespace | 1839 // } // anonymous namespace |
1826 | 1840 |
1827 bool GLES2DecoderImpl::MakeCurrent() { | 1841 bool GLES2DecoderImpl::MakeCurrent() { |
1828 return context_.get() ? context_->MakeCurrent() : false; | 1842 return context_.get() ? context_->MakeCurrent() : false; |
1829 } | 1843 } |
1830 | 1844 |
1831 gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() { | 1845 void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() { |
1832 if (bound_framebuffer_ != 0) { | 1846 glBindRenderbufferEXT( |
| 1847 GL_RENDERBUFFER, |
| 1848 bound_renderbuffer_ ? bound_renderbuffer_->service_id() : 0); |
| 1849 } |
| 1850 |
| 1851 static void RebindCurrentFramebuffer( |
| 1852 GLenum target, |
| 1853 FramebufferManager::FramebufferInfo* info, |
| 1854 FrameBuffer* offscreen_frame_buffer) { |
| 1855 GLuint framebuffer_id = info ? info->service_id() : 0; |
| 1856 if (framebuffer_id == 0 && offscreen_frame_buffer) { |
| 1857 framebuffer_id = offscreen_frame_buffer->id(); |
| 1858 } |
| 1859 glBindFramebufferEXT(target, framebuffer_id); |
| 1860 } |
| 1861 |
| 1862 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { |
| 1863 if (!group_->extension_flags().ext_framebuffer_multisample) { |
| 1864 RebindCurrentFramebuffer( |
| 1865 GL_FRAMEBUFFER, |
| 1866 bound_draw_framebuffer_.get(), |
| 1867 offscreen_target_frame_buffer_.get()); |
| 1868 } else { |
| 1869 RebindCurrentFramebuffer( |
| 1870 GL_READ_FRAMEBUFFER_EXT, |
| 1871 bound_read_framebuffer_.get(), |
| 1872 offscreen_target_frame_buffer_.get()); |
| 1873 RebindCurrentFramebuffer( |
| 1874 GL_DRAW_FRAMEBUFFER_EXT, |
| 1875 bound_draw_framebuffer_.get(), |
| 1876 offscreen_target_frame_buffer_.get()); |
| 1877 } |
| 1878 } |
| 1879 |
| 1880 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { |
| 1881 GLES2DecoderImpl::TextureUnit& info = texture_units_[0]; |
| 1882 GLuint last_id; |
| 1883 if (info.bound_texture_2d) { |
| 1884 last_id = info.bound_texture_2d->service_id(); |
| 1885 } else { |
| 1886 last_id = 0; |
| 1887 } |
| 1888 |
| 1889 glBindTexture(GL_TEXTURE_2D, last_id); |
| 1890 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); |
| 1891 } |
| 1892 |
| 1893 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { |
| 1894 if (bound_read_framebuffer_ != 0) { |
1833 int width = 0; | 1895 int width = 0; |
1834 int height = 0; | 1896 int height = 0; |
1835 | 1897 |
| 1898 GLenum target = group_->extension_flags().ext_framebuffer_multisample ? |
| 1899 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
| 1900 |
1836 // Assume we have to have COLOR_ATTACHMENT0. Should we check for depth and | 1901 // Assume we have to have COLOR_ATTACHMENT0. Should we check for depth and |
1837 // stencil. | 1902 // stencil. |
1838 GLint fb_type = 0; | 1903 GLint fb_type = 0; |
1839 glGetFramebufferAttachmentParameterivEXT( | 1904 glGetFramebufferAttachmentParameterivEXT( |
1840 GL_FRAMEBUFFER, | 1905 target, |
1841 GL_COLOR_ATTACHMENT0, | 1906 GL_COLOR_ATTACHMENT0, |
1842 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, | 1907 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, |
1843 &fb_type); | 1908 &fb_type); |
1844 switch (fb_type) { | 1909 switch (fb_type) { |
1845 case GL_RENDERBUFFER: | 1910 case GL_RENDERBUFFER: |
1846 { | 1911 { |
1847 GLint renderbuffer_id = 0; | 1912 GLint renderbuffer_id = 0; |
1848 glGetFramebufferAttachmentParameterivEXT( | 1913 glGetFramebufferAttachmentParameterivEXT( |
1849 GL_FRAMEBUFFER, | 1914 target, |
1850 GL_COLOR_ATTACHMENT0, | 1915 GL_COLOR_ATTACHMENT0, |
1851 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, | 1916 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
1852 &renderbuffer_id); | 1917 &renderbuffer_id); |
1853 if (renderbuffer_id != 0) { | 1918 if (renderbuffer_id != 0) { |
1854 glGetRenderbufferParameterivEXT( | 1919 glGetRenderbufferParameterivEXT( |
1855 GL_RENDERBUFFER, | 1920 GL_RENDERBUFFER, |
1856 GL_RENDERBUFFER_WIDTH, | 1921 GL_RENDERBUFFER_WIDTH, |
1857 &width); | 1922 &width); |
1858 glGetRenderbufferParameterivEXT( | 1923 glGetRenderbufferParameterivEXT( |
1859 GL_RENDERBUFFER, | 1924 GL_RENDERBUFFER, |
1860 GL_RENDERBUFFER_HEIGHT, | 1925 GL_RENDERBUFFER_HEIGHT, |
1861 &height); | 1926 &height); |
1862 } | 1927 } |
1863 break; | 1928 break; |
1864 } | 1929 } |
1865 case GL_TEXTURE: | 1930 case GL_TEXTURE: |
1866 { | 1931 { |
1867 GLint texture_id = 0; | 1932 GLint texture_id = 0; |
1868 glGetFramebufferAttachmentParameterivEXT( | 1933 glGetFramebufferAttachmentParameterivEXT( |
1869 GL_FRAMEBUFFER, | 1934 target, |
1870 GL_COLOR_ATTACHMENT0, | 1935 GL_COLOR_ATTACHMENT0, |
1871 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, | 1936 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
1872 &texture_id); | 1937 &texture_id); |
1873 if (texture_id != 0) { | 1938 if (texture_id != 0) { |
1874 GLuint client_id = 0; | 1939 GLuint client_id = 0; |
1875 if (texture_manager()->GetClientId(texture_id, &client_id)) { | 1940 if (texture_manager()->GetClientId(texture_id, &client_id)) { |
1876 TextureManager::TextureInfo* texture_info = | 1941 TextureManager::TextureInfo* texture_info = |
1877 GetTextureInfo(client_id); | 1942 GetTextureInfo(client_id); |
1878 if (texture_info) { | 1943 if (texture_info) { |
1879 GLint level = 0; | 1944 GLint level = 0; |
1880 GLint face = 0; | 1945 GLint face = 0; |
1881 glGetFramebufferAttachmentParameterivEXT( | 1946 glGetFramebufferAttachmentParameterivEXT( |
1882 GL_FRAMEBUFFER, | 1947 target, |
1883 GL_COLOR_ATTACHMENT0, | 1948 GL_COLOR_ATTACHMENT0, |
1884 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, | 1949 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, |
1885 &level); | 1950 &level); |
1886 glGetFramebufferAttachmentParameterivEXT( | 1951 glGetFramebufferAttachmentParameterivEXT( |
1887 GL_FRAMEBUFFER, | 1952 target, |
1888 GL_COLOR_ATTACHMENT0, | 1953 GL_COLOR_ATTACHMENT0, |
1889 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, | 1954 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, |
1890 &face); | 1955 &face); |
1891 texture_info->GetLevelSize( | 1956 texture_info->GetLevelSize( |
1892 face ? face : GL_TEXTURE_2D, level, &width, &height); | 1957 face ? face : GL_TEXTURE_2D, level, &width, &height); |
1893 } | 1958 } |
1894 } | 1959 } |
1895 } | 1960 } |
1896 break; | 1961 break; |
1897 } | 1962 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 glGenFramebuffersEXT(1, &service_id); | 2320 glGenFramebuffersEXT(1, &service_id); |
2256 CreateFramebufferInfo(client_id, service_id); | 2321 CreateFramebufferInfo(client_id, service_id); |
2257 info = GetFramebufferInfo(client_id); | 2322 info = GetFramebufferInfo(client_id); |
2258 IdAllocator* id_allocator = | 2323 IdAllocator* id_allocator = |
2259 group_->GetIdAllocator(id_namespaces::kFramebuffers); | 2324 group_->GetIdAllocator(id_namespaces::kFramebuffers); |
2260 id_allocator->MarkAsUsed(client_id); | 2325 id_allocator->MarkAsUsed(client_id); |
2261 } else { | 2326 } else { |
2262 service_id = info->service_id(); | 2327 service_id = info->service_id(); |
2263 } | 2328 } |
2264 } | 2329 } |
2265 bound_framebuffer_ = info; | 2330 |
| 2331 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { |
| 2332 bound_draw_framebuffer_ = info; |
| 2333 } |
| 2334 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { |
| 2335 bound_read_framebuffer_ = info; |
| 2336 } |
2266 | 2337 |
2267 // When rendering to an offscreen frame buffer, instead of unbinding from | 2338 // When rendering to an offscreen frame buffer, instead of unbinding from |
2268 // the current frame buffer, bind to the offscreen target frame buffer. | 2339 // the current frame buffer, bind to the offscreen target frame buffer. |
2269 if (info == NULL && offscreen_target_frame_buffer_.get()) | 2340 if (info == NULL && offscreen_target_frame_buffer_.get()) |
2270 service_id = offscreen_target_frame_buffer_->id(); | 2341 service_id = offscreen_target_frame_buffer_->id(); |
2271 | 2342 |
2272 glBindFramebufferEXT(target, service_id); | 2343 glBindFramebufferEXT(target, service_id); |
2273 } | 2344 } |
2274 | 2345 |
2275 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { | 2346 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 buffer_manager()->GetClientId( | 2522 buffer_manager()->GetClientId( |
2452 bound_element_array_buffer_->service_id(), | 2523 bound_element_array_buffer_->service_id(), |
2453 &client_id); | 2524 &client_id); |
2454 *params = client_id; | 2525 *params = client_id; |
2455 } else { | 2526 } else { |
2456 *params = 0; | 2527 *params = 0; |
2457 } | 2528 } |
2458 } | 2529 } |
2459 return true; | 2530 return true; |
2460 case GL_FRAMEBUFFER_BINDING: | 2531 case GL_FRAMEBUFFER_BINDING: |
| 2532 // case GL_DRAW_FRAMEBUFFER_BINDING_EXT: (same as GL_FRAMEBUFFER_BINDING) |
2461 *num_written = 1; | 2533 *num_written = 1; |
2462 if (params) { | 2534 if (params) { |
2463 if (bound_framebuffer_) { | 2535 if (bound_draw_framebuffer_) { |
2464 GLuint client_id = 0; | 2536 GLuint client_id = 0; |
2465 framebuffer_manager()->GetClientId( | 2537 framebuffer_manager()->GetClientId( |
2466 bound_framebuffer_->service_id(), &client_id); | 2538 bound_draw_framebuffer_->service_id(), &client_id); |
| 2539 *params = client_id; |
| 2540 } else { |
| 2541 *params = 0; |
| 2542 } |
| 2543 } |
| 2544 return true; |
| 2545 case GL_READ_FRAMEBUFFER_BINDING: |
| 2546 *num_written = 1; |
| 2547 if (params) { |
| 2548 if (bound_read_framebuffer_) { |
| 2549 GLuint client_id = 0; |
| 2550 framebuffer_manager()->GetClientId( |
| 2551 bound_read_framebuffer_->service_id(), &client_id); |
2467 *params = client_id; | 2552 *params = client_id; |
2468 } else { | 2553 } else { |
2469 *params = 0; | 2554 *params = 0; |
2470 } | 2555 } |
2471 } | 2556 } |
2472 return true; | 2557 return true; |
2473 case GL_RENDERBUFFER_BINDING: | 2558 case GL_RENDERBUFFER_BINDING: |
2474 *num_written = 1; | 2559 *num_written = 1; |
2475 if (params) { | 2560 if (params) { |
2476 if (bound_renderbuffer_) { | 2561 if (bound_renderbuffer_) { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2795 } | 2880 } |
2796 if (simulated_attrib_0) { | 2881 if (simulated_attrib_0) { |
2797 RestoreStateForSimulatedAttrib0(); | 2882 RestoreStateForSimulatedAttrib0(); |
2798 } | 2883 } |
2799 } | 2884 } |
2800 } | 2885 } |
2801 | 2886 |
2802 void GLES2DecoderImpl::DoFramebufferRenderbuffer( | 2887 void GLES2DecoderImpl::DoFramebufferRenderbuffer( |
2803 GLenum target, GLenum attachment, GLenum renderbuffertarget, | 2888 GLenum target, GLenum attachment, GLenum renderbuffertarget, |
2804 GLuint client_renderbuffer_id) { | 2889 GLuint client_renderbuffer_id) { |
2805 if (!bound_framebuffer_) { | 2890 FramebufferManager::FramebufferInfo* framebuffer_info = |
| 2891 GetFramebufferInfoForTarget(target); |
| 2892 if (!framebuffer_info) { |
2806 SetGLError(GL_INVALID_OPERATION, | 2893 SetGLError(GL_INVALID_OPERATION, |
2807 "glFramebufferRenderbuffer: no framebuffer bound"); | 2894 "glFramebufferRenderbuffer: no framebuffer bound"); |
2808 return; | 2895 return; |
2809 } | 2896 } |
2810 GLuint service_id = 0; | 2897 GLuint service_id = 0; |
2811 RenderbufferManager::RenderbufferInfo* info = NULL; | 2898 RenderbufferManager::RenderbufferInfo* info = NULL; |
2812 if (client_renderbuffer_id) { | 2899 if (client_renderbuffer_id) { |
2813 info = GetRenderbufferInfo(client_renderbuffer_id); | 2900 info = GetRenderbufferInfo(client_renderbuffer_id); |
2814 if (!info) { | 2901 if (!info) { |
2815 SetGLError(GL_INVALID_OPERATION, | 2902 SetGLError(GL_INVALID_OPERATION, |
2816 "glFramebufferRenderbuffer: unknown renderbuffer"); | 2903 "glFramebufferRenderbuffer: unknown renderbuffer"); |
2817 return; | 2904 return; |
2818 } | 2905 } |
2819 service_id = info->service_id(); | 2906 service_id = info->service_id(); |
2820 } | 2907 } |
2821 glFramebufferRenderbufferEXT( | 2908 glFramebufferRenderbufferEXT( |
2822 target, attachment, renderbuffertarget, service_id); | 2909 target, attachment, renderbuffertarget, service_id); |
2823 if (service_id == 0 || | 2910 if (service_id == 0 || |
2824 glCheckFramebufferStatusEXT(target) == GL_FRAMEBUFFER_COMPLETE) { | 2911 glCheckFramebufferStatusEXT(target) == GL_FRAMEBUFFER_COMPLETE) { |
2825 bound_framebuffer_->AttachRenderbuffer(attachment, info); | 2912 framebuffer_info->AttachRenderbuffer(attachment, info); |
2826 if (info) { | 2913 if (info) { |
2827 ClearUnclearedRenderbuffers(bound_framebuffer_); | 2914 ClearUnclearedRenderbuffers(target, framebuffer_info); |
2828 } | 2915 } |
2829 } | 2916 } |
2830 } | 2917 } |
2831 | 2918 |
2832 void GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { | 2919 void GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { |
2833 switch (cap) { | 2920 switch (cap) { |
2834 case GL_SCISSOR_TEST: | 2921 case GL_SCISSOR_TEST: |
2835 enable_scissor_test_ = enabled; | 2922 enable_scissor_test_ = enabled; |
2836 break; | 2923 break; |
2837 default: | 2924 default: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2894 } else { | 2981 } else { |
2895 mask_stencil_back_ = mask; | 2982 mask_stencil_back_ = mask; |
2896 } | 2983 } |
2897 glStencilMaskSeparate(face, mask); | 2984 glStencilMaskSeparate(face, mask); |
2898 } | 2985 } |
2899 | 2986 |
2900 // NOTE: There's an assumption here that Texture attachments | 2987 // NOTE: There's an assumption here that Texture attachments |
2901 // are cleared because they are textures so we only need to clear | 2988 // are cleared because they are textures so we only need to clear |
2902 // the renderbuffers. | 2989 // the renderbuffers. |
2903 void GLES2DecoderImpl::ClearUnclearedRenderbuffers( | 2990 void GLES2DecoderImpl::ClearUnclearedRenderbuffers( |
2904 FramebufferManager::FramebufferInfo* info) { | 2991 GLenum target, FramebufferManager::FramebufferInfo* info) { |
| 2992 if (target == GL_READ_FRAMEBUFFER_EXT) { |
| 2993 // TODO(gman): bind this to the DRAW point, clear then bind back to READ |
| 2994 } |
2905 GLbitfield clear_bits = 0; | 2995 GLbitfield clear_bits = 0; |
2906 if (info->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { | 2996 if (info->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { |
2907 glClearColor(0, 0, 0, 0); | 2997 glClearColor(0, 0, 0, 0); |
2908 glColorMask(true, true, true, true); | 2998 glColorMask(true, true, true, true); |
2909 clear_bits |= GL_COLOR_BUFFER_BIT; | 2999 clear_bits |= GL_COLOR_BUFFER_BIT; |
2910 } | 3000 } |
2911 | 3001 |
2912 if (info->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || | 3002 if (info->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || |
2913 info->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | 3003 info->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { |
2914 glClearStencil(0); | 3004 glClearStencil(0); |
(...skipping 17 matching lines...) Expand all Loading... |
2932 glClearColor(clear_red_, clear_green_, clear_blue_, clear_alpha_); | 3022 glClearColor(clear_red_, clear_green_, clear_blue_, clear_alpha_); |
2933 glColorMask(mask_red_, mask_green_, mask_blue_, mask_alpha_); | 3023 glColorMask(mask_red_, mask_green_, mask_blue_, mask_alpha_); |
2934 glClearStencil(clear_stencil_); | 3024 glClearStencil(clear_stencil_); |
2935 glStencilMaskSeparate(GL_FRONT, mask_stencil_front_); | 3025 glStencilMaskSeparate(GL_FRONT, mask_stencil_front_); |
2936 glStencilMaskSeparate(GL_BACK, mask_stencil_back_); | 3026 glStencilMaskSeparate(GL_BACK, mask_stencil_back_); |
2937 glClearDepth(clear_depth_); | 3027 glClearDepth(clear_depth_); |
2938 glDepthMask(mask_depth_); | 3028 glDepthMask(mask_depth_); |
2939 if (enable_scissor_test_) { | 3029 if (enable_scissor_test_) { |
2940 glEnable(GL_SCISSOR_TEST); | 3030 glEnable(GL_SCISSOR_TEST); |
2941 } | 3031 } |
| 3032 |
| 3033 if (target == GL_READ_FRAMEBUFFER_EXT) { |
| 3034 // TODO(gman): rebind draw. |
| 3035 } |
2942 } | 3036 } |
2943 | 3037 |
2944 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { | 3038 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { |
2945 if (!bound_framebuffer_) { | 3039 FramebufferManager::FramebufferInfo* info = |
| 3040 GetFramebufferInfoForTarget(target); |
| 3041 if (!info) { |
2946 return GL_FRAMEBUFFER_COMPLETE; | 3042 return GL_FRAMEBUFFER_COMPLETE; |
2947 } | 3043 } |
2948 return glCheckFramebufferStatusEXT(target); | 3044 return glCheckFramebufferStatusEXT(target); |
2949 } | 3045 } |
2950 | 3046 |
2951 void GLES2DecoderImpl::DoFramebufferTexture2D( | 3047 void GLES2DecoderImpl::DoFramebufferTexture2D( |
2952 GLenum target, GLenum attachment, GLenum textarget, | 3048 GLenum target, GLenum attachment, GLenum textarget, |
2953 GLuint client_texture_id, GLint level) { | 3049 GLuint client_texture_id, GLint level) { |
2954 if (!bound_framebuffer_) { | 3050 FramebufferManager::FramebufferInfo* framebuffer_info = |
| 3051 GetFramebufferInfoForTarget(target); |
| 3052 if (!framebuffer_info) { |
2955 SetGLError(GL_INVALID_OPERATION, | 3053 SetGLError(GL_INVALID_OPERATION, |
2956 "glFramebufferTexture2D: no framebuffer bound."); | 3054 "glFramebufferTexture2D: no framebuffer bound."); |
2957 return; | 3055 return; |
2958 } | 3056 } |
2959 GLuint service_id = 0; | 3057 GLuint service_id = 0; |
2960 TextureManager::TextureInfo* info = NULL; | 3058 TextureManager::TextureInfo* info = NULL; |
2961 if (client_texture_id) { | 3059 if (client_texture_id) { |
2962 info = GetTextureInfo(client_texture_id); | 3060 info = GetTextureInfo(client_texture_id); |
2963 if (!info) { | 3061 if (!info) { |
2964 SetGLError(GL_INVALID_OPERATION, | 3062 SetGLError(GL_INVALID_OPERATION, |
2965 "glFramebufferTexture2D: unknown texture"); | 3063 "glFramebufferTexture2D: unknown texture"); |
2966 return; | 3064 return; |
2967 } | 3065 } |
2968 service_id = info->service_id(); | 3066 service_id = info->service_id(); |
2969 } | 3067 } |
2970 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); | 3068 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); |
2971 if (service_id != 0 && | 3069 if (service_id != 0 && |
2972 glCheckFramebufferStatusEXT(target) == GL_FRAMEBUFFER_COMPLETE) { | 3070 glCheckFramebufferStatusEXT(target) == GL_FRAMEBUFFER_COMPLETE) { |
2973 ClearUnclearedRenderbuffers(bound_framebuffer_); | 3071 ClearUnclearedRenderbuffers(target, framebuffer_info); |
2974 } | 3072 } |
2975 } | 3073 } |
2976 | 3074 |
2977 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 3075 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
2978 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 3076 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
2979 if (!bound_framebuffer_) { | 3077 FramebufferManager::FramebufferInfo* framebuffer_info = |
| 3078 GetFramebufferInfoForTarget(target); |
| 3079 if (!framebuffer_info) { |
2980 SetGLError(GL_INVALID_OPERATION, | 3080 SetGLError(GL_INVALID_OPERATION, |
2981 "glFramebufferAttachmentParameteriv: no framebuffer bound"); | 3081 "glFramebufferAttachmentParameteriv: no framebuffer bound"); |
2982 return; | 3082 return; |
2983 } | 3083 } |
2984 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); | 3084 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); |
2985 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { | 3085 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
2986 GLint type = 0; | 3086 GLint type = 0; |
2987 GLuint client_id = 0; | 3087 GLuint client_id = 0; |
2988 glGetFramebufferAttachmentParameterivEXT( | 3088 glGetFramebufferAttachmentParameterivEXT( |
2989 target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); | 3089 target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); |
(...skipping 20 matching lines...) Expand all Loading... |
3010 "glGetRenderbufferParameteriv: no renderbuffer bound"); | 3110 "glGetRenderbufferParameteriv: no renderbuffer bound"); |
3011 return; | 3111 return; |
3012 } | 3112 } |
3013 if (pname == GL_RENDERBUFFER_INTERNAL_FORMAT) { | 3113 if (pname == GL_RENDERBUFFER_INTERNAL_FORMAT) { |
3014 *params = bound_renderbuffer_->internal_format(); | 3114 *params = bound_renderbuffer_->internal_format(); |
3015 return; | 3115 return; |
3016 } | 3116 } |
3017 glGetRenderbufferParameterivEXT(target, pname, params); | 3117 glGetRenderbufferParameterivEXT(target, pname, params); |
3018 } | 3118 } |
3019 | 3119 |
| 3120 void GLES2DecoderImpl::DoBlitFramebufferEXT( |
| 3121 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 3122 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 3123 GLbitfield mask, GLenum filter) { |
| 3124 if (!group_->extension_flags().ext_framebuffer_multisample) { |
| 3125 SetGLError(GL_INVALID_OPERATION, |
| 3126 "glBlitFramebufferEXT: function not available"); |
| 3127 } |
| 3128 glBlitFramebufferEXT( |
| 3129 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 3130 } |
| 3131 |
| 3132 void GLES2DecoderImpl::DoRenderbufferStorageMultisample( |
| 3133 GLenum target, GLsizei samples, GLenum internalformat, |
| 3134 GLsizei width, GLsizei height) { |
| 3135 if (!group_->extension_flags().ext_framebuffer_multisample) { |
| 3136 SetGLError(GL_INVALID_OPERATION, |
| 3137 "glRenderbufferStorageMultisampleEXT: function not available"); |
| 3138 return; |
| 3139 } |
| 3140 bound_renderbuffer_->set_internal_format(internalformat); |
| 3141 |
| 3142 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 3143 switch (internalformat) { |
| 3144 case GL_DEPTH_COMPONENT16: |
| 3145 internalformat = GL_DEPTH_COMPONENT; |
| 3146 break; |
| 3147 case GL_RGBA4: |
| 3148 case GL_RGB5_A1: |
| 3149 internalformat = GL_RGBA; |
| 3150 break; |
| 3151 case GL_RGB565: |
| 3152 internalformat = GL_RGB; |
| 3153 break; |
| 3154 } |
| 3155 } |
| 3156 |
| 3157 glRenderbufferStorageMultisampleEXT( |
| 3158 target, samples, internalformat, width, height); |
| 3159 // TODO(gman) should not set internal format unless this succeeds |
| 3160 } |
| 3161 |
3020 void GLES2DecoderImpl::DoRenderbufferStorage( | 3162 void GLES2DecoderImpl::DoRenderbufferStorage( |
3021 GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { | 3163 GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { |
3022 if (!bound_renderbuffer_) { | 3164 if (!bound_renderbuffer_) { |
3023 SetGLError(GL_INVALID_OPERATION, | 3165 SetGLError(GL_INVALID_OPERATION, |
3024 "glGetRenderbufferStorage: no renderbuffer bound"); | 3166 "glGetRenderbufferStorage: no renderbuffer bound"); |
3025 return; | 3167 return; |
3026 } | 3168 } |
3027 bound_renderbuffer_->set_internal_format(internalformat); | 3169 bound_renderbuffer_->set_internal_format(internalformat); |
3028 | 3170 |
3029 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 3171 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
3030 switch (internalformat) { | 3172 switch (internalformat) { |
3031 case GL_DEPTH_COMPONENT16: | 3173 case GL_DEPTH_COMPONENT16: |
3032 internalformat = GL_DEPTH_COMPONENT; | 3174 internalformat = GL_DEPTH_COMPONENT; |
3033 break; | 3175 break; |
3034 case GL_RGBA4: | 3176 case GL_RGBA4: |
3035 case GL_RGB5_A1: | 3177 case GL_RGB5_A1: |
3036 internalformat = GL_RGBA; | 3178 internalformat = GL_RGBA; |
3037 break; | 3179 break; |
3038 case GL_RGB565: | 3180 case GL_RGB565: |
3039 internalformat = GL_RGB; | 3181 internalformat = GL_RGB; |
3040 break; | 3182 break; |
3041 } | 3183 } |
3042 } | 3184 } |
3043 | 3185 |
3044 glRenderbufferStorageEXT(target, internalformat, width, height); | 3186 glRenderbufferStorageEXT(target, internalformat, width, height); |
| 3187 // TODO(gman) should not set internal format unless this succeeds |
3045 } | 3188 } |
3046 | 3189 |
3047 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { | 3190 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { |
3048 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( | 3191 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( |
3049 program, "glLinkProgram"); | 3192 program, "glLinkProgram"); |
3050 if (!info) { | 3193 if (!info) { |
3051 return; | 3194 return; |
3052 } | 3195 } |
3053 if (!info->CanLink()) { | 3196 if (!info->CanLink()) { |
3054 return; | 3197 return; |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4080 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); | 4223 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); |
4081 return error::kNoError; | 4224 return error::kNoError; |
4082 } | 4225 } |
4083 if (width == 0 || height == 0) { | 4226 if (width == 0 || height == 0) { |
4084 return error::kNoError; | 4227 return error::kNoError; |
4085 } | 4228 } |
4086 | 4229 |
4087 CopyRealGLErrorsToWrapper(); | 4230 CopyRealGLErrorsToWrapper(); |
4088 | 4231 |
4089 // Get the size of the current fbo or backbuffer. | 4232 // Get the size of the current fbo or backbuffer. |
4090 gfx::Size max_size = GetBoundFrameBufferSize(); | 4233 gfx::Size max_size = GetBoundReadFrameBufferSize(); |
4091 | 4234 |
4092 GLint max_x; | 4235 GLint max_x; |
4093 GLint max_y; | 4236 GLint max_y; |
4094 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { | 4237 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { |
4095 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); | 4238 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); |
4096 return error::kNoError; | 4239 return error::kNoError; |
4097 } | 4240 } |
4098 | 4241 |
4099 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { | 4242 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { |
4100 // The user requested an out of range area. Get the results 1 line | 4243 // The user requested an out of range area. Get the results 1 line |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5218 return error::kNoError; | 5361 return error::kNoError; |
5219 } | 5362 } |
5220 | 5363 |
5221 // Include the auto-generated part of this file. We split this because it means | 5364 // Include the auto-generated part of this file. We split this because it means |
5222 // we can easily edit the non-auto generated parts right here in this file | 5365 // we can easily edit the non-auto generated parts right here in this file |
5223 // instead of having to edit some template or the code generator. | 5366 // instead of having to edit some template or the code generator. |
5224 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 5367 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
5225 | 5368 |
5226 } // namespace gles2 | 5369 } // namespace gles2 |
5227 } // namespace gpu | 5370 } // namespace gpu |
OLD | NEW |