Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1429863009: Use a struct for client GL texture handles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
406 } else { 406 } else {
407 return origin; 407 return origin;
408 } 408 }
409 } 409 }
410 410
411 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, 411 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
412 GrWrapOwnership ownership) { 412 GrWrapOwnership ownership) {
413 if (!this->configToGLFormats(desc.fConfig, false, nullptr, nullptr, nullptr) ) { 413 if (!this->configToGLFormats(desc.fConfig, false, nullptr, nullptr, nullptr) ) {
414 return nullptr; 414 return nullptr;
415 } 415 }
416 416 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
417 if (0 == desc.fTextureHandle) { 417 if (!desc.fTextureHandle) {
418 return nullptr; 418 return nullptr;
419 } 419 }
420 #else
421 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle);
422 if (!info || !info->fID) {
423 return nullptr;
424 }
425 #endif
420 426
421 int maxSize = this->caps()->maxTextureSize(); 427 int maxSize = this->caps()->maxTextureSize();
422 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { 428 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
423 return nullptr; 429 return nullptr;
424 } 430 }
425 431
426 GrGLTexture::IDDesc idDesc; 432 GrGLTexture::IDDesc idDesc;
427 GrSurfaceDesc surfDesc; 433 GrSurfaceDesc surfDesc;
428 434
429 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); 435 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
436 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
430 // We only support GL_TEXTURE_2D at the moment. 437 // We only support GL_TEXTURE_2D at the moment.
431 idDesc.fTarget = GR_GL_TEXTURE_2D; 438 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
439 #else
440 idDesc.fInfo = *info;
441 #endif
432 442
433 switch (ownership) { 443 switch (ownership) {
434 case kAdopt_GrWrapOwnership: 444 case kAdopt_GrWrapOwnership:
435 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; 445 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle;
436 break; 446 break;
437 case kBorrow_GrWrapOwnership: 447 case kBorrow_GrWrapOwnership:
438 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; 448 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle;
439 break; 449 break;
440 } 450 }
441 451
(...skipping 11 matching lines...) Expand all
453 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { 463 if (kDefault_GrSurfaceOrigin == desc.fOrigin) {
454 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; 464 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
455 } else { 465 } else {
456 surfDesc.fOrigin = desc.fOrigin; 466 surfDesc.fOrigin = desc.fOrigin;
457 } 467 }
458 468
459 GrGLTexture* texture = nullptr; 469 GrGLTexture* texture = nullptr;
460 if (renderTarget) { 470 if (renderTarget) {
461 GrGLRenderTarget::IDDesc rtIDDesc; 471 GrGLRenderTarget::IDDesc rtIDDesc;
462 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_ LifeCycle, 472 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_ LifeCycle,
463 idDesc.fTextureID, idDesc.fTarget, &rtIDDesc)) { 473 idDesc.fInfo, &rtIDDesc)) {
464 return nullptr; 474 return nullptr;
465 } 475 }
466 texture = new GrGLTextureRenderTarget(this, surfDesc, idDesc, rtIDDesc); 476 texture = new GrGLTextureRenderTarget(this, surfDesc, idDesc, rtIDDesc);
467 } else { 477 } else {
468 texture = new GrGLTexture(this, surfDesc, idDesc); 478 texture = new GrGLTexture(this, surfDesc, idDesc);
469 } 479 }
470 if (nullptr == texture) { 480 if (nullptr == texture) {
471 return nullptr; 481 return nullptr;
472 } 482 }
473 483
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 break; 896 break;
887 case GrGLCaps::kNone_MSFBOType: 897 case GrGLCaps::kNone_MSFBOType:
888 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf fers."); 898 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf fers.");
889 break; 899 break;
890 } 900 }
891 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); 901 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
892 } 902 }
893 903
894 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, 904 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
895 GrGpuResource::LifeCycle lifeCycle, 905 GrGpuResource::LifeCycle lifeCycle,
896 GrGLuint texID, 906 const GrGLTextureInfo& texInfo,
897 GrGLenum textureTarget,
898 GrGLRenderTarget::IDDesc* idDesc) { 907 GrGLRenderTarget::IDDesc* idDesc) {
899 idDesc->fMSColorRenderbufferID = 0; 908 idDesc->fMSColorRenderbufferID = 0;
900 idDesc->fRTFBOID = 0; 909 idDesc->fRTFBOID = 0;
901 idDesc->fTexFBOID = 0; 910 idDesc->fTexFBOID = 0;
902 idDesc->fLifeCycle = lifeCycle; 911 idDesc->fLifeCycle = lifeCycle;
903 idDesc->fSampleConfig = (GrGLCaps::kMixedSamples_MSFBOType == this->glCaps() .msFBOType() && 912 idDesc->fSampleConfig = (GrGLCaps::kMixedSamples_MSFBOType == this->glCaps() .msFBOType() &&
904 desc.fSampleCnt > 0) ? GrRenderTarget::kStencil_Samp leConfig : 913 desc.fSampleCnt > 0) ? GrRenderTarget::kStencil_Samp leConfig :
905 GrRenderTarget::kUnified_Samp leConfig; 914 GrRenderTarget::kUnified_Samp leConfig;
906 915
907 GrGLenum status; 916 GrGLenum status;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 } 973 }
965 fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig); 974 fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig);
966 } 975 }
967 } 976 }
968 fStats.incRenderTargetBinds(); 977 fStats.incRenderTargetBinds();
969 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fTexFBOID)); 978 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fTexFBOID));
970 979
971 if (this->glCaps().usesImplicitMSAAResolve() && desc.fSampleCnt > 0) { 980 if (this->glCaps().usesImplicitMSAAResolve() && desc.fSampleCnt > 0) {
972 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, 981 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER,
973 GR_GL_COLOR_ATTACHMENT0, 982 GR_GL_COLOR_ATTACHMENT0,
974 textureTarget, 983 texInfo.fTarget,
975 texID, 0, desc.fSampleCnt)); 984 texInfo.fID, 0, desc.fSampleCnt) );
976 } else { 985 } else {
977 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, 986 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
978 GR_GL_COLOR_ATTACHMENT0, 987 GR_GL_COLOR_ATTACHMENT0,
979 textureTarget, 988 texInfo.fTarget,
980 texID, 0)); 989 texInfo.fID, 0));
981 } 990 }
982 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) || 991 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) ||
983 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) { 992 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) {
984 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 993 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
985 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 994 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
986 goto FAILED; 995 goto FAILED;
987 } 996 }
988 fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig); 997 fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig);
989 } 998 }
990 999
(...skipping 29 matching lines...) Expand all
1020 const void* srcData, size_t rowBytes) { 1029 const void* srcData, size_t rowBytes) {
1021 // We fail if the MSAA was requested and is not available. 1030 // We fail if the MSAA was requested and is not available.
1022 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) { 1031 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) {
1023 //SkDebugf("MSAA RT requested but not supported on this platform."); 1032 //SkDebugf("MSAA RT requested but not supported on this platform.");
1024 return return_null_texture(); 1033 return return_null_texture();
1025 } 1034 }
1026 1035
1027 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); 1036 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
1028 1037
1029 GrGLTexture::IDDesc idDesc; 1038 GrGLTexture::IDDesc idDesc;
1030 GL_CALL(GenTextures(1, &idDesc.fTextureID)); 1039 GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
1031 idDesc.fLifeCycle = lifeCycle; 1040 idDesc.fLifeCycle = lifeCycle;
1032 // We only support GL_TEXTURE_2D at the moment. 1041 // We only support GL_TEXTURE_2D at the moment.
1033 idDesc.fTarget = GR_GL_TEXTURE_2D; 1042 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
1034 1043
1035 if (!idDesc.fTextureID) { 1044 if (!idDesc.fInfo.fID) {
1036 return return_null_texture(); 1045 return return_null_texture();
1037 } 1046 }
1038 1047
1039 this->setScratchTextureUnit(); 1048 this->setScratchTextureUnit();
1040 GL_CALL(BindTexture(idDesc.fTarget, idDesc.fTextureID)); 1049 GL_CALL(BindTexture(idDesc.fInfo.fTarget, idDesc.fInfo.fID));
1041 1050
1042 if (renderTarget && this->glCaps().textureUsageSupport()) { 1051 if (renderTarget && this->glCaps().textureUsageSupport()) {
1043 // provides a hint about how this texture will be used 1052 // provides a hint about how this texture will be used
1044 GL_CALL(TexParameteri(idDesc.fTarget, 1053 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1045 GR_GL_TEXTURE_USAGE, 1054 GR_GL_TEXTURE_USAGE,
1046 GR_GL_FRAMEBUFFER_ATTACHMENT)); 1055 GR_GL_FRAMEBUFFER_ATTACHMENT));
1047 } 1056 }
1048 1057
1049 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some 1058 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some
1050 // drivers have a bug where an FBO won't be complete if it includes a 1059 // drivers have a bug where an FBO won't be complete if it includes a
1051 // texture that is not mipmap complete (considering the filter in use). 1060 // texture that is not mipmap complete (considering the filter in use).
1052 GrGLTexture::TexParams initialTexParams; 1061 GrGLTexture::TexParams initialTexParams;
1053 // we only set a subset here so invalidate first 1062 // we only set a subset here so invalidate first
1054 initialTexParams.invalidate(); 1063 initialTexParams.invalidate();
1055 initialTexParams.fMinFilter = GR_GL_NEAREST; 1064 initialTexParams.fMinFilter = GR_GL_NEAREST;
1056 initialTexParams.fMagFilter = GR_GL_NEAREST; 1065 initialTexParams.fMagFilter = GR_GL_NEAREST;
1057 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; 1066 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE;
1058 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; 1067 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE;
1059 GL_CALL(TexParameteri(idDesc.fTarget, 1068 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1060 GR_GL_TEXTURE_MAG_FILTER, 1069 GR_GL_TEXTURE_MAG_FILTER,
1061 initialTexParams.fMagFilter)); 1070 initialTexParams.fMagFilter));
1062 GL_CALL(TexParameteri(idDesc.fTarget, 1071 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1063 GR_GL_TEXTURE_MIN_FILTER, 1072 GR_GL_TEXTURE_MIN_FILTER,
1064 initialTexParams.fMinFilter)); 1073 initialTexParams.fMinFilter));
1065 GL_CALL(TexParameteri(idDesc.fTarget, 1074 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1066 GR_GL_TEXTURE_WRAP_S, 1075 GR_GL_TEXTURE_WRAP_S,
1067 initialTexParams.fWrapS)); 1076 initialTexParams.fWrapS));
1068 GL_CALL(TexParameteri(idDesc.fTarget, 1077 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1069 GR_GL_TEXTURE_WRAP_T, 1078 GR_GL_TEXTURE_WRAP_T,
1070 initialTexParams.fWrapT)); 1079 initialTexParams.fWrapT));
1071 if (!this->uploadTexData(desc, idDesc.fTarget, true, 0, 0, 1080 if (!this->uploadTexData(desc, idDesc.fInfo.fTarget, true, 0, 0,
1072 desc.fWidth, desc.fHeight, 1081 desc.fWidth, desc.fHeight,
1073 desc.fConfig, srcData, rowBytes)) { 1082 desc.fConfig, srcData, rowBytes)) {
1074 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); 1083 GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
1075 return return_null_texture(); 1084 return return_null_texture();
1076 } 1085 }
1077 1086
1078 GrGLTexture* tex; 1087 GrGLTexture* tex;
1079 if (renderTarget) { 1088 if (renderTarget) {
1080 // unbind the texture from the texture unit before binding it to the fra me buffer 1089 // unbind the texture from the texture unit before binding it to the fra me buffer
1081 GL_CALL(BindTexture(idDesc.fTarget, 0)); 1090 GL_CALL(BindTexture(idDesc.fInfo.fTarget, 0));
1082 GrGLRenderTarget::IDDesc rtIDDesc; 1091 GrGLRenderTarget::IDDesc rtIDDesc;
1083 1092
1084 if (!this->createRenderTargetObjects(desc, lifeCycle, idDesc.fTextureID, idDesc.fTarget, 1093 if (!this->createRenderTargetObjects(desc, lifeCycle, idDesc.fInfo, &rtI DDesc)) {
1085 &rtIDDesc)) { 1094 GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
1086 GL_CALL(DeleteTextures(1, &idDesc.fTextureID));
1087 return return_null_texture(); 1095 return return_null_texture();
1088 } 1096 }
1089 tex = new GrGLTextureRenderTarget(this, desc, idDesc, rtIDDesc); 1097 tex = new GrGLTextureRenderTarget(this, desc, idDesc, rtIDDesc);
1090 } else { 1098 } else {
1091 tex = new GrGLTexture(this, desc, idDesc); 1099 tex = new GrGLTexture(this, desc, idDesc);
1092 } 1100 }
1093 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); 1101 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
1094 #ifdef TRACE_TEXTURE_CREATION 1102 #ifdef TRACE_TEXTURE_CREATION
1095 SkDebugf("--- new texture [%d] size=(%d %d) config=%d\n", 1103 SkDebugf("--- new texture [%d] size=(%d %d) config=%d\n",
1096 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); 1104 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig);
1097 #endif 1105 #endif
1098 return tex; 1106 return tex;
1099 } 1107 }
1100 1108
1101 GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc, 1109 GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc,
1102 GrGpuResource::LifeCycle lifeCycle , 1110 GrGpuResource::LifeCycle lifeCycle ,
1103 const void* srcData) { 1111 const void* srcData) {
1104 // Make sure that we're not flipping Y. 1112 // Make sure that we're not flipping Y.
1105 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) { 1113 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
1106 return return_null_texture(); 1114 return return_null_texture();
1107 } 1115 }
1108 1116
1109 GrGLTexture::IDDesc idDesc; 1117 GrGLTexture::IDDesc idDesc;
1110 GL_CALL(GenTextures(1, &idDesc.fTextureID)); 1118 GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
1111 idDesc.fLifeCycle = lifeCycle; 1119 idDesc.fLifeCycle = lifeCycle;
1112 // We only support GL_TEXTURE_2D at the moment. 1120 // We only support GL_TEXTURE_2D at the moment.
1113 idDesc.fTarget = GR_GL_TEXTURE_2D; 1121 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
1114 1122
1115 if (!idDesc.fTextureID) { 1123 if (!idDesc.fInfo.fID) {
1116 return return_null_texture(); 1124 return return_null_texture();
1117 } 1125 }
1118 1126
1119 this->setScratchTextureUnit(); 1127 this->setScratchTextureUnit();
1120 GL_CALL(BindTexture(idDesc.fTarget, idDesc.fTextureID)); 1128 GL_CALL(BindTexture(idDesc.fInfo.fTarget, idDesc.fInfo.fID));
1121 1129
1122 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some 1130 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some
1123 // drivers have a bug where an FBO won't be complete if it includes a 1131 // drivers have a bug where an FBO won't be complete if it includes a
1124 // texture that is not mipmap complete (considering the filter in use). 1132 // texture that is not mipmap complete (considering the filter in use).
1125 GrGLTexture::TexParams initialTexParams; 1133 GrGLTexture::TexParams initialTexParams;
1126 // we only set a subset here so invalidate first 1134 // we only set a subset here so invalidate first
1127 initialTexParams.invalidate(); 1135 initialTexParams.invalidate();
1128 initialTexParams.fMinFilter = GR_GL_NEAREST; 1136 initialTexParams.fMinFilter = GR_GL_NEAREST;
1129 initialTexParams.fMagFilter = GR_GL_NEAREST; 1137 initialTexParams.fMagFilter = GR_GL_NEAREST;
1130 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; 1138 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE;
1131 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; 1139 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE;
1132 GL_CALL(TexParameteri(idDesc.fTarget, 1140 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1133 GR_GL_TEXTURE_MAG_FILTER, 1141 GR_GL_TEXTURE_MAG_FILTER,
1134 initialTexParams.fMagFilter)); 1142 initialTexParams.fMagFilter));
1135 GL_CALL(TexParameteri(idDesc.fTarget, 1143 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1136 GR_GL_TEXTURE_MIN_FILTER, 1144 GR_GL_TEXTURE_MIN_FILTER,
1137 initialTexParams.fMinFilter)); 1145 initialTexParams.fMinFilter));
1138 GL_CALL(TexParameteri(idDesc.fTarget, 1146 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1139 GR_GL_TEXTURE_WRAP_S, 1147 GR_GL_TEXTURE_WRAP_S,
1140 initialTexParams.fWrapS)); 1148 initialTexParams.fWrapS));
1141 GL_CALL(TexParameteri(idDesc.fTarget, 1149 GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
1142 GR_GL_TEXTURE_WRAP_T, 1150 GR_GL_TEXTURE_WRAP_T,
1143 initialTexParams.fWrapT)); 1151 initialTexParams.fWrapT));
1144 1152
1145 if (!this->uploadCompressedTexData(desc, idDesc.fTarget, srcData)) { 1153 if (!this->uploadCompressedTexData(desc, idDesc.fInfo.fTarget, srcData)) {
1146 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); 1154 GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
1147 return return_null_texture(); 1155 return return_null_texture();
1148 } 1156 }
1149 1157
1150 GrGLTexture* tex; 1158 GrGLTexture* tex;
1151 tex = new GrGLTexture(this, desc, idDesc); 1159 tex = new GrGLTexture(this, desc, idDesc);
1152 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); 1160 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
1153 #ifdef TRACE_TEXTURE_CREATION 1161 #ifdef TRACE_TEXTURE_CREATION
1154 SkDebugf("--- new compressed texture [%d] size=(%d %d) config=%d\n", 1162 SkDebugf("--- new compressed texture [%d] size=(%d %d) config=%d\n",
1155 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); 1163 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig);
1156 #endif 1164 #endif
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3213 case kBlend_GrXferBarrierType: 3221 case kBlend_GrXferBarrierType:
3214 SkASSERT(GrCaps::kAdvanced_BlendEquationSupport == 3222 SkASSERT(GrCaps::kAdvanced_BlendEquationSupport ==
3215 this->caps()->blendEquationSupport()); 3223 this->caps()->blendEquationSupport());
3216 GL_CALL(BlendBarrier()); 3224 GL_CALL(BlendBarrier());
3217 return; 3225 return;
3218 default: break; // placate compiler warnings that kNone not handled 3226 default: break; // placate compiler warnings that kNone not handled
3219 } 3227 }
3220 } 3228 }
3221 3229
3222 GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in t h, 3230 GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in t h,
3223 GrPixelConfig config) const { 3231 GrPixelConfig config) c onst {
3224 GrGLuint texID; 3232 GrGLTextureInfo* info = new GrGLTextureInfo;
3225 GL_CALL(GenTextures(1, &texID)); 3233 info->fTarget = GR_GL_TEXTURE_2D;
3234 GL_CALL(GenTextures(1, &info->fID));
3226 GL_CALL(ActiveTexture(GR_GL_TEXTURE0)); 3235 GL_CALL(ActiveTexture(GR_GL_TEXTURE0));
3227 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1)); 3236 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1));
3228 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texID)); 3237 GL_CALL(BindTexture(info->fTarget, info->fID));
3229 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAR EST)); 3238 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST ));
3230 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAR EST)); 3239 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST ));
3231 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO _EDGE)); 3240 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_ED GE));
3232 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO _EDGE)); 3241 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_ED GE));
3233 3242
3234 GrGLenum internalFormat = 0x0; // suppress warning 3243 GrGLenum internalFormat = 0x0; // suppress warning
3235 GrGLenum externalFormat = 0x0; // suppress warning 3244 GrGLenum externalFormat = 0x0; // suppress warning
3236 GrGLenum externalType = 0x0; // suppress warning 3245 GrGLenum externalType = 0x0; // suppress warning
3237 3246
3238 this->configToGLFormats(config, false, &internalFormat, &externalFormat, &ex ternalType); 3247 this->configToGLFormats(config, false, &internalFormat, &externalFormat, &ex ternalType);
3239 3248
3240 GL_CALL(TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat, w, h, 0, externalFor mat, 3249 GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat ,
3241 externalType, pixels)); 3250 externalType, pixels));
3242 3251
3243 return texID; 3252 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
3253 GrGLuint id = info->fID;
3254 delete info;
3255 return id;
3256 #else
3257 return reinterpret_cast<GrBackendObject>(info);
3258 #endif
3244 } 3259 }
3245 3260
3246 bool GrGLGpu::isTestingOnlyBackendTexture(GrBackendObject id) const { 3261 bool GrGLGpu::isTestingOnlyBackendTexture(GrBackendObject id) const {
3262 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
3247 GrGLuint texID = (GrGLuint)id; 3263 GrGLuint texID = (GrGLuint)id;
3264 #else
3265 GrGLuint texID = reinterpret_cast<const GrGLTextureInfo*>(id)->fID;
3266 #endif
3248 3267
3249 GrGLboolean result; 3268 GrGLboolean result;
3250 GL_CALL_RET(result, IsTexture(texID)); 3269 GL_CALL_RET(result, IsTexture(texID));
3251 3270
3252 return (GR_GL_TRUE == result); 3271 return (GR_GL_TRUE == result);
3253 } 3272 }
3254 3273
3255 void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendObject id) const { 3274 void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendObject id) const {
3275 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
3256 GrGLuint texID = (GrGLuint)id; 3276 GrGLuint texID = (GrGLuint)id;
3277 #else
3278 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(id);
3279 GrGLuint texID = info->fID;
3280 #endif
3281
3257 GL_CALL(DeleteTextures(1, &texID)); 3282 GL_CALL(DeleteTextures(1, &texID));
3283
3284 #ifndef SK_IGNORE_GL_TEXTURE_TARGET
3285 delete info;
3286 #endif
3258 } 3287 }
3259 3288
3260 /////////////////////////////////////////////////////////////////////////////// 3289 ///////////////////////////////////////////////////////////////////////////////
3261 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw( 3290 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw(
3262 GrGLGpu* gpu, 3291 GrGLGpu* gpu,
3263 const GrGLVertexBuffer* vbuffer, 3292 const GrGLVertexBuffer* vbuffer,
3264 const GrGLIndexBuffer* ibuffer) { 3293 const GrGLIndexBuffer* ibuffer) {
3265 SkASSERT(vbuffer); 3294 SkASSERT(vbuffer);
3266 GrGLuint vbufferID = vbuffer->bufferID(); 3295 GrGLuint vbufferID = vbuffer->bufferID();
3267 GrGLuint* ibufferIDPtr = nullptr; 3296 GrGLuint* ibufferIDPtr = nullptr;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 this->setVertexArrayID(gpu, 0); 3337 this->setVertexArrayID(gpu, 0);
3309 } 3338 }
3310 int attrCount = gpu->glCaps().maxVertexAttributes(); 3339 int attrCount = gpu->glCaps().maxVertexAttributes();
3311 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3340 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3312 fDefaultVertexArrayAttribState.resize(attrCount); 3341 fDefaultVertexArrayAttribState.resize(attrCount);
3313 } 3342 }
3314 attribState = &fDefaultVertexArrayAttribState; 3343 attribState = &fDefaultVertexArrayAttribState;
3315 } 3344 }
3316 return attribState; 3345 return attribState;
3317 } 3346 }
OLDNEW
« include/gpu/gl/GrGLTypes.h ('K') | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698