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 "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 int maxSize = this->caps()->maxTextureSize(); | 371 int maxSize = this->caps()->maxTextureSize(); |
372 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 372 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
373 return NULL; | 373 return NULL; |
374 } | 374 } |
375 | 375 |
376 GrGLTexture::IDDesc idDesc; | 376 GrGLTexture::IDDesc idDesc; |
377 GrSurfaceDesc surfDesc; | 377 GrSurfaceDesc surfDesc; |
378 | 378 |
379 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); | 379 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); |
380 idDesc.fIsWrapped = true; | 380 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
381 | 381 |
382 // next line relies on GrBackendTextureDesc's flags matching GrTexture's | 382 // next line relies on GrBackendTextureDesc's flags matching GrTexture's |
383 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | 383 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; |
384 surfDesc.fWidth = desc.fWidth; | 384 surfDesc.fWidth = desc.fWidth; |
385 surfDesc.fHeight = desc.fHeight; | 385 surfDesc.fHeight = desc.fHeight; |
386 surfDesc.fConfig = desc.fConfig; | 386 surfDesc.fConfig = desc.fConfig; |
387 surfDesc.fSampleCnt = desc.fSampleCnt; | 387 surfDesc.fSampleCnt = desc.fSampleCnt; |
388 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); | 388 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); |
389 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly | 389 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly |
390 // assuming the old behaviour, which is that backend textures are always | 390 // assuming the old behaviour, which is that backend textures are always |
391 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: | 391 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: |
392 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 392 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
393 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { | 393 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { |
394 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 394 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
395 } else { | 395 } else { |
396 surfDesc.fOrigin = desc.fOrigin; | 396 surfDesc.fOrigin = desc.fOrigin; |
397 } | 397 } |
398 | 398 |
399 GrGLTexture* texture = NULL; | 399 GrGLTexture* texture = NULL; |
400 if (renderTarget) { | 400 if (renderTarget) { |
401 GrGLRenderTarget::IDDesc rtIDDesc; | 401 GrGLRenderTarget::IDDesc rtIDDesc; |
402 if (!this->createRenderTargetObjects(surfDesc, idDesc.fTextureID, &rtIDD
esc)) { | 402 if (!this->createRenderTargetObjects(surfDesc, false, idDesc.fTextureID,
&rtIDDesc)) { |
403 return NULL; | 403 return NULL; |
404 } | 404 } |
405 texture = SkNEW_ARGS(GrGLTextureRenderTarget, (this, surfDesc, idDesc, r
tIDDesc)); | 405 texture = SkNEW_ARGS(GrGLTextureRenderTarget, (this, surfDesc, idDesc, r
tIDDesc)); |
406 } else { | 406 } else { |
407 texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc)); | 407 texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc)); |
408 } | 408 } |
409 if (NULL == texture) { | 409 if (NULL == texture) { |
410 return NULL; | 410 return NULL; |
411 } | 411 } |
412 | 412 |
413 return texture; | 413 return texture; |
414 } | 414 } |
415 | 415 |
416 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc) { | 416 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc) { |
417 GrGLRenderTarget::IDDesc idDesc; | 417 GrGLRenderTarget::IDDesc idDesc; |
418 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 418 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
419 idDesc.fMSColorRenderbufferID = 0; | 419 idDesc.fMSColorRenderbufferID = 0; |
420 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | 420 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; |
421 idDesc.fIsWrapped = true; | 421 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
422 | 422 |
423 GrSurfaceDesc desc; | 423 GrSurfaceDesc desc; |
424 desc.fConfig = wrapDesc.fConfig; | 424 desc.fConfig = wrapDesc.fConfig; |
425 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 425 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
426 desc.fWidth = wrapDesc.fWidth; | 426 desc.fWidth = wrapDesc.fWidth; |
427 desc.fHeight = wrapDesc.fHeight; | 427 desc.fHeight = wrapDesc.fHeight; |
428 desc.fSampleCnt = wrapDesc.fSampleCnt; | 428 desc.fSampleCnt = wrapDesc.fSampleCnt; |
429 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 429 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
430 | 430 |
431 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc)); | 431 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc)); |
432 if (wrapDesc.fStencilBits) { | 432 if (wrapDesc.fStencilBits) { |
433 GrGLStencilBuffer::Format format; | 433 GrGLStencilBuffer::Format format; |
434 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat; | 434 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat; |
435 format.fPacked = false; | 435 format.fPacked = false; |
436 format.fStencilBits = wrapDesc.fStencilBits; | 436 format.fStencilBits = wrapDesc.fStencilBits; |
437 format.fTotalBits = wrapDesc.fStencilBits; | 437 format.fTotalBits = wrapDesc.fStencilBits; |
438 static const bool kIsSBWrapped = false; | |
439 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer, | 438 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer, |
440 (this, | 439 (this, |
441 kIsSBWrapped, | |
442 0, | 440 0, |
443 desc.fWidth, | 441 desc.fWidth, |
444 desc.fHeight, | 442 desc.fHeight, |
445 desc.fSampleCnt, | 443 desc.fSampleCnt, |
446 format)); | 444 format)); |
447 tgt->setStencilBuffer(sb); | 445 tgt->setStencilBuffer(sb); |
448 sb->unref(); | 446 sb->unref(); |
449 } | 447 } |
450 return tgt; | 448 return tgt; |
451 } | 449 } |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 format, | 786 format, |
789 width, height)); | 787 width, height)); |
790 break; | 788 break; |
791 case GrGLCaps::kNone_MSFBOType: | 789 case GrGLCaps::kNone_MSFBOType: |
792 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf
fers."); | 790 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf
fers."); |
793 break; | 791 break; |
794 } | 792 } |
795 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; | 793 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; |
796 } | 794 } |
797 | 795 |
798 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, GrGLuint texI
D, | 796 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted
, GrGLuint texID, |
799 GrGLRenderTarget::IDDesc* idDesc) { | 797 GrGLRenderTarget::IDDesc* idDesc) { |
800 idDesc->fMSColorRenderbufferID = 0; | 798 idDesc->fMSColorRenderbufferID = 0; |
801 idDesc->fRTFBOID = 0; | 799 idDesc->fRTFBOID = 0; |
802 idDesc->fTexFBOID = 0; | 800 idDesc->fTexFBOID = 0; |
803 idDesc->fIsWrapped = false; | 801 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
| 802 GrGpuResource::kUncached_LifeCycle; |
804 | 803 |
805 GrGLenum status; | 804 GrGLenum status; |
806 | 805 |
807 GrGLenum msColorFormat = 0; // suppress warning | 806 GrGLenum msColorFormat = 0; // suppress warning |
808 | 807 |
809 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO
Type()) { | 808 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO
Type()) { |
810 goto FAILED; | 809 goto FAILED; |
811 } | 810 } |
812 | 811 |
813 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); | 812 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 // SkDEBUGFAIL("null texture"); | 905 // SkDEBUGFAIL("null texture"); |
907 return NULL; | 906 return NULL; |
908 } | 907 } |
909 | 908 |
910 #if 0 && defined(SK_DEBUG) | 909 #if 0 && defined(SK_DEBUG) |
911 static size_t as_size_t(int x) { | 910 static size_t as_size_t(int x) { |
912 return x; | 911 return x; |
913 } | 912 } |
914 #endif | 913 #endif |
915 | 914 |
916 GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& origDesc, | 915 GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& origDesc, bool budgeted
, |
917 const void* srcData, | 916 const void* srcData, size_t rowBytes) { |
918 size_t rowBytes) { | |
919 | 917 |
920 GrSurfaceDesc desc = origDesc; | 918 GrSurfaceDesc desc = origDesc; |
921 GrGLRenderTarget::IDDesc rtIDDesc; | |
922 | 919 |
923 // Attempt to catch un- or wrongly initialized sample counts; | 920 // Attempt to catch un- or wrongly initialized sample counts; |
924 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); | 921 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
925 // We fail if the MSAA was requested and is not available. | 922 // We fail if the MSAA was requested and is not available. |
926 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { | 923 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
927 //SkDebugf("MSAA RT requested but not supported on this platform."); | 924 //SkDebugf("MSAA RT requested but not supported on this platform."); |
928 return return_null_texture(); | 925 return return_null_texture(); |
929 } | 926 } |
930 | 927 |
931 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); | 928 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); |
932 | 929 |
933 // If the sample count exceeds the max then we clamp it. | 930 // If the sample count exceeds the max then we clamp it. |
934 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); | 931 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); |
935 desc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 932 desc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
936 | 933 |
937 rtIDDesc.fMSColorRenderbufferID = 0; | |
938 rtIDDesc.fRTFBOID = 0; | |
939 rtIDDesc.fTexFBOID = 0; | |
940 rtIDDesc.fIsWrapped = false; | |
941 | |
942 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { | 934 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
943 //SkDebugf("MSAA RT requested but not supported on this platform."); | 935 //SkDebugf("MSAA RT requested but not supported on this platform."); |
944 return return_null_texture(); | 936 return return_null_texture(); |
945 } | 937 } |
946 | 938 |
947 if (renderTarget) { | 939 if (renderTarget) { |
948 int maxRTSize = this->caps()->maxRenderTargetSize(); | 940 int maxRTSize = this->caps()->maxRenderTargetSize(); |
949 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { | 941 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
950 return return_null_texture(); | 942 return return_null_texture(); |
951 } | 943 } |
952 } else { | 944 } else { |
953 int maxSize = this->caps()->maxTextureSize(); | 945 int maxSize = this->caps()->maxTextureSize(); |
954 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 946 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
955 return return_null_texture(); | 947 return return_null_texture(); |
956 } | 948 } |
957 } | 949 } |
958 | 950 |
959 GrGLTexture::IDDesc idDesc; | 951 GrGLTexture::IDDesc idDesc; |
960 GL_CALL(GenTextures(1, &idDesc.fTextureID)); | 952 GL_CALL(GenTextures(1, &idDesc.fTextureID)); |
961 idDesc.fIsWrapped = false; | 953 idDesc.fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
| 954 GrGpuResource::kUncached_LifeCycle; |
962 | 955 |
963 if (!idDesc.fTextureID) { | 956 if (!idDesc.fTextureID) { |
964 return return_null_texture(); | 957 return return_null_texture(); |
965 } | 958 } |
966 | 959 |
967 this->setScratchTextureUnit(); | 960 this->setScratchTextureUnit(); |
968 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, idDesc.fTextureID)); | 961 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, idDesc.fTextureID)); |
969 | 962 |
970 if (renderTarget && this->glCaps().textureUsageSupport()) { | 963 if (renderTarget && this->glCaps().textureUsageSupport()) { |
971 // provides a hint about how this texture will be used | 964 // provides a hint about how this texture will be used |
(...skipping 28 matching lines...) Expand all Loading... |
1000 desc.fWidth, desc.fHeight, | 993 desc.fWidth, desc.fHeight, |
1001 desc.fConfig, srcData, rowBytes)) { | 994 desc.fConfig, srcData, rowBytes)) { |
1002 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); | 995 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
1003 return return_null_texture(); | 996 return return_null_texture(); |
1004 } | 997 } |
1005 | 998 |
1006 GrGLTexture* tex; | 999 GrGLTexture* tex; |
1007 if (renderTarget) { | 1000 if (renderTarget) { |
1008 // unbind the texture from the texture unit before binding it to the fra
me buffer | 1001 // unbind the texture from the texture unit before binding it to the fra
me buffer |
1009 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0)); | 1002 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0)); |
| 1003 GrGLRenderTarget::IDDesc rtIDDesc; |
1010 | 1004 |
1011 if (!this->createRenderTargetObjects(desc, idDesc.fTextureID, &rtIDDesc
)) { | 1005 if (!this->createRenderTargetObjects(desc, budgeted, idDesc.fTextureID,
&rtIDDesc)) { |
1012 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); | 1006 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
1013 return return_null_texture(); | 1007 return return_null_texture(); |
1014 } | 1008 } |
1015 tex = SkNEW_ARGS(GrGLTextureRenderTarget, (this, desc, idDesc, rtIDDesc)
); | 1009 tex = SkNEW_ARGS(GrGLTextureRenderTarget, (this, desc, idDesc, rtIDDesc)
); |
1016 } else { | 1010 } else { |
1017 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); | 1011 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); |
1018 } | 1012 } |
1019 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); | 1013 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); |
1020 #ifdef TRACE_TEXTURE_CREATION | 1014 #ifdef TRACE_TEXTURE_CREATION |
1021 SkDebugf("--- new texture [%d] size=(%d %d) config=%d\n", | 1015 SkDebugf("--- new texture [%d] size=(%d %d) config=%d\n", |
1022 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); | 1016 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); |
1023 #endif | 1017 #endif |
1024 return tex; | 1018 return tex; |
1025 } | 1019 } |
1026 | 1020 |
1027 GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& origDesc, con
st void* srcData) { | 1021 GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& origDesc, boo
l budgeted, |
| 1022 const void* srcData) { |
1028 | 1023 |
1029 if(SkToBool(origDesc.fFlags & kRenderTarget_GrSurfaceFlag) || origDesc.fSamp
leCnt > 0) { | 1024 if(SkToBool(origDesc.fFlags & kRenderTarget_GrSurfaceFlag) || origDesc.fSamp
leCnt > 0) { |
1030 return return_null_texture(); | 1025 return return_null_texture(); |
1031 } | 1026 } |
1032 | 1027 |
1033 // Make sure that we're not flipping Y. | 1028 // Make sure that we're not flipping Y. |
1034 GrSurfaceOrigin texOrigin = resolve_origin(origDesc.fOrigin, false); | 1029 GrSurfaceOrigin texOrigin = resolve_origin(origDesc.fOrigin, false); |
1035 if (kBottomLeft_GrSurfaceOrigin == texOrigin) { | 1030 if (kBottomLeft_GrSurfaceOrigin == texOrigin) { |
1036 return return_null_texture(); | 1031 return return_null_texture(); |
1037 } | 1032 } |
1038 GrSurfaceDesc desc = origDesc; | 1033 GrSurfaceDesc desc = origDesc; |
1039 desc.fOrigin = texOrigin; | 1034 desc.fOrigin = texOrigin; |
1040 | 1035 |
1041 int maxSize = this->caps()->maxTextureSize(); | 1036 int maxSize = this->caps()->maxTextureSize(); |
1042 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 1037 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
1043 return return_null_texture(); | 1038 return return_null_texture(); |
1044 } | 1039 } |
1045 | 1040 |
1046 GrGLTexture::IDDesc idDesc; | 1041 GrGLTexture::IDDesc idDesc; |
1047 GL_CALL(GenTextures(1, &idDesc.fTextureID)); | 1042 GL_CALL(GenTextures(1, &idDesc.fTextureID)); |
1048 idDesc.fIsWrapped = false; | 1043 idDesc.fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
| 1044 GrGpuResource::kUncached_LifeCycle; |
1049 | 1045 |
1050 if (!idDesc.fTextureID) { | 1046 if (!idDesc.fTextureID) { |
1051 return return_null_texture(); | 1047 return return_null_texture(); |
1052 } | 1048 } |
1053 | 1049 |
1054 this->setScratchTextureUnit(); | 1050 this->setScratchTextureUnit(); |
1055 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, idDesc.fTextureID)); | 1051 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, idDesc.fTextureID)); |
1056 | 1052 |
1057 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 1053 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
1058 // drivers have a bug where an FBO won't be complete if it includes a | 1054 // drivers have a bug where an FBO won't be complete if it includes a |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERB
UFFER, | 1152 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERB
UFFER, |
1157 sFmt.fInterna
lFormat, | 1153 sFmt.fInterna
lFormat, |
1158 width, height
)); | 1154 width, height
)); |
1159 created = (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glI
nterface())); | 1155 created = (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glI
nterface())); |
1160 } | 1156 } |
1161 if (created) { | 1157 if (created) { |
1162 // After sized formats we attempt an unsized format and take | 1158 // After sized formats we attempt an unsized format and take |
1163 // whatever sizes GL gives us. In that case we query for the size. | 1159 // whatever sizes GL gives us. In that case we query for the size. |
1164 GrGLStencilBuffer::Format format = sFmt; | 1160 GrGLStencilBuffer::Format format = sFmt; |
1165 get_stencil_rb_sizes(this->glInterface(), &format); | 1161 get_stencil_rb_sizes(this->glInterface(), &format); |
1166 static const bool kIsWrapped = false; | |
1167 SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer, | 1162 SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer, |
1168 (this, kIsWrapped, sbID, width
, height, | 1163 (this, sbID, width, height, sa
mples, format))); |
1169 samples, format))); | |
1170 if (this->attachStencilBufferToRenderTarget(sb, rt)) { | 1164 if (this->attachStencilBufferToRenderTarget(sb, rt)) { |
1171 fLastSuccessfulStencilFmtIdx = sIdx; | 1165 fLastSuccessfulStencilFmtIdx = sIdx; |
1172 rt->setStencilBuffer(sb); | 1166 rt->setStencilBuffer(sb); |
1173 return true; | 1167 return true; |
1174 } | 1168 } |
1175 // Remove the scratch key from this resource so we don't grab it fro
m the cache ever | 1169 // Remove the scratch key from this resource so we don't grab it fro
m the cache ever |
1176 // again. | 1170 // again. |
1177 sb->cacheAccess().removeScratchKey(); | 1171 sb->cacheAccess().removeScratchKey(); |
1178 // Set this to 0 since we handed the valid ID off to the failed sten
cil buffer resource. | 1172 // Set this to 0 since we handed the valid ID off to the failed sten
cil buffer resource. |
1179 sbID = 0; | 1173 sbID = 0; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 return true; | 1239 return true; |
1246 } | 1240 } |
1247 } | 1241 } |
1248 | 1242 |
1249 //////////////////////////////////////////////////////////////////////////////// | 1243 //////////////////////////////////////////////////////////////////////////////// |
1250 | 1244 |
1251 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) { | 1245 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) { |
1252 GrGLVertexBuffer::Desc desc; | 1246 GrGLVertexBuffer::Desc desc; |
1253 desc.fDynamic = dynamic; | 1247 desc.fDynamic = dynamic; |
1254 desc.fSizeInBytes = size; | 1248 desc.fSizeInBytes = size; |
1255 desc.fIsWrapped = false; | |
1256 | 1249 |
1257 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) { | 1250 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) { |
1258 desc.fID = 0; | 1251 desc.fID = 0; |
1259 GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this, des
c)); | 1252 GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this, des
c)); |
1260 return vertexBuffer; | 1253 return vertexBuffer; |
1261 } else { | 1254 } else { |
1262 GL_CALL(GenBuffers(1, &desc.fID)); | 1255 GL_CALL(GenBuffers(1, &desc.fID)); |
1263 if (desc.fID) { | 1256 if (desc.fID) { |
1264 fHWGeometryState.setVertexBufferID(this, desc.fID); | 1257 fHWGeometryState.setVertexBufferID(this, desc.fID); |
1265 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); | 1258 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
(...skipping 12 matching lines...) Expand all Loading... |
1278 return vertexBuffer; | 1271 return vertexBuffer; |
1279 } | 1272 } |
1280 return NULL; | 1273 return NULL; |
1281 } | 1274 } |
1282 } | 1275 } |
1283 | 1276 |
1284 GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) { | 1277 GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) { |
1285 GrGLIndexBuffer::Desc desc; | 1278 GrGLIndexBuffer::Desc desc; |
1286 desc.fDynamic = dynamic; | 1279 desc.fDynamic = dynamic; |
1287 desc.fSizeInBytes = size; | 1280 desc.fSizeInBytes = size; |
1288 desc.fIsWrapped = false; | |
1289 | 1281 |
1290 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) { | 1282 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) { |
1291 desc.fID = 0; | 1283 desc.fID = 0; |
1292 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc)); | 1284 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc)); |
1293 return indexBuffer; | 1285 return indexBuffer; |
1294 } else { | 1286 } else { |
1295 GL_CALL(GenBuffers(1, &desc.fID)); | 1287 GL_CALL(GenBuffers(1, &desc.fID)); |
1296 if (desc.fID) { | 1288 if (desc.fID) { |
1297 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID
); | 1289 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID
); |
1298 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); | 1290 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 this->setVertexArrayID(gpu, 0); | 2742 this->setVertexArrayID(gpu, 0); |
2751 } | 2743 } |
2752 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2744 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2753 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2745 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2754 fDefaultVertexArrayAttribState.resize(attrCount); | 2746 fDefaultVertexArrayAttribState.resize(attrCount); |
2755 } | 2747 } |
2756 attribState = &fDefaultVertexArrayAttribState; | 2748 attribState = &fDefaultVertexArrayAttribState; |
2757 } | 2749 } |
2758 return attribState; | 2750 return attribState; |
2759 } | 2751 } |
OLD | NEW |