| 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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
| 9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
| 10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 if (glFlipY) { | 1335 if (glFlipY) { |
| 1336 GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE)); | 1336 GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE)); |
| 1337 } | 1337 } |
| 1338 GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_ALIGNMENT, | 1338 GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_ALIGNMENT, |
| 1339 config_alignment(desc.fConfig))); | 1339 config_alignment(desc.fConfig))); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 bool succeeded = true; | 1342 bool succeeded = true; |
| 1343 if (kNewTexture_UploadType == uploadType && | 1343 if (kNewTexture_UploadType == uploadType && |
| 1344 0 == left && 0 == top && | 1344 0 == left && 0 == top && |
| 1345 desc.fWidth == width && desc.fHeight == height && | 1345 desc.fWidth == width && desc.fHeight == height) { |
| 1346 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { | |
| 1347 succeeded = allocate_and_populate_uncompressed_texture(desc, *interface,
caps, target, | 1346 succeeded = allocate_and_populate_uncompressed_texture(desc, *interface,
caps, target, |
| 1348 internalFormat, e
xternalFormat, | 1347 internalFormat, e
xternalFormat, |
| 1349 externalType, tex
elsShallowCopy, | 1348 externalType, tex
elsShallowCopy, |
| 1350 width, height); | 1349 width, height); |
| 1351 } else { | 1350 } else { |
| 1352 if (swFlipY || glFlipY) { | 1351 if (swFlipY || glFlipY) { |
| 1353 top = desc.fHeight - (top + height); | 1352 top = desc.fHeight - (top + height); |
| 1354 } | 1353 } |
| 1355 for (int currentMipLevel = 0; currentMipLevel < texelsShallowCopy.count(
); | 1354 for (int currentMipLevel = 0; currentMipLevel < texelsShallowCopy.count(
); |
| 1356 currentMipLevel++) { | 1355 currentMipLevel++) { |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0)); | 1855 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0)); |
| 1857 GL_CALL(DeleteFramebuffers(1, &fb)); | 1856 GL_CALL(DeleteFramebuffers(1, &fb)); |
| 1858 fGLContext->caps()->setStencilFormatIndexForConfig(config, firstWorkingS
tencilFormatIndex); | 1857 fGLContext->caps()->setStencilFormatIndexForConfig(config, firstWorkingS
tencilFormatIndex); |
| 1859 } | 1858 } |
| 1860 return this->glCaps().getStencilFormatIndexForConfig(config); | 1859 return this->glCaps().getStencilFormatIndexForConfig(config); |
| 1861 } | 1860 } |
| 1862 | 1861 |
| 1863 bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info
, | 1862 bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info
, |
| 1864 bool renderTarget, GrGLTexture::TexParams* initi
alTexParams, | 1863 bool renderTarget, GrGLTexture::TexParams* initi
alTexParams, |
| 1865 const SkTArray<GrMipLevel>& texels) { | 1864 const SkTArray<GrMipLevel>& texels) { |
| 1866 if (desc.fTextureStorageAllocator.fAllocateTextureStorage) { | |
| 1867 return this->createTextureExternalAllocatorImpl(desc, info, texels); | |
| 1868 } | |
| 1869 | |
| 1870 info->fID = 0; | 1865 info->fID = 0; |
| 1871 info->fTarget = GR_GL_TEXTURE_2D; | 1866 info->fTarget = GR_GL_TEXTURE_2D; |
| 1872 GL_CALL(GenTextures(1, &(info->fID))); | 1867 GL_CALL(GenTextures(1, &(info->fID))); |
| 1873 | 1868 |
| 1874 if (!info->fID) { | 1869 if (!info->fID) { |
| 1875 return false; | 1870 return false; |
| 1876 } | 1871 } |
| 1877 | 1872 |
| 1878 this->setScratchTextureUnit(); | 1873 this->setScratchTextureUnit(); |
| 1879 GL_CALL(BindTexture(info->fTarget, info->fID)); | 1874 GL_CALL(BindTexture(info->fTarget, info->fID)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1890 } | 1885 } |
| 1891 if (!this->uploadTexData(desc, info->fTarget, kNewTexture_UploadType, 0, 0, | 1886 if (!this->uploadTexData(desc, info->fTarget, kNewTexture_UploadType, 0, 0, |
| 1892 desc.fWidth, desc.fHeight, | 1887 desc.fWidth, desc.fHeight, |
| 1893 desc.fConfig, texels)) { | 1888 desc.fConfig, texels)) { |
| 1894 GL_CALL(DeleteTextures(1, &(info->fID))); | 1889 GL_CALL(DeleteTextures(1, &(info->fID))); |
| 1895 return false; | 1890 return false; |
| 1896 } | 1891 } |
| 1897 return true; | 1892 return true; |
| 1898 } | 1893 } |
| 1899 | 1894 |
| 1900 bool GrGLGpu::createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc, | |
| 1901 GrGLTextureInfo* info, | |
| 1902 const SkTArray<GrMipLevel>& tex
els) { | |
| 1903 // We do not make SkTArray available outside of Skia, | |
| 1904 // and so we do not want to allow mipmaps to external | |
| 1905 // allocators just yet. | |
| 1906 SkASSERT(texels.count() < 2); | |
| 1907 | |
| 1908 const void* pixels = nullptr; | |
| 1909 if (!texels.empty()) { | |
| 1910 pixels = texels.begin()->fPixels; | |
| 1911 } | |
| 1912 switch (desc.fTextureStorageAllocator.fAllocateTextureStorage( | |
| 1913 desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBacke
ndObject>(info), | |
| 1914 desc.fWidth, desc.fHeight, desc.fConfig, pixels, desc.fOrigi
n)) { | |
| 1915 case GrTextureStorageAllocator::Result::kSucceededAndUploaded: | |
| 1916 return true; | |
| 1917 case GrTextureStorageAllocator::Result::kFailed: | |
| 1918 return false; | |
| 1919 case GrTextureStorageAllocator::Result::kSucceededWithoutUpload: | |
| 1920 break; | |
| 1921 } | |
| 1922 | |
| 1923 if (!this->uploadTexData(desc, info->fTarget, kNewTexture_UploadType, 0, 0, | |
| 1924 desc.fWidth, desc.fHeight, | |
| 1925 desc.fConfig, texels)) { | |
| 1926 desc.fTextureStorageAllocator.fDeallocateTextureStorage( | |
| 1927 desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendOb
ject>(info)); | |
| 1928 return false; | |
| 1929 } | |
| 1930 return true; | |
| 1931 } | |
| 1932 | |
| 1933 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen
derTarget* rt, | 1895 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen
derTarget* rt, |
| 1934 int width, | 1896 int width, |
| 1935 int height)
{ | 1897 int height)
{ |
| 1936 SkASSERT(width >= rt->width()); | 1898 SkASSERT(width >= rt->width()); |
| 1937 SkASSERT(height >= rt->height()); | 1899 SkASSERT(height >= rt->height()); |
| 1938 | 1900 |
| 1939 int samples = rt->numStencilSamples(); | 1901 int samples = rt->numStencilSamples(); |
| 1940 GrGLStencilAttachment::IDDesc sbDesc; | 1902 GrGLStencilAttachment::IDDesc sbDesc; |
| 1941 | 1903 |
| 1942 int sIdx = this->getCompatibleStencilIndex(rt->config()); | 1904 int sIdx = this->getCompatibleStencilIndex(rt->config()); |
| (...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4317 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4279 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
| 4318 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4280 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
| 4319 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4281 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
| 4320 copyParams->fWidth = texture->width(); | 4282 copyParams->fWidth = texture->width(); |
| 4321 copyParams->fHeight = texture->height(); | 4283 copyParams->fHeight = texture->height(); |
| 4322 return true; | 4284 return true; |
| 4323 } | 4285 } |
| 4324 } | 4286 } |
| 4325 return false; | 4287 return false; |
| 4326 } | 4288 } |
| OLD | NEW |