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" |
11 #include "GrDrawingManager.h" | 11 #include "GrDrawingManager.h" |
12 #include "GrRenderTargetContext.h" | 12 #include "GrRenderTargetContext.h" |
13 #include "GrResourceCache.h" | 13 #include "GrResourceCache.h" |
14 #include "GrResourceProvider.h" | 14 #include "GrResourceProvider.h" |
| 15 #include "GrRenderTarget.h" |
15 #include "GrRenderTargetProxy.h" | 16 #include "GrRenderTargetProxy.h" |
16 #include "GrSoftwarePathRenderer.h" | 17 #include "GrSoftwarePathRenderer.h" |
17 #include "GrSurfacePriv.h" | 18 #include "GrSurfacePriv.h" |
18 | 19 |
19 #include "SkConfig8888.h" | 20 #include "SkConfig8888.h" |
20 #include "SkGrPriv.h" | 21 #include "SkGrPriv.h" |
21 | 22 |
22 #include "batches/GrCopySurfaceBatch.h" | 23 #include "batches/GrCopySurfaceBatch.h" |
23 #include "effects/GrConfigConversionEffect.h" | 24 #include "effects/GrConfigConversionEffect.h" |
24 #include "effects/GrGammaEffect.h" | 25 #include "effects/GrGammaEffect.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 GrConfigConversionEffect::kN
one_PMConversion, | 472 GrConfigConversionEffect::kN
one_PMConversion, |
472 textureMatrix); | 473 textureMatrix); |
473 } | 474 } |
474 if (fp) { | 475 if (fp) { |
475 GrPaint paint; | 476 GrPaint paint; |
476 paint.addColorFragmentProcessor(std::move(fp)); | 477 paint.addColorFragmentProcessor(std::move(fp)); |
477 paint.setPorterDuffXPFactory(SkBlendMode::kSrc); | 478 paint.setPorterDuffXPFactory(SkBlendMode::kSrc); |
478 paint.setAllowSRGBInputs(true); | 479 paint.setAllowSRGBInputs(true); |
479 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); | 480 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); |
480 tempRTC->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullpt
r); | 481 tempRTC->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullpt
r); |
481 surfaceToRead.reset(tempRTC->asTexture().release()); | 482 GrRenderTarget* tempRT = tempRTC->instantiate(); |
| 483 surfaceToRead.reset(tempRT->asTexture()); // .release()); |
482 left = 0; | 484 left = 0; |
483 top = 0; | 485 top = 0; |
484 didTempDraw = true; | 486 didTempDraw = true; |
485 } | 487 } |
486 } | 488 } |
487 } | 489 } |
488 | 490 |
489 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { | 491 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { |
490 return false; | 492 return false; |
491 } | 493 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 return nullptr; | 744 return nullptr; |
743 } | 745 } |
744 | 746 |
745 GrSurfaceDesc desc; | 747 GrSurfaceDesc desc; |
746 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 748 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
747 desc.fOrigin = origin; | 749 desc.fOrigin = origin; |
748 desc.fWidth = width; | 750 desc.fWidth = width; |
749 desc.fHeight = height; | 751 desc.fHeight = height; |
750 desc.fConfig = config; | 752 desc.fConfig = config; |
751 desc.fSampleCnt = sampleCnt; | 753 desc.fSampleCnt = sampleCnt; |
752 | 754 |
753 sk_sp<GrTexture> tex; | 755 sk_sp<GrTexture> tex; |
754 if (SkBackingFit::kExact == fit) { | 756 if (SkBackingFit::kExact == fit) { |
755 tex.reset(this->textureProvider()->createTexture(desc, budgeted)); | 757 tex.reset(this->textureProvider()->createTexture(desc, budgeted)); |
756 } else { | 758 } else { |
757 tex.reset(this->textureProvider()->createApproxTexture(desc)); | 759 tex.reset(this->textureProvider()->createApproxTexture(desc)); |
758 } | 760 } |
759 if (!tex) { | 761 if (!tex) { |
760 return nullptr; | 762 return nullptr; |
761 } | 763 } |
762 | 764 |
763 sk_sp<GrRenderTargetContext> renderTargetContext( | 765 sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(sk_ref_sp(tex->asRe
nderTarget()))); |
764 this->contextPriv().makeWrappedRenderTargetContext(sk_ref_sp(tex->asRend
erTarget()), | |
765 std::move(colorSpace)
, surfaceProps)); | |
766 if (!renderTargetContext) { | |
767 return nullptr; | |
768 } | |
769 | 766 |
770 return renderTargetContext; | 767 return fDrawingManager->makeRenderTargetContext(std::move(rtp), |
| 768 std::move(colorSpace), surfa
ceProps); |
771 } | 769 } |
772 | 770 |
773 sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext( | 771 sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext( |
774 SkBackingFit fit, | 772 SkBackingFit fit, |
775 int width, int height, | 773 int width, int height, |
776 GrPixelConfig config, | 774 GrPixelConfig config, |
777 sk_sp<SkColorSpace> colo
rSpace, | 775 sk_sp<SkColorSpace> colo
rSpace, |
778 int sampleCnt, | 776 int sampleCnt, |
779 GrSurfaceOrigin origin, | 777 GrSurfaceOrigin origin, |
780 const SkSurfaceProps* su
rfaceProps, | 778 const SkSurfaceProps* su
rfaceProps, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 ASSERT_SINGLE_OWNER | 872 ASSERT_SINGLE_OWNER |
875 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 873 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
876 } | 874 } |
877 | 875 |
878 ////////////////////////////////////////////////////////////////////////////// | 876 ////////////////////////////////////////////////////////////////////////////// |
879 | 877 |
880 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 878 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
881 ASSERT_SINGLE_OWNER | 879 ASSERT_SINGLE_OWNER |
882 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 880 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
883 } | 881 } |
OLD | NEW |