| 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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); | 124 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); |
| 125 | 125 |
| 126 GrGLClearErr(fGLContext.interface()); | 126 GrGLClearErr(fGLContext.interface()); |
| 127 if (gPrintStartupSpew) { | 127 if (gPrintStartupSpew) { |
| 128 const GrGLubyte* vendor; | 128 const GrGLubyte* vendor; |
| 129 const GrGLubyte* renderer; | 129 const GrGLubyte* renderer; |
| 130 const GrGLubyte* version; | 130 const GrGLubyte* version; |
| 131 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); | 131 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); |
| 132 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); | 132 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); |
| 133 GL_CALL_RET(version, GetString(GR_GL_VERSION)); | 133 GL_CALL_RET(version, GetString(GR_GL_VERSION)); |
| 134 GrPrintf("------------------------- create GrGpuGL %p --------------\n", | 134 SkDebugf("------------------------- create GrGpuGL %p --------------\n", |
| 135 this); | 135 this); |
| 136 GrPrintf("------ VENDOR %s\n", vendor); | 136 SkDebugf("------ VENDOR %s\n", vendor); |
| 137 GrPrintf("------ RENDERER %s\n", renderer); | 137 SkDebugf("------ RENDERER %s\n", renderer); |
| 138 GrPrintf("------ VERSION %s\n", version); | 138 SkDebugf("------ VERSION %s\n", version); |
| 139 GrPrintf("------ EXTENSIONS\n"); | 139 SkDebugf("------ EXTENSIONS\n"); |
| 140 ctx.extensions().print(); | 140 ctx.extensions().print(); |
| 141 GrPrintf("\n"); | 141 SkDebugf("\n"); |
| 142 GrPrintf(this->glCaps().dump().c_str()); | 142 SkDebugf(this->glCaps().dump().c_str()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); | 145 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); |
| 146 | 146 |
| 147 SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr
ibCnt); | 147 SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr
ibCnt); |
| 148 | 148 |
| 149 fLastSuccessfulStencilFmtIdx = 0; | 149 fLastSuccessfulStencilFmtIdx = 0; |
| 150 fHWProgramID = 0; | 150 fHWProgramID = 0; |
| 151 | 151 |
| 152 if (this->glCaps().pathRenderingSupport()) { | 152 if (this->glCaps().pathRenderingSupport()) { |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 const void* srcData, | 927 const void* srcData, |
| 928 size_t rowBytes) { | 928 size_t rowBytes) { |
| 929 | 929 |
| 930 GrSurfaceDesc desc = origDesc; | 930 GrSurfaceDesc desc = origDesc; |
| 931 GrGLRenderTarget::IDDesc rtIDDesc; | 931 GrGLRenderTarget::IDDesc rtIDDesc; |
| 932 | 932 |
| 933 // Attempt to catch un- or wrongly initialized sample counts; | 933 // Attempt to catch un- or wrongly initialized sample counts; |
| 934 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); | 934 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
| 935 // We fail if the MSAA was requested and is not available. | 935 // We fail if the MSAA was requested and is not available. |
| 936 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { | 936 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
| 937 //GrPrintf("MSAA RT requested but not supported on this platform."); | 937 //SkDebugf("MSAA RT requested but not supported on this platform."); |
| 938 return return_null_texture(); | 938 return return_null_texture(); |
| 939 } | 939 } |
| 940 | 940 |
| 941 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); | 941 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); |
| 942 | 942 |
| 943 // If the sample count exceeds the max then we clamp it. | 943 // If the sample count exceeds the max then we clamp it. |
| 944 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); | 944 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); |
| 945 desc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 945 desc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
| 946 | 946 |
| 947 rtIDDesc.fMSColorRenderbufferID = 0; | 947 rtIDDesc.fMSColorRenderbufferID = 0; |
| 948 rtIDDesc.fRTFBOID = 0; | 948 rtIDDesc.fRTFBOID = 0; |
| 949 rtIDDesc.fTexFBOID = 0; | 949 rtIDDesc.fTexFBOID = 0; |
| 950 rtIDDesc.fIsWrapped = false; | 950 rtIDDesc.fIsWrapped = false; |
| 951 | 951 |
| 952 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { | 952 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
| 953 //GrPrintf("MSAA RT requested but not supported on this platform."); | 953 //SkDebugf("MSAA RT requested but not supported on this platform."); |
| 954 return return_null_texture(); | 954 return return_null_texture(); |
| 955 } | 955 } |
| 956 | 956 |
| 957 if (renderTarget) { | 957 if (renderTarget) { |
| 958 int maxRTSize = this->caps()->maxRenderTargetSize(); | 958 int maxRTSize = this->caps()->maxRenderTargetSize(); |
| 959 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { | 959 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
| 960 return return_null_texture(); | 960 return return_null_texture(); |
| 961 } | 961 } |
| 962 } else { | 962 } else { |
| 963 int maxSize = this->caps()->maxTextureSize(); | 963 int maxSize = this->caps()->maxTextureSize(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 if (!this->createRenderTargetObjects(desc, idDesc.fTextureID, &rtIDDesc
)) { | 1021 if (!this->createRenderTargetObjects(desc, idDesc.fTextureID, &rtIDDesc
)) { |
| 1022 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); | 1022 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
| 1023 return return_null_texture(); | 1023 return return_null_texture(); |
| 1024 } | 1024 } |
| 1025 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc, rtIDDesc)); | 1025 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc, rtIDDesc)); |
| 1026 } else { | 1026 } else { |
| 1027 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); | 1027 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); |
| 1028 } | 1028 } |
| 1029 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); | 1029 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); |
| 1030 #ifdef TRACE_TEXTURE_CREATION | 1030 #ifdef TRACE_TEXTURE_CREATION |
| 1031 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n", | 1031 SkDebugf("--- new texture [%d] size=(%d %d) config=%d\n", |
| 1032 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); | 1032 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); |
| 1033 #endif | 1033 #endif |
| 1034 return tex; | 1034 return tex; |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrSurfaceDesc& origDesc, con
st void* srcData) { | 1037 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrSurfaceDesc& origDesc, con
st void* srcData) { |
| 1038 | 1038 |
| 1039 if(SkToBool(origDesc.fFlags & kRenderTarget_GrSurfaceFlag) || origDesc.fSamp
leCnt > 0) { | 1039 if(SkToBool(origDesc.fFlags & kRenderTarget_GrSurfaceFlag) || origDesc.fSamp
leCnt > 0) { |
| 1040 return return_null_texture(); | 1040 return return_null_texture(); |
| 1041 } | 1041 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1089 |
| 1090 if (!this->uploadCompressedTexData(desc, srcData)) { | 1090 if (!this->uploadCompressedTexData(desc, srcData)) { |
| 1091 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); | 1091 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
| 1092 return return_null_texture(); | 1092 return return_null_texture(); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 GrGLTexture* tex; | 1095 GrGLTexture* tex; |
| 1096 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); | 1096 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); |
| 1097 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); | 1097 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); |
| 1098 #ifdef TRACE_TEXTURE_CREATION | 1098 #ifdef TRACE_TEXTURE_CREATION |
| 1099 GrPrintf("--- new compressed texture [%d] size=(%d %d) config=%d\n", | 1099 SkDebugf("--- new compressed texture [%d] size=(%d %d) config=%d\n", |
| 1100 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); | 1100 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); |
| 1101 #endif | 1101 #endif |
| 1102 return tex; | 1102 return tex; |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 namespace { | 1105 namespace { |
| 1106 | 1106 |
| 1107 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; | 1107 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
| 1108 | 1108 |
| 1109 void inline get_stencil_rb_sizes(const GrGLInterface* gl, | 1109 void inline get_stencil_rb_sizes(const GrGLInterface* gl, |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 1683 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
| 1684 #ifdef SK_DEBUG | 1684 #ifdef SK_DEBUG |
| 1685 // don't do this check in Chromium -- this is causing | 1685 // don't do this check in Chromium -- this is causing |
| 1686 // lots of repeated command buffer flushes when the compositor is | 1686 // lots of repeated command buffer flushes when the compositor is |
| 1687 // rendering with Ganesh, which is really slow; even too slow for | 1687 // rendering with Ganesh, which is really slow; even too slow for |
| 1688 // Debug mode. | 1688 // Debug mode. |
| 1689 if (!this->glContext().isChromium()) { | 1689 if (!this->glContext().isChromium()) { |
| 1690 GrGLenum status; | 1690 GrGLenum status; |
| 1691 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1691 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
| 1692 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 1692 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
| 1693 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x
\n", status); | 1693 SkDebugf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x
\n", status); |
| 1694 } | 1694 } |
| 1695 } | 1695 } |
| 1696 #endif | 1696 #endif |
| 1697 fHWBoundRenderTargetUniqueID = rtID; | 1697 fHWBoundRenderTargetUniqueID = rtID; |
| 1698 const GrGLIRect& vp = target->getViewport(); | 1698 const GrGLIRect& vp = target->getViewport(); |
| 1699 if (fHWViewport != vp) { | 1699 if (fHWViewport != vp) { |
| 1700 vp.pushToGLViewport(this->glInterface()); | 1700 vp.pushToGLViewport(this->glInterface()); |
| 1701 fHWViewport = vp; | 1701 fHWViewport = vp; |
| 1702 } | 1702 } |
| 1703 } | 1703 } |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2574 this->setVertexArrayID(gpu, 0); | 2574 this->setVertexArrayID(gpu, 0); |
| 2575 } | 2575 } |
| 2576 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2576 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2577 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2577 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2578 fDefaultVertexArrayAttribState.resize(attrCount); | 2578 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2579 } | 2579 } |
| 2580 attribState = &fDefaultVertexArrayAttribState; | 2580 attribState = &fDefaultVertexArrayAttribState; |
| 2581 } | 2581 } |
| 2582 return attribState; | 2582 return attribState; |
| 2583 } | 2583 } |
| OLD | NEW |