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

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

Issue 133413003: Rename GrGLBinding->GrGLStandard, no longer a bitfield (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: actually fix enum names? 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
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return kBGRA_8888_GrPixelConfig; 196 return kBGRA_8888_GrPixelConfig;
197 } else { 197 } else {
198 return writeConfig; 198 return writeConfig;
199 } 199 }
200 } 200 }
201 201
202 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC onfig) const { 202 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC onfig) const {
203 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture ->config()) { 203 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture ->config()) {
204 return false; 204 return false;
205 } 205 }
206 if (srcConfig != texture->config() && kES_GrGLBinding == this->glBinding()) { 206 if (srcConfig != texture->config() && kGLES_GrGLStandard == this->glStandard ()) {
207 // In general ES2 requires the internal format of the texture and the fo rmat of the src 207 // In general ES2 requires the internal format of the texture and the fo rmat of the src
208 // pixels to match. However, It may or may not be possible to upload BGR A data to a RGBA 208 // pixels to match. However, It may or may not be possible to upload BGR A data to a RGBA
209 // texture. It depends upon which extension added BGRA. The Apple extens ion allows it 209 // texture. It depends upon which extension added BGRA. The Apple extens ion allows it
210 // (BGRA's internal format is RGBA) while the EXT extension does not (BG RA is its own 210 // (BGRA's internal format is RGBA) while the EXT extension does not (BG RA is its own
211 // internal format). 211 // internal format).
212 if (this->glCaps().bgraFormatSupport() && 212 if (this->glCaps().bgraFormatSupport() &&
213 !this->glCaps().bgraIsInternalFormat() && 213 !this->glCaps().bgraIsInternalFormat() &&
214 kBGRA_8888_GrPixelConfig == srcConfig && 214 kBGRA_8888_GrPixelConfig == srcConfig &&
215 kRGBA_8888_GrPixelConfig == texture->config()) { 215 kRGBA_8888_GrPixelConfig == texture->config()) {
216 return true; 216 return true;
(...skipping 11 matching lines...) Expand all
228 228
229 void GrGpuGL::onResetContext(uint32_t resetBits) { 229 void GrGpuGL::onResetContext(uint32_t resetBits) {
230 // we don't use the zb at all 230 // we don't use the zb at all
231 if (resetBits & kMisc_GrGLBackendState) { 231 if (resetBits & kMisc_GrGLBackendState) {
232 GL_CALL(Disable(GR_GL_DEPTH_TEST)); 232 GL_CALL(Disable(GR_GL_DEPTH_TEST));
233 GL_CALL(DepthMask(GR_GL_FALSE)); 233 GL_CALL(DepthMask(GR_GL_FALSE));
234 234
235 fHWDrawFace = GrDrawState::kInvalid_DrawFace; 235 fHWDrawFace = GrDrawState::kInvalid_DrawFace;
236 fHWDitherEnabled = kUnknown_TriState; 236 fHWDitherEnabled = kUnknown_TriState;
237 237
238 if (kDesktop_GrGLBinding == this->glBinding()) { 238 if (kGL_GrGLStandard == this->glStandard()) {
239 // Desktop-only state that we never change 239 // Desktop-only state that we never change
240 if (!this->glCaps().isCoreProfile()) { 240 if (!this->glCaps().isCoreProfile()) {
241 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); 241 GL_CALL(Disable(GR_GL_POINT_SMOOTH));
242 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); 242 GL_CALL(Disable(GR_GL_LINE_SMOOTH));
243 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); 243 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
244 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); 244 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
245 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); 245 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
246 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP)); 246 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
247 } 247 }
248 // The windows NVIDIA driver has GL_ARB_imaging in the extension str ing when using a 248 // The windows NVIDIA driver has GL_ARB_imaging in the extension str ing when using a
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 // paletted textures cannot be partially updated 554 // paletted textures cannot be partially updated
555 // We currently lazily create MIPMAPs when the we see a draw with 555 // We currently lazily create MIPMAPs when the we see a draw with
556 // GrTextureParams::kMipMap_FilterMode. Using texture storage requires that the 556 // GrTextureParams::kMipMap_FilterMode. Using texture storage requires that the
557 // MIP levels are all created when the texture is created. So for now we don 't use 557 // MIP levels are all created when the texture is created. So for now we don 't use
558 // texture storage. 558 // texture storage.
559 bool useTexStorage = false && 559 bool useTexStorage = false &&
560 isNewTexture && 560 isNewTexture &&
561 desc.fConfig != kIndex_8_GrPixelConfig && 561 desc.fConfig != kIndex_8_GrPixelConfig &&
562 this->glCaps().texStorageSupport(); 562 this->glCaps().texStorageSupport();
563 563
564 if (useTexStorage && kDesktop_GrGLBinding == this->glBinding()) { 564 if (useTexStorage && kGL_GrGLStandard == this->glStandard()) {
565 // 565 is not a sized internal format on desktop GL. So on desktop with 565 // 565 is not a sized internal format on desktop GL. So on desktop with
566 // 565 we always use an unsized internal format to let the system pick 566 // 565 we always use an unsized internal format to let the system pick
567 // the best sized format to convert the 565 data to. Since TexStorage 567 // the best sized format to convert the 565 data to. Since TexStorage
568 // only allows sized internal formats we will instead use TexImage2D. 568 // only allows sized internal formats we will instead use TexImage2D.
569 useTexStorage = desc.fConfig != kRGB_565_GrPixelConfig; 569 useTexStorage = desc.fConfig != kRGB_565_GrPixelConfig;
570 } 570 }
571 571
572 GrGLenum internalFormat; 572 GrGLenum internalFormat;
573 GrGLenum externalFormat; 573 GrGLenum externalFormat;
574 GrGLenum externalType; 574 GrGLenum externalType;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 // the texture bound to the other. The exception is the IMG multisample exte nsion. With this 780 // the texture bound to the other. The exception is the IMG multisample exte nsion. With this
781 // extension the texture is multisampled when rendered to and then auto-reso lves it when it is 781 // extension the texture is multisampled when rendered to and then auto-reso lves it when it is
782 // rendered from. 782 // rendered from.
783 if (desc->fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) { 783 if (desc->fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) {
784 GL_CALL(GenFramebuffers(1, &desc->fRTFBOID)); 784 GL_CALL(GenFramebuffers(1, &desc->fRTFBOID));
785 GL_CALL(GenRenderbuffers(1, &desc->fMSColorRenderbufferID)); 785 GL_CALL(GenRenderbuffers(1, &desc->fMSColorRenderbufferID));
786 if (!desc->fRTFBOID || 786 if (!desc->fRTFBOID ||
787 !desc->fMSColorRenderbufferID || 787 !desc->fMSColorRenderbufferID ||
788 !this->configToGLFormats(desc->fConfig, 788 !this->configToGLFormats(desc->fConfig,
789 // ES2 and ES3 require sized internal forma ts for rb storage. 789 // ES2 and ES3 require sized internal forma ts for rb storage.
790 kES_GrGLBinding == this->glBinding(), 790 kGLES_GrGLStandard == this->glStandard(),
791 &msColorFormat, 791 &msColorFormat,
792 NULL, 792 NULL,
793 NULL)) { 793 NULL)) {
794 goto FAILED; 794 goto FAILED;
795 } 795 }
796 } else { 796 } else {
797 desc->fRTFBOID = desc->fTexFBOID; 797 desc->fRTFBOID = desc->fTexFBOID;
798 } 798 }
799 799
800 // below here we may bind the FBO 800 // below here we may bind the FBO
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st ate is enabled but 1861 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st ate is enabled but
1862 // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide. 1862 // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide.
1863 #if 0 1863 #if 0
1864 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe r a relevant concern 1864 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe r a relevant concern
1865 #define RT_HAS_MSAA rt->isMultisampled() 1865 #define RT_HAS_MSAA rt->isMultisampled()
1866 #else 1866 #else
1867 #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type) 1867 #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type)
1868 #endif 1868 #endif
1869 1869
1870 const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); 1870 const GrRenderTarget* rt = this->getDrawState().getRenderTarget();
1871 if (kDesktop_GrGLBinding == this->glBinding()) { 1871 if (kGL_GrGLStandard == this->glStandard()) {
1872 // ES doesn't support toggling GL_MULTISAMPLE and doesn't have 1872 // ES doesn't support toggling GL_MULTISAMPLE and doesn't have
1873 // smooth lines. 1873 // smooth lines.
1874 // we prefer smooth lines over multisampled lines 1874 // we prefer smooth lines over multisampled lines
1875 bool smoothLines = false; 1875 bool smoothLines = false;
1876 1876
1877 if (kDrawLines_DrawType == type) { 1877 if (kDrawLines_DrawType == type) {
1878 smoothLines = this->willUseHWAALines(); 1878 smoothLines = this->willUseHWAALines();
1879 if (smoothLines) { 1879 if (smoothLines) {
1880 if (kYes_TriState != fHWAAState.fSmoothLineEnabled) { 1880 if (kYes_TriState != fHWAAState.fSmoothLineEnabled) {
1881 GL_CALL(Enable(GR_GL_LINE_SMOOTH)); 1881 GL_CALL(Enable(GR_GL_LINE_SMOOTH));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 this->setTextureUnit(unitIdx); 2068 this->setTextureUnit(unitIdx);
2069 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 2069 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
2070 GR_GL_TEXTURE_WRAP_T, 2070 GR_GL_TEXTURE_WRAP_T,
2071 newTexParams.fWrapT)); 2071 newTexParams.fWrapT));
2072 } 2072 }
2073 if (this->glCaps().textureSwizzleSupport() && 2073 if (this->glCaps().textureSwizzleSupport() &&
2074 (setAll || memcmp(newTexParams.fSwizzleRGBA, 2074 (setAll || memcmp(newTexParams.fSwizzleRGBA,
2075 oldTexParams.fSwizzleRGBA, 2075 oldTexParams.fSwizzleRGBA,
2076 sizeof(newTexParams.fSwizzleRGBA)))) { 2076 sizeof(newTexParams.fSwizzleRGBA)))) {
2077 this->setTextureUnit(unitIdx); 2077 this->setTextureUnit(unitIdx);
2078 if (this->glBinding() == kES_GrGLBinding) { 2078 if (this->glStandard() == kGLES_GrGLStandard) {
2079 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA. 2079 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA.
2080 const GrGLenum* swizzle = newTexParams.fSwizzleRGBA; 2080 const GrGLenum* swizzle = newTexParams.fSwizzleRGBA;
2081 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_R, swi zzle[0])); 2081 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_R, swi zzle[0]));
2082 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_G, swi zzle[1])); 2082 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_G, swi zzle[1]));
2083 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_B, swi zzle[2])); 2083 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_B, swi zzle[2]));
2084 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi zzle[3])); 2084 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi zzle[3]));
2085 } else { 2085 } else {
2086 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL int)); 2086 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL int));
2087 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara ms.fSwizzleRGBA); 2087 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara ms.fSwizzleRGBA);
2088 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA, swizzle)); 2088 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA, swizzle));
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 *internalFormat = GR_GL_RGBA; 2327 *internalFormat = GR_GL_RGBA;
2328 } 2328 }
2329 } 2329 }
2330 *externalFormat = GR_GL_BGRA; 2330 *externalFormat = GR_GL_BGRA;
2331 *externalType = GR_GL_UNSIGNED_BYTE; 2331 *externalType = GR_GL_UNSIGNED_BYTE;
2332 break; 2332 break;
2333 case kRGB_565_GrPixelConfig: 2333 case kRGB_565_GrPixelConfig:
2334 *internalFormat = GR_GL_RGB; 2334 *internalFormat = GR_GL_RGB;
2335 *externalFormat = GR_GL_RGB; 2335 *externalFormat = GR_GL_RGB;
2336 if (getSizedInternalFormat) { 2336 if (getSizedInternalFormat) {
2337 if (this->glBinding() == kDesktop_GrGLBinding) { 2337 if (this->glStandard() == kGL_GrGLStandard) {
2338 return false; 2338 return false;
2339 } else { 2339 } else {
2340 *internalFormat = GR_GL_RGB565; 2340 *internalFormat = GR_GL_RGB565;
2341 } 2341 }
2342 } else { 2342 } else {
2343 *internalFormat = GR_GL_RGB; 2343 *internalFormat = GR_GL_RGB;
2344 } 2344 }
2345 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5; 2345 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5;
2346 break; 2346 break;
2347 case kRGBA_4444_GrPixelConfig: 2347 case kRGBA_4444_GrPixelConfig:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 } 2438 }
2439 } 2439 }
2440 2440
2441 inline bool can_copy_texsubimage(const GrSurface* dst, 2441 inline bool can_copy_texsubimage(const GrSurface* dst,
2442 const GrSurface* src, 2442 const GrSurface* src,
2443 const GrGpuGL* gpu, 2443 const GrGpuGL* gpu,
2444 bool* wouldNeedTempFBO = NULL) { 2444 bool* wouldNeedTempFBO = NULL) {
2445 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub Image 2445 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub Image
2446 // and BGRA isn't in the spec. There doesn't appear to be any extension that adds it. Perhaps 2446 // and BGRA isn't in the spec. There doesn't appear to be any extension that adds it. Perhaps
2447 // many drivers would allow it to work, but ANGLE does not. 2447 // many drivers would allow it to work, but ANGLE does not.
2448 if (kES_GrGLBinding == gpu->glBinding() && gpu->glCaps().bgraIsInternalForma t() && 2448 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF ormat() &&
2449 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig = = src->config())) { 2449 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig = = src->config())) {
2450 return false; 2450 return false;
2451 } 2451 }
2452 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as RenderTarget()); 2452 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as RenderTarget());
2453 // If dst is multisampled (and uses an extension where there is a separate M SAA renderbuffer) 2453 // If dst is multisampled (and uses an extension where there is a separate M SAA renderbuffer)
2454 // then we don't want to copy to the texture but to the MSAA buffer. 2454 // then we don't want to copy to the texture but to the MSAA buffer.
2455 if (NULL != dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) { 2455 if (NULL != dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) {
2456 return false; 2456 return false;
2457 } 2457 }
2458 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2458 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 GR_GL_CALL(gl, BindFramebuffer(fboTarget, rt->renderFBOID())); 2501 GR_GL_CALL(gl, BindFramebuffer(fboTarget, rt->renderFBOID()));
2502 *viewport = rt->getViewport(); 2502 *viewport = rt->getViewport();
2503 } 2503 }
2504 return tempFBOID; 2504 return tempFBOID;
2505 } 2505 }
2506 2506
2507 } 2507 }
2508 2508
2509 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc) { 2509 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc) {
2510 // Check for format issues with glCopyTexSubImage2D 2510 // Check for format issues with glCopyTexSubImage2D
2511 if (kES_GrGLBinding == this->glBinding() && this->glCaps().bgraIsInternalFor mat() && 2511 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() &&
2512 kBGRA_8888_GrPixelConfig == src->config()) { 2512 kBGRA_8888_GrPixelConfig == src->config()) {
2513 // glCopyTexSubImage2D doesn't work with this config. We'll want to make it a render target 2513 // glCopyTexSubImage2D doesn't work with this config. We'll want to make it a render target
2514 // in order to call glBlitFramebuffer or to copy to it by rendering. 2514 // in order to call glBlitFramebuffer or to copy to it by rendering.
2515 INHERITED::initCopySurfaceDstDesc(src, desc); 2515 INHERITED::initCopySurfaceDstDesc(src, desc);
2516 return; 2516 return;
2517 } else if (NULL == src->asRenderTarget()) { 2517 } else if (NULL == src->asRenderTarget()) {
2518 // We don't want to have to create an FBO just to use glCopyTexSubImage2 D. Let the base 2518 // We don't want to have to create an FBO just to use glCopyTexSubImage2 D. Let the base
2519 // class handle it by rendering. 2519 // class handle it by rendering.
2520 INHERITED::initCopySurfaceDstDesc(src, desc); 2520 INHERITED::initCopySurfaceDstDesc(src, desc);
2521 return; 2521 return;
(...skipping 174 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

Powered by Google App Engine
This is Rietveld 408576698