OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 return nullptr; | 188 return nullptr; |
189 } | 189 } |
190 | 190 |
191 static bool gPrintStartupSpew; | 191 static bool gPrintStartupSpew; |
192 | 192 |
193 GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) | 193 GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) |
194 : GrGpu(context) | 194 : GrGpu(context) |
195 , fGLContext(ctx) { | 195 , fGLContext(ctx) { |
196 SkASSERT(ctx); | 196 SkASSERT(ctx); |
197 fCaps.reset(SkRef(ctx->caps())); | 197 fCaps.reset(SkRef(ctx->caps())); |
198 this->generateConfigTable(); | |
198 | 199 |
199 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); | 200 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); |
200 | 201 |
201 GrGLClearErr(this->glInterface()); | 202 GrGLClearErr(this->glInterface()); |
202 if (gPrintStartupSpew) { | 203 if (gPrintStartupSpew) { |
203 const GrGLubyte* vendor; | 204 const GrGLubyte* vendor; |
204 const GrGLubyte* renderer; | 205 const GrGLubyte* renderer; |
205 const GrGLubyte* version; | 206 const GrGLubyte* version; |
206 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); | 207 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); |
207 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); | 208 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); |
(...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2676 case GrPipelineBuilder::kBoth_DrawFace: | 2677 case GrPipelineBuilder::kBoth_DrawFace: |
2677 GL_CALL(Disable(GR_GL_CULL_FACE)); | 2678 GL_CALL(Disable(GR_GL_CULL_FACE)); |
2678 break; | 2679 break; |
2679 default: | 2680 default: |
2680 SkFAIL("Unknown draw face."); | 2681 SkFAIL("Unknown draw face."); |
2681 } | 2682 } |
2682 fHWDrawFace = face; | 2683 fHWDrawFace = face; |
2683 } | 2684 } |
2684 } | 2685 } |
2685 | 2686 |
2687 void GrGLGpu::generateConfigTable() { | |
bsalomon
2015/12/16 19:10:45
This function mirrors the logic of the old configT
| |
2688 fConfigTable[kUnknown_GrPixelConfig].fBaseInternalFormat = 0; | |
2689 fConfigTable[kUnknown_GrPixelConfig].fSizedInternalFormat = 0; | |
2690 fConfigTable[kUnknown_GrPixelConfig].fExternalFormat = 0; | |
2691 fConfigTable[kUnknown_GrPixelConfig].fExternalType = 0; | |
2692 | |
2693 fConfigTable[kRGBA_8888_GrPixelConfig].fBaseInternalFormat = GR_GL_RGBA; | |
2694 fConfigTable[kRGBA_8888_GrPixelConfig].fSizedInternalFormat = GR_GL_RGBA8; | |
2695 fConfigTable[kRGBA_8888_GrPixelConfig].fExternalFormat = GR_GL_RGBA; | |
2696 fConfigTable[kRGBA_8888_GrPixelConfig].fExternalType = GR_GL_UNSIGNED_BYTE; | |
2697 | |
2698 if (this->glCaps().bgraIsInternalFormat()) { | |
2699 fConfigTable[kBGRA_8888_GrPixelConfig].fBaseInternalFormat = GR_GL_BGRA; | |
2700 fConfigTable[kBGRA_8888_GrPixelConfig].fSizedInternalFormat = GR_GL_BGRA 8; | |
2701 } else { | |
2702 fConfigTable[kBGRA_8888_GrPixelConfig].fBaseInternalFormat = GR_GL_RGBA; | |
2703 fConfigTable[kBGRA_8888_GrPixelConfig].fSizedInternalFormat = GR_GL_RGBA 8; | |
2704 } | |
2705 fConfigTable[kBGRA_8888_GrPixelConfig].fExternalFormat= GR_GL_BGRA; | |
2706 fConfigTable[kBGRA_8888_GrPixelConfig].fExternalType = GR_GL_UNSIGNED_BYTE; | |
2707 | |
2708 | |
2709 fConfigTable[kSRGBA_8888_GrPixelConfig].fBaseInternalFormat = GR_GL_SRGB_ALP HA; | |
2710 fConfigTable[kSRGBA_8888_GrPixelConfig].fSizedInternalFormat = GR_GL_SRGB8_A LPHA8; | |
2711 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the < format> | |
2712 // param to Tex(Sub)Image2D. ES 2.0 requires the internalFormat and format t o match. | |
2713 // Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the externalFormat. However, | |
2714 // onReadPixels needs code to override that because GL_SRGB_ALPHA is not all owed as a | |
2715 // glReadPixels format. | |
2716 // On OpenGL and ES 3.0 GL_SRGB_ALPHA does not work for the <format> param t o | |
2717 // glReadPixels nor does it work with Tex(Sub)Image2D So we always set the e xternalFormat | |
2718 // return to GL_RGBA. | |
2719 if (this->glStandard() == kGLES_GrGLStandard && | |
2720 this->glVersion() == GR_GL_VER(2,0)) { | |
2721 fConfigTable[kSRGBA_8888_GrPixelConfig].fExternalFormat = GR_GL_SRGB_ALP HA; | |
2722 } else { | |
2723 fConfigTable[kSRGBA_8888_GrPixelConfig].fExternalFormat = GR_GL_RGBA; | |
2724 } | |
2725 fConfigTable[kSRGBA_8888_GrPixelConfig].fExternalType = GR_GL_UNSIGNED_BYTE; | |
2726 | |
2727 | |
2728 fConfigTable[kRGB_565_GrPixelConfig].fBaseInternalFormat = GR_GL_RGB; | |
2729 if (this->glCaps().ES2CompatibilitySupport()) { | |
2730 fConfigTable[kRGB_565_GrPixelConfig].fSizedInternalFormat = GR_GL_RGB565 ; | |
2731 } else { | |
2732 fConfigTable[kRGB_565_GrPixelConfig].fSizedInternalFormat = GR_GL_RGB5; | |
2733 } | |
2734 fConfigTable[kRGB_565_GrPixelConfig].fExternalFormat = GR_GL_RGB; | |
2735 fConfigTable[kRGB_565_GrPixelConfig].fExternalType = GR_GL_UNSIGNED_SHORT_5_ 6_5; | |
2736 | |
2737 fConfigTable[kRGBA_4444_GrPixelConfig].fBaseInternalFormat = GR_GL_RGBA; | |
2738 fConfigTable[kRGBA_4444_GrPixelConfig].fSizedInternalFormat = GR_GL_RGBA4; | |
2739 fConfigTable[kRGBA_4444_GrPixelConfig].fExternalFormat = GR_GL_RGBA; | |
2740 fConfigTable[kRGBA_4444_GrPixelConfig].fExternalType = GR_GL_UNSIGNED_SHORT_ 4_4_4_4; | |
2741 | |
2742 | |
2743 if (this->glCaps().textureRedSupport()) { | |
2744 fConfigTable[kAlpha_8_GrPixelConfig].fBaseInternalFormat = GR_GL_RED; | |
2745 fConfigTable[kAlpha_8_GrPixelConfig].fSizedInternalFormat = GR_GL_R8; | |
2746 fConfigTable[kAlpha_8_GrPixelConfig].fExternalFormat = GR_GL_RED; | |
2747 } else { | |
2748 fConfigTable[kAlpha_8_GrPixelConfig].fBaseInternalFormat = GR_GL_ALPHA; | |
2749 fConfigTable[kAlpha_8_GrPixelConfig].fSizedInternalFormat = GR_GL_ALPHA8 ; | |
2750 fConfigTable[kAlpha_8_GrPixelConfig].fExternalFormat = GR_GL_ALPHA; | |
2751 } | |
2752 fConfigTable[kAlpha_8_GrPixelConfig].fExternalType = GR_GL_UNSIGNED_BYTE; | |
2753 | |
2754 fConfigTable[kRGBA_float_GrPixelConfig].fBaseInternalFormat = GR_GL_RGBA; | |
2755 fConfigTable[kRGBA_float_GrPixelConfig].fSizedInternalFormat = GR_GL_RGBA32F ; | |
2756 fConfigTable[kRGBA_float_GrPixelConfig].fExternalFormat = GR_GL_RGBA; | |
2757 fConfigTable[kRGBA_float_GrPixelConfig].fExternalType = GR_GL_FLOAT; | |
2758 | |
2759 if (this->glCaps().textureRedSupport()) { | |
2760 fConfigTable[kAlpha_half_GrPixelConfig].fBaseInternalFormat = GR_GL_RED; | |
2761 fConfigTable[kAlpha_half_GrPixelConfig].fSizedInternalFormat = GR_GL_R16 F; | |
2762 fConfigTable[kAlpha_half_GrPixelConfig].fExternalFormat = GR_GL_RED; | |
2763 } else { | |
2764 fConfigTable[kAlpha_half_GrPixelConfig].fBaseInternalFormat = GR_GL_ALPH A; | |
2765 fConfigTable[kAlpha_half_GrPixelConfig].fSizedInternalFormat = GR_GL_ALP HA16F; | |
2766 fConfigTable[kAlpha_half_GrPixelConfig].fExternalFormat = GR_GL_ALPHA; | |
2767 } | |
2768 if (kGL_GrGLStandard == this->glStandard() || this->glVersion() >= GR_GL_VER (3, 0)) { | |
2769 fConfigTable[kAlpha_half_GrPixelConfig].fExternalType = GR_GL_HALF_FLOAT ; | |
2770 } else { | |
2771 fConfigTable[kAlpha_half_GrPixelConfig].fExternalType = GR_GL_HALF_FLOAT _OES; | |
2772 } | |
2773 | |
2774 fConfigTable[kRGBA_half_GrPixelConfig].fBaseInternalFormat = GR_GL_RGBA; | |
2775 fConfigTable[kRGBA_half_GrPixelConfig].fSizedInternalFormat = GR_GL_RGBA16F; | |
2776 fConfigTable[kRGBA_half_GrPixelConfig].fExternalFormat = GR_GL_RGBA; | |
2777 if (kGL_GrGLStandard == this->glStandard() || this->glVersion() >= GR_GL_VER (3, 0)) { | |
2778 fConfigTable[kRGBA_half_GrPixelConfig].fExternalType = GR_GL_HALF_FLOAT; | |
2779 } else { | |
2780 fConfigTable[kRGBA_half_GrPixelConfig].fExternalType = GR_GL_HALF_FLOAT_ OES; | |
2781 } | |
2782 | |
2783 // No sized/unsized internal format distinction for compressed formats, no e xternal format. | |
2784 | |
2785 fConfigTable[kIndex_8_GrPixelConfig].fBaseInternalFormat = GR_GL_PALETTE8_RG BA8; | |
2786 fConfigTable[kIndex_8_GrPixelConfig].fSizedInternalFormat = GR_GL_PALETTE8_R GBA8; | |
2787 fConfigTable[kIndex_8_GrPixelConfig].fExternalFormat = 0; | |
2788 fConfigTable[kIndex_8_GrPixelConfig].fExternalType = 0; | |
2789 | |
2790 switch(this->glCaps().latcAlias()) { | |
2791 case GrGLCaps::kLATC_LATCAlias: | |
2792 fConfigTable[kLATC_GrPixelConfig].fBaseInternalFormat = | |
2793 GR_GL_COMPRESSED_LUMINANCE_LATC1; | |
2794 fConfigTable[kLATC_GrPixelConfig].fSizedInternalFormat = | |
2795 GR_GL_COMPRESSED_LUMINANCE_LATC1; | |
2796 break; | |
2797 case GrGLCaps::kRGTC_LATCAlias: | |
2798 fConfigTable[kLATC_GrPixelConfig].fBaseInternalFormat = GR_GL_COMPRE SSED_RED_RGTC1; | |
2799 fConfigTable[kLATC_GrPixelConfig].fSizedInternalFormat = GR_GL_COMPR ESSED_RED_RGTC1; | |
2800 break; | |
2801 case GrGLCaps::k3DC_LATCAlias: | |
2802 fConfigTable[kLATC_GrPixelConfig].fBaseInternalFormat = GR_GL_COMPRE SSED_3DC_X; | |
2803 fConfigTable[kLATC_GrPixelConfig].fSizedInternalFormat = GR_GL_COMPR ESSED_3DC_X; | |
2804 break; | |
2805 } | |
2806 fConfigTable[kLATC_GrPixelConfig].fExternalFormat = 0; | |
2807 fConfigTable[kLATC_GrPixelConfig].fExternalType = 0; | |
2808 | |
2809 fConfigTable[kETC1_GrPixelConfig].fBaseInternalFormat = GR_GL_COMPRESSED_ETC 1_RGB8; | |
2810 fConfigTable[kETC1_GrPixelConfig].fSizedInternalFormat = GR_GL_COMPRESSED_ET C1_RGB8; | |
2811 fConfigTable[kETC1_GrPixelConfig].fExternalFormat = 0; | |
2812 fConfigTable[kETC1_GrPixelConfig].fExternalType = 0; | |
2813 | |
2814 fConfigTable[kR11_EAC_GrPixelConfig].fBaseInternalFormat = GR_GL_COMPRESSED_ R11_EAC; | |
2815 fConfigTable[kR11_EAC_GrPixelConfig].fSizedInternalFormat = GR_GL_COMPRESSED _R11_EAC; | |
2816 fConfigTable[kR11_EAC_GrPixelConfig].fExternalFormat = 0; | |
2817 fConfigTable[kR11_EAC_GrPixelConfig].fExternalType = 0; | |
2818 | |
2819 fConfigTable[kASTC_12x12_GrPixelConfig].fBaseInternalFormat = GR_GL_COMPRESS ED_RGBA_ASTC_12x12; | |
2820 fConfigTable[kASTC_12x12_GrPixelConfig].fSizedInternalFormat = GR_GL_COMPRES SED_RGBA_ASTC_12x12; | |
2821 fConfigTable[kASTC_12x12_GrPixelConfig].fExternalFormat = 0; | |
2822 fConfigTable[kASTC_12x12_GrPixelConfig].fExternalType = 0; | |
2823 | |
2824 #ifdef SK_DEBUG | |
2825 // Make sure we initialized everything. | |
2826 ConfigEntry defaultEntry; | |
2827 for (int i = 0; i < kLast_GrPixelConfig; ++i) { | |
2828 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fBaseIntern alFormat); | |
2829 SkASSERT(defaultEntry.fSizedInternalFormat != fConfigTable[i].fSizedInte rnalFormat); | |
2830 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fExternalFormat ); | |
2831 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fExternalType); | |
2832 } | |
2833 #endif | |
2834 } | |
2835 | |
2686 bool GrGLGpu::configToGLFormats(GrPixelConfig config, | 2836 bool GrGLGpu::configToGLFormats(GrPixelConfig config, |
2687 bool getSizedInternalFormat, | 2837 bool getSizedInternalFormat, |
2688 GrGLenum* internalFormat, | 2838 GrGLenum* internalFormat, |
2689 GrGLenum* externalFormat, | 2839 GrGLenum* externalFormat, |
2690 GrGLenum* externalType) const { | 2840 GrGLenum* externalType) const { |
2691 GrGLenum dontCare; | |
2692 if (nullptr == internalFormat) { | |
2693 internalFormat = &dontCare; | |
2694 } | |
2695 if (nullptr == externalFormat) { | |
2696 externalFormat = &dontCare; | |
2697 } | |
2698 if (nullptr == externalType) { | |
2699 externalType = &dontCare; | |
2700 } | |
2701 | |
2702 if(!this->glCaps().isConfigTexturable(config)) { | 2841 if(!this->glCaps().isConfigTexturable(config)) { |
2703 return false; | 2842 return false; |
2704 } | 2843 } |
2705 | 2844 |
2706 switch (config) { | 2845 if (nullptr != internalFormat) { |
2707 case kRGBA_8888_GrPixelConfig: | 2846 if (getSizedInternalFormat) { |
2708 *internalFormat = GR_GL_RGBA; | 2847 *internalFormat = fConfigTable[config].fSizedInternalFormat; |
2709 *externalFormat = GR_GL_RGBA; | 2848 } else { |
2710 if (getSizedInternalFormat) { | 2849 *internalFormat = fConfigTable[config].fBaseInternalFormat; |
2711 *internalFormat = GR_GL_RGBA8; | 2850 } |
2712 } else { | 2851 } |
2713 *internalFormat = GR_GL_RGBA; | 2852 if (nullptr != externalFormat) { |
2714 } | 2853 *externalFormat = fConfigTable[config].fExternalFormat; |
2715 *externalType = GR_GL_UNSIGNED_BYTE; | 2854 } |
2716 break; | 2855 if (nullptr != externalType) { |
2717 case kBGRA_8888_GrPixelConfig: | 2856 *externalType = fConfigTable[config].fExternalType; |
2718 if (this->glCaps().bgraIsInternalFormat()) { | 2857 } |
2719 if (getSizedInternalFormat) { | |
2720 *internalFormat = GR_GL_BGRA8; | |
2721 } else { | |
2722 *internalFormat = GR_GL_BGRA; | |
2723 } | |
2724 } else { | |
2725 if (getSizedInternalFormat) { | |
2726 *internalFormat = GR_GL_RGBA8; | |
2727 } else { | |
2728 *internalFormat = GR_GL_RGBA; | |
2729 } | |
2730 } | |
2731 *externalFormat = GR_GL_BGRA; | |
2732 *externalType = GR_GL_UNSIGNED_BYTE; | |
2733 break; | |
2734 case kSRGBA_8888_GrPixelConfig: | |
2735 if (getSizedInternalFormat) { | |
2736 *internalFormat = GR_GL_SRGB8_ALPHA8; | |
2737 } else { | |
2738 *internalFormat = GR_GL_SRGB_ALPHA; | |
2739 } | |
2740 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the <format> | |
2741 // param to Tex(Sub)Image2D. ES 2.0 requires the internalFormat and format to match. | |
2742 // Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the externalFormat. However, | |
2743 // onReadPixels needs code to override that because GL_SRGB_ALPHA is not allowed as a | |
2744 // glReadPixels format. | |
2745 // On OpenGL and ES 3.0 GL_SRGB_ALPHA does not work for the <format> param to | |
2746 // glReadPixels nor does it work with Tex(Sub)Image2D So we always s et the externalFormat | |
2747 // return to GL_RGBA. | |
2748 if (this->glStandard() == kGLES_GrGLStandard && | |
2749 this->glVersion() == GR_GL_VER(2,0)) { | |
2750 *externalFormat = GR_GL_SRGB_ALPHA; | |
2751 } else { | |
2752 *externalFormat = GR_GL_RGBA; | |
2753 } | |
2754 *externalType = GR_GL_UNSIGNED_BYTE; | |
2755 break; | |
2756 case kRGB_565_GrPixelConfig: | |
2757 *internalFormat = GR_GL_RGB; | |
2758 *externalFormat = GR_GL_RGB; | |
2759 if (getSizedInternalFormat) { | |
2760 if (!this->glCaps().ES2CompatibilitySupport()) { | |
2761 *internalFormat = GR_GL_RGB5; | |
2762 } else { | |
2763 *internalFormat = GR_GL_RGB565; | |
2764 } | |
2765 } else { | |
2766 *internalFormat = GR_GL_RGB; | |
2767 } | |
2768 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5; | |
2769 break; | |
2770 case kRGBA_4444_GrPixelConfig: | |
2771 *internalFormat = GR_GL_RGBA; | |
2772 *externalFormat = GR_GL_RGBA; | |
2773 if (getSizedInternalFormat) { | |
2774 *internalFormat = GR_GL_RGBA4; | |
2775 } else { | |
2776 *internalFormat = GR_GL_RGBA; | |
2777 } | |
2778 *externalType = GR_GL_UNSIGNED_SHORT_4_4_4_4; | |
2779 break; | |
2780 case kIndex_8_GrPixelConfig: | |
2781 // no sized/unsized internal format distinction here | |
2782 *internalFormat = GR_GL_PALETTE8_RGBA8; | |
2783 break; | |
2784 case kAlpha_8_GrPixelConfig: | |
2785 if (this->glCaps().textureRedSupport()) { | |
2786 *internalFormat = GR_GL_RED; | |
2787 *externalFormat = GR_GL_RED; | |
2788 if (getSizedInternalFormat) { | |
2789 *internalFormat = GR_GL_R8; | |
2790 } else { | |
2791 *internalFormat = GR_GL_RED; | |
2792 } | |
2793 *externalType = GR_GL_UNSIGNED_BYTE; | |
2794 } else { | |
2795 *internalFormat = GR_GL_ALPHA; | |
2796 *externalFormat = GR_GL_ALPHA; | |
2797 if (getSizedInternalFormat) { | |
2798 *internalFormat = GR_GL_ALPHA8; | |
2799 } else { | |
2800 *internalFormat = GR_GL_ALPHA; | |
2801 } | |
2802 *externalType = GR_GL_UNSIGNED_BYTE; | |
2803 } | |
2804 break; | |
2805 case kETC1_GrPixelConfig: | |
2806 *internalFormat = GR_GL_COMPRESSED_ETC1_RGB8; | |
2807 break; | |
2808 case kLATC_GrPixelConfig: | |
2809 switch(this->glCaps().latcAlias()) { | |
2810 case GrGLCaps::kLATC_LATCAlias: | |
2811 *internalFormat = GR_GL_COMPRESSED_LUMINANCE_LATC1; | |
2812 break; | |
2813 case GrGLCaps::kRGTC_LATCAlias: | |
2814 *internalFormat = GR_GL_COMPRESSED_RED_RGTC1; | |
2815 break; | |
2816 case GrGLCaps::k3DC_LATCAlias: | |
2817 *internalFormat = GR_GL_COMPRESSED_3DC_X; | |
2818 break; | |
2819 } | |
2820 break; | |
2821 case kR11_EAC_GrPixelConfig: | |
2822 *internalFormat = GR_GL_COMPRESSED_R11_EAC; | |
2823 break; | |
2824 | 2858 |
2825 case kASTC_12x12_GrPixelConfig: | |
2826 *internalFormat = GR_GL_COMPRESSED_RGBA_ASTC_12x12_KHR; | |
2827 break; | |
2828 | |
2829 case kRGBA_float_GrPixelConfig: | |
2830 *internalFormat = GR_GL_RGBA32F; | |
2831 *externalFormat = GR_GL_RGBA; | |
2832 *externalType = GR_GL_FLOAT; | |
2833 break; | |
2834 | |
2835 case kAlpha_half_GrPixelConfig: | |
2836 if (this->glCaps().textureRedSupport()) { | |
2837 if (getSizedInternalFormat) { | |
2838 *internalFormat = GR_GL_R16F; | |
2839 } else { | |
2840 *internalFormat = GR_GL_RED; | |
2841 } | |
2842 *externalFormat = GR_GL_RED; | |
2843 } else { | |
2844 if (getSizedInternalFormat) { | |
2845 *internalFormat = GR_GL_ALPHA16F; | |
2846 } else { | |
2847 *internalFormat = GR_GL_ALPHA; | |
2848 } | |
2849 *externalFormat = GR_GL_ALPHA; | |
2850 } | |
2851 if (kGL_GrGLStandard == this->glStandard() || this->glVersion() >= G R_GL_VER(3, 0)) { | |
2852 *externalType = GR_GL_HALF_FLOAT; | |
2853 } else { | |
2854 *externalType = GR_GL_HALF_FLOAT_OES; | |
2855 } | |
2856 break; | |
2857 | |
2858 case kRGBA_half_GrPixelConfig: | |
2859 *internalFormat = GR_GL_RGBA16F; | |
2860 *externalFormat = GR_GL_RGBA; | |
2861 if (kGL_GrGLStandard == this->glStandard() || this->glVersion() >= G R_GL_VER(3, 0)) { | |
2862 *externalType = GR_GL_HALF_FLOAT; | |
2863 } else { | |
2864 *externalType = GR_GL_HALF_FLOAT_OES; | |
2865 } | |
2866 break; | |
2867 | |
2868 default: | |
2869 return false; | |
2870 } | |
2871 return true; | 2859 return true; |
2872 } | 2860 } |
2873 | 2861 |
2874 void GrGLGpu::setTextureUnit(int unit) { | 2862 void GrGLGpu::setTextureUnit(int unit) { |
2875 SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count()); | 2863 SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count()); |
2876 if (unit != fHWActiveTextureUnitIdx) { | 2864 if (unit != fHWActiveTextureUnitIdx) { |
2877 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); | 2865 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); |
2878 fHWActiveTextureUnitIdx = unit; | 2866 fHWActiveTextureUnitIdx = unit; |
2879 } | 2867 } |
2880 } | 2868 } |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3667 this->setVertexArrayID(gpu, 0); | 3655 this->setVertexArrayID(gpu, 0); |
3668 } | 3656 } |
3669 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3657 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3670 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3658 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3671 fDefaultVertexArrayAttribState.resize(attrCount); | 3659 fDefaultVertexArrayAttribState.resize(attrCount); |
3672 } | 3660 } |
3673 attribState = &fDefaultVertexArrayAttribState; | 3661 attribState = &fDefaultVertexArrayAttribState; |
3674 } | 3662 } |
3675 return attribState; | 3663 return attribState; |
3676 } | 3664 } |
OLD | NEW |