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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 virtual Error DoCommand(unsigned int command, | 465 virtual Error DoCommand(unsigned int command, |
466 unsigned int arg_count, | 466 unsigned int arg_count, |
467 const void* args); | 467 const void* args); |
468 | 468 |
469 // Overridden from AsyncAPIInterface. | 469 // Overridden from AsyncAPIInterface. |
470 virtual const char* GetCommandName(unsigned int command_id) const; | 470 virtual const char* GetCommandName(unsigned int command_id) const; |
471 | 471 |
472 // Overridden from GLES2Decoder. | 472 // Overridden from GLES2Decoder. |
473 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 473 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
474 const scoped_refptr<gfx::GLContext>& context, | 474 const scoped_refptr<gfx::GLContext>& context, |
| 475 bool offscreen, |
475 const gfx::Size& size, | 476 const gfx::Size& size, |
476 const DisallowedFeatures& disallowed_features, | 477 const DisallowedFeatures& disallowed_features, |
477 const char* allowed_extensions, | 478 const char* allowed_extensions, |
478 const std::vector<int32>& attribs); | 479 const std::vector<int32>& attribs); |
479 virtual void Destroy(); | 480 virtual void Destroy(); |
480 virtual bool SetParent(GLES2Decoder* parent_decoder, | 481 virtual bool SetParent(GLES2Decoder* parent_decoder, |
481 uint32 parent_texture_id); | 482 uint32 parent_texture_id); |
482 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); | 483 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); |
483 void UpdateParentTextureInfo(); | 484 void UpdateParentTextureInfo(); |
484 virtual bool MakeCurrent(); | 485 virtual bool MakeCurrent(); |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 bufferdata_faster_than_buffersubdata_ = false; | 1941 bufferdata_faster_than_buffersubdata_ = false; |
1941 } | 1942 } |
1942 } | 1943 } |
1943 | 1944 |
1944 GLES2DecoderImpl::~GLES2DecoderImpl() { | 1945 GLES2DecoderImpl::~GLES2DecoderImpl() { |
1945 } | 1946 } |
1946 | 1947 |
1947 bool GLES2DecoderImpl::Initialize( | 1948 bool GLES2DecoderImpl::Initialize( |
1948 const scoped_refptr<gfx::GLSurface>& surface, | 1949 const scoped_refptr<gfx::GLSurface>& surface, |
1949 const scoped_refptr<gfx::GLContext>& context, | 1950 const scoped_refptr<gfx::GLContext>& context, |
| 1951 bool offscreen, |
1950 const gfx::Size& size, | 1952 const gfx::Size& size, |
1951 const DisallowedFeatures& disallowed_features, | 1953 const DisallowedFeatures& disallowed_features, |
1952 const char* allowed_extensions, | 1954 const char* allowed_extensions, |
1953 const std::vector<int32>& attribs) { | 1955 const std::vector<int32>& attribs) { |
1954 DCHECK(context); | 1956 DCHECK(context); |
1955 DCHECK(!context_.get()); | 1957 DCHECK(!context_.get()); |
1956 | 1958 |
1957 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1959 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1958 switches::kEnableGPUDebugging)) { | 1960 switches::kEnableGPUDebugging)) { |
1959 set_debug(true); | 1961 set_debug(true); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 // This checks if the user requested RGBA and we have RGBA then RGBA. If the | 2064 // This checks if the user requested RGBA and we have RGBA then RGBA. If the |
2063 // user requested RGB then RGB. If the user did not specify a preference than | 2065 // user requested RGB then RGB. If the user did not specify a preference than |
2064 // use whatever we were given. Same for DEPTH and STENCIL. | 2066 // use whatever we were given. Same for DEPTH and STENCIL. |
2065 back_buffer_color_format_ = | 2067 back_buffer_color_format_ = |
2066 (attrib_parser.alpha_size_ != 0 && v > 0) ? GL_RGBA : GL_RGB; | 2068 (attrib_parser.alpha_size_ != 0 && v > 0) ? GL_RGBA : GL_RGB; |
2067 glGetIntegerv(GL_DEPTH_BITS, &v); | 2069 glGetIntegerv(GL_DEPTH_BITS, &v); |
2068 back_buffer_has_depth_ = attrib_parser.depth_size_ != 0 && v > 0; | 2070 back_buffer_has_depth_ = attrib_parser.depth_size_ != 0 && v > 0; |
2069 glGetIntegerv(GL_STENCIL_BITS, &v); | 2071 glGetIntegerv(GL_STENCIL_BITS, &v); |
2070 back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; | 2072 back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; |
2071 | 2073 |
2072 if (surface_->IsOffscreen()) { | 2074 if (offscreen) { |
2073 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && | 2075 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && |
2074 (context_->HasExtension("GL_EXT_framebuffer_multisample") || | 2076 (context_->HasExtension("GL_EXT_framebuffer_multisample") || |
2075 context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) { | 2077 context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) { |
2076 // Per ext_framebuffer_multisample spec, need max bound on sample count. | 2078 // Per ext_framebuffer_multisample spec, need max bound on sample count. |
2077 // max_sample_count must be initialized to a sane value. If | 2079 // max_sample_count must be initialized to a sane value. If |
2078 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. | 2080 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. |
2079 GLint max_sample_count = 1; | 2081 GLint max_sample_count = 1; |
2080 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); | 2082 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); |
2081 offscreen_target_samples_ = std::min(attrib_parser.samples_, | 2083 offscreen_target_samples_ = std::min(attrib_parser.samples_, |
2082 max_sample_count); | 2084 max_sample_count); |
(...skipping 5620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7703 UpdateParentTextureInfo(); | 7705 UpdateParentTextureInfo(); |
7704 } | 7706 } |
7705 | 7707 |
7706 ScopedGLErrorSuppressor suppressor(this); | 7708 ScopedGLErrorSuppressor suppressor(this); |
7707 | 7709 |
7708 if (IsOffscreenBufferMultisampled()) { | 7710 if (IsOffscreenBufferMultisampled()) { |
7709 // For multisampled buffers, resolve the frame buffer. | 7711 // For multisampled buffers, resolve the frame buffer. |
7710 ScopedResolvedFrameBufferBinder binder(this, true, false); | 7712 ScopedResolvedFrameBufferBinder binder(this, true, false); |
7711 return error::kNoError; | 7713 return error::kNoError; |
7712 } else { | 7714 } else { |
7713 if (surface_->IsOffscreen()) { | 7715 ScopedFrameBufferBinder binder(this, |
7714 ScopedFrameBufferBinder binder(this, | 7716 offscreen_target_frame_buffer_->id()); |
7715 offscreen_target_frame_buffer_->id()); | |
7716 | 7717 |
7717 if (offscreen_target_buffer_preserved_) { | 7718 if (offscreen_target_buffer_preserved_) { |
7718 // Copy the target frame buffer to the saved offscreen texture. | 7719 // Copy the target frame buffer to the saved offscreen texture. |
7719 offscreen_saved_color_texture_->Copy( | 7720 offscreen_saved_color_texture_->Copy( |
7720 offscreen_saved_color_texture_->size(), | 7721 offscreen_saved_color_texture_->size(), |
7721 offscreen_saved_color_format_); | 7722 offscreen_saved_color_format_); |
7722 } else { | 7723 } else { |
7723 // Flip the textures in the parent context via the texture manager. | 7724 // Flip the textures in the parent context via the texture manager. |
7724 if (!!offscreen_saved_color_texture_info_.get()) | 7725 if (!!offscreen_saved_color_texture_info_.get()) |
7725 offscreen_saved_color_texture_info_-> | 7726 offscreen_saved_color_texture_info_-> |
7726 SetServiceId(offscreen_target_color_texture_->id()); | 7727 SetServiceId(offscreen_target_color_texture_->id()); |
7727 | 7728 |
7728 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 7729 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
7729 offscreen_target_frame_buffer_->AttachRenderTexture( | 7730 offscreen_target_frame_buffer_->AttachRenderTexture( |
7730 offscreen_target_color_texture_.get()); | 7731 offscreen_target_color_texture_.get()); |
7731 } | 7732 } |
7732 | 7733 |
7733 // Ensure the side effects of the copy are visible to the parent | 7734 // Ensure the side effects of the copy are visible to the parent |
7734 // context. There is no need to do this for ANGLE because it uses a | 7735 // context. There is no need to do this for ANGLE because it uses a |
7735 // single D3D device for all contexts. | 7736 // single D3D device for all contexts. |
7736 if (!IsAngle()) | 7737 if (!IsAngle()) |
7737 glFlush(); | 7738 glFlush(); |
7738 } | |
7739 return error::kNoError; | 7739 return error::kNoError; |
7740 } | 7740 } |
7741 } else { | 7741 } else { |
7742 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); | 7742 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); |
7743 if (!surface_->SwapBuffers()) { | 7743 if (!surface_->SwapBuffers()) { |
7744 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 7744 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
7745 return error::kLostContext; | 7745 return error::kLostContext; |
7746 } | 7746 } |
7747 } | 7747 } |
7748 | 7748 |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8502 } | 8502 } |
8503 } | 8503 } |
8504 | 8504 |
8505 // Include the auto-generated part of this file. We split this because it means | 8505 // Include the auto-generated part of this file. We split this because it means |
8506 // we can easily edit the non-auto generated parts right here in this file | 8506 // we can easily edit the non-auto generated parts right here in this file |
8507 // instead of having to edit some template or the code generator. | 8507 // instead of having to edit some template or the code generator. |
8508 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8508 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8509 | 8509 |
8510 } // namespace gles2 | 8510 } // namespace gles2 |
8511 } // namespace gpu | 8511 } // namespace gpu |
OLD | NEW |