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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 // By default, GrRenderTargets are GL's normal orientation so that they | 406 // By default, GrRenderTargets are GL's normal orientation so that they |
407 // can be drawn to by the outside world without the client having | 407 // can be drawn to by the outside world without the client having |
408 // to render upside down. | 408 // to render upside down. |
409 if (kDefault_GrSurfaceOrigin == origin) { | 409 if (kDefault_GrSurfaceOrigin == origin) { |
410 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; | 410 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; |
411 } else { | 411 } else { |
412 return origin; | 412 return origin; |
413 } | 413 } |
414 } | 414 } |
415 | 415 |
416 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, | 416 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, |
bsalomon
2015/12/18 01:24:20
Base class checks that config is texturable.
| |
417 GrWrapOwnership ownership) { | 417 GrWrapOwnership ownership) { |
418 if (!this->configToGLFormats(desc.fConfig, false, nullptr, nullptr, nullptr) ) { | |
419 return nullptr; | |
420 } | |
421 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 418 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
422 if (!desc.fTextureHandle) { | 419 if (!desc.fTextureHandle) { |
423 return nullptr; | 420 return nullptr; |
424 } | 421 } |
425 #else | 422 #else |
426 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); | 423 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); |
427 if (!info || !info->fID) { | 424 if (!info || !info->fID) { |
428 return nullptr; | 425 return nullptr; |
429 } | 426 } |
430 #endif | 427 #endif |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 // TODO: This function is using a lot of wonky semantics like, if width == -1 | 790 // TODO: This function is using a lot of wonky semantics like, if width == -1 |
794 // then set width = desc.fWdith ... blah. A better way to do it might be to | 791 // then set width = desc.fWdith ... blah. A better way to do it might be to |
795 // create a CompressedTexData struct that takes a desc/ptr and figures out | 792 // create a CompressedTexData struct that takes a desc/ptr and figures out |
796 // the proper upload semantics. Then users can construct this function how they | 793 // the proper upload semantics. Then users can construct this function how they |
797 // see fit if they want to go against the "standard" way to do it. | 794 // see fit if they want to go against the "standard" way to do it. |
798 bool GrGLGpu::uploadCompressedTexData(const GrSurfaceDesc& desc, | 795 bool GrGLGpu::uploadCompressedTexData(const GrSurfaceDesc& desc, |
799 GrGLenum target, | 796 GrGLenum target, |
800 const void* data, | 797 const void* data, |
801 bool isNewTexture, | 798 bool isNewTexture, |
802 int left, int top, int width, int height) { | 799 int left, int top, int width, int height) { |
800 SkASSERT(this->caps()->isConfigTexturable(desc.fConfig)); | |
803 SkASSERT(data || isNewTexture); | 801 SkASSERT(data || isNewTexture); |
804 | 802 |
805 // No support for software flip y, yet... | 803 // No support for software flip y, yet... |
806 SkASSERT(kBottomLeft_GrSurfaceOrigin != desc.fOrigin); | 804 SkASSERT(kBottomLeft_GrSurfaceOrigin != desc.fOrigin); |
807 | 805 |
808 if (-1 == width) { | 806 if (-1 == width) { |
809 width = desc.fWidth; | 807 width = desc.fWidth; |
810 } | 808 } |
811 #ifdef SK_DEBUG | 809 #ifdef SK_DEBUG |
812 else { | 810 else { |
813 SkASSERT(width <= desc.fWidth); | 811 SkASSERT(width <= desc.fWidth); |
814 } | 812 } |
815 #endif | 813 #endif |
816 | 814 |
817 if (-1 == height) { | 815 if (-1 == height) { |
818 height = desc.fHeight; | 816 height = desc.fHeight; |
819 } | 817 } |
820 #ifdef SK_DEBUG | 818 #ifdef SK_DEBUG |
821 else { | 819 else { |
822 SkASSERT(height <= desc.fHeight); | 820 SkASSERT(height <= desc.fHeight); |
823 } | 821 } |
824 #endif | 822 #endif |
825 | 823 |
826 // Make sure that the width and height that we pass to OpenGL | 824 // Make sure that the width and height that we pass to OpenGL |
827 // is a multiple of the block size. | 825 // is a multiple of the block size. |
828 size_t dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height); | 826 size_t dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height); |
829 | 827 |
830 // We only need the internal format for compressed 2D textures. | 828 // We only need the internal format for compressed 2D textures. There is on |
831 GrGLenum internalFormat = 0; | 829 // sized vs base internal format distinction for compressed textures. |
832 if (!this->configToGLFormats(desc.fConfig, false, &internalFormat, nullptr, nullptr)) { | 830 GrGLenum internalFormat = fConfigTable[desc.fConfig].fSizedInternalFormat; |
833 return false; | |
834 } | |
835 | 831 |
836 if (isNewTexture) { | 832 if (isNewTexture) { |
837 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); | 833 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
838 GL_ALLOC_CALL(this->glInterface(), | 834 GL_ALLOC_CALL(this->glInterface(), |
839 CompressedTexImage2D(target, | 835 CompressedTexImage2D(target, |
840 0, // level | 836 0, // level |
841 internalFormat, | 837 internalFormat, |
842 width, height, | 838 width, height, |
843 0, // border | 839 0, // border |
844 SkToInt(dataSize), | 840 SkToInt(dataSize), |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1964 GrGLRenderTarget* tgt = static_cast<GrGLRenderTarget*>(surface->asRenderTarg et()); | 1960 GrGLRenderTarget* tgt = static_cast<GrGLRenderTarget*>(surface->asRenderTarg et()); |
1965 if (!tgt) { | 1961 if (!tgt) { |
1966 return false; | 1962 return false; |
1967 } | 1963 } |
1968 | 1964 |
1969 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi xels. | 1965 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi xels. |
1970 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { | 1966 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { |
1971 return false; | 1967 return false; |
1972 } | 1968 } |
1973 | 1969 |
1974 GrGLenum format = 0; | 1970 GrGLenum format = fConfigTable[config].fExternalFormat; |
1975 GrGLenum type = 0; | 1971 GrGLenum type = fConfigTable[config].fExternalType; |
1976 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); | 1972 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); |
1977 if (!this->configToGLFormats(config, false, nullptr, &format, &type)) { | |
1978 return false; | |
1979 } | |
1980 | 1973 |
1981 // resolve the render target if necessary | 1974 // resolve the render target if necessary |
1982 switch (tgt->getResolveType()) { | 1975 switch (tgt->getResolveType()) { |
1983 case GrGLRenderTarget::kCantResolve_ResolveType: | 1976 case GrGLRenderTarget::kCantResolve_ResolveType: |
1984 return false; | 1977 return false; |
1985 case GrGLRenderTarget::kAutoResolves_ResolveType: | 1978 case GrGLRenderTarget::kAutoResolves_ResolveType: |
1986 this->flushRenderTarget(tgt, &SkIRect::EmptyIRect()); | 1979 this->flushRenderTarget(tgt, &SkIRect::EmptyIRect()); |
1987 break; | 1980 break; |
1988 case GrGLRenderTarget::kCanResolve_ResolveType: | 1981 case GrGLRenderTarget::kCanResolve_ResolveType: |
1989 this->onResolveRenderTarget(tgt); | 1982 this->onResolveRenderTarget(tgt); |
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3583 this->setVertexArrayID(gpu, 0); | 3576 this->setVertexArrayID(gpu, 0); |
3584 } | 3577 } |
3585 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3578 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3586 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3579 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3587 fDefaultVertexArrayAttribState.resize(attrCount); | 3580 fDefaultVertexArrayAttribState.resize(attrCount); |
3588 } | 3581 } |
3589 attribState = &fDefaultVertexArrayAttribState; | 3582 attribState = &fDefaultVertexArrayAttribState; |
3590 } | 3583 } |
3591 return attribState; | 3584 return attribState; |
3592 } | 3585 } |
OLD | NEW |