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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); | 1036 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); |
1037 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); | 1037 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); |
1038 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); | 1038 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); |
1039 | 1039 |
1040 // Wrapper for glUseProgram | 1040 // Wrapper for glUseProgram |
1041 void DoUseProgram(GLuint program); | 1041 void DoUseProgram(GLuint program); |
1042 | 1042 |
1043 // Wrapper for glValidateProgram. | 1043 // Wrapper for glValidateProgram. |
1044 void DoValidateProgram(GLuint program_client_id); | 1044 void DoValidateProgram(GLuint program_client_id); |
1045 | 1045 |
1046 void DoCopyTextureToParentTextureCHROMIUM( | |
1047 GLuint client_texture_id, GLuint parent_client_texture_id); | |
1048 | |
1049 void DoResizeCHROMIUM(GLuint width, GLuint height); | 1046 void DoResizeCHROMIUM(GLuint width, GLuint height); |
1050 | 1047 |
1051 void DoSetSurfaceCHROMIUM(GLint surface_id); | 1048 void DoSetSurfaceCHROMIUM(GLint surface_id); |
1052 | 1049 |
1053 // Gets the number of values that will be returned by glGetXXX. Returns | 1050 // Gets the number of values that will be returned by glGetXXX. Returns |
1054 // false if pname is unknown. | 1051 // false if pname is unknown. |
1055 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); | 1052 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); |
1056 | 1053 |
1057 // Gets the GLError through our wrapper. | 1054 // Gets the GLError through our wrapper. |
1058 GLenum GetGLError(); | 1055 GLenum GetGLError(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; | 1282 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; |
1286 scoped_ptr<Texture> offscreen_target_color_texture_; | 1283 scoped_ptr<Texture> offscreen_target_color_texture_; |
1287 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; | 1284 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; |
1288 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; | 1285 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; |
1289 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; | 1286 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; |
1290 GLenum offscreen_target_color_format_; | 1287 GLenum offscreen_target_color_format_; |
1291 GLenum offscreen_target_depth_format_; | 1288 GLenum offscreen_target_depth_format_; |
1292 GLenum offscreen_target_stencil_format_; | 1289 GLenum offscreen_target_stencil_format_; |
1293 GLsizei offscreen_target_samples_; | 1290 GLsizei offscreen_target_samples_; |
1294 | 1291 |
1295 GLuint copy_texture_to_parent_texture_fb_; | |
1296 | |
1297 // The copy that is saved when SwapBuffers is called. It is also | 1292 // The copy that is saved when SwapBuffers is called. It is also |
1298 // used as the destination for multi-sample resolves. | 1293 // used as the destination for multi-sample resolves. |
1299 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; | 1294 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; |
1300 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1295 scoped_ptr<Texture> offscreen_saved_color_texture_; |
1301 GLenum offscreen_saved_color_format_; | 1296 GLenum offscreen_saved_color_format_; |
1302 | 1297 |
1303 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; | 1298 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; |
1304 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 1299 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
1305 | 1300 |
1306 // The format of the back buffer_ | 1301 // The format of the back buffer_ |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 clear_depth_(1.0f), | 1648 clear_depth_(1.0f), |
1654 mask_depth_(true), | 1649 mask_depth_(true), |
1655 enable_scissor_test_(false), | 1650 enable_scissor_test_(false), |
1656 enable_depth_test_(false), | 1651 enable_depth_test_(false), |
1657 enable_stencil_test_(false), | 1652 enable_stencil_test_(false), |
1658 state_dirty_(true), | 1653 state_dirty_(true), |
1659 offscreen_target_color_format_(0), | 1654 offscreen_target_color_format_(0), |
1660 offscreen_target_depth_format_(0), | 1655 offscreen_target_depth_format_(0), |
1661 offscreen_target_stencil_format_(0), | 1656 offscreen_target_stencil_format_(0), |
1662 offscreen_target_samples_(0), | 1657 offscreen_target_samples_(0), |
1663 copy_texture_to_parent_texture_fb_(0), | |
1664 offscreen_saved_color_format_(0), | 1658 offscreen_saved_color_format_(0), |
1665 back_buffer_color_format_(0), | 1659 back_buffer_color_format_(0), |
1666 back_buffer_has_depth_(false), | 1660 back_buffer_has_depth_(false), |
1667 back_buffer_has_stencil_(false), | 1661 back_buffer_has_stencil_(false), |
1668 teximage2d_faster_than_texsubimage2d_(true), | 1662 teximage2d_faster_than_texsubimage2d_(true), |
1669 bufferdata_faster_than_buffersubdata_(true), | 1663 bufferdata_faster_than_buffersubdata_(true), |
1670 current_decoder_error_(error::kNoError), | 1664 current_decoder_error_(error::kNoError), |
1671 use_shader_translator_(true), | 1665 use_shader_translator_(true), |
1672 validators_(group_->feature_info()->validators()), | 1666 validators_(group_->feature_info()->validators()), |
1673 feature_info_(group_->feature_info()), | 1667 feature_info_(group_->feature_info()), |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 pending_offscreen_size_ = size; | 1899 pending_offscreen_size_ = size; |
1906 if (!UpdateOffscreenFrameBufferSize()) { | 1900 if (!UpdateOffscreenFrameBufferSize()) { |
1907 LOG(ERROR) << "Could not allocate offscreen buffer storage."; | 1901 LOG(ERROR) << "Could not allocate offscreen buffer storage."; |
1908 Destroy(); | 1902 Destroy(); |
1909 return false; | 1903 return false; |
1910 } | 1904 } |
1911 | 1905 |
1912 // Bind to the new default frame buffer (the offscreen target frame buffer). | 1906 // Bind to the new default frame buffer (the offscreen target frame buffer). |
1913 // This should now be associated with ID zero. | 1907 // This should now be associated with ID zero. |
1914 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 1908 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
1915 | |
1916 glGenFramebuffersEXT(1, ©_texture_to_parent_texture_fb_); | |
1917 } | 1909 } |
1918 | 1910 |
1919 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 1911 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
1920 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 1912 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact |
1921 // isn't well documented; it was discovered in the Khronos OpenGL ES | 1913 // isn't well documented; it was discovered in the Khronos OpenGL ES |
1922 // mailing list archives. It also implicitly enables the desktop GL | 1914 // mailing list archives. It also implicitly enables the desktop GL |
1923 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 1915 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
1924 // variable in fragment shaders. | 1916 // variable in fragment shaders. |
1925 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1917 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
1926 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 1918 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 current_program_ = NULL; | 2413 current_program_ = NULL; |
2422 } | 2414 } |
2423 | 2415 |
2424 if (attrib_0_buffer_id_) { | 2416 if (attrib_0_buffer_id_) { |
2425 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 2417 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
2426 } | 2418 } |
2427 if (fixed_attrib_buffer_id_) { | 2419 if (fixed_attrib_buffer_id_) { |
2428 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); | 2420 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); |
2429 } | 2421 } |
2430 | 2422 |
2431 if (copy_texture_to_parent_texture_fb_) | |
2432 glDeleteFramebuffersEXT(1, ©_texture_to_parent_texture_fb_); | |
2433 | |
2434 if (offscreen_target_frame_buffer_.get()) | 2423 if (offscreen_target_frame_buffer_.get()) |
2435 offscreen_target_frame_buffer_->Destroy(); | 2424 offscreen_target_frame_buffer_->Destroy(); |
2436 if (offscreen_target_color_texture_.get()) | 2425 if (offscreen_target_color_texture_.get()) |
2437 offscreen_target_color_texture_->Destroy(); | 2426 offscreen_target_color_texture_->Destroy(); |
2438 if (offscreen_target_color_render_buffer_.get()) | 2427 if (offscreen_target_color_render_buffer_.get()) |
2439 offscreen_target_color_render_buffer_->Destroy(); | 2428 offscreen_target_color_render_buffer_->Destroy(); |
2440 if (offscreen_target_depth_render_buffer_.get()) | 2429 if (offscreen_target_depth_render_buffer_.get()) |
2441 offscreen_target_depth_render_buffer_->Destroy(); | 2430 offscreen_target_depth_render_buffer_->Destroy(); |
2442 if (offscreen_target_stencil_render_buffer_.get()) | 2431 if (offscreen_target_stencil_render_buffer_.get()) |
2443 offscreen_target_stencil_render_buffer_->Destroy(); | 2432 offscreen_target_stencil_render_buffer_->Destroy(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2558 return true; | 2547 return true; |
2559 } | 2548 } |
2560 | 2549 |
2561 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { | 2550 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
2562 // We can't resize the render buffers immediately because there might be a | 2551 // We can't resize the render buffers immediately because there might be a |
2563 // partial frame rendered into them and we don't want the tail end of that | 2552 // partial frame rendered into them and we don't want the tail end of that |
2564 // rendered into the reallocated storage. Defer until the next SwapBuffers. | 2553 // rendered into the reallocated storage. Defer until the next SwapBuffers. |
2565 pending_offscreen_size_ = size; | 2554 pending_offscreen_size_ = size; |
2566 } | 2555 } |
2567 | 2556 |
2568 void GLES2DecoderImpl::DoCopyTextureToParentTextureCHROMIUM( | |
2569 GLuint client_texture_id, | |
2570 GLuint parent_client_texture_id) { | |
2571 if (parent_) { | |
2572 TextureManager::TextureInfo* texture = texture_manager()->GetTextureInfo( | |
2573 client_texture_id); | |
2574 TextureManager::TextureInfo* parent_texture = | |
2575 parent_->texture_manager()->GetTextureInfo(parent_client_texture_id); | |
2576 if (!texture || !parent_texture) { | |
2577 current_decoder_error_ = error::kInvalidArguments; | |
2578 return; | |
2579 } | |
2580 ScopedFrameBufferBinder fb_binder(this, copy_texture_to_parent_texture_fb_); | |
2581 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, | |
2582 GL_COLOR_ATTACHMENT0, | |
2583 GL_TEXTURE_2D, | |
2584 texture->service_id(), | |
2585 0); | |
2586 ScopedTexture2DBinder tex_binder(this, parent_texture->service_id()); | |
2587 GLsizei width, height; | |
2588 parent_texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height); | |
2589 glCopyTexImage2D(GL_TEXTURE_2D, | |
2590 0, // level | |
2591 GL_RGBA, | |
2592 0, 0, // x, y | |
2593 width, | |
2594 height, | |
2595 0); // border | |
2596 } | |
2597 } | |
2598 | |
2599 void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) { | 2557 void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) { |
2600 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI) | 2558 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI) |
2601 // Make sure that we are done drawing to the back buffer before resizing. | 2559 // Make sure that we are done drawing to the back buffer before resizing. |
2602 glFinish(); | 2560 glFinish(); |
2603 #endif | 2561 #endif |
2604 if (resize_callback_.get()) { | 2562 if (resize_callback_.get()) { |
2605 gfx::Size size(width, height); | 2563 gfx::Size size(width, height); |
2606 resize_callback_->Run(size); | 2564 resize_callback_->Run(size); |
2607 } | 2565 } |
2608 } | 2566 } |
(...skipping 4225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6834 return false; | 6792 return false; |
6835 } | 6793 } |
6836 | 6794 |
6837 // Include the auto-generated part of this file. We split this because it means | 6795 // Include the auto-generated part of this file. We split this because it means |
6838 // we can easily edit the non-auto generated parts right here in this file | 6796 // we can easily edit the non-auto generated parts right here in this file |
6839 // instead of having to edit some template or the code generator. | 6797 // instead of having to edit some template or the code generator. |
6840 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6798 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
6841 | 6799 |
6842 } // namespace gles2 | 6800 } // namespace gles2 |
6843 } // namespace gpu | 6801 } // namespace gpu |
OLD | NEW |