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

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

Issue 682223002: rename GrTextureDesc->GrSurfaceDesc, GrTextureFlags->GrSurfaceFlags (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 6 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
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/image/SkSurface_Gpu.cpp » ('j') | 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 return NULL; 369 return NULL;
370 } 370 }
371 371
372 int maxSize = this->caps()->maxTextureSize(); 372 int maxSize = this->caps()->maxTextureSize();
373 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { 373 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
374 return NULL; 374 return NULL;
375 } 375 }
376 376
377 GrGLTexture::Desc glTexDesc; 377 GrGLTexture::Desc glTexDesc;
378 // next line relies on GrBackendTextureDesc's flags matching GrTexture's 378 // next line relies on GrBackendTextureDesc's flags matching GrTexture's
379 glTexDesc.fFlags = (GrTextureFlags) desc.fFlags; 379 glTexDesc.fFlags = (GrSurfaceFlags) desc.fFlags;
380 glTexDesc.fWidth = desc.fWidth; 380 glTexDesc.fWidth = desc.fWidth;
381 glTexDesc.fHeight = desc.fHeight; 381 glTexDesc.fHeight = desc.fHeight;
382 glTexDesc.fConfig = desc.fConfig; 382 glTexDesc.fConfig = desc.fConfig;
383 glTexDesc.fSampleCnt = desc.fSampleCnt; 383 glTexDesc.fSampleCnt = desc.fSampleCnt;
384 glTexDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); 384 glTexDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle);
385 glTexDesc.fIsWrapped = true; 385 glTexDesc.fIsWrapped = true;
386 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla g); 386 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla g);
387 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly 387 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly
388 // assuming the old behaviour, which is that backend textures are always 388 // assuming the old behaviour, which is that backend textures are always
389 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: 389 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to:
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 *data = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>(*data) + 523 *data = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>(*data) +
524 (subRect.fTop - *top) * *rowBytes + (subRect.fLeft - *left) * bpp); 524 (subRect.fTop - *top) * *rowBytes + (subRect.fLeft - *left) * bpp);
525 525
526 *left = subRect.fLeft; 526 *left = subRect.fLeft;
527 *top = subRect.fTop; 527 *top = subRect.fTop;
528 *width = subRect.width(); 528 *width = subRect.width();
529 *height = subRect.height(); 529 *height = subRect.height();
530 return true; 530 return true;
531 } 531 }
532 532
533 GrGLenum check_alloc_error(const GrTextureDesc& desc, const GrGLInterface* inter face) { 533 GrGLenum check_alloc_error(const GrSurfaceDesc& desc, const GrGLInterface* inter face) {
534 if (SkToBool(desc.fFlags & kCheckAllocation_GrTextureFlagBit)) { 534 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) {
535 return GR_GL_GET_ERROR(interface); 535 return GR_GL_GET_ERROR(interface);
536 } else { 536 } else {
537 return CHECK_ALLOC_ERROR(interface); 537 return CHECK_ALLOC_ERROR(interface);
538 } 538 }
539 } 539 }
540 540
541 } 541 }
542 542
543 bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, 543 bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc,
544 bool isNewTexture, 544 bool isNewTexture,
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // SkDEBUGFAIL("null texture"); 934 // SkDEBUGFAIL("null texture");
935 return NULL; 935 return NULL;
936 } 936 }
937 937
938 #if 0 && defined(SK_DEBUG) 938 #if 0 && defined(SK_DEBUG)
939 static size_t as_size_t(int x) { 939 static size_t as_size_t(int x) {
940 return x; 940 return x;
941 } 941 }
942 #endif 942 #endif
943 943
944 GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, 944 GrTexture* GrGpuGL::onCreateTexture(const GrSurfaceDesc& desc,
945 const void* srcData, 945 const void* srcData,
946 size_t rowBytes) { 946 size_t rowBytes) {
947 947
948 GrGLTexture::Desc glTexDesc; 948 GrGLTexture::Desc glTexDesc;
949 GrGLRenderTarget::Desc glRTDesc; 949 GrGLRenderTarget::Desc glRTDesc;
950 950
951 // Attempt to catch un- or wrongly initialized sample counts; 951 // Attempt to catch un- or wrongly initialized sample counts;
952 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); 952 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64);
953 // We fail if the MSAA was requested and is not available. 953 // We fail if the MSAA was requested and is not available.
954 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) { 954 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) {
955 //GrPrintf("MSAA RT requested but not supported on this platform."); 955 //GrPrintf("MSAA RT requested but not supported on this platform.");
956 return return_null_texture(); 956 return return_null_texture();
957 } 957 }
958 // If the sample count exceeds the max then we clamp it. 958 // If the sample count exceeds the max then we clamp it.
959 glTexDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount( )); 959 glTexDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount( ));
960 960
961 glTexDesc.fFlags = desc.fFlags; 961 glTexDesc.fFlags = desc.fFlags;
962 glTexDesc.fWidth = desc.fWidth; 962 glTexDesc.fWidth = desc.fWidth;
963 glTexDesc.fHeight = desc.fHeight; 963 glTexDesc.fHeight = desc.fHeight;
964 glTexDesc.fConfig = desc.fConfig; 964 glTexDesc.fConfig = desc.fConfig;
965 glTexDesc.fIsWrapped = false; 965 glTexDesc.fIsWrapped = false;
966 966
967 glRTDesc.fMSColorRenderbufferID = 0; 967 glRTDesc.fMSColorRenderbufferID = 0;
968 glRTDesc.fRTFBOID = 0; 968 glRTDesc.fRTFBOID = 0;
969 glRTDesc.fTexFBOID = 0; 969 glRTDesc.fTexFBOID = 0;
970 glRTDesc.fIsWrapped = false; 970 glRTDesc.fIsWrapped = false;
971 glRTDesc.fConfig = glTexDesc.fConfig; 971 glRTDesc.fConfig = glTexDesc.fConfig;
972 glRTDesc.fCheckAllocation = SkToBool(desc.fFlags & kCheckAllocation_GrTextur eFlagBit); 972 glRTDesc.fCheckAllocation = SkToBool(desc.fFlags & kCheckAllocation_GrSurfac eFlag);
973 973
974 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrTextureFlagBit); 974 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
975 975
976 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); 976 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
977 glRTDesc.fOrigin = glTexDesc.fOrigin; 977 glRTDesc.fOrigin = glTexDesc.fOrigin;
978 978
979 glRTDesc.fSampleCnt = glTexDesc.fSampleCnt; 979 glRTDesc.fSampleCnt = glTexDesc.fSampleCnt;
980 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && 980 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() &&
981 desc.fSampleCnt) { 981 desc.fSampleCnt) {
982 //GrPrintf("MSAA RT requested but not supported on this platform."); 982 //GrPrintf("MSAA RT requested but not supported on this platform.");
983 return return_null_texture(); 983 return return_null_texture();
984 } 984 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); 1057 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc));
1058 } 1058 }
1059 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); 1059 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
1060 #ifdef TRACE_TEXTURE_CREATION 1060 #ifdef TRACE_TEXTURE_CREATION
1061 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n", 1061 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n",
1062 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); 1062 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig);
1063 #endif 1063 #endif
1064 return tex; 1064 return tex;
1065 } 1065 }
1066 1066
1067 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrTextureDesc& desc, 1067 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrSurfaceDesc& desc,
1068 const void* srcData) { 1068 const void* srcData) {
1069 1069
1070 if(SkToBool(desc.fFlags & kRenderTarget_GrTextureFlagBit)) { 1070 if(SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) {
1071 return return_null_texture(); 1071 return return_null_texture();
1072 } 1072 }
1073 1073
1074 // Make sure that we're not flipping Y. 1074 // Make sure that we're not flipping Y.
1075 GrSurfaceOrigin texOrigin = resolve_origin(desc.fOrigin, false); 1075 GrSurfaceOrigin texOrigin = resolve_origin(desc.fOrigin, false);
1076 if (kBottomLeft_GrSurfaceOrigin == texOrigin) { 1076 if (kBottomLeft_GrSurfaceOrigin == texOrigin) {
1077 return return_null_texture(); 1077 return return_null_texture();
1078 } 1078 }
1079 1079
1080 GrGLTexture::Desc glTexDesc; 1080 GrGLTexture::Desc glTexDesc;
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 viewport->fHeight = surface->height(); 2404 viewport->fHeight = surface->height();
2405 } else { 2405 } else {
2406 tempFBOID = 0; 2406 tempFBOID = 0;
2407 fGPUStats.incRenderTargetBinds(); 2407 fGPUStats.incRenderTargetBinds();
2408 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID())); 2408 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID()));
2409 *viewport = rt->getViewport(); 2409 *viewport = rt->getViewport();
2410 } 2410 }
2411 return tempFBOID; 2411 return tempFBOID;
2412 } 2412 }
2413 2413
2414 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc) { 2414 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
2415 // Check for format issues with glCopyTexSubImage2D 2415 // Check for format issues with glCopyTexSubImage2D
2416 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() && 2416 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() &&
2417 kBGRA_8888_GrPixelConfig == src->config()) { 2417 kBGRA_8888_GrPixelConfig == src->config()) {
2418 // glCopyTexSubImage2D doesn't work with this config. We'll want to make it a render target 2418 // glCopyTexSubImage2D doesn't work with this config. We'll want to make it a render target
2419 // in order to call glBlitFramebuffer or to copy to it by rendering. 2419 // in order to call glBlitFramebuffer or to copy to it by rendering.
2420 INHERITED::initCopySurfaceDstDesc(src, desc); 2420 INHERITED::initCopySurfaceDstDesc(src, desc);
2421 return; 2421 return;
2422 } else if (NULL == src->asRenderTarget()) { 2422 } else if (NULL == src->asRenderTarget()) {
2423 // We don't want to have to create an FBO just to use glCopyTexSubImage2 D. Let the base 2423 // We don't want to have to create an FBO just to use glCopyTexSubImage2 D. Let the base
2424 // class handle it by rendering. 2424 // class handle it by rendering.
2425 INHERITED::initCopySurfaceDstDesc(src, desc); 2425 INHERITED::initCopySurfaceDstDesc(src, desc);
2426 return; 2426 return;
2427 } 2427 }
2428 2428
2429 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2429 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget());
2430 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { 2430 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
2431 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. 2431 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer.
2432 INHERITED::initCopySurfaceDstDesc(src, desc); 2432 INHERITED::initCopySurfaceDstDesc(src, desc);
2433 } else { 2433 } else {
2434 desc->fConfig = src->config(); 2434 desc->fConfig = src->config();
2435 desc->fOrigin = src->origin(); 2435 desc->fOrigin = src->origin();
2436 desc->fFlags = kNone_GrTextureFlags; 2436 desc->fFlags = kNone_GrSurfaceFlags;
2437 } 2437 }
2438 } 2438 }
2439 2439
2440 bool GrGpuGL::onCopySurface(GrSurface* dst, 2440 bool GrGpuGL::onCopySurface(GrSurface* dst,
2441 GrSurface* src, 2441 GrSurface* src,
2442 const SkIRect& srcRect, 2442 const SkIRect& srcRect,
2443 const SkIPoint& dstPoint) { 2443 const SkIPoint& dstPoint) {
2444 bool inheritedCouldCopy = INHERITED::onCanCopySurface(dst, src, srcRect, dst Point); 2444 bool inheritedCouldCopy = INHERITED::onCanCopySurface(dst, src, srcRect, dst Point);
2445 bool copied = false; 2445 bool copied = false;
2446 bool wouldNeedTempFBO = false; 2446 bool wouldNeedTempFBO = false;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 this->setVertexArrayID(gpu, 0); 2609 this->setVertexArrayID(gpu, 0);
2610 } 2610 }
2611 int attrCount = gpu->glCaps().maxVertexAttributes(); 2611 int attrCount = gpu->glCaps().maxVertexAttributes();
2612 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2612 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2613 fDefaultVertexArrayAttribState.resize(attrCount); 2613 fDefaultVertexArrayAttribState.resize(attrCount);
2614 } 2614 }
2615 attribState = &fDefaultVertexArrayAttribState; 2615 attribState = &fDefaultVertexArrayAttribState;
2616 } 2616 }
2617 return attribState; 2617 return attribState;
2618 } 2618 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698