Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: src/gpu/GrContext.cpp

Issue 1914883002: Refactor drawContext/RenderTarget creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix variable name Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrBlurUtils.cpp ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
618 bool GrContext::abandoned() const { 649 bool GrContext::abandoned() const {
619 ASSERT_SINGLE_OWNER 650 ASSERT_SINGLE_OWNER
620 return fDrawingManager->abandoned(); 651 return fDrawingManager->abandoned();
621 } 652 }
622 653
623 namespace { 654 namespace {
624 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { 655 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
625 GrConfigConversionEffect::PMConversion pmToUPM; 656 GrConfigConversionEffect::PMConversion pmToUPM;
626 GrConfigConversionEffect::PMConversion upmToPM; 657 GrConfigConversionEffect::PMConversion upmToPM;
627 GrConfigConversionEffect::TestForPreservingPMConversions(ctx, &pmToUPM, &upm ToPM); 658 GrConfigConversionEffect::TestForPreservingPMConversions(ctx, &pmToUPM, &upm ToPM);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 ASSERT_SINGLE_OWNER 726 ASSERT_SINGLE_OWNER
696 fResourceCache->setLimits(maxTextures, maxTextureBytes); 727 fResourceCache->setLimits(maxTextures, maxTextureBytes);
697 } 728 }
698 729
699 ////////////////////////////////////////////////////////////////////////////// 730 //////////////////////////////////////////////////////////////////////////////
700 731
701 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 732 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
702 ASSERT_SINGLE_OWNER 733 ASSERT_SINGLE_OWNER
703 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 734 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
704 } 735 }
OLDNEW
« no previous file with comments | « src/gpu/GrBlurUtils.cpp ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698