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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 scoped_ptr<gfx::GLFence> fence; | 504 scoped_ptr<gfx::GLFence> fence; |
505 }; | 505 }; |
506 | 506 |
507 class AsyncUploadTokenCompletionObserver | 507 class AsyncUploadTokenCompletionObserver |
508 : public AsyncPixelTransferCompletionObserver { | 508 : public AsyncPixelTransferCompletionObserver { |
509 public: | 509 public: |
510 explicit AsyncUploadTokenCompletionObserver(uint32 async_upload_token) | 510 explicit AsyncUploadTokenCompletionObserver(uint32 async_upload_token) |
511 : async_upload_token_(async_upload_token) { | 511 : async_upload_token_(async_upload_token) { |
512 } | 512 } |
513 | 513 |
514 virtual void DidComplete(const AsyncMemoryParams& mem_params) override { | 514 void DidComplete(const AsyncMemoryParams& mem_params) override { |
515 DCHECK(mem_params.buffer().get()); | 515 DCHECK(mem_params.buffer().get()); |
516 void* data = mem_params.GetDataAddress(); | 516 void* data = mem_params.GetDataAddress(); |
517 AsyncUploadSync* sync = static_cast<AsyncUploadSync*>(data); | 517 AsyncUploadSync* sync = static_cast<AsyncUploadSync*>(data); |
518 sync->SetAsyncUploadToken(async_upload_token_); | 518 sync->SetAsyncUploadToken(async_upload_token_); |
519 } | 519 } |
520 | 520 |
521 private: | 521 private: |
522 virtual ~AsyncUploadTokenCompletionObserver() { | 522 ~AsyncUploadTokenCompletionObserver() override {} |
523 } | |
524 | 523 |
525 uint32 async_upload_token_; | 524 uint32 async_upload_token_; |
526 | 525 |
527 DISALLOW_COPY_AND_ASSIGN(AsyncUploadTokenCompletionObserver); | 526 DISALLOW_COPY_AND_ASSIGN(AsyncUploadTokenCompletionObserver); |
528 }; | 527 }; |
529 | 528 |
530 // } // anonymous namespace. | 529 // } // anonymous namespace. |
531 | 530 |
532 // static | 531 // static |
533 const unsigned int GLES2Decoder::kDefaultStencilMask = | 532 const unsigned int GLES2Decoder::kDefaultStencilMask = |
(...skipping 17 matching lines...) Expand all Loading... |
551 | 550 |
552 void GLES2Decoder::EndDecoding() {} | 551 void GLES2Decoder::EndDecoding() {} |
553 | 552 |
554 // This class implements GLES2Decoder so we don't have to expose all the GLES2 | 553 // This class implements GLES2Decoder so we don't have to expose all the GLES2 |
555 // cmd stuff to outside this class. | 554 // cmd stuff to outside this class. |
556 class GLES2DecoderImpl : public GLES2Decoder, | 555 class GLES2DecoderImpl : public GLES2Decoder, |
557 public FramebufferManager::TextureDetachObserver, | 556 public FramebufferManager::TextureDetachObserver, |
558 public ErrorStateClient { | 557 public ErrorStateClient { |
559 public: | 558 public: |
560 explicit GLES2DecoderImpl(ContextGroup* group); | 559 explicit GLES2DecoderImpl(ContextGroup* group); |
561 virtual ~GLES2DecoderImpl(); | 560 ~GLES2DecoderImpl() override; |
562 | 561 |
563 // Overridden from AsyncAPIInterface. | 562 // Overridden from AsyncAPIInterface. |
564 virtual Error DoCommand(unsigned int command, | 563 Error DoCommand(unsigned int command, |
565 unsigned int arg_count, | 564 unsigned int arg_count, |
566 const void* args) override; | 565 const void* args) override; |
567 | 566 |
568 virtual error::Error DoCommands(unsigned int num_commands, | 567 error::Error DoCommands(unsigned int num_commands, |
569 const void* buffer, | 568 const void* buffer, |
570 int num_entries, | 569 int num_entries, |
571 int* entries_processed) override; | 570 int* entries_processed) override; |
572 | 571 |
573 template <bool DebugImpl> | 572 template <bool DebugImpl> |
574 error::Error DoCommandsImpl(unsigned int num_commands, | 573 error::Error DoCommandsImpl(unsigned int num_commands, |
575 const void* buffer, | 574 const void* buffer, |
576 int num_entries, | 575 int num_entries, |
577 int* entries_processed); | 576 int* entries_processed); |
578 | 577 |
579 // Overridden from AsyncAPIInterface. | 578 // Overridden from AsyncAPIInterface. |
580 virtual const char* GetCommandName(unsigned int command_id) const override; | 579 const char* GetCommandName(unsigned int command_id) const override; |
581 | 580 |
582 // Overridden from GLES2Decoder. | 581 // Overridden from GLES2Decoder. |
583 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 582 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
584 const scoped_refptr<gfx::GLContext>& context, | 583 const scoped_refptr<gfx::GLContext>& context, |
585 bool offscreen, | 584 bool offscreen, |
586 const gfx::Size& size, | 585 const gfx::Size& size, |
587 const DisallowedFeatures& disallowed_features, | 586 const DisallowedFeatures& disallowed_features, |
588 const std::vector<int32>& attribs) override; | 587 const std::vector<int32>& attribs) override; |
589 virtual void Destroy(bool have_context) override; | 588 void Destroy(bool have_context) override; |
590 virtual void SetSurface( | 589 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; |
591 const scoped_refptr<gfx::GLSurface>& surface) override; | 590 void ProduceFrontBuffer(const Mailbox& mailbox) override; |
592 virtual void ProduceFrontBuffer(const Mailbox& mailbox) override; | 591 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
593 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | |
594 void UpdateParentTextureInfo(); | 592 void UpdateParentTextureInfo(); |
595 virtual bool MakeCurrent() override; | 593 bool MakeCurrent() override; |
596 virtual GLES2Util* GetGLES2Util() override { return &util_; } | 594 GLES2Util* GetGLES2Util() override { return &util_; } |
597 virtual gfx::GLContext* GetGLContext() override { return context_.get(); } | 595 gfx::GLContext* GetGLContext() override { return context_.get(); } |
598 virtual ContextGroup* GetContextGroup() override { return group_.get(); } | 596 ContextGroup* GetContextGroup() override { return group_.get(); } |
599 virtual Capabilities GetCapabilities() override; | 597 Capabilities GetCapabilities() override; |
600 virtual void RestoreState(const ContextState* prev_state) override; | 598 void RestoreState(const ContextState* prev_state) override; |
601 | 599 |
602 virtual void RestoreActiveTexture() const override { | 600 void RestoreActiveTexture() const override { state_.RestoreActiveTexture(); } |
603 state_.RestoreActiveTexture(); | 601 void RestoreAllTextureUnitBindings( |
604 } | |
605 virtual void RestoreAllTextureUnitBindings( | |
606 const ContextState* prev_state) const override { | 602 const ContextState* prev_state) const override { |
607 state_.RestoreAllTextureUnitBindings(prev_state); | 603 state_.RestoreAllTextureUnitBindings(prev_state); |
608 } | 604 } |
609 virtual void RestoreActiveTextureUnitBinding( | 605 void RestoreActiveTextureUnitBinding(unsigned int target) const override { |
610 unsigned int target) const override { | |
611 state_.RestoreActiveTextureUnitBinding(target); | 606 state_.RestoreActiveTextureUnitBinding(target); |
612 } | 607 } |
613 virtual void RestoreBufferBindings() const override { | 608 void RestoreBufferBindings() const override { |
614 state_.RestoreBufferBindings(); | 609 state_.RestoreBufferBindings(); |
615 } | 610 } |
616 virtual void RestoreGlobalState() const override { | 611 void RestoreGlobalState() const override { state_.RestoreGlobalState(NULL); } |
617 state_.RestoreGlobalState(NULL); | 612 void RestoreProgramBindings() const override { |
618 } | |
619 virtual void RestoreProgramBindings() const override { | |
620 state_.RestoreProgramBindings(); | 613 state_.RestoreProgramBindings(); |
621 } | 614 } |
622 virtual void RestoreTextureUnitBindings(unsigned unit) const override { | 615 void RestoreTextureUnitBindings(unsigned unit) const override { |
623 state_.RestoreTextureUnitBindings(unit, NULL); | 616 state_.RestoreTextureUnitBindings(unit, NULL); |
624 } | 617 } |
625 virtual void RestoreFramebufferBindings() const override; | 618 void RestoreFramebufferBindings() const override; |
626 virtual void RestoreRenderbufferBindings() override; | 619 void RestoreRenderbufferBindings() override; |
627 virtual void RestoreTextureState(unsigned service_id) const override; | 620 void RestoreTextureState(unsigned service_id) const override; |
628 | 621 |
629 virtual void ClearAllAttributes() const override; | 622 void ClearAllAttributes() const override; |
630 virtual void RestoreAllAttributes() const override; | 623 void RestoreAllAttributes() const override; |
631 | 624 |
632 virtual QueryManager* GetQueryManager() override { | 625 QueryManager* GetQueryManager() override { return query_manager_.get(); } |
633 return query_manager_.get(); | 626 VertexArrayManager* GetVertexArrayManager() override { |
634 } | |
635 virtual VertexArrayManager* GetVertexArrayManager() override { | |
636 return vertex_array_manager_.get(); | 627 return vertex_array_manager_.get(); |
637 } | 628 } |
638 virtual ImageManager* GetImageManager() override { | 629 ImageManager* GetImageManager() override { return image_manager_.get(); } |
639 return image_manager_.get(); | 630 bool ProcessPendingQueries() override; |
640 } | 631 bool HasMoreIdleWork() override; |
641 virtual bool ProcessPendingQueries() override; | 632 void PerformIdleWork() override; |
642 virtual bool HasMoreIdleWork() override; | |
643 virtual void PerformIdleWork() override; | |
644 | 633 |
645 virtual void WaitForReadPixels(base::Closure callback) override; | 634 void WaitForReadPixels(base::Closure callback) override; |
646 | 635 |
647 virtual void SetResizeCallback( | 636 void SetResizeCallback( |
648 const base::Callback<void(gfx::Size, float)>& callback) override; | 637 const base::Callback<void(gfx::Size, float)>& callback) override; |
649 | 638 |
650 virtual Logger* GetLogger() override; | 639 Logger* GetLogger() override; |
651 | 640 |
652 virtual void BeginDecoding() override; | 641 void BeginDecoding() override; |
653 virtual void EndDecoding() override; | 642 void EndDecoding() override; |
654 | 643 |
655 virtual ErrorState* GetErrorState() override; | 644 ErrorState* GetErrorState() override; |
656 virtual const ContextState* GetContextState() override { return &state_; } | 645 const ContextState* GetContextState() override { return &state_; } |
657 | 646 |
658 virtual void SetShaderCacheCallback( | 647 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; |
659 const ShaderCacheCallback& callback) override; | 648 void SetWaitSyncPointCallback(const WaitSyncPointCallback& callback) override; |
660 virtual void SetWaitSyncPointCallback( | |
661 const WaitSyncPointCallback& callback) override; | |
662 | 649 |
663 virtual AsyncPixelTransferManager* | 650 AsyncPixelTransferManager* GetAsyncPixelTransferManager() override; |
664 GetAsyncPixelTransferManager() override; | 651 void ResetAsyncPixelTransferManagerForTest() override; |
665 virtual void ResetAsyncPixelTransferManagerForTest() override; | 652 void SetAsyncPixelTransferManagerForTest( |
666 virtual void SetAsyncPixelTransferManagerForTest( | |
667 AsyncPixelTransferManager* manager) override; | 653 AsyncPixelTransferManager* manager) override; |
668 virtual void SetIgnoreCachedStateForTest(bool ignore) override; | 654 void SetIgnoreCachedStateForTest(bool ignore) override; |
669 void ProcessFinishedAsyncTransfers(); | 655 void ProcessFinishedAsyncTransfers(); |
670 | 656 |
671 virtual bool GetServiceTextureId(uint32 client_texture_id, | 657 bool GetServiceTextureId(uint32 client_texture_id, |
672 uint32* service_texture_id) override; | 658 uint32* service_texture_id) override; |
673 | 659 |
674 virtual uint32 GetTextureUploadCount() override; | 660 uint32 GetTextureUploadCount() override; |
675 virtual base::TimeDelta GetTotalTextureUploadTime() override; | 661 base::TimeDelta GetTotalTextureUploadTime() override; |
676 virtual base::TimeDelta GetTotalProcessingCommandsTime() override; | 662 base::TimeDelta GetTotalProcessingCommandsTime() override; |
677 virtual void AddProcessingCommandsTime(base::TimeDelta) override; | 663 void AddProcessingCommandsTime(base::TimeDelta) override; |
678 | 664 |
679 // Restores the current state to the user's settings. | 665 // Restores the current state to the user's settings. |
680 void RestoreCurrentFramebufferBindings(); | 666 void RestoreCurrentFramebufferBindings(); |
681 | 667 |
682 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. | 668 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
683 void ApplyDirtyState(); | 669 void ApplyDirtyState(); |
684 | 670 |
685 // These check the state of the currently bound framebuffer or the | 671 // These check the state of the currently bound framebuffer or the |
686 // backbuffer if no framebuffer is bound. | 672 // backbuffer if no framebuffer is bound. |
687 // If all_draw_buffers is false, only check with COLOR_ATTACHMENT0, otherwise | 673 // If all_draw_buffers is false, only check with COLOR_ATTACHMENT0, otherwise |
688 // check with all attached and enabled color attachments. | 674 // check with all attached and enabled color attachments. |
689 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); | 675 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); |
690 bool BoundFramebufferHasDepthAttachment(); | 676 bool BoundFramebufferHasDepthAttachment(); |
691 bool BoundFramebufferHasStencilAttachment(); | 677 bool BoundFramebufferHasStencilAttachment(); |
692 | 678 |
693 virtual error::ContextLostReason GetContextLostReason() override; | 679 error::ContextLostReason GetContextLostReason() override; |
694 | 680 |
695 // Overridden from FramebufferManager::TextureDetachObserver: | 681 // Overridden from FramebufferManager::TextureDetachObserver: |
696 virtual void OnTextureRefDetachedFromFramebuffer( | 682 void OnTextureRefDetachedFromFramebuffer(TextureRef* texture) override; |
697 TextureRef* texture) override; | |
698 | 683 |
699 // Overriden from ErrorStateClient. | 684 // Overriden from ErrorStateClient. |
700 virtual void OnOutOfMemoryError() override; | 685 void OnOutOfMemoryError() override; |
701 | 686 |
702 // Ensure Renderbuffer corresponding to last DoBindRenderbuffer() is bound. | 687 // Ensure Renderbuffer corresponding to last DoBindRenderbuffer() is bound. |
703 void EnsureRenderbufferBound(); | 688 void EnsureRenderbufferBound(); |
704 | 689 |
705 // Helpers to facilitate calling into compatible extensions. | 690 // Helpers to facilitate calling into compatible extensions. |
706 static void RenderbufferStorageMultisampleHelper( | 691 static void RenderbufferStorageMultisampleHelper( |
707 const FeatureInfo* feature_info, | 692 const FeatureInfo* feature_info, |
708 GLenum target, | 693 GLenum target, |
709 GLsizei samples, | 694 GLsizei samples, |
710 GLenum internal_format, | 695 GLenum internal_format, |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 GLuint client_id, const char* data, uint32 data_size); | 1133 GLuint client_id, const char* data, uint32 data_size); |
1149 | 1134 |
1150 // Clear any textures used by the current program. | 1135 // Clear any textures used by the current program. |
1151 bool ClearUnclearedTextures(); | 1136 bool ClearUnclearedTextures(); |
1152 | 1137 |
1153 // Clears any uncleared attachments attached to the given frame buffer. | 1138 // Clears any uncleared attachments attached to the given frame buffer. |
1154 // Returns false if there was a generated GL error. | 1139 // Returns false if there was a generated GL error. |
1155 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); | 1140 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); |
1156 | 1141 |
1157 // overridden from GLES2Decoder | 1142 // overridden from GLES2Decoder |
1158 virtual bool ClearLevel(unsigned service_id, | 1143 bool ClearLevel(unsigned service_id, |
1159 unsigned bind_target, | 1144 unsigned bind_target, |
1160 unsigned target, | 1145 unsigned target, |
1161 int level, | 1146 int level, |
1162 unsigned internal_format, | 1147 unsigned internal_format, |
1163 unsigned format, | 1148 unsigned format, |
1164 unsigned type, | 1149 unsigned type, |
1165 int width, | 1150 int width, |
1166 int height, | 1151 int height, |
1167 bool is_texture_immutable) override; | 1152 bool is_texture_immutable) override; |
1168 | 1153 |
1169 // Restore all GL state that affects clearing. | 1154 // Restore all GL state that affects clearing. |
1170 void RestoreClearState(); | 1155 void RestoreClearState(); |
1171 | 1156 |
1172 // Remembers the state of some capabilities. | 1157 // Remembers the state of some capabilities. |
1173 // Returns: true if glEnable/glDisable should actually be called. | 1158 // Returns: true if glEnable/glDisable should actually be called. |
1174 bool SetCapabilityState(GLenum cap, bool enabled); | 1159 bool SetCapabilityState(GLenum cap, bool enabled); |
1175 | 1160 |
1176 // Check that the currently bound framebuffers are valid. | 1161 // Check that the currently bound framebuffers are valid. |
1177 // Generates GL error if not. | 1162 // Generates GL error if not. |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 // Validates the program and location for a glGetUniform call and returns | 1555 // Validates the program and location for a glGetUniform call and returns |
1571 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1556 // a SizeResult setup to receive the result. Returns true if glGetUniform |
1572 // should be called. | 1557 // should be called. |
1573 bool GetUniformSetup( | 1558 bool GetUniformSetup( |
1574 GLuint program, GLint fake_location, | 1559 GLuint program, GLint fake_location, |
1575 uint32 shm_id, uint32 shm_offset, | 1560 uint32 shm_id, uint32 shm_offset, |
1576 error::Error* error, GLint* real_location, GLuint* service_id, | 1561 error::Error* error, GLint* real_location, GLuint* service_id, |
1577 void** result, GLenum* result_type); | 1562 void** result, GLenum* result_type); |
1578 | 1563 |
1579 void MaybeExitOnContextLost(); | 1564 void MaybeExitOnContextLost(); |
1580 virtual bool WasContextLost() override; | 1565 bool WasContextLost() override; |
1581 virtual bool WasContextLostByRobustnessExtension() override; | 1566 bool WasContextLostByRobustnessExtension() override; |
1582 virtual void LoseContext(uint32 reset_status) override; | 1567 void LoseContext(uint32 reset_status) override; |
1583 | 1568 |
1584 #if defined(OS_MACOSX) | 1569 #if defined(OS_MACOSX) |
1585 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1570 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
1586 #endif | 1571 #endif |
1587 | 1572 |
1588 bool ValidateCompressedTexDimensions( | 1573 bool ValidateCompressedTexDimensions( |
1589 const char* function_name, | 1574 const char* function_name, |
1590 GLint level, GLsizei width, GLsizei height, GLenum format); | 1575 GLint level, GLsizei width, GLsizei height, GLenum format); |
1591 bool ValidateCompressedTexFuncData( | 1576 bool ValidateCompressedTexFuncData( |
1592 const char* function_name, | 1577 const char* function_name, |
(...skipping 9650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11243 } | 11228 } |
11244 } | 11229 } |
11245 | 11230 |
11246 // Include the auto-generated part of this file. We split this because it means | 11231 // Include the auto-generated part of this file. We split this because it means |
11247 // we can easily edit the non-auto generated parts right here in this file | 11232 // we can easily edit the non-auto generated parts right here in this file |
11248 // instead of having to edit some template or the code generator. | 11233 // instead of having to edit some template or the code generator. |
11249 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11234 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11250 | 11235 |
11251 } // namespace gles2 | 11236 } // namespace gles2 |
11252 } // namespace gpu | 11237 } // namespace gpu |
OLD | NEW |