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

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

Issue 2296193005: Add a makeDrawContextWithFallback that handles config fallback (Closed)
Patch Set: update Created 4 years, 3 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
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 "GrContextPriv.h" 9 #include "GrContextPriv.h"
10 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 682 }
683 683
684 sk_sp<GrDrawContext> GrContext::makeDrawContext(SkBackingFit fit, 684 sk_sp<GrDrawContext> GrContext::makeDrawContext(SkBackingFit fit,
685 int width, int height, 685 int width, int height,
686 GrPixelConfig config, 686 GrPixelConfig config,
687 sk_sp<SkColorSpace> colorSpace, 687 sk_sp<SkColorSpace> colorSpace,
688 int sampleCnt, 688 int sampleCnt,
689 GrSurfaceOrigin origin, 689 GrSurfaceOrigin origin,
690 const SkSurfaceProps* surfacePro ps, 690 const SkSurfaceProps* surfacePro ps,
691 SkBudgeted budgeted) { 691 SkBudgeted budgeted) {
692 // If the config isn't renderable try converting to either A8 or an 32 bit c onfig. Otherwise,
bsalomon 2016/09/01 19:47:05 I think this should be more narrowly defined as al
robertphillips 2016/09/01 20:52:54 Done.
693 // fail.
694 if (!this->caps()->isConfigRenderable(config, sampleCnt > 0)) {
695 if (GrPixelConfigIsAlphaOnly(config)) {
696 if (this->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, sampleC nt > 0)) {
697 config = kAlpha_8_GrPixelConfig;
698 } else if (this->caps()->isConfigRenderable(kSkia8888_GrPixelConfig, sampleCnt > 0)) {
bsalomon 2016/09/01 19:47:05 Let's not use kSkia8888. I'd like to remove it. kR
robertphillips 2016/09/01 20:52:54 Done.
699 config = kSkia8888_GrPixelConfig;
700 } else {
701 return nullptr;
702 }
703 } else if (kRGB_GrColorComponentFlags ==
704 (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(config) )) {
705 if (this->caps()->isConfigRenderable(kSkia8888_GrPixelConfig, sample Cnt > 0)) {
706 config = kSkia8888_GrPixelConfig;
707 } else {
708 return nullptr;
709 }
710 } else {
711 return nullptr;
712 }
713 }
714
692 GrSurfaceDesc desc; 715 GrSurfaceDesc desc;
693 desc.fFlags = kRenderTarget_GrSurfaceFlag; 716 desc.fFlags = kRenderTarget_GrSurfaceFlag;
694 desc.fOrigin = origin; 717 desc.fOrigin = origin;
695 desc.fWidth = width; 718 desc.fWidth = width;
696 desc.fHeight = height; 719 desc.fHeight = height;
697 desc.fConfig = config; 720 desc.fConfig = config;
698 desc.fSampleCnt = sampleCnt; 721 desc.fSampleCnt = sampleCnt;
699 722
700 sk_sp<GrTexture> tex; 723 sk_sp<GrTexture> tex;
701 if (SkBackingFit::kExact == fit) { 724 if (SkBackingFit::kExact == fit) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 ASSERT_SINGLE_OWNER 820 ASSERT_SINGLE_OWNER
798 fResourceCache->setLimits(maxTextures, maxTextureBytes); 821 fResourceCache->setLimits(maxTextures, maxTextureBytes);
799 } 822 }
800 823
801 ////////////////////////////////////////////////////////////////////////////// 824 //////////////////////////////////////////////////////////////////////////////
802 825
803 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 826 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
804 ASSERT_SINGLE_OWNER 827 ASSERT_SINGLE_OWNER
805 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 828 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
806 } 829 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698