| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 std::unique_ptr<BackTexture> offscreen_target_color_texture_; | 2041 std::unique_ptr<BackTexture> offscreen_target_color_texture_; |
| 2042 std::unique_ptr<BackRenderbuffer> offscreen_target_color_render_buffer_; | 2042 std::unique_ptr<BackRenderbuffer> offscreen_target_color_render_buffer_; |
| 2043 std::unique_ptr<BackRenderbuffer> offscreen_target_depth_render_buffer_; | 2043 std::unique_ptr<BackRenderbuffer> offscreen_target_depth_render_buffer_; |
| 2044 std::unique_ptr<BackRenderbuffer> offscreen_target_stencil_render_buffer_; | 2044 std::unique_ptr<BackRenderbuffer> offscreen_target_stencil_render_buffer_; |
| 2045 GLenum offscreen_target_color_format_; | 2045 GLenum offscreen_target_color_format_; |
| 2046 GLenum offscreen_target_depth_format_; | 2046 GLenum offscreen_target_depth_format_; |
| 2047 GLenum offscreen_target_stencil_format_; | 2047 GLenum offscreen_target_stencil_format_; |
| 2048 GLsizei offscreen_target_samples_; | 2048 GLsizei offscreen_target_samples_; |
| 2049 GLboolean offscreen_target_buffer_preserved_; | 2049 GLboolean offscreen_target_buffer_preserved_; |
| 2050 | 2050 |
| 2051 // The copy that is saved when SwapBuffers is called. | 2051 // The saved copy of the backbuffer after a call to SwapBuffers. |
| 2052 std::unique_ptr<BackTexture> offscreen_saved_color_texture_; |
| 2053 |
| 2054 // For simplicity, |offscreen_saved_color_texture_| is always bound to |
| 2055 // |offscreen_saved_frame_buffer_|. |
| 2052 std::unique_ptr<BackFramebuffer> offscreen_saved_frame_buffer_; | 2056 std::unique_ptr<BackFramebuffer> offscreen_saved_frame_buffer_; |
| 2053 std::unique_ptr<BackTexture> offscreen_saved_color_texture_; | |
| 2054 scoped_refptr<TextureRef> | 2057 scoped_refptr<TextureRef> |
| 2055 offscreen_saved_color_texture_info_; | 2058 offscreen_saved_color_texture_info_; |
| 2056 | 2059 |
| 2057 // When a client requests ownership of the swapped front buffer, all | 2060 // When a client requests ownership of the swapped front buffer, all |
| 2058 // information is saved in this structure, and |in_use| is set to true. When a | 2061 // information is saved in this structure, and |in_use| is set to true. When a |
| 2059 // client releases ownership, |in_use| is set to false. | 2062 // client releases ownership, |in_use| is set to false. |
| 2060 // | 2063 // |
| 2061 // An instance of this struct, with |in_use| = false may be reused instead of | 2064 // An instance of this struct, with |in_use| = false may be reused instead of |
| 2062 // making a new BackTexture. | 2065 // making a new BackTexture. |
| 2063 struct SavedBackTexture { | 2066 struct SavedBackTexture { |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4215 state_.bound_transform_feedback_buffer = nullptr; | 4218 state_.bound_transform_feedback_buffer = nullptr; |
| 4216 state_.bound_uniform_buffer = nullptr; | 4219 state_.bound_uniform_buffer = nullptr; |
| 4217 framebuffer_state_.bound_read_framebuffer = nullptr; | 4220 framebuffer_state_.bound_read_framebuffer = nullptr; |
| 4218 framebuffer_state_.bound_draw_framebuffer = nullptr; | 4221 framebuffer_state_.bound_draw_framebuffer = nullptr; |
| 4219 state_.bound_renderbuffer = nullptr; | 4222 state_.bound_renderbuffer = nullptr; |
| 4220 state_.bound_transform_feedback = nullptr; | 4223 state_.bound_transform_feedback = nullptr; |
| 4221 state_.default_transform_feedback = nullptr; | 4224 state_.default_transform_feedback = nullptr; |
| 4222 state_.indexed_uniform_buffer_bindings = nullptr; | 4225 state_.indexed_uniform_buffer_bindings = nullptr; |
| 4223 | 4226 |
| 4224 if (offscreen_saved_color_texture_info_.get()) { | 4227 if (offscreen_saved_color_texture_info_.get()) { |
| 4225 DCHECK(offscreen_target_color_texture_); | 4228 DCHECK(offscreen_saved_color_texture_); |
| 4226 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 4229 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
| 4227 offscreen_saved_color_texture_->id()); | 4230 offscreen_saved_color_texture_->id()); |
| 4228 offscreen_saved_color_texture_->Invalidate(); | 4231 offscreen_saved_color_texture_->Invalidate(); |
| 4229 offscreen_saved_color_texture_info_ = NULL; | 4232 offscreen_saved_color_texture_info_ = NULL; |
| 4230 } | 4233 } |
| 4231 ReleaseAllBackTextures(); | 4234 ReleaseAllBackTextures(); |
| 4232 if (have_context) { | 4235 if (have_context) { |
| 4233 if (copy_texture_CHROMIUM_.get()) { | 4236 if (copy_texture_CHROMIUM_.get()) { |
| 4234 copy_texture_CHROMIUM_->Destroy(); | 4237 copy_texture_CHROMIUM_->Destroy(); |
| 4235 copy_texture_CHROMIUM_.reset(); | 4238 copy_texture_CHROMIUM_.reset(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4397 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4400 offscreen_saved_color_texture_info_ = TextureRef::Create( |
| 4398 texture_manager(), 0, service_id); | 4401 texture_manager(), 0, service_id); |
| 4399 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), | 4402 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), |
| 4400 GL_TEXTURE_2D); | 4403 GL_TEXTURE_2D); |
| 4401 UpdateParentTextureInfo(); | 4404 UpdateParentTextureInfo(); |
| 4402 } | 4405 } |
| 4403 | 4406 |
| 4404 mailbox_manager()->ProduceTexture( | 4407 mailbox_manager()->ProduceTexture( |
| 4405 mailbox, offscreen_saved_color_texture_info_->texture()); | 4408 mailbox, offscreen_saved_color_texture_info_->texture()); |
| 4406 | 4409 |
| 4407 // Save the BackTexture and TextureRef. | 4410 // Save the BackTexture and TextureRef. There's no need to update |
| 4411 // |offscreen_saved_frame_buffer_| since CreateBackTexture() will take care of |
| 4412 // that. |
| 4408 SavedBackTexture save; | 4413 SavedBackTexture save; |
| 4409 save.back_texture.swap(offscreen_saved_color_texture_); | 4414 save.back_texture.swap(offscreen_saved_color_texture_); |
| 4410 save.texture_ref = offscreen_saved_color_texture_info_; | 4415 save.texture_ref = offscreen_saved_color_texture_info_; |
| 4411 offscreen_saved_color_texture_info_ = nullptr; | 4416 offscreen_saved_color_texture_info_ = nullptr; |
| 4412 save.in_use = true; | 4417 save.in_use = true; |
| 4413 saved_back_textures_.push_back(std::move(save)); | 4418 saved_back_textures_.push_back(std::move(save)); |
| 4414 | 4419 |
| 4415 CreateBackTexture(); | 4420 CreateBackTexture(); |
| 4416 } | 4421 } |
| 4417 | 4422 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4438 void GLES2DecoderImpl::CreateBackTexture() { | 4443 void GLES2DecoderImpl::CreateBackTexture() { |
| 4439 for (auto it = saved_back_textures_.begin(); it != saved_back_textures_.end(); | 4444 for (auto it = saved_back_textures_.begin(); it != saved_back_textures_.end(); |
| 4440 ++it) { | 4445 ++it) { |
| 4441 if (it->in_use) | 4446 if (it->in_use) |
| 4442 continue; | 4447 continue; |
| 4443 | 4448 |
| 4444 if (it->back_texture->size() != offscreen_size_) | 4449 if (it->back_texture->size() != offscreen_size_) |
| 4445 continue; | 4450 continue; |
| 4446 offscreen_saved_color_texture_ = std::move(it->back_texture); | 4451 offscreen_saved_color_texture_ = std::move(it->back_texture); |
| 4447 offscreen_saved_color_texture_info_ = it->texture_ref; | 4452 offscreen_saved_color_texture_info_ = it->texture_ref; |
| 4453 offscreen_saved_frame_buffer_->AttachRenderTexture( |
| 4454 offscreen_saved_color_texture_.get()); |
| 4448 saved_back_textures_.erase(it); | 4455 saved_back_textures_.erase(it); |
| 4449 return; | 4456 return; |
| 4450 } | 4457 } |
| 4451 | 4458 |
| 4452 ++create_back_texture_count_for_test_; | 4459 ++create_back_texture_count_for_test_; |
| 4453 offscreen_saved_color_texture_.reset( | 4460 offscreen_saved_color_texture_.reset( |
| 4454 new BackTexture(memory_tracker(), &state_)); | 4461 new BackTexture(memory_tracker(), &state_)); |
| 4455 offscreen_saved_color_texture_->Create(); | 4462 offscreen_saved_color_texture_->Create(); |
| 4456 offscreen_saved_color_texture_->AllocateStorage( | 4463 offscreen_saved_color_texture_->AllocateStorage( |
| 4457 offscreen_size_, offscreen_saved_color_format_, false); | 4464 offscreen_size_, offscreen_saved_color_format_, false); |
| (...skipping 8773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13231 offscreen_saved_color_format_); | 13238 offscreen_saved_color_format_); |
| 13232 } else { | 13239 } else { |
| 13233 // Flip the textures in the parent context via the texture manager. | 13240 // Flip the textures in the parent context via the texture manager. |
| 13234 if (!!offscreen_saved_color_texture_info_.get()) | 13241 if (!!offscreen_saved_color_texture_info_.get()) |
| 13235 offscreen_saved_color_texture_info_->texture()-> | 13242 offscreen_saved_color_texture_info_->texture()-> |
| 13236 SetServiceId(offscreen_target_color_texture_->id()); | 13243 SetServiceId(offscreen_target_color_texture_->id()); |
| 13237 | 13244 |
| 13238 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 13245 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
| 13239 offscreen_target_frame_buffer_->AttachRenderTexture( | 13246 offscreen_target_frame_buffer_->AttachRenderTexture( |
| 13240 offscreen_target_color_texture_.get()); | 13247 offscreen_target_color_texture_.get()); |
| 13248 offscreen_saved_frame_buffer_->AttachRenderTexture( |
| 13249 offscreen_saved_color_texture_.get()); |
| 13241 } | 13250 } |
| 13242 | 13251 |
| 13243 // Ensure the side effects of the copy are visible to the parent | 13252 // Ensure the side effects of the copy are visible to the parent |
| 13244 // context. There is no need to do this for ANGLE because it uses a | 13253 // context. There is no need to do this for ANGLE because it uses a |
| 13245 // single D3D device for all contexts. | 13254 // single D3D device for all contexts. |
| 13246 if (!feature_info_->gl_version_info().is_angle) | 13255 if (!feature_info_->gl_version_info().is_angle) |
| 13247 glFlush(); | 13256 glFlush(); |
| 13248 } | 13257 } |
| 13249 } else if (supports_async_swap_) { | 13258 } else if (supports_async_swap_) { |
| 13250 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); | 13259 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); |
| (...skipping 3563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16814 } | 16823 } |
| 16815 | 16824 |
| 16816 // Include the auto-generated part of this file. We split this because it means | 16825 // Include the auto-generated part of this file. We split this because it means |
| 16817 // we can easily edit the non-auto generated parts right here in this file | 16826 // we can easily edit the non-auto generated parts right here in this file |
| 16818 // instead of having to edit some template or the code generator. | 16827 // instead of having to edit some template or the code generator. |
| 16819 #include "base/macros.h" | 16828 #include "base/macros.h" |
| 16820 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16829 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 16821 | 16830 |
| 16822 } // namespace gles2 | 16831 } // namespace gles2 |
| 16823 } // namespace gpu | 16832 } // namespace gpu |
| OLD | NEW |