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

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

Issue 140843003: Make GrGLContextInfo have private ptr to GrGLInterface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tot Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 /////////////////////////////////////////////////////////////////////////////// 111 ///////////////////////////////////////////////////////////////////////////////
112 112
113 static bool gPrintStartupSpew; 113 static bool gPrintStartupSpew;
114 114
115 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) 115 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
116 : GrGpu(context) 116 : GrGpu(context)
117 , fGLContext(ctx) { 117 , fGLContext(ctx) {
118 118
119 SkASSERT(ctx.isInitialized()); 119 SkASSERT(ctx.isInitialized());
120 120
121 fCaps.reset(SkRef(ctx.info().caps())); 121 fCaps.reset(SkRef(ctx.caps()));
122 122
123 fHWBoundTextures.reset(ctx.info().caps()->maxFragmentTextureUnits()); 123 fHWBoundTextures.reset(this->glCaps().maxFragmentTextureUnits());
124 fHWTexGenSettings.reset(ctx.info().caps()->maxFixedFunctionTextureCoords()); 124 fHWTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords());
125 125
126 GrGLClearErr(fGLContext.interface()); 126 GrGLClearErr(fGLContext.interface());
127 127
128 if (gPrintStartupSpew) { 128 if (gPrintStartupSpew) {
129 const GrGLubyte* vendor; 129 const GrGLubyte* vendor;
130 const GrGLubyte* renderer; 130 const GrGLubyte* renderer;
131 const GrGLubyte* version; 131 const GrGLubyte* version;
132 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); 132 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR));
133 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); 133 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER));
134 GL_CALL_RET(version, GetString(GR_GL_VERSION)); 134 GL_CALL_RET(version, GetString(GR_GL_VERSION));
135 GrPrintf("------------------------- create GrGpuGL %p --------------\n", 135 GrPrintf("------------------------- create GrGpuGL %p --------------\n",
136 this); 136 this);
137 GrPrintf("------ VENDOR %s\n", vendor); 137 GrPrintf("------ VENDOR %s\n", vendor);
138 GrPrintf("------ RENDERER %s\n", renderer); 138 GrPrintf("------ RENDERER %s\n", renderer);
139 GrPrintf("------ VERSION %s\n", version); 139 GrPrintf("------ VERSION %s\n", version);
140 GrPrintf("------ EXTENSIONS\n"); 140 GrPrintf("------ EXTENSIONS\n");
141 ctx.info().extensions().print(); 141 ctx.extensions().print();
142 GrPrintf("\n"); 142 GrPrintf("\n");
143 GrPrintf(ctx.info().caps()->dump().c_str()); 143 GrPrintf(this->glCaps().dump().c_str());
144 } 144 }
145 145
146 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); 146 fProgramCache = SkNEW_ARGS(ProgramCache, (this));
147 147
148 SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr ibCnt); 148 SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr ibCnt);
149 149
150 fLastSuccessfulStencilFmtIdx = 0; 150 fLastSuccessfulStencilFmtIdx = 0;
151 fHWProgramID = 0; 151 fHWProgramID = 0;
152 } 152 }
153 153
(...skipping 14 matching lines...) Expand all
168 this->releaseResources(); 168 this->releaseResources();
169 } 169 }
170 170
171 /////////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////////
172 172
173 173
174 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, 174 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig,
175 GrPixelConfig surfaceConfig) co nst { 175 GrPixelConfig surfaceConfig) co nst {
176 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig ) { 176 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig ) {
177 return kBGRA_8888_GrPixelConfig; 177 return kBGRA_8888_GrPixelConfig;
178 } else if (fGLContext.info().isMesa() && 178 } else if (this->glContext().isMesa() &&
179 GrBytesPerPixel(readConfig) == 4 && 179 GrBytesPerPixel(readConfig) == 4 &&
180 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { 180 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) {
181 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur face and vice-versa. 181 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur face and vice-versa.
182 // Perhaps this should be guarded by some compiletime or runtime check. 182 // Perhaps this should be guarded by some compiletime or runtime check.
183 return surfaceConfig; 183 return surfaceConfig;
184 } else if (readConfig == kBGRA_8888_GrPixelConfig && 184 } else if (readConfig == kBGRA_8888_GrPixelConfig &&
185 !this->glCaps().readPixelsSupported(this->glInterface(), 185 !this->glCaps().readPixelsSupported(this->glInterface(),
186 GR_GL_BGRA, GR_GL_UNSIGNED_BY TE)) { 186 GR_GL_BGRA, GR_GL_UNSIGNED_BY TE)) {
187 return kRGBA_8888_GrPixelConfig; 187 return kRGBA_8888_GrPixelConfig;
188 } else { 188 } else {
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); 706 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
707 } 707 }
708 return succeeded; 708 return succeeded;
709 } 709 }
710 710
711 static bool renderbuffer_storage_msaa(GrGLContext& ctx, 711 static bool renderbuffer_storage_msaa(GrGLContext& ctx,
712 int sampleCount, 712 int sampleCount,
713 GrGLenum format, 713 GrGLenum format,
714 int width, int height) { 714 int width, int height) {
715 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); 715 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
716 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.info().caps()->msFBOType()); 716 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType());
717 #if GR_GL_IGNORE_ES3_MSAA 717 #if GR_GL_IGNORE_ES3_MSAA
718 GL_ALLOC_CALL(ctx.interface(), 718 GL_ALLOC_CALL(ctx.interface(),
719 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, 719 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
720 sampleCount, 720 sampleCount,
721 format, 721 format,
722 width, height)); 722 width, height));
723 #else 723 #else
724 switch (ctx.info().caps()->msFBOType()) { 724 switch (ctx.caps()->msFBOType()) {
725 case GrGLCaps::kDesktop_ARB_MSFBOType: 725 case GrGLCaps::kDesktop_ARB_MSFBOType:
726 case GrGLCaps::kDesktop_EXT_MSFBOType: 726 case GrGLCaps::kDesktop_EXT_MSFBOType:
727 case GrGLCaps::kES_3_0_MSFBOType: 727 case GrGLCaps::kES_3_0_MSFBOType:
728 GL_ALLOC_CALL(ctx.interface(), 728 GL_ALLOC_CALL(ctx.interface(),
729 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, 729 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
730 sampleCount, 730 sampleCount,
731 format, 731 format,
732 width, height)); 732 width, height));
733 break; 733 break;
734 case GrGLCaps::kES_Apple_MSFBOType: 734 case GrGLCaps::kES_Apple_MSFBOType:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 813 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
814 GR_GL_COLOR_ATTACHMENT0, 814 GR_GL_COLOR_ATTACHMENT0,
815 GR_GL_RENDERBUFFER, 815 GR_GL_RENDERBUFFER,
816 desc->fMSColorRenderbufferID)); 816 desc->fMSColorRenderbufferID));
817 if (desc->fCheckAllocation || 817 if (desc->fCheckAllocation ||
818 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { 818 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) {
819 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 819 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
820 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 820 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
821 goto FAILED; 821 goto FAILED;
822 } 822 }
823 fGLContext.info().caps()->markConfigAsValidColorAttachment(desc->fCo nfig); 823 fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig);
824 } 824 }
825 } 825 }
826 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID)); 826 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID));
827 827
828 if (this->glCaps().usesImplicitMSAAResolve() && desc->fSampleCnt > 0) { 828 if (this->glCaps().usesImplicitMSAAResolve() && desc->fSampleCnt > 0) {
829 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, 829 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER,
830 GR_GL_COLOR_ATTACHMENT0, 830 GR_GL_COLOR_ATTACHMENT0,
831 GR_GL_TEXTURE_2D, 831 GR_GL_TEXTURE_2D,
832 texID, 0, desc->fSampleCnt)); 832 texID, 0, desc->fSampleCnt));
833 } else { 833 } else {
834 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, 834 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
835 GR_GL_COLOR_ATTACHMENT0, 835 GR_GL_COLOR_ATTACHMENT0,
836 GR_GL_TEXTURE_2D, 836 GR_GL_TEXTURE_2D,
837 texID, 0)); 837 texID, 0));
838 } 838 }
839 if (desc->fCheckAllocation || 839 if (desc->fCheckAllocation ||
840 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { 840 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) {
841 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 841 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
842 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 842 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
843 goto FAILED; 843 goto FAILED;
844 } 844 }
845 fGLContext.info().caps()->markConfigAsValidColorAttachment(desc->fConfig ); 845 fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig);
846 } 846 }
847 847
848 return true; 848 return true;
849 849
850 FAILED: 850 FAILED:
851 if (desc->fMSColorRenderbufferID) { 851 if (desc->fMSColorRenderbufferID) {
852 GL_CALL(DeleteRenderbuffers(1, &desc->fMSColorRenderbufferID)); 852 GL_CALL(DeleteRenderbuffers(1, &desc->fMSColorRenderbufferID));
853 } 853 }
854 if (desc->fRTFBOID != desc->fTexFBOID) { 854 if (desc->fRTFBOID != desc->fTexFBOID) {
855 GL_CALL(DeleteFramebuffers(1, &desc->fRTFBOID)); 855 GL_CALL(DeleteFramebuffers(1, &desc->fRTFBOID));
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1131 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1132 GR_GL_STENCIL_ATTACHMENT, 1132 GR_GL_STENCIL_ATTACHMENT,
1133 GR_GL_RENDERBUFFER, 0)); 1133 GR_GL_RENDERBUFFER, 0));
1134 if (glsb->format().fPacked) { 1134 if (glsb->format().fPacked) {
1135 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1135 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1136 GR_GL_DEPTH_ATTACHMENT, 1136 GR_GL_DEPTH_ATTACHMENT,
1137 GR_GL_RENDERBUFFER, 0)); 1137 GR_GL_RENDERBUFFER, 0));
1138 } 1138 }
1139 return false; 1139 return false;
1140 } else { 1140 } else {
1141 fGLContext.info().caps()->markColorConfigAndStencilFormatAsVerif ied( 1141 fGLContext.caps()->markColorConfigAndStencilFormatAsVerified(
1142 rt->config(), 1142 rt->config(),
1143 glsb->format()); 1143 glsb->format());
1144 } 1144 }
1145 } 1145 }
1146 return true; 1146 return true;
1147 } 1147 }
1148 } 1148 }
1149 1149
1150 //////////////////////////////////////////////////////////////////////////////// 1150 ////////////////////////////////////////////////////////////////////////////////
1151 1151
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget()); 1524 static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget());
1525 SkASSERT(NULL != rt); 1525 SkASSERT(NULL != rt);
1526 1526
1527 if (fHWBoundRenderTarget != rt) { 1527 if (fHWBoundRenderTarget != rt) {
1528 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID())); 1528 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID()));
1529 #ifdef SK_DEBUG 1529 #ifdef SK_DEBUG
1530 // don't do this check in Chromium -- this is causing 1530 // don't do this check in Chromium -- this is causing
1531 // lots of repeated command buffer flushes when the compositor is 1531 // lots of repeated command buffer flushes when the compositor is
1532 // rendering with Ganesh, which is really slow; even too slow for 1532 // rendering with Ganesh, which is really slow; even too slow for
1533 // Debug mode. 1533 // Debug mode.
1534 if (!this->glContext().info().isChromium()) { 1534 if (!this->glContext().isChromium()) {
1535 GrGLenum status; 1535 GrGLenum status;
1536 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1536 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1537 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 1537 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
1538 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x \n", status); 1538 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x \n", status);
1539 } 1539 }
1540 } 1540 }
1541 #endif 1541 #endif
1542 fHWBoundRenderTarget = rt; 1542 fHWBoundRenderTarget = rt;
1543 const GrGLIRect& vp = rt->getViewport(); 1543 const GrGLIRect& vp = rt->getViewport();
1544 if (fHWViewport != vp) { 1544 if (fHWViewport != vp) {
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 this->setVertexArrayID(gpu, 0); 2696 this->setVertexArrayID(gpu, 0);
2697 } 2697 }
2698 int attrCount = gpu->glCaps().maxVertexAttributes(); 2698 int attrCount = gpu->glCaps().maxVertexAttributes();
2699 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2699 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2700 fDefaultVertexArrayAttribState.resize(attrCount); 2700 fDefaultVertexArrayAttribState.resize(attrCount);
2701 } 2701 }
2702 attribState = &fDefaultVertexArrayAttribState; 2702 attribState = &fDefaultVertexArrayAttribState;
2703 } 2703 }
2704 return attribState; 2704 return attribState;
2705 } 2705 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698