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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
6 | 6 |
7 #include "third_party/khronos/GLES2/gl2.h" | 7 #include "third_party/khronos/GLES2/gl2.h" |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
99 | 99 |
100 base::LazyInstance<GLES2Initializer> g_gles2_initializer = | 100 base::LazyInstance<GLES2Initializer> g_gles2_initializer = |
101 LAZY_INSTANCE_INITIALIZER; | 101 LAZY_INSTANCE_INITIALIZER; |
102 | 102 |
103 //////////////////////////////////////////////////////////////////////////////// | 103 //////////////////////////////////////////////////////////////////////////////// |
104 | 104 |
105 } // namespace anonymous | 105 } // namespace anonymous |
106 | 106 |
| 107 // Helper macros to reduce the amount of code. |
| 108 |
| 109 #define DELEGATE_TO_GL(name, glname) \ |
| 110 void WebGraphicsContext3DCommandBufferImpl::name() { \ |
| 111 gl_->glname(); \ |
| 112 } |
| 113 |
| 114 #define DELEGATE_TO_GL_R(name, glname, rt) \ |
| 115 rt WebGraphicsContext3DCommandBufferImpl::name() { \ |
| 116 return gl_->glname(); \ |
| 117 } |
| 118 |
| 119 #define DELEGATE_TO_GL_1(name, glname, t1) \ |
| 120 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ |
| 121 gl_->glname(a1); \ |
| 122 } |
| 123 |
| 124 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \ |
| 125 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ |
| 126 return gl_->glname(a1); \ |
| 127 } |
| 128 |
| 129 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \ |
| 130 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ |
| 131 return gl_->glname(a1) ? true : false; \ |
| 132 } |
| 133 |
| 134 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \ |
| 135 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \ |
| 136 gl_->glname(a1, a2); \ |
| 137 } |
| 138 |
| 139 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \ |
| 140 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \ |
| 141 return gl_->glname(a1, a2); \ |
| 142 } |
| 143 |
| 144 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \ |
| 145 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3) { \ |
| 146 gl_->glname(a1, a2, a3); \ |
| 147 } |
| 148 |
| 149 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \ |
| 150 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 151 t4 a4) { \ |
| 152 gl_->glname(a1, a2, a3, a4); \ |
| 153 } |
| 154 |
| 155 #define DELEGATE_TO_GL_4R(name, glname, t1, t2, t3, t4, rt) \ |
| 156 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 157 t4 a4) { \ |
| 158 return gl_->glname(a1, a2, a3, a4); \ |
| 159 } |
| 160 |
| 161 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \ |
| 162 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 163 t4 a4, t5 a5) { \ |
| 164 gl_->glname(a1, a2, a3, a4, a5); \ |
| 165 } |
| 166 |
| 167 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \ |
| 168 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 169 t4 a4, t5 a5, t6 a6) { \ |
| 170 gl_->glname(a1, a2, a3, a4, a5, a6); \ |
| 171 } |
| 172 |
| 173 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \ |
| 174 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 175 t4 a4, t5 a5, t6 a6, \ |
| 176 t7 a7) { \ |
| 177 gl_->glname(a1, a2, a3, a4, a5, a6, a7); \ |
| 178 } |
| 179 |
| 180 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \ |
| 181 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 182 t4 a4, t5 a5, t6 a6, \ |
| 183 t7 a7, t8 a8) { \ |
| 184 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \ |
| 185 } |
| 186 |
| 187 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ |
| 188 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ |
| 189 t4 a4, t5 a5, t6 a6, \ |
| 190 t7 a7, t8 a8, t9 a9) { \ |
| 191 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ |
| 192 } |
| 193 |
107 class WebGraphicsContext3DErrorMessageCallback | 194 class WebGraphicsContext3DErrorMessageCallback |
108 : public gpu::gles2::GLES2Implementation::ErrorMessageCallback { | 195 : public gpu::gles2::GLES2Implementation::ErrorMessageCallback { |
109 public: | 196 public: |
110 WebGraphicsContext3DErrorMessageCallback( | 197 WebGraphicsContext3DErrorMessageCallback( |
111 WebGraphicsContext3DCommandBufferImpl* context) | 198 WebGraphicsContext3DCommandBufferImpl* context) |
112 : graphics_context_(context) { | 199 : graphics_context_(context) { |
113 } | 200 } |
114 | 201 |
115 virtual void OnErrorMessage(const char* msg, int id) OVERRIDE; | 202 virtual void OnErrorMessage(const char* msg, int id) OVERRIDE; |
116 | 203 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 484 } |
398 | 485 |
399 int WebGraphicsContext3DCommandBufferImpl::width() { | 486 int WebGraphicsContext3DCommandBufferImpl::width() { |
400 return cached_width_; | 487 return cached_width_; |
401 } | 488 } |
402 | 489 |
403 int WebGraphicsContext3DCommandBufferImpl::height() { | 490 int WebGraphicsContext3DCommandBufferImpl::height() { |
404 return cached_height_; | 491 return cached_height_; |
405 } | 492 } |
406 | 493 |
407 unsigned int WebGraphicsContext3DCommandBufferImpl::insertSyncPoint() { | 494 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int) |
408 return gl_->InsertSyncPointCHROMIUM(); | |
409 } | |
410 | 495 |
411 void WebGraphicsContext3DCommandBufferImpl::Destroy() { | 496 void WebGraphicsContext3DCommandBufferImpl::Destroy() { |
412 if (gl_) { | 497 if (gl_) { |
413 // First flush the context to ensure that any pending frees of resources | 498 // First flush the context to ensure that any pending frees of resources |
414 // are completed. Otherwise, if this context is part of a share group, | 499 // are completed. Otherwise, if this context is part of a share group, |
415 // those resources might leak. Also, any remaining side effects of commands | 500 // those resources might leak. Also, any remaining side effects of commands |
416 // issued on this context might not be visible to other contexts in the | 501 // issued on this context might not be visible to other contexts in the |
417 // share group. | 502 // share group. |
418 gl_->Flush(); | 503 gl_->Flush(); |
419 gl_ = NULL; | 504 gl_ = NULL; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 668 } |
584 | 669 |
585 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( | 670 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( |
586 WGC3Denum error) { | 671 WGC3Denum error) { |
587 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == | 672 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == |
588 synthetic_errors_.end()) { | 673 synthetic_errors_.end()) { |
589 synthetic_errors_.push_back(error); | 674 synthetic_errors_.push_back(error); |
590 } | 675 } |
591 } | 676 } |
592 | 677 |
593 void* WebGraphicsContext3DCommandBufferImpl::mapBufferSubDataCHROMIUM( | 678 DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM, MapBufferSubDataCHROMIUM, WGC3Denum, |
594 WGC3Denum target, | 679 WGC3Dintptr, WGC3Dsizeiptr, WGC3Denum, void*) |
595 WGC3Dintptr offset, | |
596 WGC3Dsizeiptr size, | |
597 WGC3Denum access) { | |
598 return gl_->MapBufferSubDataCHROMIUM(target, offset, size, access); | |
599 } | |
600 | 680 |
601 void WebGraphicsContext3DCommandBufferImpl::unmapBufferSubDataCHROMIUM( | 681 DELEGATE_TO_GL_1(unmapBufferSubDataCHROMIUM, UnmapBufferSubDataCHROMIUM, |
602 const void* mem) { | 682 const void*) |
603 return gl_->UnmapBufferSubDataCHROMIUM(mem); | |
604 } | |
605 | 683 |
606 void* WebGraphicsContext3DCommandBufferImpl::mapTexSubImage2DCHROMIUM( | 684 void* WebGraphicsContext3DCommandBufferImpl::mapTexSubImage2DCHROMIUM( |
607 WGC3Denum target, | 685 WGC3Denum target, |
608 WGC3Dint level, | 686 WGC3Dint level, |
609 WGC3Dint xoffset, | 687 WGC3Dint xoffset, |
610 WGC3Dint yoffset, | 688 WGC3Dint yoffset, |
611 WGC3Dsizei width, | 689 WGC3Dsizei width, |
612 WGC3Dsizei height, | 690 WGC3Dsizei height, |
613 WGC3Denum format, | 691 WGC3Denum format, |
614 WGC3Denum type, | 692 WGC3Denum type, |
615 WGC3Denum access) { | 693 WGC3Denum access) { |
616 return gl_->MapTexSubImage2DCHROMIUM( | 694 return gl_->MapTexSubImage2DCHROMIUM( |
617 target, level, xoffset, yoffset, width, height, format, type, access); | 695 target, level, xoffset, yoffset, width, height, format, type, access); |
618 } | 696 } |
619 | 697 |
620 void WebGraphicsContext3DCommandBufferImpl::unmapTexSubImage2DCHROMIUM( | 698 DELEGATE_TO_GL_1(unmapTexSubImage2DCHROMIUM, UnmapTexSubImage2DCHROMIUM, |
621 const void* mem) { | 699 const void*) |
622 gl_->UnmapTexSubImage2DCHROMIUM(mem); | |
623 } | |
624 | 700 |
625 void WebGraphicsContext3DCommandBufferImpl::setVisibilityCHROMIUM( | 701 void WebGraphicsContext3DCommandBufferImpl::setVisibilityCHROMIUM( |
626 bool visible) { | 702 bool visible) { |
627 gl_->Flush(); | 703 gl_->Flush(); |
628 visible_ = visible; | 704 visible_ = visible; |
629 command_buffer_->SetSurfaceVisible(visible); | 705 command_buffer_->SetSurfaceVisible(visible); |
630 if (!visible) | 706 if (!visible) |
631 real_gl_->FreeEverything(); | 707 real_gl_->FreeEverything(); |
632 } | 708 } |
633 | 709 |
634 void WebGraphicsContext3DCommandBufferImpl::discardFramebufferEXT( | 710 DELEGATE_TO_GL_3(discardFramebufferEXT, DiscardFramebufferEXT, WGC3Denum, |
635 WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { | 711 WGC3Dsizei, const WGC3Denum*) |
636 gl_->DiscardFramebufferEXT(target, numAttachments, attachments); | |
637 } | |
638 | 712 |
639 void WebGraphicsContext3DCommandBufferImpl::discardBackbufferCHROMIUM() { | 713 void WebGraphicsContext3DCommandBufferImpl::discardBackbufferCHROMIUM() { |
640 gl_->Flush(); | 714 gl_->Flush(); |
641 command_buffer_->DiscardBackbuffer(); | 715 command_buffer_->DiscardBackbuffer(); |
642 } | 716 } |
643 | 717 |
644 void WebGraphicsContext3DCommandBufferImpl::ensureBackbufferCHROMIUM() { | 718 void WebGraphicsContext3DCommandBufferImpl::ensureBackbufferCHROMIUM() { |
645 gl_->Flush(); | 719 gl_->Flush(); |
646 command_buffer_->EnsureBackbuffer(); | 720 command_buffer_->EnsureBackbuffer(); |
647 } | 721 } |
(...skipping 24 matching lines...) Expand all Loading... |
672 command_buffer_->SetMemoryAllocationChangedCallback( | 746 command_buffer_->SetMemoryAllocationChangedCallback( |
673 base::Callback<void(const GpuMemoryAllocationForRenderer&)>()); | 747 base::Callback<void(const GpuMemoryAllocationForRenderer&)>()); |
674 } | 748 } |
675 | 749 |
676 | 750 |
677 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( | 751 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( |
678 WebGLId texture, WebGLId parentTexture) { | 752 WebGLId texture, WebGLId parentTexture) { |
679 NOTIMPLEMENTED(); | 753 NOTIMPLEMENTED(); |
680 } | 754 } |
681 | 755 |
682 void WebGraphicsContext3DCommandBufferImpl:: | 756 DELEGATE_TO_GL(rateLimitOffscreenContextCHROMIUM, |
683 rateLimitOffscreenContextCHROMIUM() { | 757 RateLimitOffscreenContextCHROMIUM) |
684 gl_->RateLimitOffscreenContextCHROMIUM(); | |
685 } | |
686 | 758 |
687 WebKit::WebString WebGraphicsContext3DCommandBufferImpl:: | 759 WebKit::WebString WebGraphicsContext3DCommandBufferImpl:: |
688 getRequestableExtensionsCHROMIUM() { | 760 getRequestableExtensionsCHROMIUM() { |
689 return WebKit::WebString::fromUTF8( | 761 return WebKit::WebString::fromUTF8( |
690 gl_->GetRequestableExtensionsCHROMIUM()); | 762 gl_->GetRequestableExtensionsCHROMIUM()); |
691 } | 763 } |
692 | 764 |
693 void WebGraphicsContext3DCommandBufferImpl::requestExtensionCHROMIUM( | 765 DELEGATE_TO_GL_1(requestExtensionCHROMIUM, RequestExtensionCHROMIUM, |
694 const char* extension) { | 766 const char*) |
695 gl_->RequestExtensionCHROMIUM(extension); | |
696 } | |
697 | 767 |
698 void WebGraphicsContext3DCommandBufferImpl::blitFramebufferCHROMIUM( | 768 void WebGraphicsContext3DCommandBufferImpl::blitFramebufferCHROMIUM( |
699 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, | 769 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, |
700 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, | 770 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, |
701 WGC3Dbitfield mask, WGC3Denum filter) { | 771 WGC3Dbitfield mask, WGC3Denum filter) { |
702 gl_->BlitFramebufferEXT( | 772 gl_->BlitFramebufferEXT( |
703 srcX0, srcY0, srcX1, srcY1, | 773 srcX0, srcY0, srcX1, srcY1, |
704 dstX0, dstY0, dstX1, dstY1, | 774 dstX0, dstY0, dstX1, dstY1, |
705 mask, filter); | 775 mask, filter); |
706 } | 776 } |
707 | 777 |
708 void WebGraphicsContext3DCommandBufferImpl:: | 778 DELEGATE_TO_GL_5(renderbufferStorageMultisampleCHROMIUM, |
709 renderbufferStorageMultisampleCHROMIUM( | 779 RenderbufferStorageMultisampleEXT, WGC3Denum, WGC3Dsizei, |
710 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, | 780 WGC3Denum, WGC3Dsizei, WGC3Dsizei) |
711 WGC3Dsizei width, WGC3Dsizei height) { | |
712 gl_->RenderbufferStorageMultisampleEXT( | |
713 target, samples, internalformat, width, height); | |
714 } | |
715 | 781 |
716 WebGLId WebGraphicsContext3DCommandBufferImpl::createStreamTextureCHROMIUM( | 782 DELEGATE_TO_GL_1R(createStreamTextureCHROMIUM, CreateStreamTextureCHROMIUM, |
717 WebGLId texture) { | 783 WebGLId, WebGLId) |
718 return gl_->CreateStreamTextureCHROMIUM(texture); | |
719 } | |
720 | 784 |
721 void WebGraphicsContext3DCommandBufferImpl::destroyStreamTextureCHROMIUM( | 785 DELEGATE_TO_GL_1(destroyStreamTextureCHROMIUM, DestroyStreamTextureCHROMIUM, |
722 WebGLId texture) { | 786 WebGLId) |
723 gl_->DestroyStreamTextureCHROMIUM(texture); | |
724 } | |
725 | |
726 // Helper macros to reduce the amount of code. | |
727 | |
728 #define DELEGATE_TO_GL(name, glname) \ | |
729 void WebGraphicsContext3DCommandBufferImpl::name() { \ | |
730 gl_->glname(); \ | |
731 } | |
732 | |
733 #define DELEGATE_TO_GL_1(name, glname, t1) \ | |
734 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ | |
735 gl_->glname(a1); \ | |
736 } | |
737 | |
738 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \ | |
739 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ | |
740 return gl_->glname(a1); \ | |
741 } | |
742 | |
743 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \ | |
744 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ | |
745 return gl_->glname(a1) ? true : false; \ | |
746 } | |
747 | |
748 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \ | |
749 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \ | |
750 gl_->glname(a1, a2); \ | |
751 } | |
752 | |
753 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \ | |
754 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \ | |
755 return gl_->glname(a1, a2); \ | |
756 } | |
757 | |
758 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \ | |
759 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3) { \ | |
760 gl_->glname(a1, a2, a3); \ | |
761 } | |
762 | |
763 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \ | |
764 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \ | |
765 gl_->glname(a1, a2, a3, a4); \ | |
766 } | |
767 | |
768 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \ | |
769 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ | |
770 t4 a4, t5 a5) { \ | |
771 gl_->glname(a1, a2, a3, a4, a5); \ | |
772 } | |
773 | |
774 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \ | |
775 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ | |
776 t4 a4, t5 a5, t6 a6) { \ | |
777 gl_->glname(a1, a2, a3, a4, a5, a6); \ | |
778 } | |
779 | |
780 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \ | |
781 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ | |
782 t4 a4, t5 a5, t6 a6, t7 a7) { \ | |
783 gl_->glname(a1, a2, a3, a4, a5, a6, a7); \ | |
784 } | |
785 | |
786 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \ | |
787 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ | |
788 t4 a4, t5 a5, t6 a6, \ | |
789 t7 a7, t8 a8) { \ | |
790 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \ | |
791 } | |
792 | |
793 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ | |
794 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ | |
795 t4 a4, t5 a5, t6 a6, \ | |
796 t7 a7, t8 a8, t9 a9) { \ | |
797 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ | |
798 } | |
799 | 787 |
800 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum) | 788 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum) |
801 | 789 |
802 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId) | 790 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId) |
803 | 791 |
804 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId, | 792 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId, |
805 WGC3Duint, const WGC3Dchar*) | 793 WGC3Duint, const WGC3Dchar*) |
806 | 794 |
807 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId) | 795 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId) |
808 | 796 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 gl_->GenBuffers(1, &o); | 1304 gl_->GenBuffers(1, &o); |
1317 return o; | 1305 return o; |
1318 } | 1306 } |
1319 | 1307 |
1320 WebGLId WebGraphicsContext3DCommandBufferImpl::createFramebuffer() { | 1308 WebGLId WebGraphicsContext3DCommandBufferImpl::createFramebuffer() { |
1321 GLuint o = 0; | 1309 GLuint o = 0; |
1322 gl_->GenFramebuffers(1, &o); | 1310 gl_->GenFramebuffers(1, &o); |
1323 return o; | 1311 return o; |
1324 } | 1312 } |
1325 | 1313 |
1326 WebGLId WebGraphicsContext3DCommandBufferImpl::createProgram() { | 1314 DELEGATE_TO_GL_R(createProgram, CreateProgram, WebGLId) |
1327 return gl_->CreateProgram(); | |
1328 } | |
1329 | 1315 |
1330 WebGLId WebGraphicsContext3DCommandBufferImpl::createRenderbuffer() { | 1316 WebGLId WebGraphicsContext3DCommandBufferImpl::createRenderbuffer() { |
1331 GLuint o; | 1317 GLuint o; |
1332 gl_->GenRenderbuffers(1, &o); | 1318 gl_->GenRenderbuffers(1, &o); |
1333 return o; | 1319 return o; |
1334 } | 1320 } |
1335 | 1321 |
1336 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId); | 1322 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId) |
1337 | 1323 |
1338 WebGLId WebGraphicsContext3DCommandBufferImpl::createTexture() { | 1324 WebGLId WebGraphicsContext3DCommandBufferImpl::createTexture() { |
1339 GLuint o; | 1325 GLuint o; |
1340 gl_->GenTextures(1, &o); | 1326 gl_->GenTextures(1, &o); |
1341 return o; | 1327 return o; |
1342 } | 1328 } |
1343 | 1329 |
1344 void WebGraphicsContext3DCommandBufferImpl::deleteBuffer(WebGLId buffer) { | 1330 void WebGraphicsContext3DCommandBufferImpl::deleteBuffer(WebGLId buffer) { |
1345 gl_->DeleteBuffers(1, &buffer); | 1331 gl_->DeleteBuffers(1, &buffer); |
1346 } | 1332 } |
1347 | 1333 |
1348 void WebGraphicsContext3DCommandBufferImpl::deleteFramebuffer( | 1334 void WebGraphicsContext3DCommandBufferImpl::deleteFramebuffer( |
1349 WebGLId framebuffer) { | 1335 WebGLId framebuffer) { |
1350 gl_->DeleteFramebuffers(1, &framebuffer); | 1336 gl_->DeleteFramebuffers(1, &framebuffer); |
1351 } | 1337 } |
1352 | 1338 |
1353 void WebGraphicsContext3DCommandBufferImpl::deleteProgram(WebGLId program) { | 1339 DELEGATE_TO_GL_1(deleteProgram, DeleteProgram, WebGLId) |
1354 gl_->DeleteProgram(program); | |
1355 } | |
1356 | 1340 |
1357 void WebGraphicsContext3DCommandBufferImpl::deleteRenderbuffer( | 1341 void WebGraphicsContext3DCommandBufferImpl::deleteRenderbuffer( |
1358 WebGLId renderbuffer) { | 1342 WebGLId renderbuffer) { |
1359 gl_->DeleteRenderbuffers(1, &renderbuffer); | 1343 gl_->DeleteRenderbuffers(1, &renderbuffer); |
1360 } | 1344 } |
1361 | 1345 |
1362 void WebGraphicsContext3DCommandBufferImpl::deleteShader(WebGLId shader) { | 1346 DELEGATE_TO_GL_1(deleteShader, DeleteShader, WebGLId) |
1363 gl_->DeleteShader(shader); | |
1364 } | |
1365 | 1347 |
1366 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { | 1348 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { |
1367 gl_->DeleteTextures(1, &texture); | 1349 gl_->DeleteTextures(1, &texture); |
1368 } | 1350 } |
1369 | 1351 |
1370 bool WebGraphicsContext3DCommandBufferImpl::ShouldUseSwapClient() { | 1352 bool WebGraphicsContext3DCommandBufferImpl::ShouldUseSwapClient() { |
1371 return factory_ && factory_->IsMainThread() && swap_client_.get(); | 1353 return factory_ && factory_->IsMainThread() && swap_client_.get(); |
1372 } | 1354 } |
1373 | 1355 |
1374 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { | 1356 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 } | 1560 } |
1579 | 1561 |
1580 DELEGATE_TO_GL_1R(isVertexArrayOES, IsVertexArrayOES, WebGLId, WGC3Dboolean) | 1562 DELEGATE_TO_GL_1R(isVertexArrayOES, IsVertexArrayOES, WebGLId, WGC3Dboolean) |
1581 DELEGATE_TO_GL_1(bindVertexArrayOES, BindVertexArrayOES, WebGLId) | 1563 DELEGATE_TO_GL_1(bindVertexArrayOES, BindVertexArrayOES, WebGLId) |
1582 | 1564 |
1583 DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM, | 1565 DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM, |
1584 WGC3Denum, WGC3Dint) | 1566 WGC3Denum, WGC3Dint) |
1585 DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM, | 1567 DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM, |
1586 WGC3Denum, WGC3Dint) | 1568 WGC3Denum, WGC3Dint) |
1587 | 1569 |
1588 void* WebGraphicsContext3DCommandBufferImpl::mapBufferCHROMIUM( | 1570 DELEGATE_TO_GL_2R(mapBufferCHROMIUM, MapBufferCHROMIUM, WGC3Denum, WGC3Denum, |
1589 WGC3Denum target, WGC3Denum access) { | 1571 void*) |
1590 return gl_->MapBufferCHROMIUM(target, access); | 1572 DELEGATE_TO_GL_1R(unmapBufferCHROMIUM, UnmapBufferCHROMIUM, WGC3Denum, |
1591 } | 1573 WGC3Dboolean) |
1592 | 1574 |
1593 WGC3Dboolean WebGraphicsContext3DCommandBufferImpl::unmapBufferCHROMIUM( | 1575 DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM, WGC3Denum, |
1594 WGC3Denum target) { | 1576 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint, |
1595 return gl_->UnmapBufferCHROMIUM(target); | 1577 WGC3Denum, WGC3Denum, const void*) |
1596 } | 1578 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM, |
| 1579 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 1580 WGC3Dsizei, WGC3Denum, WGC3Denum, const void*) |
1597 | 1581 |
1598 void WebGraphicsContext3DCommandBufferImpl::asyncTexImage2DCHROMIUM( | 1582 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, |
1599 WGC3Denum target, | 1583 WGC3Denum) |
1600 WGC3Dint level, | |
1601 WGC3Denum internalformat, | |
1602 WGC3Dsizei width, | |
1603 WGC3Dsizei height, | |
1604 WGC3Dint border, | |
1605 WGC3Denum format, | |
1606 WGC3Denum type, | |
1607 const void* pixels) { | |
1608 return gl_->AsyncTexImage2DCHROMIUM( | |
1609 target, level, internalformat, | |
1610 width, height, border, format, type, pixels); | |
1611 } | |
1612 | 1584 |
1613 void WebGraphicsContext3DCommandBufferImpl::asyncTexSubImage2DCHROMIUM( | 1585 DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, WGC3Dsizei, const WGC3Denum*) |
1614 WGC3Denum target, | |
1615 WGC3Dint level, | |
1616 WGC3Dint xoffset, | |
1617 WGC3Dint yoffset, | |
1618 WGC3Dsizei width, | |
1619 WGC3Dsizei height, | |
1620 WGC3Denum format, | |
1621 WGC3Denum type, | |
1622 const void *pixels) { | |
1623 return gl_->AsyncTexSubImage2DCHROMIUM( | |
1624 target, level, xoffset, yoffset, | |
1625 width, height, format, type, pixels); | |
1626 } | |
1627 | |
1628 void WebGraphicsContext3DCommandBufferImpl::waitAsyncTexImage2DCHROMIUM( | |
1629 WGC3Denum target) { | |
1630 return gl_->WaitAsyncTexImage2DCHROMIUM(target); | |
1631 } | |
1632 | |
1633 void WebGraphicsContext3DCommandBufferImpl::drawBuffersEXT( | |
1634 WGC3Dsizei n, | |
1635 const WGC3Denum* bufs) { | |
1636 gl_->DrawBuffersEXT(n, bufs); | |
1637 } | |
1638 | 1586 |
1639 GrGLInterface* WebGraphicsContext3DCommandBufferImpl::onCreateGrGLInterface() { | 1587 GrGLInterface* WebGraphicsContext3DCommandBufferImpl::onCreateGrGLInterface() { |
1640 return webkit::gpu::CreateCommandBufferSkiaGLBinding(); | 1588 return webkit::gpu::CreateCommandBufferSkiaGLBinding(); |
1641 } | 1589 } |
1642 | 1590 |
1643 namespace { | 1591 namespace { |
1644 | 1592 |
1645 WGC3Denum convertReason(gpu::error::ContextLostReason reason) { | 1593 WGC3Denum convertReason(gpu::error::ContextLostReason reason) { |
1646 switch (reason) { | 1594 switch (reason) { |
1647 case gpu::error::kGuilty: | 1595 case gpu::error::kGuilty: |
(...skipping 24 matching lines...) Expand all Loading... |
1672 | 1620 |
1673 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1621 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1674 const std::string& message, int id) { | 1622 const std::string& message, int id) { |
1675 if (error_message_callback_) { | 1623 if (error_message_callback_) { |
1676 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1624 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
1677 error_message_callback_->onErrorMessage(str, id); | 1625 error_message_callback_->onErrorMessage(str, id); |
1678 } | 1626 } |
1679 } | 1627 } |
1680 | 1628 |
1681 } // namespace content | 1629 } // namespace content |
OLD | NEW |