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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 virtual bool SetParent(GLES2Decoder* parent_decoder, | 533 virtual bool SetParent(GLES2Decoder* parent_decoder, |
534 uint32 parent_texture_id) OVERRIDE; | 534 uint32 parent_texture_id) OVERRIDE; |
535 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) OVERRIDE; | 535 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) OVERRIDE; |
536 void UpdateParentTextureInfo(); | 536 void UpdateParentTextureInfo(); |
537 virtual bool MakeCurrent() OVERRIDE; | 537 virtual bool MakeCurrent() OVERRIDE; |
538 virtual void ReleaseCurrent() OVERRIDE; | 538 virtual void ReleaseCurrent() OVERRIDE; |
539 virtual GLES2Util* GetGLES2Util() OVERRIDE { return &util_; } | 539 virtual GLES2Util* GetGLES2Util() OVERRIDE { return &util_; } |
540 virtual gfx::GLContext* GetGLContext() OVERRIDE { return context_.get(); } | 540 virtual gfx::GLContext* GetGLContext() OVERRIDE { return context_.get(); } |
541 virtual ContextGroup* GetContextGroup() OVERRIDE { return group_.get(); } | 541 virtual ContextGroup* GetContextGroup() OVERRIDE { return group_.get(); } |
542 virtual void RestoreState() const OVERRIDE; | 542 virtual void RestoreState() const OVERRIDE; |
| 543 |
| 544 virtual void RestoreActiveTexture() const OVERRIDE { |
| 545 state_.RestoreActiveTexture(); |
| 546 } |
| 547 virtual void RestoreAttribute(unsigned index) const OVERRIDE { |
| 548 state_.RestoreAttribute(index); |
| 549 } |
| 550 virtual void RestoreBufferBindings() const OVERRIDE { |
| 551 state_.RestoreBufferBindings(); |
| 552 } |
| 553 virtual void RestoreGlobalState() const OVERRIDE { |
| 554 state_.RestoreGlobalState(); |
| 555 } |
| 556 virtual void RestoreProgramBindings() const OVERRIDE { |
| 557 state_.RestoreProgramBindings(); |
| 558 } |
| 559 virtual void RestoreRenderbufferBindings() const OVERRIDE { |
| 560 state_.RestoreRenderbufferBindings(); |
| 561 } |
| 562 virtual void RestoreTextureUnitBindings(unsigned unit) const OVERRIDE { |
| 563 state_.RestoreTextureUnitBindings(unit); |
| 564 } |
| 565 virtual void RestoreFramebufferBindings() const OVERRIDE; |
| 566 virtual void RestoreTextureState(unsigned service_id) const OVERRIDE; |
| 567 |
543 virtual QueryManager* GetQueryManager() OVERRIDE { | 568 virtual QueryManager* GetQueryManager() OVERRIDE { |
544 return query_manager_.get(); | 569 return query_manager_.get(); |
545 } | 570 } |
546 virtual VertexArrayManager* GetVertexArrayManager() OVERRIDE { | 571 virtual VertexArrayManager* GetVertexArrayManager() OVERRIDE { |
547 return vertex_array_manager_.get(); | 572 return vertex_array_manager_.get(); |
548 } | 573 } |
549 virtual bool ProcessPendingQueries() OVERRIDE; | 574 virtual bool ProcessPendingQueries() OVERRIDE; |
550 | 575 |
551 virtual void SetGLError(GLenum error, | 576 virtual void SetGLError(GLenum error, |
552 const char* function_name, | 577 const char* function_name, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 662 } |
638 | 663 |
639 ProgramManager* program_manager() { | 664 ProgramManager* program_manager() { |
640 return group_->program_manager(); | 665 return group_->program_manager(); |
641 } | 666 } |
642 | 667 |
643 ShaderManager* shader_manager() { | 668 ShaderManager* shader_manager() { |
644 return group_->shader_manager(); | 669 return group_->shader_manager(); |
645 } | 670 } |
646 | 671 |
| 672 const TextureManager* texture_manager() const { |
| 673 return group_->texture_manager(); |
| 674 } |
| 675 |
647 TextureManager* texture_manager() { | 676 TextureManager* texture_manager() { |
648 return group_->texture_manager(); | 677 return group_->texture_manager(); |
649 } | 678 } |
650 | 679 |
651 MailboxManager* mailbox_manager() { | 680 MailboxManager* mailbox_manager() { |
652 return group_->mailbox_manager(); | 681 return group_->mailbox_manager(); |
653 } | 682 } |
654 | 683 |
655 ImageManager* image_manager() { | 684 ImageManager* image_manager() { |
656 return group_->image_manager(); | 685 return group_->image_manager(); |
(...skipping 19 matching lines...) Expand all Loading... |
676 return offscreen_target_samples_ > 1; | 705 return offscreen_target_samples_ > 1; |
677 } | 706 } |
678 | 707 |
679 // Creates a TextureInfo for the given texture. | 708 // Creates a TextureInfo for the given texture. |
680 TextureManager::TextureInfo* CreateTextureInfo( | 709 TextureManager::TextureInfo* CreateTextureInfo( |
681 GLuint client_id, GLuint service_id) { | 710 GLuint client_id, GLuint service_id) { |
682 return texture_manager()->CreateTextureInfo(client_id, service_id); | 711 return texture_manager()->CreateTextureInfo(client_id, service_id); |
683 } | 712 } |
684 | 713 |
685 // Gets the texture info for the given texture. Returns NULL if none exists. | 714 // Gets the texture info for the given texture. Returns NULL if none exists. |
686 TextureManager::TextureInfo* GetTextureInfo(GLuint client_id) { | 715 TextureManager::TextureInfo* GetTextureInfo(GLuint client_id) const { |
687 TextureManager::TextureInfo* info = | 716 TextureManager::TextureInfo* info = |
688 texture_manager()->GetTextureInfo(client_id); | 717 texture_manager()->GetTextureInfo(client_id); |
689 return info; | 718 return info; |
690 } | 719 } |
691 | 720 |
692 // Deletes the texture info for the given texture. | 721 // Deletes the texture info for the given texture. |
693 void RemoveTextureInfo(GLuint client_id) { | 722 void RemoveTextureInfo(GLuint client_id) { |
694 texture_manager()->RemoveTextureInfo(client_id); | 723 texture_manager()->RemoveTextureInfo(client_id); |
695 } | 724 } |
696 | 725 |
(...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3598 } | 3627 } |
3599 } | 3628 } |
3600 | 3629 |
3601 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { | 3630 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { |
3602 return (offscreen_target_frame_buffer_.get()) ? | 3631 return (offscreen_target_frame_buffer_.get()) ? |
3603 offscreen_target_frame_buffer_->id() : | 3632 offscreen_target_frame_buffer_->id() : |
3604 (surface_ ? surface_->GetBackingFrameBufferObject() : 0); | 3633 (surface_ ? surface_->GetBackingFrameBufferObject() : 0); |
3605 } | 3634 } |
3606 | 3635 |
3607 void GLES2DecoderImpl::RestoreState() const { | 3636 void GLES2DecoderImpl::RestoreState() const { |
3608 // TODO: Restore multisample bindings | 3637 // Restore the Framebuffer first because of bugs in Intel drivers. |
| 3638 // Intel drivers incorrectly clip the viewport settings to |
| 3639 // the size of the current framebuffer object. |
| 3640 RestoreFramebufferBindings(); |
| 3641 state_.RestoreState(); |
| 3642 } |
| 3643 |
| 3644 void GLES2DecoderImpl::RestoreFramebufferBindings() const { |
3609 GLuint service_id = state_.bound_draw_framebuffer ? | 3645 GLuint service_id = state_.bound_draw_framebuffer ? |
3610 state_.bound_draw_framebuffer->service_id() : | 3646 state_.bound_draw_framebuffer->service_id() : |
3611 GetBackbufferServiceId(); | 3647 GetBackbufferServiceId(); |
3612 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); | 3648 if (!features().chromium_framebuffer_multisample) { |
| 3649 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); |
| 3650 } else { |
| 3651 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); |
| 3652 service_id = state_.bound_read_framebuffer ? |
| 3653 state_.bound_read_framebuffer->service_id() : |
| 3654 GetBackbufferServiceId(); |
| 3655 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); |
| 3656 } |
3613 OnFboChanged(); | 3657 OnFboChanged(); |
3614 | 3658 |
3615 // Restore gl states after bind framebuffer, to ensure the gl states | 3659 } |
3616 // applied to right FBO | 3660 |
3617 // gman: There is no framebuffer state so this is a bug in the driver | 3661 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { |
3618 state_.RestoreState(); | 3662 GLuint client_id = 0; |
| 3663 if (texture_manager()->GetClientId(service_id, &client_id)) { |
| 3664 TextureManager::TextureInfo* texture = GetTextureInfo(client_id); |
| 3665 glBindTexture(GL_TEXTURE_2D, service_id); |
| 3666 glTexParameteri( |
| 3667 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap_s()); |
| 3668 glTexParameteri( |
| 3669 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->wrap_t()); |
| 3670 glTexParameteri( |
| 3671 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->min_filter()); |
| 3672 glTexParameteri( |
| 3673 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture->mag_filter()); |
| 3674 RestoreTextureUnitBindings(state_.active_texture_unit); |
| 3675 } |
3619 } | 3676 } |
3620 | 3677 |
3621 void GLES2DecoderImpl::OnFboChanged() const { | 3678 void GLES2DecoderImpl::OnFboChanged() const { |
3622 if (workarounds().restore_scissor_on_fbo_change) | 3679 if (workarounds().restore_scissor_on_fbo_change) |
3623 glScissor(state_.scissor_x, state_.scissor_y, | 3680 glScissor(state_.scissor_x, state_.scissor_y, |
3624 state_.scissor_width, state_.scissor_height); | 3681 state_.scissor_width, state_.scissor_height); |
3625 } | 3682 } |
3626 | 3683 |
3627 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 3684 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
3628 FramebufferManager::FramebufferInfo* info = NULL; | 3685 FramebufferManager::FramebufferInfo* info = NULL; |
(...skipping 6467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10096 return error::kNoError; | 10153 return error::kNoError; |
10097 } | 10154 } |
10098 | 10155 |
10099 // Include the auto-generated part of this file. We split this because it means | 10156 // Include the auto-generated part of this file. We split this because it means |
10100 // we can easily edit the non-auto generated parts right here in this file | 10157 // we can easily edit the non-auto generated parts right here in this file |
10101 // instead of having to edit some template or the code generator. | 10158 // instead of having to edit some template or the code generator. |
10102 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10159 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10103 | 10160 |
10104 } // namespace gles2 | 10161 } // namespace gles2 |
10105 } // namespace gpu | 10162 } // namespace gpu |
OLD | NEW |