| 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 "GrContextOptions.h" | 9 #include "GrContextOptions.h" |
| 10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? chosenSampleCou
nt : 0; | 608 return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? chosenSampleCou
nt : 0; |
| 609 } | 609 } |
| 610 | 610 |
| 611 | 611 |
| 612 sk_sp<GrDrawContext> GrContext::drawContext(sk_sp<GrRenderTarget> rt, | 612 sk_sp<GrDrawContext> GrContext::drawContext(sk_sp<GrRenderTarget> rt, |
| 613 const SkSurfaceProps* surfaceProps)
{ | 613 const SkSurfaceProps* surfaceProps)
{ |
| 614 ASSERT_SINGLE_OWNER | 614 ASSERT_SINGLE_OWNER |
| 615 return fDrawingManager->drawContext(std::move(rt), surfaceProps); | 615 return fDrawingManager->drawContext(std::move(rt), surfaceProps); |
| 616 } | 616 } |
| 617 | 617 |
| 618 sk_sp<GrDrawContext> GrContext::newDrawContext(BackingFit fit, | |
| 619 int width, int height, | |
| 620 GrPixelConfig config, | |
| 621 int sampleCnt, | |
| 622 GrSurfaceOrigin origin) { | |
| 623 GrSurfaceDesc desc; | |
| 624 desc.fFlags = kRenderTarget_GrSurfaceFlag; | |
| 625 desc.fOrigin = origin; | |
| 626 desc.fWidth = width; | |
| 627 desc.fHeight = height; | |
| 628 desc.fConfig = config; | |
| 629 desc.fSampleCnt = sampleCnt; | |
| 630 | |
| 631 sk_sp<GrTexture> tex; | |
| 632 if (kTight_BackingFit == fit) { | |
| 633 tex.reset(this->textureProvider()->createTexture(desc, SkBudgeted::kYes)
); | |
| 634 } else { | |
| 635 tex.reset(this->textureProvider()->createApproxTexture(desc)); | |
| 636 } | |
| 637 if (!tex) { | |
| 638 return nullptr; | |
| 639 } | |
| 640 | |
| 641 sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(tex->asRenderTa
rget()))); | |
| 642 if (!drawContext) { | |
| 643 return nullptr; | |
| 644 } | |
| 645 | |
| 646 return drawContext; | |
| 647 } | |
| 648 | |
| 649 bool GrContext::abandoned() const { | 618 bool GrContext::abandoned() const { |
| 650 ASSERT_SINGLE_OWNER | 619 ASSERT_SINGLE_OWNER |
| 651 return fDrawingManager->abandoned(); | 620 return fDrawingManager->abandoned(); |
| 652 } | 621 } |
| 653 | 622 |
| 654 namespace { | 623 namespace { |
| 655 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { | 624 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { |
| 656 GrConfigConversionEffect::PMConversion pmToUPM; | 625 GrConfigConversionEffect::PMConversion pmToUPM; |
| 657 GrConfigConversionEffect::PMConversion upmToPM; | 626 GrConfigConversionEffect::PMConversion upmToPM; |
| 658 GrConfigConversionEffect::TestForPreservingPMConversions(ctx, &pmToUPM, &upm
ToPM); | 627 GrConfigConversionEffect::TestForPreservingPMConversions(ctx, &pmToUPM, &upm
ToPM); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 ASSERT_SINGLE_OWNER | 695 ASSERT_SINGLE_OWNER |
| 727 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 696 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 728 } | 697 } |
| 729 | 698 |
| 730 ////////////////////////////////////////////////////////////////////////////// | 699 ////////////////////////////////////////////////////////////////////////////// |
| 731 | 700 |
| 732 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 701 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 733 ASSERT_SINGLE_OWNER | 702 ASSERT_SINGLE_OWNER |
| 734 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 703 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 735 } | 704 } |
| OLD | NEW |