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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 template <bool DebugImpl> | 512 template <bool DebugImpl> |
513 error::Error DoCommandsImpl(unsigned int num_commands, | 513 error::Error DoCommandsImpl(unsigned int num_commands, |
514 const volatile void* buffer, | 514 const volatile void* buffer, |
515 int num_entries, | 515 int num_entries, |
516 int* entries_processed); | 516 int* entries_processed); |
517 | 517 |
518 // Overridden from AsyncAPIInterface. | 518 // Overridden from AsyncAPIInterface. |
519 const char* GetCommandName(unsigned int command_id) const override; | 519 const char* GetCommandName(unsigned int command_id) const override; |
520 | 520 |
521 // Overridden from GLES2Decoder. | 521 // Overridden from GLES2Decoder. |
| 522 base::WeakPtr<GLES2Decoder> AsWeakPtr() override; |
522 bool Initialize(const scoped_refptr<gl::GLSurface>& surface, | 523 bool Initialize(const scoped_refptr<gl::GLSurface>& surface, |
523 const scoped_refptr<gl::GLContext>& context, | 524 const scoped_refptr<gl::GLContext>& context, |
524 bool offscreen, | 525 bool offscreen, |
525 const DisallowedFeatures& disallowed_features, | 526 const DisallowedFeatures& disallowed_features, |
526 const ContextCreationAttribHelper& attrib_helper) override; | 527 const ContextCreationAttribHelper& attrib_helper) override; |
527 void Destroy(bool have_context) override; | 528 void Destroy(bool have_context) override; |
528 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; | 529 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; |
529 void ReleaseSurface() override; | 530 void ReleaseSurface() override; |
530 void TakeFrontBuffer(const Mailbox& mailbox) override; | 531 void TakeFrontBuffer(const Mailbox& mailbox) override; |
531 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; | 532 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; |
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 struct DCLayerSharedState { | 2492 struct DCLayerSharedState { |
2492 float opacity; | 2493 float opacity; |
2493 bool is_clipped; | 2494 bool is_clipped; |
2494 gfx::Rect clip_rect; | 2495 gfx::Rect clip_rect; |
2495 int z_order; | 2496 int z_order; |
2496 gfx::Transform transform; | 2497 gfx::Transform transform; |
2497 }; | 2498 }; |
2498 | 2499 |
2499 std::unique_ptr<DCLayerSharedState> dc_layer_shared_state_; | 2500 std::unique_ptr<DCLayerSharedState> dc_layer_shared_state_; |
2500 | 2501 |
| 2502 base::WeakPtrFactory<GLES2DecoderImpl> weak_ptr_factory_; |
| 2503 |
2501 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 2504 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
2502 }; | 2505 }; |
2503 | 2506 |
2504 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { | 2507 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { |
2505 #define GLES2_CMD_OP(name) \ | 2508 #define GLES2_CMD_OP(name) \ |
2506 { \ | 2509 { \ |
2507 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ | 2510 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ |
2508 cmds::name::cmd_flags, \ | 2511 cmds::name::cmd_flags, \ |
2509 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 2512 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
2510 } \ | 2513 } \ |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 num_stencil_bits_(0), | 3113 num_stencil_bits_(0), |
3111 texture_state_(group_->feature_info()->workarounds()), | 3114 texture_state_(group_->feature_info()->workarounds()), |
3112 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | 3115 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
3113 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), | 3116 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), |
3114 gpu_trace_level_(2), | 3117 gpu_trace_level_(2), |
3115 gpu_trace_commands_(false), | 3118 gpu_trace_commands_(false), |
3116 gpu_debug_commands_(false), | 3119 gpu_debug_commands_(false), |
3117 validation_fbo_multisample_(0), | 3120 validation_fbo_multisample_(0), |
3118 validation_fbo_(0), | 3121 validation_fbo_(0), |
3119 texture_manager_service_id_generation_(0), | 3122 texture_manager_service_id_generation_(0), |
3120 force_shader_name_hashing_for_test(false) { | 3123 force_shader_name_hashing_for_test(false), |
| 3124 weak_ptr_factory_(this) { |
3121 DCHECK(group); | 3125 DCHECK(group); |
3122 } | 3126 } |
3123 | 3127 |
3124 GLES2DecoderImpl::~GLES2DecoderImpl() { | 3128 GLES2DecoderImpl::~GLES2DecoderImpl() { |
3125 } | 3129 } |
3126 | 3130 |
| 3131 base::WeakPtr<GLES2Decoder> GLES2DecoderImpl::AsWeakPtr() { |
| 3132 return weak_ptr_factory_.GetWeakPtr(); |
| 3133 } |
| 3134 |
3127 bool GLES2DecoderImpl::Initialize( | 3135 bool GLES2DecoderImpl::Initialize( |
3128 const scoped_refptr<gl::GLSurface>& surface, | 3136 const scoped_refptr<gl::GLSurface>& surface, |
3129 const scoped_refptr<gl::GLContext>& context, | 3137 const scoped_refptr<gl::GLContext>& context, |
3130 bool offscreen, | 3138 bool offscreen, |
3131 const DisallowedFeatures& disallowed_features, | 3139 const DisallowedFeatures& disallowed_features, |
3132 const ContextCreationAttribHelper& attrib_helper) { | 3140 const ContextCreationAttribHelper& attrib_helper) { |
3133 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 3141 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
3134 DCHECK(context->IsCurrent(surface.get())); | 3142 DCHECK(context->IsCurrent(surface.get())); |
3135 DCHECK(!context_.get()); | 3143 DCHECK(!context_.get()); |
3136 | 3144 |
(...skipping 8576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11713 gl_version_info().is_angle ? GL_STATIC_DRAW : GL_STREAM_READ; | 11721 gl_version_info().is_angle ? GL_STATIC_DRAW : GL_STREAM_READ; |
11714 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); | 11722 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); |
11715 GLenum error = glGetError(); | 11723 GLenum error = glGetError(); |
11716 if (error == GL_NO_ERROR) { | 11724 if (error == GL_NO_ERROR) { |
11717 // No need to worry about ES3 pixel pack parameters, because no | 11725 // No need to worry about ES3 pixel pack parameters, because no |
11718 // PIXEL_PACK_BUFFER is bound, and all these settings haven't been | 11726 // PIXEL_PACK_BUFFER is bound, and all these settings haven't been |
11719 // sent to GL. | 11727 // sent to GL. |
11720 glReadPixels(x, y, width, height, format, type, 0); | 11728 glReadPixels(x, y, width, height, format, type, 0); |
11721 pending_readpixel_fences_.push(FenceCallback()); | 11729 pending_readpixel_fences_.push(FenceCallback()); |
11722 WaitForReadPixels(base::Bind( | 11730 WaitForReadPixels(base::Bind( |
11723 &GLES2DecoderImpl::FinishReadPixels, base::AsWeakPtr(this), width, | 11731 &GLES2DecoderImpl::FinishReadPixels, weak_ptr_factory_.GetWeakPtr(), |
11724 height, format, type, pixels_shm_id, pixels_shm_offset, | 11732 width, height, format, type, pixels_shm_id, pixels_shm_offset, |
11725 result_shm_id, result_shm_offset, state_.pack_alignment, | 11733 result_shm_id, result_shm_offset, state_.pack_alignment, |
11726 read_format, buffer)); | 11734 read_format, buffer)); |
11727 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); | 11735 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); |
11728 return error::kNoError; | 11736 return error::kNoError; |
11729 } else { | 11737 } else { |
11730 // On error, unbind pack buffer and fall through to sync readpixels | 11738 // On error, unbind pack buffer and fall through to sync readpixels |
11731 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); | 11739 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); |
11732 glDeleteBuffersARB(1, &buffer); | 11740 glDeleteBuffersARB(1, &buffer); |
11733 } | 11741 } |
11734 } | 11742 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11926 | 11934 |
11927 if (supports_async_swap_) { | 11935 if (supports_async_swap_) { |
11928 DCHECK_LT(pending_swaps_, 2u); | 11936 DCHECK_LT(pending_swaps_, 2u); |
11929 uint32_t async_swap_id = next_async_swap_id_++; | 11937 uint32_t async_swap_id = next_async_swap_id_++; |
11930 ++pending_swaps_; | 11938 ++pending_swaps_; |
11931 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id); | 11939 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id); |
11932 | 11940 |
11933 surface_->PostSubBufferAsync( | 11941 surface_->PostSubBufferAsync( |
11934 c.x, c.y, c.width, c.height, | 11942 c.x, c.y, c.width, c.height, |
11935 base::Bind(&GLES2DecoderImpl::FinishAsyncSwapBuffers, | 11943 base::Bind(&GLES2DecoderImpl::FinishAsyncSwapBuffers, |
11936 base::AsWeakPtr(this))); | 11944 weak_ptr_factory_.GetWeakPtr())); |
11937 } else { | 11945 } else { |
11938 FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height)); | 11946 FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height)); |
11939 } | 11947 } |
11940 | 11948 |
11941 return error::kNoError; | 11949 return error::kNoError; |
11942 } | 11950 } |
11943 | 11951 |
11944 error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM( | 11952 error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM( |
11945 uint32_t immediate_data_size, | 11953 uint32_t immediate_data_size, |
11946 const volatile void* cmd_data) { | 11954 const volatile void* cmd_data) { |
(...skipping 3648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15595 // single D3D device for all contexts. | 15603 // single D3D device for all contexts. |
15596 if (!gl_version_info().is_angle) | 15604 if (!gl_version_info().is_angle) |
15597 glFlush(); | 15605 glFlush(); |
15598 } | 15606 } |
15599 } else if (supports_async_swap_) { | 15607 } else if (supports_async_swap_) { |
15600 DCHECK_LT(pending_swaps_, 2u); | 15608 DCHECK_LT(pending_swaps_, 2u); |
15601 uint32_t async_swap_id = next_async_swap_id_++; | 15609 uint32_t async_swap_id = next_async_swap_id_++; |
15602 ++pending_swaps_; | 15610 ++pending_swaps_; |
15603 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id); | 15611 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id); |
15604 | 15612 |
15605 surface_->SwapBuffersAsync(base::Bind( | 15613 surface_->SwapBuffersAsync( |
15606 &GLES2DecoderImpl::FinishAsyncSwapBuffers, base::AsWeakPtr(this))); | 15614 base::Bind(&GLES2DecoderImpl::FinishAsyncSwapBuffers, |
| 15615 weak_ptr_factory_.GetWeakPtr())); |
15607 } else { | 15616 } else { |
15608 FinishSwapBuffers(surface_->SwapBuffers()); | 15617 FinishSwapBuffers(surface_->SwapBuffers()); |
15609 } | 15618 } |
15610 | 15619 |
15611 // This may be a slow command. Exit command processing to allow for | 15620 // This may be a slow command. Exit command processing to allow for |
15612 // context preemption and GPU watchdog checks. | 15621 // context preemption and GPU watchdog checks. |
15613 ExitCommandProcessingEarly(); | 15622 ExitCommandProcessingEarly(); |
15614 } | 15623 } |
15615 | 15624 |
15616 void GLES2DecoderImpl::FinishAsyncSwapBuffers(gfx::SwapResult result) { | 15625 void GLES2DecoderImpl::FinishAsyncSwapBuffers(gfx::SwapResult result) { |
(...skipping 25 matching lines...) Expand all Loading... |
15642 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes"); | 15651 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes"); |
15643 if (!supports_commit_overlay_planes_) { | 15652 if (!supports_commit_overlay_planes_) { |
15644 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCommitOverlayPlanes", | 15653 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCommitOverlayPlanes", |
15645 "command not supported by surface"); | 15654 "command not supported by surface"); |
15646 return; | 15655 return; |
15647 } | 15656 } |
15648 ClearScheduleCALayerState(); | 15657 ClearScheduleCALayerState(); |
15649 ClearScheduleDCLayerState(); | 15658 ClearScheduleDCLayerState(); |
15650 if (supports_async_swap_) { | 15659 if (supports_async_swap_) { |
15651 surface_->CommitOverlayPlanesAsync(base::Bind( | 15660 surface_->CommitOverlayPlanesAsync(base::Bind( |
15652 &GLES2DecoderImpl::FinishSwapBuffers, base::AsWeakPtr(this))); | 15661 &GLES2DecoderImpl::FinishSwapBuffers, weak_ptr_factory_.GetWeakPtr())); |
15653 } else { | 15662 } else { |
15654 FinishSwapBuffers(surface_->CommitOverlayPlanes()); | 15663 FinishSwapBuffers(surface_->CommitOverlayPlanes()); |
15655 } | 15664 } |
15656 } | 15665 } |
15657 | 15666 |
15658 void GLES2DecoderImpl::DoSwapInterval(int interval) { | 15667 void GLES2DecoderImpl::DoSwapInterval(int interval) { |
15659 context_->SetSwapInterval(interval); | 15668 context_->SetSwapInterval(interval); |
15660 } | 15669 } |
15661 | 15670 |
15662 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( | 15671 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( |
(...skipping 4062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19725 } | 19734 } |
19726 | 19735 |
19727 // Include the auto-generated part of this file. We split this because it means | 19736 // Include the auto-generated part of this file. We split this because it means |
19728 // we can easily edit the non-auto generated parts right here in this file | 19737 // we can easily edit the non-auto generated parts right here in this file |
19729 // instead of having to edit some template or the code generator. | 19738 // instead of having to edit some template or the code generator. |
19730 #include "base/macros.h" | 19739 #include "base/macros.h" |
19731 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19740 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19732 | 19741 |
19733 } // namespace gles2 | 19742 } // namespace gles2 |
19734 } // namespace gpu | 19743 } // namespace gpu |
OLD | NEW |