| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "GrVkGpu.h" | 8 #include "GrVkGpu.h" |
| 9 | 9 |
| 10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 } | 576 } |
| 577 | 577 |
| 578 int maxSize = this->caps()->maxTextureSize(); | 578 int maxSize = this->caps()->maxTextureSize(); |
| 579 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 579 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 580 return nullptr; | 580 return nullptr; |
| 581 } | 581 } |
| 582 | 582 |
| 583 // TODO: determine what format Chrome will actually send us and turn it into
a Resource | 583 // TODO: determine what format Chrome will actually send us and turn it into
a Resource |
| 584 GrVkImage::Resource* imageRsrc = reinterpret_cast<GrVkImage::Resource*>(desc
.fTextureHandle); | 584 GrVkImage::Resource* imageRsrc = reinterpret_cast<GrVkImage::Resource*>(desc
.fTextureHandle); |
| 585 | 585 |
| 586 GrGpuResource::LifeCycle lifeCycle; | 586 GrGpuResource::LifeCycle lifeCycle = (kAdopt_GrWrapOwnership == ownership) |
| 587 switch (ownership) { | 587 ? GrGpuResource::kAdopted_LifeCycle |
| 588 case kAdopt_GrWrapOwnership: | 588 : GrGpuResource::kBorrowed_LifeCycle; |
| 589 lifeCycle = GrGpuResource::kAdopted_LifeCycle; | |
| 590 break; | |
| 591 case kBorrow_GrWrapOwnership: | |
| 592 lifeCycle = GrGpuResource::kBorrowed_LifeCycle; | |
| 593 break; | |
| 594 } | |
| 595 | 589 |
| 596 GrSurfaceDesc surfDesc; | 590 GrSurfaceDesc surfDesc; |
| 597 // next line relies on GrBackendTextureDesc's flags matching GrTexture's | 591 // next line relies on GrBackendTextureDesc's flags matching GrTexture's |
| 598 surfDesc.fFlags = (GrSurfaceFlags)desc.fFlags; | 592 surfDesc.fFlags = (GrSurfaceFlags)desc.fFlags; |
| 599 surfDesc.fWidth = desc.fWidth; | 593 surfDesc.fWidth = desc.fWidth; |
| 600 surfDesc.fHeight = desc.fHeight; | 594 surfDesc.fHeight = desc.fHeight; |
| 601 surfDesc.fConfig = desc.fConfig; | 595 surfDesc.fConfig = desc.fConfig; |
| 602 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); | 596 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); |
| 603 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); | 597 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); |
| 604 // In GL, Chrome assumes all textures are BottomLeft | 598 // In GL, Chrome assumes all textures are BottomLeft |
| (...skipping 15 matching lines...) Expand all Loading... |
| 620 return texture; | 614 return texture; |
| 621 } | 615 } |
| 622 | 616 |
| 623 GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc, | 617 GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& wrapDesc, |
| 624 GrWrapOwnership ownership) { | 618 GrWrapOwnership ownership) { |
| 625 | 619 |
| 626 // TODO: determine what format Chrome will actually send us and turn it into
a Resource | 620 // TODO: determine what format Chrome will actually send us and turn it into
a Resource |
| 627 GrVkImage::Resource* imageRsrc = | 621 GrVkImage::Resource* imageRsrc = |
| 628 reinterpret_cast<GrVkImage::Resource*>(wrapDesc.fRenderTargetHandle); | 622 reinterpret_cast<GrVkImage::Resource*>(wrapDesc.fRenderTargetHandle); |
| 629 | 623 |
| 630 GrGpuResource::LifeCycle lifeCycle; | 624 GrGpuResource::LifeCycle lifeCycle = (kAdopt_GrWrapOwnership == ownership) |
| 631 switch (ownership) { | 625 ? GrGpuResource::kAdopted_LifeCycle |
| 632 case kAdopt_GrWrapOwnership: | 626 : GrGpuResource::kBorrowed_LifeCycle; |
| 633 lifeCycle = GrGpuResource::kAdopted_LifeCycle; | |
| 634 break; | |
| 635 case kBorrow_GrWrapOwnership: | |
| 636 lifeCycle = GrGpuResource::kBorrowed_LifeCycle; | |
| 637 break; | |
| 638 } | |
| 639 | 627 |
| 640 GrSurfaceDesc desc; | 628 GrSurfaceDesc desc; |
| 641 desc.fConfig = wrapDesc.fConfig; | 629 desc.fConfig = wrapDesc.fConfig; |
| 642 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 630 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
| 643 desc.fWidth = wrapDesc.fWidth; | 631 desc.fWidth = wrapDesc.fWidth; |
| 644 desc.fHeight = wrapDesc.fHeight; | 632 desc.fHeight = wrapDesc.fHeight; |
| 645 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
); | 633 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
); |
| 646 | 634 |
| 647 desc.fOrigin = resolve_origin(wrapDesc.fOrigin); | 635 desc.fOrigin = resolve_origin(wrapDesc.fOrigin); |
| 648 | 636 |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 int set_a_break_pt_here = 9; | 1407 int set_a_break_pt_here = 9; |
| 1420 aglSwapBuffers(aglGetCurrentContext()); | 1408 aglSwapBuffers(aglGetCurrentContext()); |
| 1421 #elif defined(SK_BUILD_FOR_WIN32) | 1409 #elif defined(SK_BUILD_FOR_WIN32) |
| 1422 SwapBuf(); | 1410 SwapBuf(); |
| 1423 int set_a_break_pt_here = 9; | 1411 int set_a_break_pt_here = 9; |
| 1424 SwapBuf(); | 1412 SwapBuf(); |
| 1425 #endif | 1413 #endif |
| 1426 #endif | 1414 #endif |
| 1427 } | 1415 } |
| 1428 | 1416 |
| OLD | NEW |