| 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, | 618 sk_sp<GrDrawContext> GrContext::newDrawContext(SkBackingFit fit, |
| 619 int width, int height, | 619 int width, int height, |
| 620 GrPixelConfig config, | 620 GrPixelConfig config, |
| 621 int sampleCnt, | 621 int sampleCnt, |
| 622 GrSurfaceOrigin origin) { | 622 GrSurfaceOrigin origin) { |
| 623 GrSurfaceDesc desc; | 623 GrSurfaceDesc desc; |
| 624 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 624 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 625 desc.fOrigin = origin; | 625 desc.fOrigin = origin; |
| 626 desc.fWidth = width; | 626 desc.fWidth = width; |
| 627 desc.fHeight = height; | 627 desc.fHeight = height; |
| 628 desc.fConfig = config; | 628 desc.fConfig = config; |
| 629 desc.fSampleCnt = sampleCnt; | 629 desc.fSampleCnt = sampleCnt; |
| 630 | 630 |
| 631 sk_sp<GrTexture> tex; | 631 sk_sp<GrTexture> tex; |
| 632 if (kTight_BackingFit == fit) { | 632 if (SkBackingFit::kExact == fit) { |
| 633 tex.reset(this->textureProvider()->createTexture(desc, SkBudgeted::kYes)
); | 633 tex.reset(this->textureProvider()->createTexture(desc, SkBudgeted::kYes)
); |
| 634 } else { | 634 } else { |
| 635 tex.reset(this->textureProvider()->createApproxTexture(desc)); | 635 tex.reset(this->textureProvider()->createApproxTexture(desc)); |
| 636 } | 636 } |
| 637 if (!tex) { | 637 if (!tex) { |
| 638 return nullptr; | 638 return nullptr; |
| 639 } | 639 } |
| 640 | 640 |
| 641 sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(tex->asRenderTa
rget()))); | 641 sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(tex->asRenderTa
rget()))); |
| 642 if (!drawContext) { | 642 if (!drawContext) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 ASSERT_SINGLE_OWNER | 726 ASSERT_SINGLE_OWNER |
| 727 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 727 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 728 } | 728 } |
| 729 | 729 |
| 730 ////////////////////////////////////////////////////////////////////////////// | 730 ////////////////////////////////////////////////////////////////////////////// |
| 731 | 731 |
| 732 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 732 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 733 ASSERT_SINGLE_OWNER | 733 ASSERT_SINGLE_OWNER |
| 734 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 734 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 735 } | 735 } |
| OLD | NEW |