| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 if (0 == desc.fTextureHandle) { | 368 if (0 == desc.fTextureHandle) { |
| 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::IDDesc idDesc; |
| 378 GrSurfaceDesc surfDesc; |
| 379 |
| 380 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); |
| 381 idDesc.fIsWrapped = true; |
| 382 |
| 378 // next line relies on GrBackendTextureDesc's flags matching GrTexture's | 383 // next line relies on GrBackendTextureDesc's flags matching GrTexture's |
| 379 glTexDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | 384 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; |
| 380 glTexDesc.fWidth = desc.fWidth; | 385 surfDesc.fWidth = desc.fWidth; |
| 381 glTexDesc.fHeight = desc.fHeight; | 386 surfDesc.fHeight = desc.fHeight; |
| 382 glTexDesc.fConfig = desc.fConfig; | 387 surfDesc.fConfig = desc.fConfig; |
| 383 glTexDesc.fSampleCnt = desc.fSampleCnt; | 388 surfDesc.fSampleCnt = desc.fSampleCnt; |
| 384 glTexDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); | |
| 385 glTexDesc.fIsWrapped = true; | |
| 386 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); | 389 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); |
| 387 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly | 390 // 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 | 391 // 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: | 392 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: |
| 390 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 393 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
| 391 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { | 394 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { |
| 392 glTexDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 395 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 393 } else { | 396 } else { |
| 394 glTexDesc.fOrigin = desc.fOrigin; | 397 surfDesc.fOrigin = desc.fOrigin; |
| 395 } | 398 } |
| 396 | 399 |
| 397 GrGLTexture* texture = NULL; | 400 GrGLTexture* texture = NULL; |
| 398 if (renderTarget) { | 401 if (renderTarget) { |
| 399 GrGLRenderTarget::Desc glRTDesc; | 402 GrGLRenderTarget::IDDesc rtIDDesc; |
| 400 glRTDesc.fRTFBOID = 0; | 403 if (!this->createRenderTargetObjects(surfDesc, idDesc.fTextureID, &rtIDD
esc)) { |
| 401 glRTDesc.fTexFBOID = 0; | |
| 402 glRTDesc.fMSColorRenderbufferID = 0; | |
| 403 glRTDesc.fConfig = desc.fConfig; | |
| 404 glRTDesc.fSampleCnt = desc.fSampleCnt; | |
| 405 glRTDesc.fOrigin = glTexDesc.fOrigin; | |
| 406 glRTDesc.fCheckAllocation = false; | |
| 407 if (!this->createRenderTargetObjects(glTexDesc.fWidth, | |
| 408 glTexDesc.fHeight, | |
| 409 glTexDesc.fTextureID, | |
| 410 &glRTDesc)) { | |
| 411 return NULL; | 404 return NULL; |
| 412 } | 405 } |
| 413 texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc, glRTDesc)); | 406 texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc, rtIDDesc)); |
| 414 } else { | 407 } else { |
| 415 texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); | 408 texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc)); |
| 416 } | 409 } |
| 417 if (NULL == texture) { | 410 if (NULL == texture) { |
| 418 return NULL; | 411 return NULL; |
| 419 } | 412 } |
| 420 | 413 |
| 421 return texture; | 414 return texture; |
| 422 } | 415 } |
| 423 | 416 |
| 424 GrRenderTarget* GrGpuGL::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& desc) { | 417 GrRenderTarget* GrGpuGL::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc) { |
| 425 GrGLRenderTarget::Desc glDesc; | 418 GrGLRenderTarget::IDDesc idDesc; |
| 426 glDesc.fConfig = desc.fConfig; | 419 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
| 427 glDesc.fRTFBOID = static_cast<GrGLuint>(desc.fRenderTargetHandle); | 420 idDesc.fMSColorRenderbufferID = 0; |
| 428 glDesc.fMSColorRenderbufferID = 0; | 421 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; |
| 429 glDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | |
| 430 glDesc.fSampleCnt = desc.fSampleCnt; | |
| 431 glDesc.fIsWrapped = true; | |
| 432 glDesc.fCheckAllocation = false; | |
| 433 | 422 |
| 434 glDesc.fOrigin = resolve_origin(desc.fOrigin, true); | 423 GrSurfaceDesc desc; |
| 424 desc.fConfig = wrapDesc.fConfig; |
| 425 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
| 426 desc.fWidth = wrapDesc.fWidth; |
| 427 desc.fHeight = wrapDesc.fHeight; |
| 428 desc.fSampleCnt = wrapDesc.fSampleCnt; |
| 429 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
| 430 |
| 435 GrGLIRect viewport; | 431 GrGLIRect viewport; |
| 436 viewport.fLeft = 0; | 432 viewport.fLeft = 0; |
| 437 viewport.fBottom = 0; | 433 viewport.fBottom = 0; |
| 438 viewport.fWidth = desc.fWidth; | 434 viewport.fWidth = desc.fWidth; |
| 439 viewport.fHeight = desc.fHeight; | 435 viewport.fHeight = desc.fHeight; |
| 440 | 436 |
| 441 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, | 437 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc, view
port)); |
| 442 (this, glDesc, viewport)); | 438 if (wrapDesc.fStencilBits) { |
| 443 if (desc.fStencilBits) { | |
| 444 GrGLStencilBuffer::Format format; | 439 GrGLStencilBuffer::Format format; |
| 445 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat; | 440 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat; |
| 446 format.fPacked = false; | 441 format.fPacked = false; |
| 447 format.fStencilBits = desc.fStencilBits; | 442 format.fStencilBits = wrapDesc.fStencilBits; |
| 448 format.fTotalBits = desc.fStencilBits; | 443 format.fTotalBits = wrapDesc.fStencilBits; |
| 449 static const bool kIsSBWrapped = false; | 444 static const bool kIsSBWrapped = false; |
| 450 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer, | 445 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer, |
| 451 (this, | 446 (this, |
| 452 kIsSBWrapped, | 447 kIsSBWrapped, |
| 453 0, | 448 0, |
| 454 desc.fWidth, | 449 desc.fWidth, |
| 455 desc.fHeight, | 450 desc.fHeight, |
| 456 desc.fSampleCnt, | 451 desc.fSampleCnt, |
| 457 format)); | 452 format)); |
| 458 tgt->setStencilBuffer(sb); | 453 tgt->setStencilBuffer(sb); |
| 459 sb->unref(); | 454 sb->unref(); |
| 460 } | 455 } |
| 461 return tgt; | 456 return tgt; |
| 462 } | 457 } |
| 463 | 458 |
| 464 //////////////////////////////////////////////////////////////////////////////// | 459 //////////////////////////////////////////////////////////////////////////////// |
| 465 | 460 |
| 466 bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, | 461 bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, |
| 467 int left, int top, int width, int height, | 462 int left, int top, int width, int height, |
| 468 GrPixelConfig config, const void* buffer, | 463 GrPixelConfig config, const void* buffer, |
| 469 size_t rowBytes) { | 464 size_t rowBytes) { |
| 470 if (NULL == buffer) { | 465 if (NULL == buffer) { |
| 471 return false; | 466 return false; |
| 472 } | 467 } |
| 473 GrGLTexture* glTex = static_cast<GrGLTexture*>(texture); | 468 GrGLTexture* glTex = static_cast<GrGLTexture*>(texture); |
| 474 | 469 |
| 475 this->setScratchTextureUnit(); | 470 this->setScratchTextureUnit(); |
| 476 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTex->textureID())); | 471 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTex->textureID())); |
| 477 GrGLTexture::Desc desc; | |
| 478 desc.fFlags = glTex->desc().fFlags; | |
| 479 desc.fWidth = glTex->width(); | |
| 480 desc.fHeight = glTex->height(); | |
| 481 desc.fConfig = glTex->config(); | |
| 482 desc.fSampleCnt = glTex->desc().fSampleCnt; | |
| 483 desc.fTextureID = glTex->textureID(); | |
| 484 desc.fOrigin = glTex->origin(); | |
| 485 | 472 |
| 486 bool success = false; | 473 bool success = false; |
| 487 if (GrPixelConfigIsCompressed(desc.fConfig)) { | 474 if (GrPixelConfigIsCompressed(glTex->desc().fConfig)) { |
| 488 // We check that config == desc.fConfig in GrGpuGL::canWriteTexturePixel
s() | 475 // We check that config == desc.fConfig in GrGpuGL::canWriteTexturePixel
s() |
| 489 SkASSERT(config == desc.fConfig); | 476 SkASSERT(config == glTex->desc().fConfig); |
| 490 success = this->uploadCompressedTexData(desc, buffer, false, | 477 success = this->uploadCompressedTexData(glTex->desc(), buffer, false, le
ft, top, width, |
| 491 left, top, width, height); | 478 height); |
| 492 } else { | 479 } else { |
| 493 success = this->uploadTexData(desc, false, | 480 success = this->uploadTexData(glTex->desc(), false, left, top, width, he
ight, config, |
| 494 left, top, width, height, | 481 buffer, rowBytes); |
| 495 config, buffer, rowBytes); | |
| 496 } | 482 } |
| 497 | 483 |
| 498 if (success) { | 484 if (success) { |
| 499 texture->texturePriv().dirtyMipMaps(true); | 485 texture->texturePriv().dirtyMipMaps(true); |
| 500 return true; | 486 return true; |
| 501 } | 487 } |
| 502 | 488 |
| 503 return false; | 489 return false; |
| 504 } | 490 } |
| 505 | 491 |
| 506 namespace { | 492 static bool adjust_pixel_ops_params(int surfaceWidth, |
| 507 bool adjust_pixel_ops_params(int surfaceWidth, | 493 int surfaceHeight, |
| 508 int surfaceHeight, | 494 size_t bpp, |
| 509 size_t bpp, | 495 int* left, int* top, int* width, int* height
, |
| 510 int* left, int* top, int* width, int* height, | 496 const void** data, |
| 511 const void** data, | 497 size_t* rowBytes) { |
| 512 size_t* rowBytes) { | |
| 513 if (!*rowBytes) { | 498 if (!*rowBytes) { |
| 514 *rowBytes = *width * bpp; | 499 *rowBytes = *width * bpp; |
| 515 } | 500 } |
| 516 | 501 |
| 517 SkIRect subRect = SkIRect::MakeXYWH(*left, *top, *width, *height); | 502 SkIRect subRect = SkIRect::MakeXYWH(*left, *top, *width, *height); |
| 518 SkIRect bounds = SkIRect::MakeWH(surfaceWidth, surfaceHeight); | 503 SkIRect bounds = SkIRect::MakeWH(surfaceWidth, surfaceHeight); |
| 519 | 504 |
| 520 if (!subRect.intersect(bounds)) { | 505 if (!subRect.intersect(bounds)) { |
| 521 return false; | 506 return false; |
| 522 } | 507 } |
| 523 *data = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>(*data) + | 508 *data = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>(*data) + |
| 524 (subRect.fTop - *top) * *rowBytes + (subRect.fLeft - *left) * bpp); | 509 (subRect.fTop - *top) * *rowBytes + (subRect.fLeft - *left) * bpp); |
| 525 | 510 |
| 526 *left = subRect.fLeft; | 511 *left = subRect.fLeft; |
| 527 *top = subRect.fTop; | 512 *top = subRect.fTop; |
| 528 *width = subRect.width(); | 513 *width = subRect.width(); |
| 529 *height = subRect.height(); | 514 *height = subRect.height(); |
| 530 return true; | 515 return true; |
| 531 } | 516 } |
| 532 | 517 |
| 533 GrGLenum check_alloc_error(const GrSurfaceDesc& desc, const GrGLInterface* inter
face) { | 518 static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc, |
| 519 const GrGLInterface* interface) { |
| 534 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) { | 520 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) { |
| 535 return GR_GL_GET_ERROR(interface); | 521 return GR_GL_GET_ERROR(interface); |
| 536 } else { | 522 } else { |
| 537 return CHECK_ALLOC_ERROR(interface); | 523 return CHECK_ALLOC_ERROR(interface); |
| 538 } | 524 } |
| 539 } | 525 } |
| 540 | 526 |
| 541 } | 527 bool GrGpuGL::uploadTexData(const GrSurfaceDesc& desc, |
| 542 | |
| 543 bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, | |
| 544 bool isNewTexture, | 528 bool isNewTexture, |
| 545 int left, int top, int width, int height, | 529 int left, int top, int width, int height, |
| 546 GrPixelConfig dataConfig, | 530 GrPixelConfig dataConfig, |
| 547 const void* data, | 531 const void* data, |
| 548 size_t rowBytes) { | 532 size_t rowBytes) { |
| 549 SkASSERT(data || isNewTexture); | 533 SkASSERT(data || isNewTexture); |
| 550 | 534 |
| 551 // If we're uploading compressed data then we should be using uploadCompress
edTexData | 535 // If we're uploading compressed data then we should be using uploadCompress
edTexData |
| 552 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); | 536 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); |
| 553 | 537 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); | 692 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); |
| 709 } | 693 } |
| 710 return succeeded; | 694 return succeeded; |
| 711 } | 695 } |
| 712 | 696 |
| 713 // TODO: This function is using a lot of wonky semantics like, if width == -1 | 697 // TODO: This function is using a lot of wonky semantics like, if width == -1 |
| 714 // then set width = desc.fWdith ... blah. A better way to do it might be to | 698 // then set width = desc.fWdith ... blah. A better way to do it might be to |
| 715 // create a CompressedTexData struct that takes a desc/ptr and figures out | 699 // create a CompressedTexData struct that takes a desc/ptr and figures out |
| 716 // the proper upload semantics. Then users can construct this function how they | 700 // the proper upload semantics. Then users can construct this function how they |
| 717 // see fit if they want to go against the "standard" way to do it. | 701 // see fit if they want to go against the "standard" way to do it. |
| 718 bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, | 702 bool GrGpuGL::uploadCompressedTexData(const GrSurfaceDesc& desc, |
| 719 const void* data, | 703 const void* data, |
| 720 bool isNewTexture, | 704 bool isNewTexture, |
| 721 int left, int top, int width, int height)
{ | 705 int left, int top, int width, int height)
{ |
| 722 SkASSERT(data || isNewTexture); | 706 SkASSERT(data || isNewTexture); |
| 723 | 707 |
| 724 // No support for software flip y, yet... | 708 // No support for software flip y, yet... |
| 725 SkASSERT(kBottomLeft_GrSurfaceOrigin != desc.fOrigin); | 709 SkASSERT(kBottomLeft_GrSurfaceOrigin != desc.fOrigin); |
| 726 | 710 |
| 727 if (-1 == width) { | 711 if (-1 == width) { |
| 728 width = desc.fWidth; | 712 width = desc.fWidth; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 format, | 798 format, |
| 815 width, height)); | 799 width, height)); |
| 816 break; | 800 break; |
| 817 case GrGLCaps::kNone_MSFBOType: | 801 case GrGLCaps::kNone_MSFBOType: |
| 818 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf
fers."); | 802 SkFAIL("Shouldn't be here if we don't support multisampled renderbuf
fers."); |
| 819 break; | 803 break; |
| 820 } | 804 } |
| 821 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; | 805 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; |
| 822 } | 806 } |
| 823 | 807 |
| 824 bool GrGpuGL::createRenderTargetObjects(int width, int height, | 808 bool GrGpuGL::createRenderTargetObjects(const GrSurfaceDesc& desc, GrGLuint texI
D, |
| 825 GrGLuint texID, | 809 GrGLRenderTarget::IDDesc* idDesc) { |
| 826 GrGLRenderTarget::Desc* desc) { | 810 idDesc->fMSColorRenderbufferID = 0; |
| 827 desc->fMSColorRenderbufferID = 0; | 811 idDesc->fRTFBOID = 0; |
| 828 desc->fRTFBOID = 0; | 812 idDesc->fTexFBOID = 0; |
| 829 desc->fTexFBOID = 0; | 813 idDesc->fIsWrapped = false; |
| 830 desc->fIsWrapped = false; | |
| 831 | 814 |
| 832 GrGLenum status; | 815 GrGLenum status; |
| 833 | 816 |
| 834 GrGLenum msColorFormat = 0; // suppress warning | 817 GrGLenum msColorFormat = 0; // suppress warning |
| 835 | 818 |
| 836 if (desc->fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFB
OType()) { | 819 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO
Type()) { |
| 837 goto FAILED; | 820 goto FAILED; |
| 838 } | 821 } |
| 839 | 822 |
| 840 GL_CALL(GenFramebuffers(1, &desc->fTexFBOID)); | 823 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
| 841 if (!desc->fTexFBOID) { | 824 if (!idDesc->fTexFBOID) { |
| 842 goto FAILED; | 825 goto FAILED; |
| 843 } | 826 } |
| 844 | 827 |
| 845 | 828 |
| 846 // If we are using multisampling we will create two FBOS. We render to one a
nd then resolve to | 829 // If we are using multisampling we will create two FBOS. We render to one a
nd then resolve to |
| 847 // the texture bound to the other. The exception is the IMG multisample exte
nsion. With this | 830 // the texture bound to the other. The exception is the IMG multisample exte
nsion. With this |
| 848 // extension the texture is multisampled when rendered to and then auto-reso
lves it when it is | 831 // extension the texture is multisampled when rendered to and then auto-reso
lves it when it is |
| 849 // rendered from. | 832 // rendered from. |
| 850 if (desc->fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) { | 833 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) { |
| 851 GL_CALL(GenFramebuffers(1, &desc->fRTFBOID)); | 834 GL_CALL(GenFramebuffers(1, &idDesc->fRTFBOID)); |
| 852 GL_CALL(GenRenderbuffers(1, &desc->fMSColorRenderbufferID)); | 835 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID)); |
| 853 if (!desc->fRTFBOID || | 836 if (!idDesc->fRTFBOID || |
| 854 !desc->fMSColorRenderbufferID || | 837 !idDesc->fMSColorRenderbufferID || |
| 855 !this->configToGLFormats(desc->fConfig, | 838 !this->configToGLFormats(desc.fConfig, |
| 856 // ES2 and ES3 require sized internal forma
ts for rb storage. | 839 // ES2 and ES3 require sized internal forma
ts for rb storage. |
| 857 kGLES_GrGLStandard == this->glStandard(), | 840 kGLES_GrGLStandard == this->glStandard(), |
| 858 &msColorFormat, | 841 &msColorFormat, |
| 859 NULL, | 842 NULL, |
| 860 NULL)) { | 843 NULL)) { |
| 861 goto FAILED; | 844 goto FAILED; |
| 862 } | 845 } |
| 863 } else { | 846 } else { |
| 864 desc->fRTFBOID = desc->fTexFBOID; | 847 idDesc->fRTFBOID = idDesc->fTexFBOID; |
| 865 } | 848 } |
| 866 | 849 |
| 867 // below here we may bind the FBO | 850 // below here we may bind the FBO |
| 868 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 851 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 869 if (desc->fRTFBOID != desc->fTexFBOID) { | 852 if (idDesc->fRTFBOID != idDesc->fTexFBOID) { |
| 870 SkASSERT(desc->fSampleCnt > 0); | 853 SkASSERT(desc.fSampleCnt > 0); |
| 871 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, | 854 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, idDesc->fMSColorRenderbuffe
rID)); |
| 872 desc->fMSColorRenderbufferID)); | |
| 873 if (!renderbuffer_storage_msaa(fGLContext, | 855 if (!renderbuffer_storage_msaa(fGLContext, |
| 874 desc->fSampleCnt, | 856 desc.fSampleCnt, |
| 875 msColorFormat, | 857 msColorFormat, |
| 876 width, height)) { | 858 desc.fWidth, desc.fHeight)) { |
| 877 goto FAILED; | 859 goto FAILED; |
| 878 } | 860 } |
| 879 fGPUStats.incRenderTargetBinds(); | 861 fGPUStats.incRenderTargetBinds(); |
| 880 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fRTFBOID)); | 862 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fRTFBOID)); |
| 881 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 863 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
| 882 GR_GL_COLOR_ATTACHMENT0, | 864 GR_GL_COLOR_ATTACHMENT0, |
| 883 GR_GL_RENDERBUFFER, | 865 GR_GL_RENDERBUFFER, |
| 884 desc->fMSColorRenderbufferID)); | 866 idDesc->fMSColorRenderbufferID)); |
| 885 if (desc->fCheckAllocation || | 867 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) || |
| 886 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { | 868 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) { |
| 887 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 869 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
| 888 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 870 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
| 889 goto FAILED; | 871 goto FAILED; |
| 890 } | 872 } |
| 891 fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig); | 873 fGLContext.caps()->markConfigAsValidColorAttachment(desc.fConfig); |
| 892 } | 874 } |
| 893 } | 875 } |
| 894 fGPUStats.incRenderTargetBinds(); | 876 fGPUStats.incRenderTargetBinds(); |
| 895 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID)); | 877 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fTexFBOID)); |
| 896 | 878 |
| 897 if (this->glCaps().usesImplicitMSAAResolve() && desc->fSampleCnt > 0) { | 879 if (this->glCaps().usesImplicitMSAAResolve() && desc.fSampleCnt > 0) { |
| 898 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, | 880 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, |
| 899 GR_GL_COLOR_ATTACHMENT0, | 881 GR_GL_COLOR_ATTACHMENT0, |
| 900 GR_GL_TEXTURE_2D, | 882 GR_GL_TEXTURE_2D, |
| 901 texID, 0, desc->fSampleCnt)); | 883 texID, 0, desc.fSampleCnt)); |
| 902 } else { | 884 } else { |
| 903 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, | 885 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, |
| 904 GR_GL_COLOR_ATTACHMENT0, | 886 GR_GL_COLOR_ATTACHMENT0, |
| 905 GR_GL_TEXTURE_2D, | 887 GR_GL_TEXTURE_2D, |
| 906 texID, 0)); | 888 texID, 0)); |
| 907 } | 889 } |
| 908 if (desc->fCheckAllocation || | 890 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) || |
| 909 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { | 891 !this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) { |
| 910 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 892 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
| 911 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 893 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
| 912 goto FAILED; | 894 goto FAILED; |
| 913 } | 895 } |
| 914 fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig); | 896 fGLContext.caps()->markConfigAsValidColorAttachment(desc.fConfig); |
| 915 } | 897 } |
| 916 | 898 |
| 917 return true; | 899 return true; |
| 918 | 900 |
| 919 FAILED: | 901 FAILED: |
| 920 if (desc->fMSColorRenderbufferID) { | 902 if (idDesc->fMSColorRenderbufferID) { |
| 921 GL_CALL(DeleteRenderbuffers(1, &desc->fMSColorRenderbufferID)); | 903 GL_CALL(DeleteRenderbuffers(1, &idDesc->fMSColorRenderbufferID)); |
| 922 } | 904 } |
| 923 if (desc->fRTFBOID != desc->fTexFBOID) { | 905 if (idDesc->fRTFBOID != idDesc->fTexFBOID) { |
| 924 GL_CALL(DeleteFramebuffers(1, &desc->fRTFBOID)); | 906 GL_CALL(DeleteFramebuffers(1, &idDesc->fRTFBOID)); |
| 925 } | 907 } |
| 926 if (desc->fTexFBOID) { | 908 if (idDesc->fTexFBOID) { |
| 927 GL_CALL(DeleteFramebuffers(1, &desc->fTexFBOID)); | 909 GL_CALL(DeleteFramebuffers(1, &idDesc->fTexFBOID)); |
| 928 } | 910 } |
| 929 return false; | 911 return false; |
| 930 } | 912 } |
| 931 | 913 |
| 932 // good to set a break-point here to know when createTexture fails | 914 // good to set a break-point here to know when createTexture fails |
| 933 static GrTexture* return_null_texture() { | 915 static GrTexture* return_null_texture() { |
| 934 // SkDEBUGFAIL("null texture"); | 916 // SkDEBUGFAIL("null texture"); |
| 935 return NULL; | 917 return NULL; |
| 936 } | 918 } |
| 937 | 919 |
| 938 #if 0 && defined(SK_DEBUG) | 920 #if 0 && defined(SK_DEBUG) |
| 939 static size_t as_size_t(int x) { | 921 static size_t as_size_t(int x) { |
| 940 return x; | 922 return x; |
| 941 } | 923 } |
| 942 #endif | 924 #endif |
| 943 | 925 |
| 944 GrTexture* GrGpuGL::onCreateTexture(const GrSurfaceDesc& desc, | 926 GrTexture* GrGpuGL::onCreateTexture(const GrSurfaceDesc& origDesc, |
| 945 const void* srcData, | 927 const void* srcData, |
| 946 size_t rowBytes) { | 928 size_t rowBytes) { |
| 947 | 929 |
| 948 GrGLTexture::Desc glTexDesc; | 930 GrSurfaceDesc desc = origDesc; |
| 949 GrGLRenderTarget::Desc glRTDesc; | 931 GrGLRenderTarget::IDDesc rtIDDesc; |
| 950 | 932 |
| 951 // Attempt to catch un- or wrongly initialized sample counts; | 933 // Attempt to catch un- or wrongly initialized sample counts; |
| 952 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); | 934 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
| 953 // We fail if the MSAA was requested and is not available. | 935 // We fail if the MSAA was requested and is not available. |
| 954 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { | 936 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
| 955 //GrPrintf("MSAA RT requested but not supported on this platform."); | 937 //GrPrintf("MSAA RT requested but not supported on this platform."); |
| 956 return return_null_texture(); | 938 return return_null_texture(); |
| 957 } | 939 } |
| 958 // If the sample count exceeds the max then we clamp it. | |
| 959 glTexDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount(
)); | |
| 960 | |
| 961 glTexDesc.fFlags = desc.fFlags; | |
| 962 glTexDesc.fWidth = desc.fWidth; | |
| 963 glTexDesc.fHeight = desc.fHeight; | |
| 964 glTexDesc.fConfig = desc.fConfig; | |
| 965 glTexDesc.fIsWrapped = false; | |
| 966 | |
| 967 glRTDesc.fMSColorRenderbufferID = 0; | |
| 968 glRTDesc.fRTFBOID = 0; | |
| 969 glRTDesc.fTexFBOID = 0; | |
| 970 glRTDesc.fIsWrapped = false; | |
| 971 glRTDesc.fConfig = glTexDesc.fConfig; | |
| 972 glRTDesc.fCheckAllocation = SkToBool(desc.fFlags & kCheckAllocation_GrSurfac
eFlag); | |
| 973 | 940 |
| 974 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); | 941 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); |
| 975 | 942 |
| 976 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 943 // If the sample count exceeds the max then we clamp it. |
| 977 glRTDesc.fOrigin = glTexDesc.fOrigin; | 944 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); |
| 945 desc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
| 978 | 946 |
| 979 glRTDesc.fSampleCnt = glTexDesc.fSampleCnt; | 947 rtIDDesc.fMSColorRenderbufferID = 0; |
| 980 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && | 948 rtIDDesc.fRTFBOID = 0; |
| 981 desc.fSampleCnt) { | 949 rtIDDesc.fTexFBOID = 0; |
| 950 rtIDDesc.fIsWrapped = false; |
| 951 |
| 952 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
| 982 //GrPrintf("MSAA RT requested but not supported on this platform."); | 953 //GrPrintf("MSAA RT requested but not supported on this platform."); |
| 983 return return_null_texture(); | 954 return return_null_texture(); |
| 984 } | 955 } |
| 985 | 956 |
| 986 if (renderTarget) { | 957 if (renderTarget) { |
| 987 int maxRTSize = this->caps()->maxRenderTargetSize(); | 958 int maxRTSize = this->caps()->maxRenderTargetSize(); |
| 988 if (glTexDesc.fWidth > maxRTSize || glTexDesc.fHeight > maxRTSize) { | 959 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
| 989 return return_null_texture(); | 960 return return_null_texture(); |
| 990 } | 961 } |
| 991 } else { | 962 } else { |
| 992 int maxSize = this->caps()->maxTextureSize(); | 963 int maxSize = this->caps()->maxTextureSize(); |
| 993 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) { | 964 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 994 return return_null_texture(); | 965 return return_null_texture(); |
| 995 } | 966 } |
| 996 } | 967 } |
| 997 | 968 |
| 998 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); | 969 GrGLTexture::IDDesc idDesc; |
| 970 GL_CALL(GenTextures(1, &idDesc.fTextureID)); |
| 971 idDesc.fIsWrapped = false; |
| 999 | 972 |
| 1000 if (!glTexDesc.fTextureID) { | 973 if (!idDesc.fTextureID) { |
| 1001 return return_null_texture(); | 974 return return_null_texture(); |
| 1002 } | 975 } |
| 1003 | 976 |
| 1004 this->setScratchTextureUnit(); | 977 this->setScratchTextureUnit(); |
| 1005 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); | 978 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, idDesc.fTextureID)); |
| 1006 | 979 |
| 1007 if (renderTarget && this->glCaps().textureUsageSupport()) { | 980 if (renderTarget && this->glCaps().textureUsageSupport()) { |
| 1008 // provides a hint about how this texture will be used | 981 // provides a hint about how this texture will be used |
| 1009 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 982 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1010 GR_GL_TEXTURE_USAGE, | 983 GR_GL_TEXTURE_USAGE, |
| 1011 GR_GL_FRAMEBUFFER_ATTACHMENT)); | 984 GR_GL_FRAMEBUFFER_ATTACHMENT)); |
| 1012 } | 985 } |
| 1013 | 986 |
| 1014 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 987 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
| 1015 // drivers have a bug where an FBO won't be complete if it includes a | 988 // drivers have a bug where an FBO won't be complete if it includes a |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1026 initialTexParams.fMagFilter)); | 999 initialTexParams.fMagFilter)); |
| 1027 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1000 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1028 GR_GL_TEXTURE_MIN_FILTER, | 1001 GR_GL_TEXTURE_MIN_FILTER, |
| 1029 initialTexParams.fMinFilter)); | 1002 initialTexParams.fMinFilter)); |
| 1030 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1003 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1031 GR_GL_TEXTURE_WRAP_S, | 1004 GR_GL_TEXTURE_WRAP_S, |
| 1032 initialTexParams.fWrapS)); | 1005 initialTexParams.fWrapS)); |
| 1033 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1006 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1034 GR_GL_TEXTURE_WRAP_T, | 1007 GR_GL_TEXTURE_WRAP_T, |
| 1035 initialTexParams.fWrapT)); | 1008 initialTexParams.fWrapT)); |
| 1036 if (!this->uploadTexData(glTexDesc, true, 0, 0, | 1009 if (!this->uploadTexData(desc, true, 0, 0, |
| 1037 glTexDesc.fWidth, glTexDesc.fHeight, | 1010 desc.fWidth, desc.fHeight, |
| 1038 desc.fConfig, srcData, rowBytes)) { | 1011 desc.fConfig, srcData, rowBytes)) { |
| 1039 GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID)); | 1012 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
| 1040 return return_null_texture(); | 1013 return return_null_texture(); |
| 1041 } | 1014 } |
| 1042 | 1015 |
| 1043 GrGLTexture* tex; | 1016 GrGLTexture* tex; |
| 1044 if (renderTarget) { | 1017 if (renderTarget) { |
| 1045 // unbind the texture from the texture unit before binding it to the fra
me buffer | 1018 // unbind the texture from the texture unit before binding it to the fra
me buffer |
| 1046 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0)); | 1019 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0)); |
| 1047 | 1020 |
| 1048 if (!this->createRenderTargetObjects(glTexDesc.fWidth, | 1021 if (!this->createRenderTargetObjects(desc, idDesc.fTextureID, &rtIDDesc
)) { |
| 1049 glTexDesc.fHeight, | 1022 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
| 1050 glTexDesc.fTextureID, | |
| 1051 &glRTDesc)) { | |
| 1052 GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID)); | |
| 1053 return return_null_texture(); | 1023 return return_null_texture(); |
| 1054 } | 1024 } |
| 1055 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc, glRTDesc)); | 1025 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc, rtIDDesc)); |
| 1056 } else { | 1026 } else { |
| 1057 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); | 1027 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); |
| 1058 } | 1028 } |
| 1059 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); | 1029 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); |
| 1060 #ifdef TRACE_TEXTURE_CREATION | 1030 #ifdef TRACE_TEXTURE_CREATION |
| 1061 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n", | 1031 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n", |
| 1062 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); | 1032 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); |
| 1063 #endif | 1033 #endif |
| 1064 return tex; | 1034 return tex; |
| 1065 } | 1035 } |
| 1066 | 1036 |
| 1067 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrSurfaceDesc& desc, | 1037 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrSurfaceDesc& origDesc, con
st void* srcData) { |
| 1068 const void* srcData) { | |
| 1069 | 1038 |
| 1070 if(SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) { | 1039 if(SkToBool(origDesc.fFlags & kRenderTarget_GrSurfaceFlag) || origDesc.fSamp
leCnt > 0) { |
| 1071 return return_null_texture(); | 1040 return return_null_texture(); |
| 1072 } | 1041 } |
| 1073 | 1042 |
| 1074 // Make sure that we're not flipping Y. | 1043 // Make sure that we're not flipping Y. |
| 1075 GrSurfaceOrigin texOrigin = resolve_origin(desc.fOrigin, false); | 1044 GrSurfaceOrigin texOrigin = resolve_origin(origDesc.fOrigin, false); |
| 1076 if (kBottomLeft_GrSurfaceOrigin == texOrigin) { | 1045 if (kBottomLeft_GrSurfaceOrigin == texOrigin) { |
| 1077 return return_null_texture(); | 1046 return return_null_texture(); |
| 1078 } | 1047 } |
| 1079 | 1048 GrSurfaceDesc desc = origDesc; |
| 1080 GrGLTexture::Desc glTexDesc; | 1049 desc.fOrigin = texOrigin; |
| 1081 | |
| 1082 glTexDesc.fFlags = desc.fFlags; | |
| 1083 glTexDesc.fWidth = desc.fWidth; | |
| 1084 glTexDesc.fHeight = desc.fHeight; | |
| 1085 glTexDesc.fConfig = desc.fConfig; | |
| 1086 glTexDesc.fIsWrapped = false; | |
| 1087 glTexDesc.fOrigin = texOrigin; | |
| 1088 | 1050 |
| 1089 int maxSize = this->caps()->maxTextureSize(); | 1051 int maxSize = this->caps()->maxTextureSize(); |
| 1090 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) { | 1052 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 1091 return return_null_texture(); | 1053 return return_null_texture(); |
| 1092 } | 1054 } |
| 1093 | 1055 |
| 1094 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); | 1056 GrGLTexture::IDDesc idDesc; |
| 1057 GL_CALL(GenTextures(1, &idDesc.fTextureID)); |
| 1058 idDesc.fIsWrapped = false; |
| 1095 | 1059 |
| 1096 if (!glTexDesc.fTextureID) { | 1060 if (!idDesc.fTextureID) { |
| 1097 return return_null_texture(); | 1061 return return_null_texture(); |
| 1098 } | 1062 } |
| 1099 | 1063 |
| 1100 this->setScratchTextureUnit(); | 1064 this->setScratchTextureUnit(); |
| 1101 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); | 1065 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, idDesc.fTextureID)); |
| 1102 | 1066 |
| 1103 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 1067 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
| 1104 // drivers have a bug where an FBO won't be complete if it includes a | 1068 // drivers have a bug where an FBO won't be complete if it includes a |
| 1105 // texture that is not mipmap complete (considering the filter in use). | 1069 // texture that is not mipmap complete (considering the filter in use). |
| 1106 GrGLTexture::TexParams initialTexParams; | 1070 GrGLTexture::TexParams initialTexParams; |
| 1107 // we only set a subset here so invalidate first | 1071 // we only set a subset here so invalidate first |
| 1108 initialTexParams.invalidate(); | 1072 initialTexParams.invalidate(); |
| 1109 initialTexParams.fMinFilter = GR_GL_NEAREST; | 1073 initialTexParams.fMinFilter = GR_GL_NEAREST; |
| 1110 initialTexParams.fMagFilter = GR_GL_NEAREST; | 1074 initialTexParams.fMagFilter = GR_GL_NEAREST; |
| 1111 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; | 1075 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; |
| 1112 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; | 1076 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; |
| 1113 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1077 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1114 GR_GL_TEXTURE_MAG_FILTER, | 1078 GR_GL_TEXTURE_MAG_FILTER, |
| 1115 initialTexParams.fMagFilter)); | 1079 initialTexParams.fMagFilter)); |
| 1116 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1080 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1117 GR_GL_TEXTURE_MIN_FILTER, | 1081 GR_GL_TEXTURE_MIN_FILTER, |
| 1118 initialTexParams.fMinFilter)); | 1082 initialTexParams.fMinFilter)); |
| 1119 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1083 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1120 GR_GL_TEXTURE_WRAP_S, | 1084 GR_GL_TEXTURE_WRAP_S, |
| 1121 initialTexParams.fWrapS)); | 1085 initialTexParams.fWrapS)); |
| 1122 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 1086 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 1123 GR_GL_TEXTURE_WRAP_T, | 1087 GR_GL_TEXTURE_WRAP_T, |
| 1124 initialTexParams.fWrapT)); | 1088 initialTexParams.fWrapT)); |
| 1125 | 1089 |
| 1126 if (!this->uploadCompressedTexData(glTexDesc, srcData)) { | 1090 if (!this->uploadCompressedTexData(desc, srcData)) { |
| 1127 GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID)); | 1091 GL_CALL(DeleteTextures(1, &idDesc.fTextureID)); |
| 1128 return return_null_texture(); | 1092 return return_null_texture(); |
| 1129 } | 1093 } |
| 1130 | 1094 |
| 1131 GrGLTexture* tex; | 1095 GrGLTexture* tex; |
| 1132 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); | 1096 tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc)); |
| 1133 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); | 1097 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); |
| 1134 #ifdef TRACE_TEXTURE_CREATION | 1098 #ifdef TRACE_TEXTURE_CREATION |
| 1135 GrPrintf("--- new compressed texture [%d] size=(%d %d) config=%d\n", | 1099 GrPrintf("--- new compressed texture [%d] size=(%d %d) config=%d\n", |
| 1136 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); | 1100 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); |
| 1137 #endif | 1101 #endif |
| 1138 return tex; | 1102 return tex; |
| 1139 } | 1103 } |
| 1140 | 1104 |
| 1141 namespace { | 1105 namespace { |
| 1142 | 1106 |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 this->setVertexArrayID(gpu, 0); | 2574 this->setVertexArrayID(gpu, 0); |
| 2611 } | 2575 } |
| 2612 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2576 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2613 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2577 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2614 fDefaultVertexArrayAttribState.resize(attrCount); | 2578 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2615 } | 2579 } |
| 2616 attribState = &fDefaultVertexArrayAttribState; | 2580 attribState = &fDefaultVertexArrayAttribState; |
| 2617 } | 2581 } |
| 2618 return attribState; | 2582 return attribState; |
| 2619 } | 2583 } |
| OLD | NEW |