| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); | 1029 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); |
| 1030 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); | 1030 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); |
| 1031 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); | 1031 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); |
| 1032 | 1032 |
| 1033 // Wrapper for glUseProgram | 1033 // Wrapper for glUseProgram |
| 1034 void DoUseProgram(GLuint program); | 1034 void DoUseProgram(GLuint program); |
| 1035 | 1035 |
| 1036 // Wrapper for glValidateProgram. | 1036 // Wrapper for glValidateProgram. |
| 1037 void DoValidateProgram(GLuint program_client_id); | 1037 void DoValidateProgram(GLuint program_client_id); |
| 1038 | 1038 |
| 1039 void DoCopyTextureToParentTextureCHROMIUM( | |
| 1040 GLuint client_texture_id, GLuint parent_client_texture_id); | |
| 1041 | |
| 1042 void DoResizeCHROMIUM(GLuint width, GLuint height); | 1039 void DoResizeCHROMIUM(GLuint width, GLuint height); |
| 1043 | 1040 |
| 1044 void DoSetSurfaceCHROMIUM(GLint surface_id); | 1041 void DoSetSurfaceCHROMIUM(GLint surface_id); |
| 1045 | 1042 |
| 1046 // Gets the number of values that will be returned by glGetXXX. Returns | 1043 // Gets the number of values that will be returned by glGetXXX. Returns |
| 1047 // false if pname is unknown. | 1044 // false if pname is unknown. |
| 1048 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); | 1045 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); |
| 1049 | 1046 |
| 1050 // Gets the GLError through our wrapper. | 1047 // Gets the GLError through our wrapper. |
| 1051 GLenum GetGLError(); | 1048 GLenum GetGLError(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; | 1275 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; |
| 1279 scoped_ptr<Texture> offscreen_target_color_texture_; | 1276 scoped_ptr<Texture> offscreen_target_color_texture_; |
| 1280 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; | 1277 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; |
| 1281 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; | 1278 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; |
| 1282 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; | 1279 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; |
| 1283 GLenum offscreen_target_color_format_; | 1280 GLenum offscreen_target_color_format_; |
| 1284 GLenum offscreen_target_depth_format_; | 1281 GLenum offscreen_target_depth_format_; |
| 1285 GLenum offscreen_target_stencil_format_; | 1282 GLenum offscreen_target_stencil_format_; |
| 1286 GLsizei offscreen_target_samples_; | 1283 GLsizei offscreen_target_samples_; |
| 1287 | 1284 |
| 1288 GLuint copy_texture_to_parent_texture_fb_; | |
| 1289 | |
| 1290 // The copy that is saved when SwapBuffers is called. | 1285 // The copy that is saved when SwapBuffers is called. |
| 1291 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; | 1286 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; |
| 1292 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1287 scoped_ptr<Texture> offscreen_saved_color_texture_; |
| 1293 | 1288 |
| 1294 // The copy that is used as the destination for multi-sample resolves. | 1289 // The copy that is used as the destination for multi-sample resolves. |
| 1295 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; | 1290 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; |
| 1296 scoped_ptr<Texture> offscreen_resolved_color_texture_; | 1291 scoped_ptr<Texture> offscreen_resolved_color_texture_; |
| 1297 GLenum offscreen_saved_color_format_; | 1292 GLenum offscreen_saved_color_format_; |
| 1298 | 1293 |
| 1299 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; | 1294 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 clear_depth_(1.0f), | 1668 clear_depth_(1.0f), |
| 1674 mask_depth_(true), | 1669 mask_depth_(true), |
| 1675 enable_scissor_test_(false), | 1670 enable_scissor_test_(false), |
| 1676 enable_depth_test_(false), | 1671 enable_depth_test_(false), |
| 1677 enable_stencil_test_(false), | 1672 enable_stencil_test_(false), |
| 1678 state_dirty_(true), | 1673 state_dirty_(true), |
| 1679 offscreen_target_color_format_(0), | 1674 offscreen_target_color_format_(0), |
| 1680 offscreen_target_depth_format_(0), | 1675 offscreen_target_depth_format_(0), |
| 1681 offscreen_target_stencil_format_(0), | 1676 offscreen_target_stencil_format_(0), |
| 1682 offscreen_target_samples_(0), | 1677 offscreen_target_samples_(0), |
| 1683 copy_texture_to_parent_texture_fb_(0), | |
| 1684 offscreen_saved_color_format_(0), | 1678 offscreen_saved_color_format_(0), |
| 1685 back_buffer_color_format_(0), | 1679 back_buffer_color_format_(0), |
| 1686 back_buffer_has_depth_(false), | 1680 back_buffer_has_depth_(false), |
| 1687 back_buffer_has_stencil_(false), | 1681 back_buffer_has_stencil_(false), |
| 1688 teximage2d_faster_than_texsubimage2d_(true), | 1682 teximage2d_faster_than_texsubimage2d_(true), |
| 1689 bufferdata_faster_than_buffersubdata_(true), | 1683 bufferdata_faster_than_buffersubdata_(true), |
| 1690 current_decoder_error_(error::kNoError), | 1684 current_decoder_error_(error::kNoError), |
| 1691 use_shader_translator_(true), | 1685 use_shader_translator_(true), |
| 1692 validators_(group_->feature_info()->validators()), | 1686 validators_(group_->feature_info()->validators()), |
| 1693 feature_info_(group_->feature_info()), | 1687 feature_info_(group_->feature_info()), |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 pending_offscreen_size_ = size; | 1921 pending_offscreen_size_ = size; |
| 1928 if (!UpdateOffscreenFrameBufferSize()) { | 1922 if (!UpdateOffscreenFrameBufferSize()) { |
| 1929 LOG(ERROR) << "Could not allocate offscreen buffer storage."; | 1923 LOG(ERROR) << "Could not allocate offscreen buffer storage."; |
| 1930 Destroy(); | 1924 Destroy(); |
| 1931 return false; | 1925 return false; |
| 1932 } | 1926 } |
| 1933 | 1927 |
| 1934 // Bind to the new default frame buffer (the offscreen target frame buffer). | 1928 // Bind to the new default frame buffer (the offscreen target frame buffer). |
| 1935 // This should now be associated with ID zero. | 1929 // This should now be associated with ID zero. |
| 1936 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 1930 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 1937 | |
| 1938 glGenFramebuffersEXT(1, ©_texture_to_parent_texture_fb_); | |
| 1939 } | 1931 } |
| 1940 | 1932 |
| 1941 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 1933 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
| 1942 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 1934 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact |
| 1943 // isn't well documented; it was discovered in the Khronos OpenGL ES | 1935 // isn't well documented; it was discovered in the Khronos OpenGL ES |
| 1944 // mailing list archives. It also implicitly enables the desktop GL | 1936 // mailing list archives. It also implicitly enables the desktop GL |
| 1945 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 1937 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
| 1946 // variable in fragment shaders. | 1938 // variable in fragment shaders. |
| 1947 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1939 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 1948 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 1940 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 current_program_ = NULL; | 2441 current_program_ = NULL; |
| 2450 } | 2442 } |
| 2451 | 2443 |
| 2452 if (attrib_0_buffer_id_) { | 2444 if (attrib_0_buffer_id_) { |
| 2453 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 2445 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
| 2454 } | 2446 } |
| 2455 if (fixed_attrib_buffer_id_) { | 2447 if (fixed_attrib_buffer_id_) { |
| 2456 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); | 2448 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); |
| 2457 } | 2449 } |
| 2458 | 2450 |
| 2459 if (copy_texture_to_parent_texture_fb_) | |
| 2460 glDeleteFramebuffersEXT(1, ©_texture_to_parent_texture_fb_); | |
| 2461 | |
| 2462 if (offscreen_target_frame_buffer_.get()) | 2451 if (offscreen_target_frame_buffer_.get()) |
| 2463 offscreen_target_frame_buffer_->Destroy(); | 2452 offscreen_target_frame_buffer_->Destroy(); |
| 2464 if (offscreen_target_color_texture_.get()) | 2453 if (offscreen_target_color_texture_.get()) |
| 2465 offscreen_target_color_texture_->Destroy(); | 2454 offscreen_target_color_texture_->Destroy(); |
| 2466 if (offscreen_target_color_render_buffer_.get()) | 2455 if (offscreen_target_color_render_buffer_.get()) |
| 2467 offscreen_target_color_render_buffer_->Destroy(); | 2456 offscreen_target_color_render_buffer_->Destroy(); |
| 2468 if (offscreen_target_depth_render_buffer_.get()) | 2457 if (offscreen_target_depth_render_buffer_.get()) |
| 2469 offscreen_target_depth_render_buffer_->Destroy(); | 2458 offscreen_target_depth_render_buffer_->Destroy(); |
| 2470 if (offscreen_target_stencil_render_buffer_.get()) | 2459 if (offscreen_target_stencil_render_buffer_.get()) |
| 2471 offscreen_target_stencil_render_buffer_->Destroy(); | 2460 offscreen_target_stencil_render_buffer_->Destroy(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2565 return true; | 2554 return true; |
| 2566 } | 2555 } |
| 2567 | 2556 |
| 2568 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { | 2557 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| 2569 // We can't resize the render buffers immediately because there might be a | 2558 // We can't resize the render buffers immediately because there might be a |
| 2570 // partial frame rendered into them and we don't want the tail end of that | 2559 // partial frame rendered into them and we don't want the tail end of that |
| 2571 // rendered into the reallocated storage. Defer until the next SwapBuffers. | 2560 // rendered into the reallocated storage. Defer until the next SwapBuffers. |
| 2572 pending_offscreen_size_ = size; | 2561 pending_offscreen_size_ = size; |
| 2573 } | 2562 } |
| 2574 | 2563 |
| 2575 void GLES2DecoderImpl::DoCopyTextureToParentTextureCHROMIUM( | |
| 2576 GLuint client_texture_id, | |
| 2577 GLuint parent_client_texture_id) { | |
| 2578 if (parent_) { | |
| 2579 TextureManager::TextureInfo* texture = texture_manager()->GetTextureInfo( | |
| 2580 client_texture_id); | |
| 2581 TextureManager::TextureInfo* parent_texture = | |
| 2582 parent_->texture_manager()->GetTextureInfo(parent_client_texture_id); | |
| 2583 if (!texture || !parent_texture) { | |
| 2584 current_decoder_error_ = error::kInvalidArguments; | |
| 2585 return; | |
| 2586 } | |
| 2587 ScopedFrameBufferBinder fb_binder(this, copy_texture_to_parent_texture_fb_); | |
| 2588 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, | |
| 2589 GL_COLOR_ATTACHMENT0, | |
| 2590 GL_TEXTURE_2D, | |
| 2591 texture->service_id(), | |
| 2592 0); | |
| 2593 ScopedTexture2DBinder tex_binder(this, parent_texture->service_id()); | |
| 2594 GLsizei width, height; | |
| 2595 parent_texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height); | |
| 2596 glCopyTexImage2D(GL_TEXTURE_2D, | |
| 2597 0, // level | |
| 2598 GL_RGBA, | |
| 2599 0, 0, // x, y | |
| 2600 width, | |
| 2601 height, | |
| 2602 0); // border | |
| 2603 } | |
| 2604 } | |
| 2605 | |
| 2606 void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) { | 2564 void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) { |
| 2607 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI) | 2565 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI) |
| 2608 // Make sure that we are done drawing to the back buffer before resizing. | 2566 // Make sure that we are done drawing to the back buffer before resizing. |
| 2609 glFinish(); | 2567 glFinish(); |
| 2610 #endif | 2568 #endif |
| 2611 if (resize_callback_.get()) { | 2569 if (resize_callback_.get()) { |
| 2612 gfx::Size size(width, height); | 2570 gfx::Size size(width, height); |
| 2613 resize_callback_->Run(size); | 2571 resize_callback_->Run(size); |
| 2614 } | 2572 } |
| 2615 } | 2573 } |
| (...skipping 4217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6833 return false; | 6791 return false; |
| 6834 } | 6792 } |
| 6835 | 6793 |
| 6836 // Include the auto-generated part of this file. We split this because it means | 6794 // Include the auto-generated part of this file. We split this because it means |
| 6837 // we can easily edit the non-auto generated parts right here in this file | 6795 // we can easily edit the non-auto generated parts right here in this file |
| 6838 // instead of having to edit some template or the code generator. | 6796 // instead of having to edit some template or the code generator. |
| 6839 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6797 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 6840 | 6798 |
| 6841 } // namespace gles2 | 6799 } // namespace gles2 |
| 6842 } // namespace gpu | 6800 } // namespace gpu |
| OLD | NEW |