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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 015776099038649fd1134e0974329ec17028a2c1..a25bcf1dc5acf599284ed3a8821afa73c9350c2c 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -689,6 +689,29 @@ sk_sp<GrDrawContext> GrContext::makeDrawContext(SkBackingFit fit,
GrSurfaceOrigin origin,
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted) {
+ // If the config isn't renderable try converting to either A8 or an 32 bit config. 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.
+ // fail.
+ if (!this->caps()->isConfigRenderable(config, sampleCnt > 0)) {
+ if (GrPixelConfigIsAlphaOnly(config)) {
+ if (this->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, sampleCnt > 0)) {
+ config = kAlpha_8_GrPixelConfig;
+ } 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.
+ config = kSkia8888_GrPixelConfig;
+ } else {
+ return nullptr;
+ }
+ } else if (kRGB_GrColorComponentFlags ==
+ (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(config))) {
+ if (this->caps()->isConfigRenderable(kSkia8888_GrPixelConfig, sampleCnt > 0)) {
+ config = kSkia8888_GrPixelConfig;
+ } else {
+ return nullptr;
+ }
+ } else {
+ return nullptr;
+ }
+ }
+
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fOrigin = origin;

Powered by Google App Engine
This is Rietveld 408576698