OLD | NEW |
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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 virtual Error DoCommand(unsigned int command, | 464 virtual Error DoCommand(unsigned int command, |
465 unsigned int arg_count, | 465 unsigned int arg_count, |
466 const void* args); | 466 const void* args); |
467 | 467 |
468 // Overridden from AsyncAPIInterface. | 468 // Overridden from AsyncAPIInterface. |
469 virtual const char* GetCommandName(unsigned int command_id) const; | 469 virtual const char* GetCommandName(unsigned int command_id) const; |
470 | 470 |
471 // Overridden from GLES2Decoder. | 471 // Overridden from GLES2Decoder. |
472 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 472 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
473 const scoped_refptr<gfx::GLContext>& context, | 473 const scoped_refptr<gfx::GLContext>& context, |
474 bool offscreen, | |
475 const gfx::Size& size, | 474 const gfx::Size& size, |
476 const DisallowedFeatures& disallowed_features, | 475 const DisallowedFeatures& disallowed_features, |
477 const char* allowed_extensions, | 476 const char* allowed_extensions, |
478 const std::vector<int32>& attribs); | 477 const std::vector<int32>& attribs); |
479 virtual void Destroy(); | 478 virtual void Destroy(); |
480 virtual bool SetParent(GLES2Decoder* parent_decoder, | 479 virtual bool SetParent(GLES2Decoder* parent_decoder, |
481 uint32 parent_texture_id); | 480 uint32 parent_texture_id); |
482 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); | 481 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); |
483 void UpdateParentTextureInfo(); | 482 void UpdateParentTextureInfo(); |
484 virtual bool MakeCurrent(); | 483 virtual bool MakeCurrent(); |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 bufferdata_faster_than_buffersubdata_ = false; | 1906 bufferdata_faster_than_buffersubdata_ = false; |
1908 } | 1907 } |
1909 } | 1908 } |
1910 | 1909 |
1911 GLES2DecoderImpl::~GLES2DecoderImpl() { | 1910 GLES2DecoderImpl::~GLES2DecoderImpl() { |
1912 } | 1911 } |
1913 | 1912 |
1914 bool GLES2DecoderImpl::Initialize( | 1913 bool GLES2DecoderImpl::Initialize( |
1915 const scoped_refptr<gfx::GLSurface>& surface, | 1914 const scoped_refptr<gfx::GLSurface>& surface, |
1916 const scoped_refptr<gfx::GLContext>& context, | 1915 const scoped_refptr<gfx::GLContext>& context, |
1917 bool offscreen, | |
1918 const gfx::Size& size, | 1916 const gfx::Size& size, |
1919 const DisallowedFeatures& disallowed_features, | 1917 const DisallowedFeatures& disallowed_features, |
1920 const char* allowed_extensions, | 1918 const char* allowed_extensions, |
1921 const std::vector<int32>& attribs) { | 1919 const std::vector<int32>& attribs) { |
1922 DCHECK(context); | 1920 DCHECK(context); |
1923 DCHECK(!context_.get()); | 1921 DCHECK(!context_.get()); |
1924 | 1922 |
1925 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1923 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1926 switches::kEnableGPUDebugging)) { | 1924 switches::kEnableGPUDebugging)) { |
1927 set_debug(true); | 1925 set_debug(true); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 // This checks if the user requested RGBA and we have RGBA then RGBA. If the | 2024 // This checks if the user requested RGBA and we have RGBA then RGBA. If the |
2027 // user requested RGB then RGB. If the user did not specify a preference than | 2025 // user requested RGB then RGB. If the user did not specify a preference than |
2028 // use whatever we were given. Same for DEPTH and STENCIL. | 2026 // use whatever we were given. Same for DEPTH and STENCIL. |
2029 back_buffer_color_format_ = | 2027 back_buffer_color_format_ = |
2030 (attrib_parser.alpha_size_ != 0 && v > 0) ? GL_RGBA : GL_RGB; | 2028 (attrib_parser.alpha_size_ != 0 && v > 0) ? GL_RGBA : GL_RGB; |
2031 glGetIntegerv(GL_DEPTH_BITS, &v); | 2029 glGetIntegerv(GL_DEPTH_BITS, &v); |
2032 back_buffer_has_depth_ = attrib_parser.depth_size_ != 0 && v > 0; | 2030 back_buffer_has_depth_ = attrib_parser.depth_size_ != 0 && v > 0; |
2033 glGetIntegerv(GL_STENCIL_BITS, &v); | 2031 glGetIntegerv(GL_STENCIL_BITS, &v); |
2034 back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; | 2032 back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; |
2035 | 2033 |
2036 if (offscreen) { | 2034 if (surface_->IsOffscreen()) { |
2037 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && | 2035 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && |
2038 (context_->HasExtension("GL_EXT_framebuffer_multisample") || | 2036 (context_->HasExtension("GL_EXT_framebuffer_multisample") || |
2039 context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) { | 2037 context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) { |
2040 // Per ext_framebuffer_multisample spec, need max bound on sample count. | 2038 // Per ext_framebuffer_multisample spec, need max bound on sample count. |
2041 // max_sample_count must be initialized to a sane value. If | 2039 // max_sample_count must be initialized to a sane value. If |
2042 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. | 2040 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. |
2043 GLint max_sample_count = 1; | 2041 GLint max_sample_count = 1; |
2044 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); | 2042 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); |
2045 offscreen_target_samples_ = std::min(attrib_parser.samples_, | 2043 offscreen_target_samples_ = std::min(attrib_parser.samples_, |
2046 max_sample_count); | 2044 max_sample_count); |
(...skipping 5557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7604 UpdateParentTextureInfo(); | 7602 UpdateParentTextureInfo(); |
7605 } | 7603 } |
7606 | 7604 |
7607 ScopedGLErrorSuppressor suppressor(this); | 7605 ScopedGLErrorSuppressor suppressor(this); |
7608 | 7606 |
7609 if (IsOffscreenBufferMultisampled()) { | 7607 if (IsOffscreenBufferMultisampled()) { |
7610 // For multisampled buffers, resolve the frame buffer. | 7608 // For multisampled buffers, resolve the frame buffer. |
7611 ScopedResolvedFrameBufferBinder binder(this, true, false); | 7609 ScopedResolvedFrameBufferBinder binder(this, true, false); |
7612 return error::kNoError; | 7610 return error::kNoError; |
7613 } else { | 7611 } else { |
7614 ScopedFrameBufferBinder binder(this, | 7612 if (surface_->IsOffscreen()) { |
7615 offscreen_target_frame_buffer_->id()); | 7613 ScopedFrameBufferBinder binder(this, |
| 7614 offscreen_target_frame_buffer_->id()); |
7616 | 7615 |
7617 if (offscreen_target_buffer_preserved_) { | 7616 if (offscreen_target_buffer_preserved_) { |
7618 // Copy the target frame buffer to the saved offscreen texture. | 7617 // Copy the target frame buffer to the saved offscreen texture. |
7619 offscreen_saved_color_texture_->Copy( | 7618 offscreen_saved_color_texture_->Copy( |
7620 offscreen_saved_color_texture_->size(), | 7619 offscreen_saved_color_texture_->size(), |
7621 offscreen_saved_color_format_); | 7620 offscreen_saved_color_format_); |
7622 } else { | 7621 } else { |
7623 // Flip the textures in the parent context via the texture manager. | 7622 // Flip the textures in the parent context via the texture manager. |
7624 if (!!offscreen_saved_color_texture_info_.get()) | 7623 if (!!offscreen_saved_color_texture_info_.get()) |
7625 offscreen_saved_color_texture_info_-> | 7624 offscreen_saved_color_texture_info_-> |
7626 SetServiceId(offscreen_target_color_texture_->id()); | 7625 SetServiceId(offscreen_target_color_texture_->id()); |
7627 | 7626 |
7628 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 7627 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
7629 offscreen_target_frame_buffer_->AttachRenderTexture( | 7628 offscreen_target_frame_buffer_->AttachRenderTexture( |
7630 offscreen_target_color_texture_.get()); | 7629 offscreen_target_color_texture_.get()); |
| 7630 } |
| 7631 |
| 7632 // Ensure the side effects of the copy are visible to the parent |
| 7633 // context. There is no need to do this for ANGLE because it uses a |
| 7634 // single D3D device for all contexts. |
| 7635 if (!IsAngle()) |
| 7636 glFlush(); |
7631 } | 7637 } |
7632 | |
7633 // Ensure the side effects of the copy are visible to the parent | |
7634 // context. There is no need to do this for ANGLE because it uses a | |
7635 // single D3D device for all contexts. | |
7636 if (!IsAngle()) | |
7637 glFlush(); | |
7638 return error::kNoError; | 7638 return error::kNoError; |
7639 } | 7639 } |
7640 } else { | 7640 } else { |
7641 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); | 7641 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); |
7642 if (!surface_->SwapBuffers()) { | 7642 if (!surface_->SwapBuffers()) { |
7643 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 7643 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
7644 return error::kLostContext; | 7644 return error::kLostContext; |
7645 } | 7645 } |
7646 } | 7646 } |
7647 | 7647 |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8318 } | 8318 } |
8319 } | 8319 } |
8320 | 8320 |
8321 // Include the auto-generated part of this file. We split this because it means | 8321 // Include the auto-generated part of this file. We split this because it means |
8322 // we can easily edit the non-auto generated parts right here in this file | 8322 // we can easily edit the non-auto generated parts right here in this file |
8323 // instead of having to edit some template or the code generator. | 8323 // instead of having to edit some template or the code generator. |
8324 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8324 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8325 | 8325 |
8326 } // namespace gles2 | 8326 } // namespace gles2 |
8327 } // namespace gpu | 8327 } // namespace gpu |
OLD | NEW |