| 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 #include "GrContext.h" | 8 #include "GrContext.h" |
| 9 #include "GrContextPriv.h" | 9 #include "GrContextPriv.h" |
| 10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 chosenSampleCount = 16; | 610 chosenSampleCount = 16; |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? chosenSampleCou
nt : 0; | 613 return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? chosenSampleCou
nt : 0; |
| 614 } | 614 } |
| 615 | 615 |
| 616 sk_sp<GrDrawContext> GrContextPriv::makeWrappedDrawContext(sk_sp<GrRenderTarget>
rt, | 616 sk_sp<GrDrawContext> GrContextPriv::makeWrappedDrawContext(sk_sp<GrRenderTarget>
rt, |
| 617 sk_sp<SkColorSpace> c
olorSpace, | 617 sk_sp<SkColorSpace> c
olorSpace, |
| 618 const SkSurfaceProps*
surfaceProps) { | 618 const SkSurfaceProps*
surfaceProps) { |
| 619 ASSERT_SINGLE_OWNER_PRIV | 619 ASSERT_SINGLE_OWNER_PRIV |
| 620 return fContext->drawingManager()->drawContext(std::move(rt), std::move(colo
rSpace), | 620 return fContext->drawingManager()->makeDrawContext(std::move(rt), |
| 621 surfaceProps); | 621 std::move(colorSpace), |
| 622 surfaceProps); |
| 622 } | 623 } |
| 623 | 624 |
| 624 sk_sp<GrDrawContext> GrContextPriv::makeBackendTextureDrawContext(const GrBacken
dTextureDesc& desc, | 625 sk_sp<GrDrawContext> GrContextPriv::makeBackendTextureDrawContext(const GrBacken
dTextureDesc& desc, |
| 625 sk_sp<SkColorS
pace> colorSpace, | 626 sk_sp<SkColorS
pace> colorSpace, |
| 626 const SkSurfac
eProps* props, | 627 const SkSurfac
eProps* props, |
| 627 GrWrapOwnershi
p ownership) { | 628 GrWrapOwnershi
p ownership) { |
| 628 ASSERT_SINGLE_OWNER_PRIV | 629 ASSERT_SINGLE_OWNER_PRIV |
| 629 SkASSERT(desc.fFlags & kRenderTarget_GrBackendTextureFlag); | 630 SkASSERT(desc.fFlags & kRenderTarget_GrBackendTextureFlag); |
| 630 | 631 |
| 631 sk_sp<GrSurface> surface(fContext->textureProvider()->wrapBackendTexture(des
c, ownership)); | 632 sk_sp<GrSurface> surface(fContext->textureProvider()->wrapBackendTexture(des
c, ownership)); |
| 632 if (!surface) { | 633 if (!surface) { |
| 633 return nullptr; | 634 return nullptr; |
| 634 } | 635 } |
| 635 | 636 |
| 636 return fContext->drawingManager()->drawContext(sk_ref_sp(surface->asRenderTa
rget()), | 637 return fContext->drawingManager()->makeDrawContext(sk_ref_sp(surface->asRend
erTarget()), |
| 637 std::move(colorSpace), props)
; | 638 std::move(colorSpace), pr
ops); |
| 638 } | 639 } |
| 639 | 640 |
| 640 sk_sp<GrDrawContext> GrContextPriv::makeBackendRenderTargetDrawContext( | 641 sk_sp<GrDrawContext> GrContextPriv::makeBackendRenderTargetDrawContext( |
| 641 const GrBackendRenderTargetDesc&
desc, | 642 const GrBackendRenderTargetDesc&
desc, |
| 642 sk_sp<SkColorSpace> colorSpace, | 643 sk_sp<SkColorSpace> colorSpace, |
| 643 const SkSurfaceProps* surfacePro
ps) { | 644 const SkSurfaceProps* surfacePro
ps) { |
| 644 ASSERT_SINGLE_OWNER_PRIV | 645 ASSERT_SINGLE_OWNER_PRIV |
| 645 | 646 |
| 646 sk_sp<GrRenderTarget> rt(fContext->textureProvider()->wrapBackendRenderTarge
t(desc)); | 647 sk_sp<GrRenderTarget> rt(fContext->textureProvider()->wrapBackendRenderTarge
t(desc)); |
| 647 if (!rt) { | 648 if (!rt) { |
| 648 return nullptr; | 649 return nullptr; |
| 649 } | 650 } |
| 650 | 651 |
| 651 return fContext->drawingManager()->drawContext(std::move(rt), std::move(colo
rSpace), | 652 return fContext->drawingManager()->makeDrawContext(std::move(rt), |
| 652 surfaceProps); | 653 std::move(colorSpace), |
| 654 surfaceProps); |
| 653 } | 655 } |
| 654 | 656 |
| 655 sk_sp<GrDrawContext> GrContextPriv::makeBackendTextureAsRenderTargetDrawContext( | 657 sk_sp<GrDrawContext> GrContextPriv::makeBackendTextureAsRenderTargetDrawContext( |
| 656 const GrBackendTextureDesc&
desc, | 658 const GrBackendTextureDesc&
desc, |
| 657 sk_sp<SkColorSpace> colorSp
ace, | 659 sk_sp<SkColorSpace> colorSp
ace, |
| 658 const SkSurfaceProps* surfa
ceProps) { | 660 const SkSurfaceProps* surfa
ceProps) { |
| 659 ASSERT_SINGLE_OWNER_PRIV | 661 ASSERT_SINGLE_OWNER_PRIV |
| 660 SkASSERT(desc.fFlags & kRenderTarget_GrBackendTextureFlag); | 662 SkASSERT(desc.fFlags & kRenderTarget_GrBackendTextureFlag); |
| 661 | 663 |
| 662 sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTextureAsR
enderTarget(desc)); | 664 sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTextureAsR
enderTarget(desc)); |
| 663 if (!surface) { | 665 if (!surface) { |
| 664 return nullptr; | 666 return nullptr; |
| 665 } | 667 } |
| 666 | 668 |
| 667 return fContext->drawingManager()->drawContext(sk_ref_sp(surface->asRenderTa
rget()), | 669 return fContext->drawingManager()->makeDrawContext(sk_ref_sp(surface->asRend
erTarget()), |
| 668 std::move(colorSpace), surfac
eProps); | 670 std::move(colorSpace), |
| 671 surfaceProps); |
| 669 } | 672 } |
| 670 | 673 |
| 671 sk_sp<GrDrawContext> GrContext::makeDrawContext(SkBackingFit fit, | 674 sk_sp<GrDrawContext> GrContext::makeDrawContext(SkBackingFit fit, |
| 672 int width, int height, | 675 int width, int height, |
| 673 GrPixelConfig config, | 676 GrPixelConfig config, |
| 674 sk_sp<SkColorSpace> colorSpace, | 677 sk_sp<SkColorSpace> colorSpace, |
| 675 int sampleCnt, | 678 int sampleCnt, |
| 676 GrSurfaceOrigin origin, | 679 GrSurfaceOrigin origin, |
| 677 const SkSurfaceProps* surfacePro
ps, | 680 const SkSurfaceProps* surfacePro
ps, |
| 678 SkBudgeted budgeted) { | 681 SkBudgeted budgeted) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 ASSERT_SINGLE_OWNER | 787 ASSERT_SINGLE_OWNER |
| 785 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 788 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 786 } | 789 } |
| 787 | 790 |
| 788 ////////////////////////////////////////////////////////////////////////////// | 791 ////////////////////////////////////////////////////////////////////////////// |
| 789 | 792 |
| 790 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 793 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 791 ASSERT_SINGLE_OWNER | 794 ASSERT_SINGLE_OWNER |
| 792 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 795 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 793 } | 796 } |
| OLD | NEW |