| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 // By default, GrRenderTargets are GL's normal orientation so that they | 445 // By default, GrRenderTargets are GL's normal orientation so that they |
| 446 // can be drawn to by the outside world without the client having | 446 // can be drawn to by the outside world without the client having |
| 447 // to render upside down. | 447 // to render upside down. |
| 448 if (kDefault_GrSurfaceOrigin == origin) { | 448 if (kDefault_GrSurfaceOrigin == origin) { |
| 449 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr
igin; | 449 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr
igin; |
| 450 } else { | 450 } else { |
| 451 return origin; | 451 return origin; |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 | 454 |
| 455 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc) { | 455 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, |
| 456 GrWrapOwnership ownership) { |
| 456 if (!this->configToGLFormats(desc.fConfig, false, NULL, NULL, NULL)) { | 457 if (!this->configToGLFormats(desc.fConfig, false, NULL, NULL, NULL)) { |
| 457 return NULL; | 458 return NULL; |
| 458 } | 459 } |
| 459 | 460 |
| 460 if (0 == desc.fTextureHandle) { | 461 if (0 == desc.fTextureHandle) { |
| 461 return NULL; | 462 return NULL; |
| 462 } | 463 } |
| 463 | 464 |
| 464 int maxSize = this->caps()->maxTextureSize(); | 465 int maxSize = this->caps()->maxTextureSize(); |
| 465 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 466 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 466 return NULL; | 467 return NULL; |
| 467 } | 468 } |
| 468 | 469 |
| 469 GrGLTexture::IDDesc idDesc; | 470 GrGLTexture::IDDesc idDesc; |
| 470 GrSurfaceDesc surfDesc; | 471 GrSurfaceDesc surfDesc; |
| 471 | 472 |
| 472 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); | 473 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); |
| 473 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 474 |
| 475 switch (ownership) { |
| 476 case kAdopt_GrWrapOwnership: |
| 477 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; |
| 478 break; |
| 479 case kBorrow_GrWrapOwnership: |
| 480 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; |
| 481 break; |
| 482 } |
| 474 | 483 |
| 475 // next line relies on GrBackendTextureDesc's flags matching GrTexture's | 484 // next line relies on GrBackendTextureDesc's flags matching GrTexture's |
| 476 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | 485 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; |
| 477 surfDesc.fWidth = desc.fWidth; | 486 surfDesc.fWidth = desc.fWidth; |
| 478 surfDesc.fHeight = desc.fHeight; | 487 surfDesc.fHeight = desc.fHeight; |
| 479 surfDesc.fConfig = desc.fConfig; | 488 surfDesc.fConfig = desc.fConfig; |
| 480 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); | 489 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); |
| 481 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); | 490 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); |
| 482 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly | 491 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly |
| 483 // assuming the old behaviour, which is that backend textures are always | 492 // assuming the old behaviour, which is that backend textures are always |
| (...skipping 16 matching lines...) Expand all Loading... |
| 500 } else { | 509 } else { |
| 501 texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc)); | 510 texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc)); |
| 502 } | 511 } |
| 503 if (NULL == texture) { | 512 if (NULL == texture) { |
| 504 return NULL; | 513 return NULL; |
| 505 } | 514 } |
| 506 | 515 |
| 507 return texture; | 516 return texture; |
| 508 } | 517 } |
| 509 | 518 |
| 510 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc) { | 519 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc, |
| 520 GrWrapOwnership ownership) { |
| 511 GrGLRenderTarget::IDDesc idDesc; | 521 GrGLRenderTarget::IDDesc idDesc; |
| 512 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 522 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
| 513 idDesc.fMSColorRenderbufferID = 0; | 523 idDesc.fMSColorRenderbufferID = 0; |
| 514 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | 524 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; |
| 515 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 525 switch (ownership) { |
| 526 case kAdopt_GrWrapOwnership: |
| 527 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; |
| 528 break; |
| 529 case kBorrow_GrWrapOwnership: |
| 530 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; |
| 531 break; |
| 532 } |
| 516 | 533 |
| 517 GrSurfaceDesc desc; | 534 GrSurfaceDesc desc; |
| 518 desc.fConfig = wrapDesc.fConfig; | 535 desc.fConfig = wrapDesc.fConfig; |
| 519 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 536 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
| 520 desc.fWidth = wrapDesc.fWidth; | 537 desc.fWidth = wrapDesc.fWidth; |
| 521 desc.fHeight = wrapDesc.fHeight; | 538 desc.fHeight = wrapDesc.fHeight; |
| 522 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
); | 539 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
); |
| 523 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 540 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
| 524 | 541 |
| 525 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc)); | 542 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc)); |
| (...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 this->setVertexArrayID(gpu, 0); | 3096 this->setVertexArrayID(gpu, 0); |
| 3080 } | 3097 } |
| 3081 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3098 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3082 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3099 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3083 fDefaultVertexArrayAttribState.resize(attrCount); | 3100 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3084 } | 3101 } |
| 3085 attribState = &fDefaultVertexArrayAttribState; | 3102 attribState = &fDefaultVertexArrayAttribState; |
| 3086 } | 3103 } |
| 3087 return attribState; | 3104 return attribState; |
| 3088 } | 3105 } |
| OLD | NEW |